This commit is contained in:
monitor1394
2022-05-22 22:17:38 +08:00
parent 003f4da9de
commit bafe032bb9
391 changed files with 3718 additions and 2774 deletions

View File

@@ -1,4 +1,3 @@
using System.Collections.Generic;
using UnityEngine;

View File

@@ -86,7 +86,7 @@ namespace XCharts.Runtime
bool inside = axis.axisLabel.inside;
var labelName = AxisHelper.GetLabelName(axis, total, i, axis.context.minValue, axis.context.maxValue,
null, isPercentStack);
var label = ChartHelper.AddAxisLabelObject(splitNumber, i, objName + i, axisObj.transform,
var label = ChartHelper.AddAxisLabelObject(splitNumber, i, objName + i, axisObj.transform,
new Vector2(scaleAngle, txtHig), axis,
chart.theme.axis, labelName, Color.clear);
label.text.SetAlignment(axis.axisLabel.textStyle.GetAlignment(TextAnchor.MiddleCenter));
@@ -124,9 +124,9 @@ namespace XCharts.Runtime
}
if (angleAxis.show && angleAxis.axisTick.show)
{
if ((i == 1 && angleAxis.axisTick.showStartTick)
|| (i == size - 1 && angleAxis.axisTick.showEndTick)
|| (i > 1 && i < size - 1))
if ((i == 1 && angleAxis.axisTick.showStartTick) ||
(i == size - 1 && angleAxis.axisTick.showEndTick) ||
(i > 1 && i < size - 1))
{
var tickY = radius + tickLength;
var tickPos = ChartHelper.GetPos(cenPos, tickY, currAngle, true);

View File

@@ -1,4 +1,3 @@

using System;
using System.Collections.Generic;
using UnityEngine;
@@ -366,11 +365,11 @@ namespace XCharts.Runtime
{
get
{
return m_VertsDirty
|| axisLine.anyDirty
|| axisTick.anyDirty
|| splitLine.anyDirty
|| splitArea.anyDirty;
return m_VertsDirty ||
axisLine.anyDirty ||
axisTick.anyDirty ||
splitLine.anyDirty ||
splitArea.anyDirty;
}
}
@@ -378,9 +377,9 @@ namespace XCharts.Runtime
{
get
{
return m_ComponentDirty
|| axisName.anyDirty
|| axisLabel.anyDirty;
return m_ComponentDirty ||
axisName.anyDirty ||
axisLabel.anyDirty;
}
}
@@ -656,11 +655,11 @@ namespace XCharts.Runtime
if (IsCategory() && boundaryGap)
{
var each = axisLength / data.Count;
return (float)(each * (value + 0.5f));
return (float) (each * (value + 0.5f));
}
else
{
return axisLength * (float)((value - context.minValue) / context.minMaxRange);
return axisLength * (float) ((value - context.minValue) / context.minMaxRange);
}
}
@@ -754,21 +753,21 @@ namespace XCharts.Runtime
if (value <= 0 || value == 1)
return 0;
else
return logBaseE ? (float)Math.Log(value) : (float)Math.Log(value, logBase);
return logBaseE ? (float) Math.Log(value) : (float) Math.Log(value, logBase);
}
public int GetLogMinIndex()
{
return logBaseE
? (int)Math.Log(context.minValue)
: (int)Math.Log(context.minValue, logBase);
return logBaseE ?
(int) Math.Log(context.minValue) :
(int) Math.Log(context.minValue, logBase);
}
public int GetLogMaxIndex()
{
return logBaseE
? (int)Math.Log(context.maxValue)
: (int)Math.Log(context.maxValue, logBase);
return logBaseE ?
(int) Math.Log(context.maxValue) :
(int) Math.Log(context.maxValue, logBase);
}
public double GetLabelValue(int index)

View File

@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using UnityEngine;
@@ -56,7 +55,6 @@ namespace XCharts.Runtime
private List<double> m_LabelValueList = new List<double>();
private List<string> m_RuntimeData = new List<string>();
internal void Clear()
{
m_RuntimeData.Clear();
@@ -87,10 +85,10 @@ namespace XCharts.Runtime
if (end > data.Count) end = data.Count;
}
if (start != filterStart
|| end != filterEnd
|| dataZoom.minShowNum != filterMinShow
|| isNeedUpdateFilterData)
if (start != filterStart ||
end != filterEnd ||
dataZoom.minShowNum != filterMinShow ||
isNeedUpdateFilterData)
{
filterStart = start;
filterEnd = end;

View File

@@ -1,4 +1,3 @@
using System;
using UnityEngine;
using UnityEngine.UI;
@@ -8,7 +7,7 @@ using XUGL;
namespace XCharts
{
public abstract class AxisHandler<T> : MainComponentHandler
where T : Axis
where T : Axis
{
private static readonly string s_DefaultAxisName = "name";
private double m_LastInterval = double.MinValue;
@@ -17,7 +16,7 @@ namespace XCharts
internal override void SetComponent(MainComponent component)
{
this.component = (T)component;
this.component = (T) component;
}
protected virtual Vector3 GetLabelPosition(float scaleWid, int i)
@@ -25,6 +24,11 @@ namespace XCharts
return Vector3.zero;
}
protected virtual float GetAxisLineXOrY()
{
return 0;
}
protected virtual Orient orient { get; set; }
protected virtual void UpdatePointerValue(Axis axis)
@@ -50,8 +54,8 @@ namespace XCharts
for (int j = 0; j < axis.GetDataCount(dataZoom); j++)
{
float pY = grid.context.y + j * splitWid;
if ((axis.boundaryGap && (local.y > pY && local.y <= pY + splitWid))
|| (!axis.boundaryGap && (local.y > pY - splitWid / 2 && local.y <= pY + splitWid / 2)))
if ((axis.boundaryGap && (local.y > pY && local.y <= pY + splitWid)) ||
(!axis.boundaryGap && (local.y > pY - splitWid / 2 && local.y <= pY + splitWid / 2)))
{
axis.context.pointerValue = j;
axis.context.pointerLabelPosition = axis.GetLabelObjectPosition(j);
@@ -70,8 +74,8 @@ namespace XCharts
for (int j = 0; j < axis.GetDataCount(dataZoom); j++)
{
float pX = grid.context.x + j * splitWid;
if ((axis.boundaryGap && (local.x > pX && local.x <= pX + splitWid))
|| (!axis.boundaryGap && (local.x > pX - splitWid / 2 && local.x <= pX + splitWid / 2)))
if ((axis.boundaryGap && (local.x > pX && local.x <= pX + splitWid)) ||
(!axis.boundaryGap && (local.x > pX - splitWid / 2 && local.x <= pX + splitWid / 2)))
{
axis.context.pointerValue = j;
axis.context.pointerLabelPosition = axis.GetLabelObjectPosition(j);
@@ -140,10 +144,10 @@ namespace XCharts
double tempMaxValue = 0;
chart.GetSeriesMinMaxValue(axis, axisIndex, out tempMinValue, out tempMaxValue);
if (tempMinValue != axis.context.minValue
|| tempMaxValue != axis.context.maxValue
|| m_LastInterval != axis.interval
|| m_LastSplitNumber != axis.splitNumber)
if (tempMinValue != axis.context.minValue ||
tempMaxValue != axis.context.maxValue ||
m_LastInterval != axis.interval ||
m_LastSplitNumber != axis.splitNumber)
{
m_LastSplitNumber = axis.splitNumber;
m_LastInterval = axis.interval;
@@ -151,7 +155,6 @@ namespace XCharts
axis.UpdateMinMaxValue(tempMinValue, tempMaxValue);
axis.context.offset = 0;
axis.context.lastCheckInverse = axis.inverse;
UpdateAxisTickValueList(axis);
if (tempMinValue != 0 || tempMaxValue != 0)
@@ -159,31 +162,31 @@ namespace XCharts
var grid = chart.GetChartComponent<GridCoord>(axis.gridIndex);
if (grid != null && axis is XAxis && axis.IsValue())
{
axis.context.offset = axis.context.minValue > 0
? 0
: (axis.context.maxValue < 0
? grid.context.width
: (float)(Math.Abs(axis.context.minValue) * (grid.context.width
/ (Math.Abs(axis.context.minValue) + Math.Abs(axis.context.maxValue))))
axis.context.offset = axis.context.minValue > 0 ?
0 :
(axis.context.maxValue < 0 ?
grid.context.width :
(float) (Math.Abs(axis.context.minValue) * (grid.context.width /
(Math.Abs(axis.context.minValue) + Math.Abs(axis.context.maxValue))))
);
axis.context.x = grid.context.x;
axis.context.y = grid.context.y;
axis.context.y = GetAxisLineXOrY();
axis.context.zeroY = grid.context.y;
axis.context.zeroX = grid.context.x - (float)(axis.context.minValue * grid.context.width / axis.context.minMaxRange);
axis.context.zeroX = grid.context.x - (float) (axis.context.minValue * grid.context.width / axis.context.minMaxRange);
}
if (grid != null && axis is YAxis && axis.IsValue())
{
axis.context.offset = axis.context.minValue > 0
? 0
: (axis.context.maxValue < 0
? grid.context.height
: (float)(Math.Abs(axis.context.minValue) * (grid.context.height
/ (Math.Abs(axis.context.minValue) + Math.Abs(axis.context.maxValue))))
axis.context.offset = axis.context.minValue > 0 ?
0 :
(axis.context.maxValue < 0 ?
grid.context.height :
(float) (Math.Abs(axis.context.minValue) * (grid.context.height /
(Math.Abs(axis.context.minValue) + Math.Abs(axis.context.maxValue))))
);
axis.context.x = grid.context.x;
axis.context.x = GetAxisLineXOrY();
axis.context.y = grid.context.y;
axis.context.zeroX = grid.context.x;
axis.context.zeroY = grid.context.y - (float)(axis.context.minValue * grid.context.height / axis.context.minMaxRange);
axis.context.zeroY = grid.context.y - (float) (axis.context.minValue * grid.context.height / axis.context.minMaxRange);
}
}
var dataZoom = chart.GetDataZoomOfAxis(axis);
@@ -220,8 +223,8 @@ namespace XCharts
if (axis.IsTime())
{
var lastCount = axis.context.labelValueList.Count;
DateTimeUtil.UpdateTimeAxisDateTimeList(axis.context.labelValueList, (int)axis.context.minValue,
(int)axis.context.maxValue, axis.splitNumber);
DateTimeUtil.UpdateTimeAxisDateTimeList(axis.context.labelValueList, (int) axis.context.minValue,
(int) axis.context.maxValue, axis.splitNumber);
if (axis.context.labelValueList.Count != lastCount)
axis.SetAllDirty();
@@ -255,7 +258,7 @@ namespace XCharts
}
}
var value = 0d;
if (Mathf.Approximately((float)(axis.context.minValue % tick), 0))
if (Mathf.Approximately((float) (axis.context.minValue % tick), 0))
{
value = axis.context.minValue;
}
@@ -328,9 +331,10 @@ namespace XCharts
}
}
internal static void InitAxis(Axis axis, Axis relativedAxis, BaseChart chart, AxisHandler<T> handler,
Orient orient, float axisStartX, float axisStartY, float axisLength, float relativedLength)
protected void InitAxis(Axis relativedAxis, Orient orient,
float axisStartX, float axisStartY, float axisLength, float relativedLength)
{
Axis axis = component;
chart.InitAxisRuntimeData(axis);
var objName = ChartCached.GetComponentObjectName(axis);
@@ -358,23 +362,23 @@ namespace XCharts
var eachWidth = AxisHelper.GetEachWidth(axis, axisLength, dataZoom);
var gapWidth = axis.boundaryGap ? eachWidth / 2 : 0;
var textWidth = axis.axisLabel.width > 0
? axis.axisLabel.width
: (orient == Orient.Horizonal
? AxisHelper.GetScaleWidth(axis, axisLength, 0, dataZoom)
: (axisStartX - chart.chartX)
var textWidth = axis.axisLabel.width > 0 ?
axis.axisLabel.width :
(orient == Orient.Horizonal ?
AxisHelper.GetScaleWidth(axis, axisLength, 0, dataZoom) :
(axisStartX - chart.chartX)
);
var textHeight = axis.axisLabel.height > 0
? axis.axisLabel.height
: 20f;
var textHeight = axis.axisLabel.height > 0 ?
axis.axisLabel.height :
20f;
var isPercentStack = SeriesHelper.IsPercentStack<Bar>(chart.series);
var inside = axis.axisLabel.inside;
var defaultAlignment = orient == Orient.Horizonal ? TextAnchor.MiddleCenter :
((inside && axis.IsLeft()) || (!inside && axis.IsRight())
? TextAnchor.MiddleLeft
: TextAnchor.MiddleRight);
((inside && axis.IsLeft()) || (!inside && axis.IsRight()) ?
TextAnchor.MiddleLeft :
TextAnchor.MiddleRight);
if (axis.IsCategory() && axis.boundaryGap)
splitNumber -= 1;
@@ -398,9 +402,9 @@ namespace XCharts
if (i == 0)
axis.axisLabel.SetRelatedText(label.text, labelWidth);
var pos = handler.GetLabelPosition(totalWidth + gapWidth, i);
var pos = GetLabelPosition(totalWidth + gapWidth, i);
label.SetPosition(pos);
handler.CheckValueLabelActive(axis, i, label, pos);
CheckValueLabelActive(axis, i, label, pos);
axis.context.labelObjectList.Add(label);
@@ -415,6 +419,7 @@ namespace XCharts
var autoColor = axis.axisLine.GetColor(chart.theme.axis.lineColor);
if (orient == Orient.Horizonal)
{
var posY = GetAxisLineXOrY() + offset.y;
switch (axis.axisName.labelStyle.position)
{
case LabelStyle.Position.Start:
@@ -422,9 +427,9 @@ namespace XCharts
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleRight);
label.SetActive(axis.axisName.labelStyle.show);
label.SetPosition(axis.position == Axis.AxisPosition.Top
? new Vector2(zeroPos.x - offset.x, axisStartY + relativedLength + offset.y + axis.offset)
: new Vector2(zeroPos.x - offset.x, zeroPos.y + offset.y + axis.offset));
label.SetPosition(axis.position == Axis.AxisPosition.Top ?
new Vector2(zeroPos.x - offset.x, axisStartY + relativedLength + offset.y + axis.offset) :
new Vector2(zeroPos.x - offset.x, posY));
break;
case LabelStyle.Position.Middle:
@@ -432,9 +437,9 @@ namespace XCharts
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
label.SetActive(axis.axisName.labelStyle.show);
label.SetPosition(axis.position == Axis.AxisPosition.Top
? new Vector2(axisStartX + axisLength / 2 + offset.x, axisStartY + relativedLength - offset.y + axis.offset)
: new Vector2(axisStartX + axisLength / 2 + offset.x, axisStartY - offset.y + axis.offset));
label.SetPosition(axis.position == Axis.AxisPosition.Top ?
new Vector2(axisStartX + axisLength / 2 + offset.x, axisStartY + relativedLength - offset.y + axis.offset) :
new Vector2(axisStartX + axisLength / 2 + offset.x, posY));
break;
default:
@@ -442,44 +447,45 @@ namespace XCharts
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleLeft);
label.SetActive(axis.axisName.labelStyle.show);
label.SetPosition(axis.position == Axis.AxisPosition.Top
? new Vector2(axisStartX + axisLength + offset.x, axisStartY + relativedLength + offset.y + axis.offset)
: new Vector2(axisStartX + axisLength + offset.x, zeroPos.y + offset.y + axis.offset));
label.SetPosition(axis.position == Axis.AxisPosition.Top ?
new Vector2(axisStartX + axisLength + offset.x, axisStartY + relativedLength + offset.y + axis.offset) :
new Vector2(axisStartX + axisLength + offset.x, posY));
break;
}
}
else
{
var posX = GetAxisLineXOrY() + offset.x;
switch (axis.axisName.labelStyle.position)
{
case LabelStyle.Position.Start:
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
label.SetActive(axis.axisName.labelStyle.show);
label.SetPosition(axis.position == Axis.AxisPosition.Right ?
new Vector2(axisStartX + relativedLength + offset.x + axis.offset, axisStartY - offset.y) :
new Vector2(zeroPos.x + offset.x + axis.offset, axisStartY - offset.y));
new Vector2(posX, axisStartY - offset.y));
break;
case LabelStyle.Position.Middle:
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
label.SetActive(axis.axisName.labelStyle.show);
label.SetPosition(axis.position == Axis.AxisPosition.Right ?
new Vector2(axisStartX + relativedLength - offset.x + axis.offset, axisStartY + axisLength / 2 + offset.y) :
new Vector2(axisStartX - offset.x + axis.offset, axisStartY + axisLength / 2 + offset.y));
new Vector2(posX, axisStartY + axisLength / 2 + offset.y));
break;
default:
//LabelStyle.Position
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
label.SetActive(axis.axisName.labelStyle.show);
label.SetPosition(axis.position == Axis.AxisPosition.Right ?
new Vector2(axisStartX + relativedLength + offset.x + axis.offset, axisStartY + axisLength + offset.y) :
new Vector2(zeroPos.x + offset.x + axis.offset, axisStartY + axisLength + offset.y));
new Vector2(posX, axisStartY + axisLength + offset.y));
break;
}
}
@@ -495,9 +501,9 @@ namespace XCharts
if (axis.IsTime() || axis.IsValue())
{
scaleWid = axis.context.minMaxRange != 0
? axis.GetDistance(axis.GetLabelValue(i), axisLength)
: 0;
scaleWid = axis.context.minMaxRange != 0 ?
axis.GetDistance(axis.GetLabelValue(i), axisLength) :
0;
}
if (orient == Orient.Horizonal)
@@ -513,7 +519,7 @@ namespace XCharts
else
current += axisStartY - axis.axisLabel.distance - fontSize / 2;
return new Vector3(axisStartX + scaleWid, current);
return new Vector3(axisStartX + scaleWid, current) + axis.axisLabel.offset;
}
else
{
@@ -528,7 +534,7 @@ namespace XCharts
else
current += axisStartX - axis.axisLabel.distance;
return new Vector3(current, axisStartY + scaleWid);
return new Vector3(current, axisStartY + scaleWid) + axis.axisLabel.offset;
}
}
@@ -566,9 +572,9 @@ namespace XCharts
{
var size = AxisHelper.GetScaleNumber(axis, axisLength, dataZoom);
var current = orient == Orient.Horizonal
? startX
: startY;
var current = orient == Orient.Horizonal ?
startX :
startY;
for (int i = 0; i < size; i++)
{
@@ -587,17 +593,17 @@ namespace XCharts
{
if (orient == Orient.Horizonal)
{
float pX = axis.IsTime()
? (startX + axis.GetDistance(axis.GetLabelValue(i), axisLength))
: current;
float pX = axis.IsTime() ?
(startX + axis.GetDistance(axis.GetLabelValue(i), axisLength)) :
current;
if (axis.boundaryGap && axis.axisTick.alignWithLabel)
pX -= scaleWidth / 2;
var sY = 0f;
var eY = 0f;
if ((axis.axisTick.inside && axis.IsBottom())
|| (!axis.axisTick.inside && axis.IsTop()))
if ((axis.axisTick.inside && axis.IsBottom()) ||
(!axis.axisTick.inside && axis.IsTop()))
{
sY = startY + axis.offset + lineWidth;
eY = sY + tickLength;
@@ -614,17 +620,17 @@ namespace XCharts
}
else
{
float pY = axis.IsTime()
? (startY + axis.GetDistance(axis.GetLabelValue(i), axisLength))
: current;
float pY = axis.IsTime() ?
(startY + axis.GetDistance(axis.GetLabelValue(i), axisLength)) :
current;
if (axis.boundaryGap && axis.axisTick.alignWithLabel)
pY -= scaleWidth / 2;
var sX = 0f;
var eX = 0f;
if ((axis.axisTick.inside && axis.IsLeft())
|| (!axis.axisTick.inside && axis.IsRight()))
if ((axis.axisTick.inside && axis.IsLeft()) ||
(!axis.axisTick.inside && axis.IsRight()))
{
sX = startX + axis.offset + lineWidth;
eX = sX + tickLength;
@@ -690,9 +696,10 @@ namespace XCharts
}
}
internal static void DrawAxisSplit(VertexHelper vh, Axis axis, AxisTheme theme, DataZoom dataZoom,
protected void DrawAxisSplit(VertexHelper vh, AxisTheme theme, DataZoom dataZoom,
Orient orient, float startX, float startY, float axisLength, float splitLength, Axis relativedAxis = null)
{
Axis axis = component;
var lineColor = axis.splitLine.GetColor(theme.splitLineColor);
var lineWidth = axis.splitLine.GetWidth(theme.lineWidth);
var lineType = axis.splitLine.GetType(theme.splitLineType);
@@ -705,9 +712,9 @@ namespace XCharts
size += 1;
}
var current = orient == Orient.Horizonal
? startX
: startY;
var current = orient == Orient.Horizonal ?
startX :
startY;
for (int i = 0; i < size; i++)
{
var scaleWidth = AxisHelper.GetScaleWidth(axis, axisLength, axis.IsTime() ? i : i + 1, dataZoom);
@@ -743,7 +750,7 @@ namespace XCharts
{
if (orient == Orient.Horizonal)
{
if (relativedAxis == null || !MathUtil.Approximately(current, relativedAxis.context.x))
if (relativedAxis == null || !MathUtil.Approximately(current, GetAxisLineXOrY()))
ChartDrawer.DrawLineStyle(vh,
lineType,
lineWidth,
@@ -753,7 +760,7 @@ namespace XCharts
}
else
{
if (relativedAxis == null || !MathUtil.Approximately(current, relativedAxis.context.y))
if (relativedAxis == null || !MathUtil.Approximately(current, GetAxisLineXOrY()))
ChartDrawer.DrawLineStyle(vh,
lineType,
lineWidth,
@@ -761,7 +768,6 @@ namespace XCharts
new Vector3(startX + splitLength, current),
lineColor);
}
}
}
current += scaleWidth;

View File

@@ -120,15 +120,15 @@ namespace XCharts.Runtime
maxValue = -maxValue;
}
if (forcePercent)
return string.Format("{0}%", (int)value);
return string.Format("{0}%", (int) value);
else
return axis.axisLabel.GetFormatterContent(index, value, minValue, maxValue);
}
else if (axis.type == Axis.AxisType.Log)
{
float value = axis.logBaseE
? Mathf.Exp(axis.GetLogMinIndex() + index)
: Mathf.Pow(axis.logBase, axis.GetLogMinIndex() + index);
double value = axis.logBaseE ?
System.Math.Exp(axis.GetLogMinIndex() + index) :
System.Math.Pow(axis.logBase, axis.GetLogMinIndex() + index);
if (axis.inverse)
{
value = -value;
@@ -206,16 +206,16 @@ namespace XCharts.Runtime
if (axis.boundaryGap)
{
scaleNum = dataCount > 2 && dataCount % splitNum == 0
? splitNum + 1
: splitNum + 2;
scaleNum = dataCount > 2 && dataCount % splitNum == 0 ?
splitNum + 1 :
splitNum + 2;
}
else
{
if (dataCount < splitNum) scaleNum = splitNum;
else scaleNum = dataCount > 2 && dataCount % splitNum == 0
? splitNum
: splitNum + 1;
else scaleNum = dataCount > 2 && dataCount % splitNum == 0 ?
splitNum :
splitNum + 1;
}
return scaleNum;
}
@@ -245,9 +245,9 @@ namespace XCharts.Runtime
{
var value = axis.GetLabelValue(index);
var lastValue = axis.GetLabelValue(index - 1);
return axis.context.minMaxRange == 0
? 0
: (float)(coordinateWidth * (value - lastValue) / axis.context.minMaxRange);
return axis.context.minMaxRange == 0 ?
0 :
(float) (coordinateWidth * (value - lastValue) / axis.context.minMaxRange);
}
else
{
@@ -339,8 +339,7 @@ namespace XCharts.Runtime
return;
}
if (axis.type == Axis.AxisType.Time)
{
}
{ }
else if (axis.minMaxType == Axis.AxisMinMaxType.Custom)
{
if (axis.min != 0 || axis.max != 0)
@@ -365,8 +364,7 @@ namespace XCharts.Runtime
case Axis.AxisMinMaxType.Default:
if (minValue == 0 && maxValue == 0)
{
}
{ }
else if (minValue > 0 && maxValue > 0)
{
minValue = 0;
@@ -454,7 +452,7 @@ namespace XCharts.Runtime
if (axis.IsCategory())
{
if (dataCount == 0) dataCount = axis.data.Count;
var categoryIndex = (int)value;
var categoryIndex = (int) value;
var scaleWid = AxisHelper.GetDataWidth(axis, gridHeight, dataCount, dataZoom);
float startY = gridXY + (axis.boundaryGap ? scaleWid / 2 : 0);
return startY + scaleWid * categoryIndex;
@@ -462,7 +460,7 @@ namespace XCharts.Runtime
else
{
var yDataHig = (axis.context.minMaxRange == 0) ? 0f :
(float)((value - axis.context.minValue) / axis.context.minMaxRange * gridHeight);
(float) ((value - axis.context.minValue) / axis.context.minMaxRange * gridHeight);
return gridXY + yDataHig;
}
@@ -533,16 +531,16 @@ namespace XCharts.Runtime
{
int minIndex = axis.GetLogMinIndex();
float nowIndex = axis.GetLogValue(value);
return includeGridXY
? gridXY + (nowIndex - minIndex) / axis.splitNumber * gridHeight
: (nowIndex - minIndex) / axis.splitNumber * gridHeight;
return includeGridXY ?
gridXY + (nowIndex - minIndex) / axis.splitNumber * gridHeight :
(nowIndex - minIndex) / axis.splitNumber * gridHeight;
}
else if (axis.IsCategory())
{
var categoryIndex = (int)value;
return includeGridXY
? gridXY + (axis.boundaryGap ? scaleWidth / 2 : 0) + scaleWidth * categoryIndex
: (axis.boundaryGap ? scaleWidth / 2 : 0) + scaleWidth * categoryIndex;
var categoryIndex = (int) value;
return includeGridXY ?
gridXY + (axis.boundaryGap ? scaleWidth / 2 : 0) + scaleWidth * categoryIndex :
(axis.boundaryGap ? scaleWidth / 2 : 0) + scaleWidth * categoryIndex;
}
else
{
@@ -550,13 +548,13 @@ namespace XCharts.Runtime
if (axis.context.minMaxRange != 0)
{
if (realLength)
yDataHig = (float)(value * gridHeight / axis.context.minMaxRange);
yDataHig = (float) (value * gridHeight / axis.context.minMaxRange);
else
yDataHig = (float)((value - axis.context.minValue) / axis.context.minMaxRange * gridHeight);
yDataHig = (float) ((value - axis.context.minValue) / axis.context.minMaxRange * gridHeight);
}
return includeGridXY
? gridXY + yDataHig
: yDataHig;
return includeGridXY ?
gridXY + yDataHig :
yDataHig;
}
}
}

View File

@@ -1,4 +1,3 @@
using System;
using UnityEngine;
using UnityEngine.UI;
@@ -97,10 +96,10 @@ namespace XCharts.Runtime
return new AxisLabel()
{
m_Show = true,
m_Interval = 0,
m_Inside = false,
m_Distance = 8,
m_TextStyle = new TextStyle(),
m_Interval = 0,
m_Inside = false,
m_Distance = 8,
m_TextStyle = new TextStyle(),
};
}
}
@@ -150,9 +149,9 @@ namespace XCharts.Runtime
{
return m_FormatterFunction(labelIndex, 0, category);
}
if (string.IsNullOrEmpty(category))
if (string.IsNullOrEmpty(category))
return category;
if (string.IsNullOrEmpty(m_Formatter))
{
return m_TextLimit.GetLimitContent(category);
@@ -205,7 +204,7 @@ namespace XCharts.Runtime
{
return m_FormatterFunction(labelIndex, value, null);
}
var timestamp = (int)value;
var timestamp = (int) value;
var dateTime = DateTimeUtil.GetDateTime(timestamp);
var dateString = string.Empty;
if (string.IsNullOrEmpty(numericFormatter))

View File

@@ -1,4 +1,3 @@
using UnityEngine;
namespace XCharts.Runtime

View File

@@ -1,4 +1,3 @@
using System;
using UnityEngine;

View File

@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using UnityEngine;
@@ -43,7 +42,7 @@ namespace XCharts.Runtime
return new AxisSplitArea()
{
m_Show = false,
m_Color = new List<Color32>() { }
m_Color = new List<Color32>() { }
};
}
}

View File

@@ -1,4 +1,3 @@
using System;
using UnityEngine;

View File

@@ -1,5 +1,3 @@
using UnityEngine;
namespace XCharts.Runtime

View File

@@ -1,4 +1,3 @@
using System.Collections.Generic;
using UnityEngine;
@@ -26,6 +25,5 @@ namespace XCharts.Runtime
axisLabel.textLimit.enable = true;
}
}
}

View File

@@ -1,4 +1,3 @@
using UnityEngine;
using UnityEngine.UI;
@@ -64,10 +63,10 @@ namespace XCharts.Runtime
var theme = chart.theme;
var xAxisIndex = axis.index;
axis.painter = chart.painter;
axis.refreshComponent = delegate ()
axis.refreshComponent = delegate()
{
UpdateContext(axis);
InitAxis(axis, null, chart, this,
InitAxis(null,
m_Orient,
axis.context.x,
axis.context.y,
@@ -118,7 +117,7 @@ namespace XCharts.Runtime
var dataZoom = chart.GetDataZoomOfAxis(axis);
DrawAxisSplit(vh, axis, chart.theme.axis, dataZoom,
DrawAxisSplit(vh, chart.theme.axis, dataZoom,
m_Orient,
axis.context.x,
axis.context.y,
@@ -159,5 +158,10 @@ namespace XCharts.Runtime
axis.context.width);
}
}
protected override float GetAxisLineXOrY()
{
return component.context.y;
}
}
}

View File

@@ -1,4 +1,3 @@
using System.Collections.Generic;
namespace XCharts.Runtime

View File

@@ -1,4 +1,3 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@@ -52,7 +51,7 @@ namespace XCharts.Runtime
double tempMinValue = 0;
double tempMaxValue = 0;
SeriesHelper.GetXMinMaxValue(chart.series, null, axis.polarIndex, true, axis.inverse, out tempMinValue,
out tempMaxValue, true);
out tempMaxValue, true);
AxisHelper.AdjustMinMaxValue(axis, ref tempMinValue, ref tempMaxValue, true);
if (tempMinValue != axis.context.minValue || tempMaxValue != axis.context.maxValue)
{
@@ -132,8 +131,8 @@ namespace XCharts.Runtime
var cenPos = polar.context.center;
var dire = ChartHelper.GetDire(startAngle, true).normalized;
var tickLength = axis.axisTick.GetLength(chart.theme.axis.tickLength);
var tickVector = ChartHelper.GetVertialDire(dire)
* (tickLength + axis.axisLabel.distance);
var tickVector = ChartHelper.GetVertialDire(dire) *
(tickLength + axis.axisLabel.distance);
return ChartHelper.GetPos(cenPos, totalWidth, startAngle, true) + tickVector;
}
@@ -168,9 +167,9 @@ namespace XCharts.Runtime
}
if (radiusAxis.show && radiusAxis.axisTick.show)
{
if ((i == 0 && radiusAxis.axisTick.showStartTick)
|| (i == size && radiusAxis.axisTick.showEndTick)
|| (i > 0 && i < size))
if ((i == 0 && radiusAxis.axisTick.showStartTick) ||
(i == size && radiusAxis.axisTick.showEndTick) ||
(i > 0 && i < size))
{
UGL.DrawLine(vh, pos, pos + tickVetor, tickWidth, chart.theme.axis.lineColor);
}

View File

@@ -1,4 +1,3 @@
using System.Collections.Generic;
using UnityEngine;
@@ -87,15 +86,15 @@ namespace XCharts.Runtime
if (m_Orient == Orient.Horizonal)
{
context.width = width == 0
? chartWidth - context.left - context.right
: (width <= 1 ? chartWidth * width : width);
context.width = width == 0 ?
chartWidth - context.left - context.right :
(width <= 1 ? chartWidth * width : width);
}
else
{
context.width = width == 0
? chartHeight - context.top - context.bottom
: (width <= 1 ? chartHeight * width : width);
context.width = width == 0 ?
chartHeight - context.top - context.bottom :
(width <= 1 ? chartHeight * width : width);
}
if (context.left != 0 && context.right == 0)

View File

@@ -1,4 +1,3 @@
using UnityEngine;
using UnityEngine.UI;
@@ -32,14 +31,14 @@ namespace XCharts.Runtime
var theme = chart.theme;
var xAxisIndex = axis.index;
axis.painter = chart.painter;
axis.refreshComponent = delegate ()
axis.refreshComponent = delegate()
{
axis.UpdateRuntimeData(chart.chartX,
chart.chartY,
chart.chartWidth,
chart.chartHeight);
InitAxis(axis, null, chart, this,
InitAxis(null,
axis.orient,
axis.context.x,
axis.context.y,
@@ -83,7 +82,7 @@ namespace XCharts.Runtime
if (AxisHelper.NeedShowSplit(axis))
{
var dataZoom = chart.GetDataZoomOfAxis(axis);
DrawAxisSplit(vh, axis, chart.theme.axis, dataZoom,
DrawAxisSplit(vh, chart.theme.axis, dataZoom,
axis.orient,
axis.context.x,
axis.context.y,
@@ -109,14 +108,18 @@ namespace XCharts.Runtime
{
if (axis.show && axis.axisLine.show)
{
var axisStartY = axis.context.y + axis.offset;
DrawAxisLine(vh, axis,
chart.theme.axis,
axis.orient,
axis.context.x,
axisStartY,
GetAxisLineXOrY(),
axis.context.width);
}
}
protected override float GetAxisLineXOrY()
{
return component.context.y + component.offset;
}
}
}

View File

@@ -1,4 +1,3 @@
using System.Collections.Generic;
using UnityEngine;

View File

@@ -1,4 +1,3 @@
using UnityEngine;
using UnityEngine.UI;
@@ -32,13 +31,13 @@ namespace XCharts.Runtime
var theme = chart.theme;
var xAxisIndex = xAxis.index;
xAxis.painter = chart.painter;
xAxis.refreshComponent = delegate ()
xAxis.refreshComponent = delegate()
{
var grid = chart.GetChartComponent<GridCoord>(xAxis.gridIndex);
if (grid != null)
{
var yAxis = chart.GetChartComponent<YAxis>(xAxis.index);
InitAxis(xAxis, yAxis, chart, this,
InitAxis(yAxis,
orient,
grid.context.x,
grid.context.y,
@@ -94,7 +93,7 @@ namespace XCharts.Runtime
var relativedAxis = chart.GetChartComponent<YAxis>(xAxis.gridIndex);
var dataZoom = chart.GetDataZoomOfAxis(xAxis);
DrawAxisSplit(vh, xAxis, chart.theme.axis, dataZoom,
DrawAxisSplit(vh, chart.theme.axis, dataZoom,
Orient.Horizonal,
grid.context.x,
grid.context.y,
@@ -114,16 +113,10 @@ namespace XCharts.Runtime
var dataZoom = chart.GetDataZoomOfAxis(xAxis);
var startY = grid.context.y + xAxis.offset;
if (xAxis.IsTop())
startY += grid.context.height;
else
startY += ComponentHelper.GetXAxisOnZeroOffset(chart.components, xAxis);
DrawAxisTick(vh, xAxis, chart.theme.axis, dataZoom,
Orient.Horizonal,
grid.context.x,
startY,
GetAxisLineXOrY(),
grid.context.width);
}
}
@@ -136,18 +129,24 @@ namespace XCharts.Runtime
if (grid == null)
return;
var startY = grid.context.y + xAxis.offset;
if (xAxis.IsTop())
startY += grid.context.height;
else
startY += ComponentHelper.GetXAxisOnZeroOffset(chart.components, xAxis);
DrawAxisLine(vh, xAxis, chart.theme.axis,
Orient.Horizonal,
grid.context.x,
startY,
GetAxisLineXOrY(),
grid.context.width);
}
}
protected override float GetAxisLineXOrY()
{
var xAxis = component;
var grid = chart.GetChartComponent<GridCoord>(xAxis.gridIndex);
var startY = grid.context.y + xAxis.offset;
if (xAxis.IsTop())
startY += grid.context.height;
else
startY += ComponentHelper.GetXAxisOnZeroOffset(chart.components, xAxis);
return startY;
}
}
}

View File

@@ -1,4 +1,3 @@
using System.Collections.Generic;
namespace XCharts.Runtime

View File

@@ -1,4 +1,3 @@
using UnityEngine;
using UnityEngine.UI;
@@ -32,13 +31,13 @@ namespace XCharts.Runtime
var theme = chart.theme;
var yAxisIndex = yAxis.index;
yAxis.painter = chart.painter;
yAxis.refreshComponent = delegate ()
yAxis.refreshComponent = delegate()
{
var grid = chart.GetChartComponent<GridCoord>(yAxis.gridIndex);
if (grid != null)
{
var xAxis = chart.GetChartComponent<YAxis>(yAxis.index);
InitAxis(yAxis, xAxis, chart, this,
InitAxis(xAxis,
orient,
grid.context.x,
grid.context.y,
@@ -91,7 +90,7 @@ namespace XCharts.Runtime
return;
var relativedAxis = chart.GetChartComponent<XAxis>(yAxis.gridIndex);
var dataZoom = chart.GetDataZoomOfAxis(yAxis);
DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom,
DrawAxisSplit(vh, chart.theme.axis, dataZoom,
Orient.Vertical,
grid.context.x,
grid.context.y,
@@ -111,15 +110,9 @@ namespace XCharts.Runtime
var dataZoom = chart.GetDataZoomOfAxis(yAxis);
var startX = grid.context.x + yAxis.offset;
if (yAxis.IsRight())
startX += grid.context.width;
else
startX += ComponentHelper.GetYAxisOnZeroOffset(chart.components, yAxis);
DrawAxisTick(vh, yAxis, chart.theme.axis, dataZoom,
Orient.Vertical,
startX,
GetAxisLineXOrY(),
grid.context.y,
grid.context.height);
}
@@ -133,18 +126,24 @@ namespace XCharts.Runtime
if (grid == null)
return;
var startX = grid.context.x + yAxis.offset;
if (yAxis.IsRight())
startX += grid.context.width;
else
startX += ComponentHelper.GetYAxisOnZeroOffset(chart.components, yAxis);
DrawAxisLine(vh, yAxis, chart.theme.axis,
Orient.Vertical,
startX,
GetAxisLineXOrY(),
grid.context.y,
grid.context.height);
}
}
protected override float GetAxisLineXOrY()
{
var yAxis = component;
var grid = chart.GetChartComponent<GridCoord>(yAxis.gridIndex);
var startX = grid.context.x + yAxis.offset;
if (yAxis.IsRight())
startX += grid.context.width;
else
startX += ComponentHelper.GetYAxisOnZeroOffset(chart.components, yAxis);
return startX;
}
}
}