mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-20 07:20:08 +00:00
3.0
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
@@ -27,4 +26,4 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
@@ -28,4 +26,4 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -31,8 +30,8 @@ namespace XCharts.Runtime
|
||||
RemoveData();
|
||||
|
||||
var heatmapGridWid = 10f;
|
||||
int xSplitNumber = (int)(grid.context.width / heatmapGridWid);
|
||||
int ySplitNumber = (int)(grid.context.height / heatmapGridWid);
|
||||
int xSplitNumber = (int) (grid.context.width / heatmapGridWid);
|
||||
int ySplitNumber = (int) (grid.context.height / heatmapGridWid);
|
||||
|
||||
Heatmap.AddDefaultSerie(this, GenerateDefaultSerieName());
|
||||
|
||||
@@ -45,13 +44,21 @@ namespace XCharts.Runtime
|
||||
visualMap.location.align = Location.Align.BottomLeft;
|
||||
visualMap.location.bottom = 100;
|
||||
visualMap.location.left = 30;
|
||||
var colors = new List<string>{"#313695", "#4575b4", "#74add1", "#abd9e9", "#e0f3f8", "#ffffbf",
|
||||
"#fee090", "#fdae61", "#f46d43", "#d73027", "#a50026"};
|
||||
visualMap.inRange.Clear();
|
||||
foreach (var str in colors)
|
||||
var colors = new List<string>
|
||||
{
|
||||
visualMap.inRange.Add(ThemeStyle.GetColor(str));
|
||||
}
|
||||
"#313695",
|
||||
"#4575b4",
|
||||
"#74add1",
|
||||
"#abd9e9",
|
||||
"#e0f3f8",
|
||||
"#ffffbf",
|
||||
"#fee090",
|
||||
"#fdae61",
|
||||
"#f46d43",
|
||||
"#d73027",
|
||||
"#a50026"
|
||||
};
|
||||
visualMap.AddColors(colors);
|
||||
for (int i = 0; i < xSplitNumber; i++)
|
||||
{
|
||||
xAxis.data.Add((i + 1).ToString());
|
||||
@@ -74,4 +81,4 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
@@ -28,4 +26,4 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -28,4 +27,4 @@ namespace XCharts.Runtime
|
||||
Parallel.AddDefaultSerie(this, GenerateDefaultSerieName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
@@ -18,4 +17,4 @@ namespace XCharts.Runtime
|
||||
Pie.AddDefaultSerie(this, GenerateDefaultSerieName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
@@ -32,4 +30,4 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
@@ -17,4 +16,4 @@ namespace XCharts.Runtime
|
||||
Radar.AddDefaultSerie(this, GenerateDefaultSerieName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
@@ -17,4 +15,4 @@ namespace XCharts.Runtime
|
||||
Ring.AddDefaultSerie(this, GenerateDefaultSerieName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
@@ -29,4 +28,4 @@ namespace XCharts.Runtime
|
||||
Scatter.AddDefaultSerie(this, GenerateDefaultSerieName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
@@ -28,4 +26,4 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
@@ -28,4 +26,4 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
@@ -28,4 +26,4 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
@@ -233,7 +232,7 @@ namespace XCharts.Runtime
|
||||
if (m_IsEnd)
|
||||
return;
|
||||
|
||||
m_ActualDuration = (int)((Time.time - startTime) * 1000) - (m_FadeOut ? fadeOutDelay : fadeInDelay);
|
||||
m_ActualDuration = (int) ((Time.time - startTime) * 1000) - (m_FadeOut ? fadeOutDelay : fadeInDelay);
|
||||
m_IsEnd = true;
|
||||
m_IsInit = false;
|
||||
|
||||
@@ -380,9 +379,9 @@ namespace XCharts.Runtime
|
||||
|
||||
public bool IsIndexAnimation()
|
||||
{
|
||||
return context.type == AnimationType.LeftToRight
|
||||
|| context.type == AnimationType.Clockwise
|
||||
|| context.type == AnimationType.AlongPath;
|
||||
return context.type == AnimationType.LeftToRight ||
|
||||
context.type == AnimationType.Clockwise ||
|
||||
context.type == AnimationType.AlongPath;
|
||||
}
|
||||
|
||||
public float GetIndexDelay(int dataIndex)
|
||||
@@ -462,9 +461,9 @@ namespace XCharts.Runtime
|
||||
if (IsInDelay())
|
||||
return;
|
||||
|
||||
m_ActualDuration = (int)((Time.time - startTime) * 1000) - fadeInDelay;
|
||||
m_ActualDuration = (int) ((Time.time - startTime) * 1000) - fadeInDelay;
|
||||
var duration = GetCurrAnimationDuration();
|
||||
var delta = (float)(total / duration * Time.deltaTime);
|
||||
var delta = (float) (total / duration * Time.deltaTime);
|
||||
if (m_FadeOut)
|
||||
{
|
||||
m_CurrDetailProgress -= delta;
|
||||
@@ -534,8 +533,8 @@ namespace XCharts.Runtime
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((destProgress - startProgress > 0 && currHig > destProgress)
|
||||
|| (destProgress - startProgress < 0 && currHig < destProgress))
|
||||
if ((destProgress - startProgress > 0 && currHig > destProgress) ||
|
||||
(destProgress - startProgress < 0 && currHig < destProgress))
|
||||
{
|
||||
currHig = destProgress;
|
||||
isEnd = true;
|
||||
@@ -613,7 +612,7 @@ namespace XCharts.Runtime
|
||||
#endif
|
||||
if (!enable || m_IsEnd)
|
||||
return -1;
|
||||
return (int)m_CurrDetailProgress;
|
||||
return (int) m_CurrDetailProgress;
|
||||
}
|
||||
|
||||
public float GetUpdateAnimationDuration()
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -39,9 +39,9 @@ namespace XCharts.Runtime
|
||||
|
||||
public static void UpdateAnimationType(AnimationStyle animation, AnimationType defaultType)
|
||||
{
|
||||
animation.context.type = animation.type == AnimationType.Default
|
||||
? defaultType
|
||||
: animation.type;
|
||||
animation.context.type = animation.type == AnimationType.Default ?
|
||||
defaultType :
|
||||
animation.type;
|
||||
}
|
||||
|
||||
public static bool GetAnimationPosition(AnimationStyle animation, bool isY, Vector3 lp, Vector3 cp, float progress, ref Vector3 ip)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@@ -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>() { }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -26,6 +25,5 @@ namespace XCharts.Runtime
|
||||
axisLabel.textLimit.enable = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -13,7 +12,7 @@ namespace XCharts.Runtime
|
||||
public override void InitComponent()
|
||||
{
|
||||
component.painter = chart.painter;
|
||||
component.refreshComponent = delegate ()
|
||||
component.refreshComponent = delegate()
|
||||
{
|
||||
var backgroundObj = ChartHelper.AddObject(s_BackgroundObjectName, chart.transform, chart.chartMinAnchor,
|
||||
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
||||
@@ -43,7 +42,7 @@ namespace XCharts.Runtime
|
||||
var p3 = new Vector3(chart.chartX + chart.chartWidth, chart.chartY);
|
||||
var p4 = new Vector3(chart.chartX, chart.chartY);
|
||||
var backgroundColor = chart.theme.GetBackgroundColor(component);
|
||||
|
||||
|
||||
UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, backgroundColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
@@ -33,11 +31,12 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
End
|
||||
}
|
||||
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private AreaOrigin m_Origin;
|
||||
[SerializeField] private Color32 m_Color;
|
||||
[SerializeField] private Color32 m_ToColor;
|
||||
[SerializeField] [Range(0, 1)] private float m_Opacity = 0.6f;
|
||||
[SerializeField][Range(0, 1)] private float m_Opacity = 0.6f;
|
||||
[SerializeField] private Color32 m_HighlightColor;
|
||||
[SerializeField] private Color32 m_HighlightToColor;
|
||||
|
||||
@@ -111,7 +110,7 @@ namespace XCharts.Runtime
|
||||
return m_Color;
|
||||
|
||||
var color = m_Color;
|
||||
color.a = (byte)(color.a * m_Opacity);
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -124,7 +123,7 @@ namespace XCharts.Runtime
|
||||
else
|
||||
{
|
||||
var color = themeColor;
|
||||
color.a = (byte)(color.a * opacity);
|
||||
color.a = (byte) (color.a * opacity);
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@@ -20,6 +19,7 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
AboveText
|
||||
}
|
||||
|
||||
[SerializeField] private bool m_Show = false;
|
||||
[SerializeField] private Layer m_Layer;
|
||||
[SerializeField] private Align m_Align = Align.Left;
|
||||
@@ -115,4 +115,4 @@ namespace XCharts.Runtime
|
||||
autoHideWhenLabelEmpty = iconStyle.autoHideWhenLabelEmpty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@@ -79,4 +78,4 @@ namespace XCharts.Runtime
|
||||
height = imageStyle.height;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ namespace XCharts.Runtime
|
||||
[SerializeField] private Color32 m_BorderColor;
|
||||
[SerializeField] private Color32 m_BorderColor0;
|
||||
[SerializeField] private Color32 m_BorderToColor;
|
||||
[SerializeField] [Range(0, 1)] private float m_Opacity = 1;
|
||||
[SerializeField][Range(0, 1)] private float m_Opacity = 1;
|
||||
[SerializeField] private string m_ItemMarker;
|
||||
[SerializeField] private string m_ItemFormatter;
|
||||
[SerializeField] private string m_NumericFormatter = "";
|
||||
@@ -237,7 +237,7 @@ namespace XCharts.Runtime
|
||||
return m_Color;
|
||||
|
||||
var color = m_Color;
|
||||
color.a = (byte)(color.a * m_Opacity);
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ namespace XCharts.Runtime
|
||||
return m_ToColor;
|
||||
|
||||
var color = m_ToColor;
|
||||
color.a = (byte)(color.a * m_Opacity);
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ namespace XCharts.Runtime
|
||||
return m_Color0;
|
||||
|
||||
var color = m_Color0;
|
||||
color.a = (byte)(color.a * m_Opacity);
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ namespace XCharts.Runtime
|
||||
if (m_Opacity == 1 || color.a == 0)
|
||||
return color;
|
||||
|
||||
color.a = (byte)(color.a * m_Opacity);
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ namespace XCharts.Runtime
|
||||
if (m_Opacity == 1 || color.a == 0)
|
||||
return color;
|
||||
|
||||
color.a = (byte)(color.a * m_Opacity);
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ namespace XCharts.Runtime
|
||||
if (m_Opacity == 1 || color.a == 0)
|
||||
return color;
|
||||
|
||||
color.a = (byte)(color.a * m_Opacity);
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ namespace XCharts.Runtime
|
||||
if (m_Opacity == 1 || color.a == 0)
|
||||
return color;
|
||||
|
||||
color.a = (byte)(color.a * m_Opacity);
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
if (m_Opacity != 1)
|
||||
{
|
||||
color.a = (byte)(color.a * m_Opacity);
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
}
|
||||
return color;
|
||||
}
|
||||
@@ -347,4 +347,4 @@ namespace XCharts.Runtime
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -20,6 +19,7 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
Start
|
||||
}
|
||||
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] private Position m_Position;
|
||||
[SerializeField]
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
@@ -40,6 +38,7 @@ namespace XCharts.Runtime
|
||||
DashDotDot,
|
||||
None,
|
||||
}
|
||||
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private Type m_Type = Type.Solid;
|
||||
[SerializeField] private Color32 m_Color;
|
||||
@@ -47,7 +46,7 @@ namespace XCharts.Runtime
|
||||
[SerializeField] private Color32 m_ToColor2;
|
||||
[SerializeField] private float m_Width = 0;
|
||||
[SerializeField] private float m_Length = 0;
|
||||
[SerializeField] [Range(0, 1)] private float m_Opacity = 1;
|
||||
[SerializeField][Range(0, 1)] private float m_Opacity = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Whether show line.
|
||||
@@ -123,8 +122,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
|
||||
public LineStyle()
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
public LineStyle(float width)
|
||||
{
|
||||
@@ -172,7 +170,7 @@ namespace XCharts.Runtime
|
||||
return m_Color;
|
||||
|
||||
var color = m_Color;
|
||||
color.a = (byte)(color.a * m_Opacity);
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -203,7 +201,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
if (m_Opacity != 1)
|
||||
{
|
||||
color.a = (byte)(color.a * m_Opacity);
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
}
|
||||
return color;
|
||||
}
|
||||
@@ -232,7 +230,7 @@ namespace XCharts.Runtime
|
||||
else
|
||||
{
|
||||
var color = themeColor;
|
||||
color.a = (byte)(color.a * opacity);
|
||||
color.a = (byte) (color.a * opacity);
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
#if dUI_TextMeshPro
|
||||
@@ -126,10 +125,10 @@ namespace XCharts.Runtime
|
||||
return new Location()
|
||||
{
|
||||
align = Align.CenterLeft,
|
||||
left = 0.03f,
|
||||
right = 0,
|
||||
top = 0,
|
||||
bottom = 0
|
||||
left = 0.03f,
|
||||
right = 0,
|
||||
top = 0,
|
||||
bottom = 0
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -141,10 +140,10 @@ namespace XCharts.Runtime
|
||||
return new Location()
|
||||
{
|
||||
align = Align.CenterRight,
|
||||
left = 0,
|
||||
right = 0.03f,
|
||||
top = 0,
|
||||
bottom = 0
|
||||
left = 0,
|
||||
right = 0.03f,
|
||||
top = 0,
|
||||
bottom = 0
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -156,10 +155,10 @@ namespace XCharts.Runtime
|
||||
return new Location()
|
||||
{
|
||||
align = Align.TopCenter,
|
||||
left = 0,
|
||||
right = 0,
|
||||
top = 0.03f,
|
||||
bottom = 0
|
||||
left = 0,
|
||||
right = 0,
|
||||
top = 0.03f,
|
||||
bottom = 0
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -171,10 +170,10 @@ namespace XCharts.Runtime
|
||||
return new Location()
|
||||
{
|
||||
align = Align.BottomCenter,
|
||||
left = 0,
|
||||
right = 0,
|
||||
top = 0,
|
||||
bottom = 0.03f
|
||||
left = 0,
|
||||
right = 0,
|
||||
top = 0,
|
||||
bottom = 0.03f
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -319,4 +318,4 @@ namespace XCharts.Runtime
|
||||
UpdateAlign();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据项的其他基础数据。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class SerieDataBaseInfo : ChildComponent, ISerieDataComponent
|
||||
{
|
||||
[SerializeField] private bool m_Ignore = false;
|
||||
[SerializeField] private bool m_Selected;
|
||||
[SerializeField] private float m_Radius;
|
||||
|
||||
/// <summary>
|
||||
/// 是否忽略数据。当为 true 时,数据不进行绘制。
|
||||
/// </summary>
|
||||
public bool ignore
|
||||
{
|
||||
get { return m_Ignore; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Ignore, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 自定义半径。可用在饼图中自定义某个数据项的半径。
|
||||
/// </summary>
|
||||
public float radius { get { return m_Radius; } set { m_Radius = value; } }
|
||||
/// <summary>
|
||||
/// Whether the data item is selected.
|
||||
/// |该数据项是否被选中。
|
||||
/// </summary>
|
||||
public bool selected { get { return m_Selected; } set { m_Selected = value; } }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -174,7 +173,7 @@ namespace XCharts.Runtime
|
||||
case SymbolSizeType.FromData:
|
||||
if (data != null && dataIndex >= 0 && dataIndex < data.Count)
|
||||
{
|
||||
return (float)data[dataIndex] * m_DataScale;
|
||||
return (float) data[dataIndex] * m_DataScale;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -183,7 +182,8 @@ namespace XCharts.Runtime
|
||||
case SymbolSizeType.Function:
|
||||
if (data != null && sizeFunction != null) return sizeFunction(data);
|
||||
else return size == 0 ? themeSize : size;
|
||||
default: return size == 0 ? themeSize : size;
|
||||
default:
|
||||
return size == 0 ? themeSize : size;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ namespace XCharts.Runtime
|
||||
|
||||
if (data != null && dataIndex >= 0 && dataIndex < data.Count)
|
||||
{
|
||||
return (float)data[dataIndex] * m_SelectedDataScale;
|
||||
return (float) data[dataIndex] * m_SelectedDataScale;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -218,7 +218,8 @@ namespace XCharts.Runtime
|
||||
else
|
||||
return selectedSize == 0 ? themeSelectedSize : selectedSize;
|
||||
|
||||
default: return selectedSize == 0 ? themeSelectedSize : selectedSize;
|
||||
default:
|
||||
return selectedSize == 0 ? themeSelectedSize : selectedSize;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,4 +240,4 @@ namespace XCharts.Runtime
|
||||
return (dataIndex - startIndex) % (m_Interval + 1) == 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -179,11 +178,10 @@ namespace XCharts.Runtime
|
||||
/// |带有涟漪特效动画的散点图的动画参数。
|
||||
/// </summary>
|
||||
public List<float> animationSize { get { return m_AnimationSize; } }
|
||||
|
||||
|
||||
public Color32 GetColor(Color32 defaultColor)
|
||||
{
|
||||
return ChartHelper.IsClearColor(m_Color) ? defaultColor : m_Color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -87,7 +86,6 @@ namespace XCharts.Runtime
|
||||
m_RelatedTextWidth = labelWidth;
|
||||
}
|
||||
|
||||
|
||||
public string GetLimitContent(string content)
|
||||
{
|
||||
float checkWidth = m_MaxWidth > 0 ? m_MaxWidth : m_RelatedTextWidth;
|
||||
@@ -123,9 +121,9 @@ namespace XCharts.Runtime
|
||||
int middle = content.Length / 2;
|
||||
int end = content.Length;
|
||||
float checkWidth = m_MaxWidth > 0 ? m_MaxWidth : m_RelatedTextWidth;
|
||||
|
||||
|
||||
float limit = checkWidth - m_Gap * 2 - suffixLen;
|
||||
if (limit < 0)
|
||||
if (limit < 0)
|
||||
return 0;
|
||||
|
||||
float len = 0;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -26,7 +25,7 @@ namespace XCharts.Runtime
|
||||
|
||||
public void SetPadding(float top, float right, float bottom, float left)
|
||||
{
|
||||
m_Top = top; ;
|
||||
m_Top = top;;
|
||||
m_Right = right;
|
||||
m_Bottom = bottom;
|
||||
m_Left = left;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
#if dUI_TextMeshPro
|
||||
@@ -141,9 +140,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
#endif
|
||||
|
||||
public TextStyle()
|
||||
{
|
||||
}
|
||||
public TextStyle() { }
|
||||
|
||||
public TextStyle(int fontSize)
|
||||
{
|
||||
|
||||
8
Runtime/Component/Comment.meta
Normal file
8
Runtime/Component/Comment.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81fe767917cd3492a9f587f5d5e3a037
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
65
Runtime/Component/Comment/Comment.cs
Normal file
65
Runtime/Component/Comment/Comment.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// comment of chart.
|
||||
/// |图表注解组件。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[ComponentHandler(typeof(CommentHander), true)]
|
||||
public class Comment : MainComponent
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private LabelStyle m_LabelStyle = new LabelStyle();
|
||||
[SerializeField] private CommentMarkStyle m_MarkStyle;
|
||||
[SerializeField] private List<CommentItem> m_Items = new List<CommentItem>() { new CommentItem() };
|
||||
|
||||
/// <summary>
|
||||
/// Set this to false to prevent the comment from showing.
|
||||
/// |是否显示注解组件。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); } }
|
||||
public List<CommentItem> items { get { return m_Items; } set { m_Items = value; SetComponentDirty(); } }
|
||||
/// <summary>
|
||||
/// The text style of all comments.
|
||||
/// |所有组件的文本样式。
|
||||
/// </summary>
|
||||
public LabelStyle labelStyle
|
||||
{
|
||||
get { return m_LabelStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_LabelStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The text style of all comments.
|
||||
/// |所有组件的文本样式。
|
||||
/// </summary>
|
||||
public CommentMarkStyle markStyle
|
||||
{
|
||||
get { return m_MarkStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_MarkStyle, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public LabelStyle GetLabelStyle(int index)
|
||||
{
|
||||
if (index >= 0 && index < items.Count)
|
||||
{
|
||||
var labelStyle = items[index].labelStyle;
|
||||
if (labelStyle.show) return labelStyle;
|
||||
}
|
||||
return m_LabelStyle;
|
||||
}
|
||||
|
||||
public CommentMarkStyle GetMarkStyle(int index)
|
||||
{
|
||||
if (index >= 0 && index < items.Count)
|
||||
{
|
||||
var markStyle = items[index].markStyle;
|
||||
if (markStyle.show) return markStyle;
|
||||
}
|
||||
return m_MarkStyle;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6d8757fbd847419aaed450e020e827c
|
||||
guid: ec99dd6b13a3b4e9789d007f23ffa499
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
71
Runtime/Component/Comment/CommentHander.cs
Normal file
71
Runtime/Component/Comment/CommentHander.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XUGL;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
[UnityEngine.Scripting.Preserve]
|
||||
internal sealed class CommentHander : MainComponentHandler<Comment>
|
||||
{
|
||||
private static readonly string s_CommentObjectName = "comment";
|
||||
|
||||
public override void InitComponent()
|
||||
{
|
||||
var comment = component;
|
||||
comment.painter = null;
|
||||
comment.refreshComponent = delegate()
|
||||
{
|
||||
var objName = ChartCached.GetComponentObjectName(comment);
|
||||
var commentObj = ChartHelper.AddObject(objName,
|
||||
chart.transform,
|
||||
chart.chartMinAnchor,
|
||||
chart.chartMaxAnchor,
|
||||
chart.chartPivot,
|
||||
chart.chartSizeDelta);
|
||||
|
||||
commentObj.SetActive(comment.show);
|
||||
commentObj.hideFlags = chart.chartHideFlags;
|
||||
ChartHelper.HideAllObject(commentObj);
|
||||
for (int i = 0; i < comment.items.Count; i++)
|
||||
{
|
||||
var item = comment.items[i];
|
||||
var labelStyle = comment.GetLabelStyle(i);
|
||||
var label = ChartHelper.AddChartLabel(s_CommentObjectName + i, commentObj.transform, labelStyle, chart.theme.common,
|
||||
GetContent(item), Color.clear, TextAnchor.MiddleCenter);
|
||||
label.SetActive(comment.show && item.show);
|
||||
label.SetPosition(item.position + labelStyle.offset);
|
||||
}
|
||||
};
|
||||
comment.refreshComponent();
|
||||
}
|
||||
|
||||
private string GetContent(CommentItem item)
|
||||
{
|
||||
if (item.content.IndexOf("{") >= 0)
|
||||
{
|
||||
var content = item.content;
|
||||
FormatterHelper.ReplaceContent(ref content, 0, item.labelStyle.numericFormatter, null, chart);
|
||||
return content;
|
||||
}
|
||||
else
|
||||
{
|
||||
return item.content;
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawTop(VertexHelper vh)
|
||||
{
|
||||
for (int i = 0; i < component.items.Count; i++)
|
||||
{
|
||||
var item = component.items[i];
|
||||
var markStyle = component.GetMarkStyle(i);
|
||||
if (!markStyle.show) continue;
|
||||
var color = ChartHelper.IsClearColor(markStyle.lineStyle.color) ?
|
||||
chart.theme.axis.splitLineColor :
|
||||
markStyle.lineStyle.color;
|
||||
var width = markStyle.lineStyle.width == 0 ? 1 : markStyle.lineStyle.width;
|
||||
UGL.DrawBorder(vh, item.markRect, width, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Comment/CommentHander.cs.meta
Normal file
11
Runtime/Component/Comment/CommentHander.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 45362c4eed0e54d2880f2ed359ce9385
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
47
Runtime/Component/Comment/CommentItem.cs
Normal file
47
Runtime/Component/Comment/CommentItem.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// comment of chart.
|
||||
/// |注解项。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class CommentItem : ChildComponent
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private string m_Content = "comment";
|
||||
[SerializeField] private Vector3 m_Position;
|
||||
[SerializeField] private Rect m_MarkRect;
|
||||
[SerializeField] private CommentMarkStyle m_MarkStyle = new CommentMarkStyle() { show = false };
|
||||
[SerializeField] private LabelStyle m_LabelStyle = new LabelStyle() { show = false };
|
||||
|
||||
/// <summary>
|
||||
/// Set this to false to prevent this comment item from showing.
|
||||
/// |是否显示当前注解项。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); } }
|
||||
/// <summary>
|
||||
/// position of comment.
|
||||
/// |注解项的位置坐标。
|
||||
/// </summary>
|
||||
public Vector3 position { get { return m_Position; } set { if (PropertyUtil.SetStruct(ref m_Position, value)) SetComponentDirty(); } }
|
||||
/// <summary>
|
||||
/// content of comment.
|
||||
/// |注解的文本内容。
|
||||
/// </summary>
|
||||
public string content { get { return m_Content; } set { if (PropertyUtil.SetClass(ref m_Content, value)) SetComponentDirty(); } }
|
||||
public Rect markRect { get { return m_MarkRect; } set { if (PropertyUtil.SetStruct(ref m_MarkRect, value)) SetVerticesDirty(); } }
|
||||
public CommentMarkStyle markStyle { get { return m_MarkStyle; } set { if (PropertyUtil.SetClass(ref m_MarkStyle, value)) SetVerticesDirty(); } }
|
||||
/// <summary>
|
||||
/// The text style of all comments.
|
||||
/// |注解项的文本样式。
|
||||
/// </summary>
|
||||
public LabelStyle labelStyle
|
||||
{
|
||||
get { return m_LabelStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_LabelStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Comment/CommentItem.cs.meta
Normal file
11
Runtime/Component/Comment/CommentItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f082815b255e546019b6b43ac20bf4cb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
23
Runtime/Component/Comment/CommentMarkStyle.cs
Normal file
23
Runtime/Component/Comment/CommentMarkStyle.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// comment of chart.
|
||||
/// |注解项。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class CommentMarkStyle : ChildComponent
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private LineStyle m_LineStyle;
|
||||
|
||||
/// <summary>
|
||||
/// Set this to false to prevent this comment item from showing.
|
||||
/// |是否显示当前注解项。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); } }
|
||||
public LineStyle lineStyle { get { return m_LineStyle; } set { if (PropertyUtil.SetClass(ref m_LineStyle, value)) SetVerticesDirty(); } }
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Comment/CommentMarkStyle.cs.meta
Normal file
11
Runtime/Component/Comment/CommentMarkStyle.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 764734b787d72455782bf75bb38e465e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -57,6 +56,7 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
Percent
|
||||
}
|
||||
|
||||
[SerializeField] private bool m_Enable = true;
|
||||
[SerializeField] private FilterMode m_FilterMode;
|
||||
[SerializeField] private List<int> m_XAxisIndexs = new List<int>() { 0 };
|
||||
@@ -448,11 +448,11 @@ namespace XCharts.Runtime
|
||||
start = context.y + context.height * m_Start / 100;
|
||||
end = context.y + context.height * m_End / 100;
|
||||
return ChartHelper.IsInRect(pos, context.x, context.x + context.width, start, end);
|
||||
default: return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool IsInSelectedZoom(int totalIndex, int index, bool invert)
|
||||
{
|
||||
if (totalIndex <= 0)
|
||||
@@ -486,7 +486,8 @@ namespace XCharts.Runtime
|
||||
case Orient.Vertical:
|
||||
start = context.y + context.height * m_Start / 100;
|
||||
return ChartHelper.IsInRect(pos, context.x, context.x + context.width, start - 10, start + 10);
|
||||
default: return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -507,11 +508,11 @@ namespace XCharts.Runtime
|
||||
case Orient.Vertical:
|
||||
end = context.y + context.height * m_End / 100;
|
||||
return ChartHelper.IsInRect(pos, context.x, context.x + context.width, end - 10, end + 10);
|
||||
default: return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool IsContainsAxis(Axis axis)
|
||||
{
|
||||
if (axis == null)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
@@ -21,7 +20,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
var dataZoom = component;
|
||||
dataZoom.painter = chart.m_PainterTop;
|
||||
dataZoom.refreshComponent = delegate ()
|
||||
dataZoom.refreshComponent = delegate()
|
||||
{
|
||||
var dataZoomObject = ChartHelper.AddObject(s_DefaultDataZoom + dataZoom.index, chart.transform,
|
||||
chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
||||
@@ -34,7 +33,7 @@ namespace XCharts.Runtime
|
||||
startLabel.gameObject.SetActive(true);
|
||||
|
||||
var endLabel = ChartHelper.AddChartLabel(s_DefaultDataZoom + "end", dataZoomObject.transform,
|
||||
dataZoom.labelStyle, chart.theme.dataZoom, "", Color.clear, TextAnchor.MiddleLeft);
|
||||
dataZoom.labelStyle, chart.theme.dataZoom, "", Color.clear, TextAnchor.MiddleLeft);
|
||||
endLabel.gameObject.SetActive(true);
|
||||
|
||||
dataZoom.SetStartLabel(startLabel);
|
||||
@@ -158,8 +157,8 @@ namespace XCharts.Runtime
|
||||
return;
|
||||
|
||||
var dataZoom = component;
|
||||
if (dataZoom.context.isDrag || dataZoom.context.isStartDrag || dataZoom.context.isEndDrag
|
||||
|| dataZoom.context.isCoordinateDrag)
|
||||
if (dataZoom.context.isDrag || dataZoom.context.isStartDrag || dataZoom.context.isEndDrag ||
|
||||
dataZoom.context.isCoordinateDrag)
|
||||
{
|
||||
chart.RefreshChart();
|
||||
}
|
||||
@@ -187,8 +186,8 @@ namespace XCharts.Runtime
|
||||
return;
|
||||
}
|
||||
|
||||
if (dataZoom.IsInZoom(localPos)
|
||||
&& !dataZoom.IsInSelectedZoom(localPos))
|
||||
if (dataZoom.IsInZoom(localPos) &&
|
||||
!dataZoom.IsInSelectedZoom(localPos))
|
||||
{
|
||||
var pointerX = localPos.x;
|
||||
var selectWidth = grid.context.width * (dataZoom.end - dataZoom.start) / 100;
|
||||
@@ -313,8 +312,8 @@ namespace XCharts.Runtime
|
||||
{
|
||||
var grid = chart.GetGridOfDataZoom(dataZoom);
|
||||
var deltaPercent = dataZoom.orient == Orient.Horizonal ?
|
||||
Mathf.Abs(delta / grid.context.width * 100) :
|
||||
Mathf.Abs(delta / grid.context.height * 100);
|
||||
Mathf.Abs(delta / grid.context.width * 100) :
|
||||
Mathf.Abs(delta / grid.context.height * 100);
|
||||
if (delta > 0)
|
||||
{
|
||||
if (dataZoom.end <= dataZoom.start)
|
||||
@@ -390,9 +389,9 @@ namespace XCharts.Runtime
|
||||
dataZoom.SetLabelActive(false);
|
||||
return;
|
||||
}
|
||||
if (dataZoom.IsInSelectedZoom(local)
|
||||
|| dataZoom.IsInStartZoom(local)
|
||||
|| dataZoom.IsInEndZoom(local))
|
||||
if (dataZoom.IsInSelectedZoom(local) ||
|
||||
dataZoom.IsInStartZoom(local) ||
|
||||
dataZoom.IsInEndZoom(local))
|
||||
{
|
||||
dataZoom.SetLabelActive(true);
|
||||
RefreshDataZoomLabel();
|
||||
@@ -406,8 +405,8 @@ namespace XCharts.Runtime
|
||||
{
|
||||
m_CheckDataZoomLabel = false;
|
||||
var xAxis = chart.GetChartComponent<XAxis>(dataZoom.xAxisIndexs[0]);
|
||||
var startIndex = (int)((xAxis.data.Count - 1) * dataZoom.start / 100);
|
||||
var endIndex = (int)((xAxis.data.Count - 1) * dataZoom.end / 100);
|
||||
var startIndex = (int) ((xAxis.data.Count - 1) * dataZoom.start / 100);
|
||||
var endIndex = (int) ((xAxis.data.Count - 1) * dataZoom.end / 100);
|
||||
|
||||
if (m_DataZoomLastStartIndex != startIndex || m_DataZoomLastEndIndex != endIndex)
|
||||
{
|
||||
@@ -472,7 +471,7 @@ namespace XCharts.Runtime
|
||||
var sampleDist = serie.sampleDist < 2 ? 2 : serie.sampleDist;
|
||||
var maxCount = showData.Count;
|
||||
if (sampleDist > 0)
|
||||
rate = (int)((maxCount - serie.minShow) / (dataZoom.context.width / sampleDist));
|
||||
rate = (int) ((maxCount - serie.minShow) / (dataZoom.context.width / sampleDist));
|
||||
if (rate < 1)
|
||||
rate = 1;
|
||||
|
||||
@@ -485,7 +484,7 @@ namespace XCharts.Runtime
|
||||
double value = DataHelper.SampleValue(ref showData, serie.sampleType, rate, serie.minShow, maxCount, totalAverage, i,
|
||||
serie.animation.GetUpdateAnimationDuration(), ref dataChanging, axis);
|
||||
float pX = dataZoom.context.x + i * scaleWid;
|
||||
float dataHig = (float)((maxValue - minValue) == 0 ? 0 :
|
||||
float dataHig = (float) ((maxValue - minValue) == 0 ? 0 :
|
||||
(value - minValue) / (maxValue - minValue) * dataZoom.context.height);
|
||||
np = new Vector3(pX, chart.chartY + dataZoom.bottom + dataHig);
|
||||
if (i > 0)
|
||||
@@ -561,7 +560,7 @@ namespace XCharts.Runtime
|
||||
var sampleDist = serie.sampleDist < 2 ? 2 : serie.sampleDist;
|
||||
var maxCount = showData.Count;
|
||||
if (sampleDist > 0)
|
||||
rate = (int)((maxCount - serie.minShow) / (dataZoom.context.height / sampleDist));
|
||||
rate = (int) ((maxCount - serie.minShow) / (dataZoom.context.height / sampleDist));
|
||||
if (rate < 1)
|
||||
rate = 1;
|
||||
|
||||
@@ -575,7 +574,7 @@ namespace XCharts.Runtime
|
||||
serie.animation.GetUpdateAnimationDuration(), ref dataChanging, axis);
|
||||
float pY = dataZoom.context.y + i * scaleWid;
|
||||
float dataHig = (maxValue - minValue) == 0 ? 0 :
|
||||
(float)((value - minValue) / (maxValue - minValue) * dataZoom.context.width);
|
||||
(float) ((value - minValue) / (maxValue - minValue) * dataZoom.context.width);
|
||||
np = new Vector3(chart.chartX + chart.chartWidth - dataZoom.right - dataHig, pY);
|
||||
if (i > 0)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
public static class DataZoomHelper
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
@@ -20,12 +19,12 @@ namespace XCharts.Runtime
|
||||
{
|
||||
background = new ImageStyle()
|
||||
{
|
||||
color = new Color32(32, 32, 32, 170)
|
||||
color = new Color32(32, 32, 32, 170)
|
||||
},
|
||||
textStyle = new TextStyle()
|
||||
{
|
||||
fontSize = 18,
|
||||
color = Color.white
|
||||
fontSize = 18,
|
||||
color = Color.white
|
||||
}
|
||||
};
|
||||
|
||||
@@ -56,7 +55,7 @@ namespace XCharts.Runtime
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (clickChartCount >= 2)
|
||||
if (clickChartCount > 2)
|
||||
{
|
||||
m_ShowDebugInfo = !m_ShowDebugInfo;
|
||||
ChartHelper.SetActive(m_Label.transform, m_ShowDebugInfo);
|
||||
@@ -108,6 +107,13 @@ namespace XCharts.Runtime
|
||||
SetValueWithKInfo(s_Sb, "s-vert", vertCount);
|
||||
SetValueWithKInfo(s_Sb, "t-vert", m_Chart.m_TopPainterVertCount, false);
|
||||
|
||||
var serie0 = m_Chart.GetSerie(0);
|
||||
for (int i = 0; i < serie0.dataCount; i++)
|
||||
{
|
||||
var serieData = serie0.data[i];
|
||||
s_Sb.AppendFormat("{0}:{1}\n", i, serieData.interact.targetVaue);
|
||||
}
|
||||
|
||||
m_Label.SetText(s_Sb.ToString());
|
||||
}
|
||||
}
|
||||
@@ -144,7 +150,7 @@ namespace XCharts.Runtime
|
||||
ChartHelper.SetActive(labelGameObject, m_ShowDebugInfo);
|
||||
|
||||
var label = ChartHelper.AddChartLabel("info", labelGameObject.transform, labelStyle, theme.common,
|
||||
"", Color.clear, TextAnchor.UpperLeft);
|
||||
"", Color.clear, TextAnchor.UpperLeft);
|
||||
label.SetActive(labelStyle.show);
|
||||
return label;
|
||||
}
|
||||
|
||||
8
Runtime/Component/Emphasis.meta
Normal file
8
Runtime/Component/Emphasis.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4cd4074bb11fc40059363dd78b9ee98d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
11
Runtime/Component/Emphasis/EmphasisItemStyle.cs
Normal file
11
Runtime/Component/Emphasis/EmphasisItemStyle.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 高亮的图形样式
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class EmphasisItemStyle : ItemStyle, ISerieExtraComponent, ISerieDataComponent
|
||||
{ }
|
||||
}
|
||||
11
Runtime/Component/Emphasis/EmphasisItemStyle.cs.meta
Normal file
11
Runtime/Component/Emphasis/EmphasisItemStyle.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d1095175540449f99bb9da27a5aaf04
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
11
Runtime/Component/Emphasis/EmphasisLabelLine.cs
Normal file
11
Runtime/Component/Emphasis/EmphasisLabelLine.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 高亮的标签引导线样式
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class EmphasisLabelLine : LabelLine, ISerieExtraComponent, ISerieDataComponent
|
||||
{ }
|
||||
}
|
||||
11
Runtime/Component/Emphasis/EmphasisLabelLine.cs.meta
Normal file
11
Runtime/Component/Emphasis/EmphasisLabelLine.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0d9ff3b8e09d464e9b5ea996b941314
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
11
Runtime/Component/Emphasis/EmphasisLabelStyle.cs
Normal file
11
Runtime/Component/Emphasis/EmphasisLabelStyle.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 高亮的标签样式
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class EmphasisLabelStyle : LabelStyle, ISerieExtraComponent, ISerieDataComponent
|
||||
{ }
|
||||
}
|
||||
11
Runtime/Component/Emphasis/EmphasisLabelStyle.cs.meta
Normal file
11
Runtime/Component/Emphasis/EmphasisLabelStyle.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e025b0f4be6d4141aa08bdad0102aa7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Runtime/Component/Interaction.meta
Normal file
8
Runtime/Component/Interaction.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8445ec442e5314aa891cbbd6d4d966c4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
@@ -15,6 +14,8 @@ namespace XCharts.Runtime
|
||||
private bool m_UpdateFlag = false;
|
||||
private bool m_ValueEnable = false;
|
||||
|
||||
internal float targetVaue { get { return m_TargetValue; } }
|
||||
|
||||
public void SetValue(ref bool needInteract, float size, bool highlight, float rate = 1.3f)
|
||||
{
|
||||
size = highlight ? size * rate : size;
|
||||
@@ -25,14 +26,11 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (m_TargetValue != size)
|
||||
{
|
||||
if (float.IsNaN(m_TargetValue))
|
||||
{
|
||||
needInteract = true;
|
||||
m_UpdateFlag = true;
|
||||
m_ValueEnable = true;
|
||||
m_UpdateTime = Time.time;
|
||||
m_PreviousValue = m_TargetValue;
|
||||
}
|
||||
needInteract = true;
|
||||
m_UpdateFlag = true;
|
||||
m_ValueEnable = true;
|
||||
m_UpdateTime = Time.time;
|
||||
m_PreviousValue = m_TargetValue;
|
||||
m_TargetValue = size;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ab01b44ab2454ef7ac2d71313c3d707
|
||||
guid: 42f150814cce84d66b931eed0a07d4ce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
8
Runtime/Component/Label.meta
Normal file
8
Runtime/Component/Label.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad378dd158b5d438a87405d35a3a6546
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -143,4 +142,4 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetClass(ref m_EndSymbol, value)) SetVerticesDirty(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
@@ -117,18 +117,19 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetStruct(ref m_Position, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 标签内容字符串模版格式器。支持用 \n 换行。
|
||||
/// formatter of label.
|
||||
/// |标签内容字符串模版格式器。支持用 \n 换行。
|
||||
/// 模板变量有:
|
||||
/// <list type="bullet">
|
||||
/// <item><description>{a}:系列名。</description></item>
|
||||
/// <item><description>{b}:数据名。</description></item>
|
||||
/// <item><description>{c}:数据值。</description></item>
|
||||
/// <item><description>{d}:百分比。</description></item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// {.}:圆点标记。
|
||||
/// {a}:系列名。
|
||||
/// {a}:系列名。
|
||||
/// {b}:类目值或数据名。
|
||||
/// {c}:数据值。
|
||||
/// {d}:百分比。
|
||||
/// {e}:数据名。
|
||||
/// {f}:数据和。
|
||||
/// 示例:“{b}:{c}”
|
||||
/// </example>
|
||||
/// </summary>
|
||||
public string formatter
|
||||
{
|
||||
get { return m_Formatter; }
|
||||
@@ -315,4 +316,4 @@ namespace XCharts.Runtime
|
||||
m_TextStyle.Copy(label.m_TextStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -63,7 +62,8 @@ namespace XCharts.Runtime
|
||||
/// 无法选择。
|
||||
/// </summary>
|
||||
None
|
||||
};
|
||||
}
|
||||
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private Type m_IconType = Type.Auto;
|
||||
[SerializeField] private SelectedMode m_SelectedMode = SelectedMode.Multiple;
|
||||
@@ -73,11 +73,13 @@ namespace XCharts.Runtime
|
||||
[SerializeField] private float m_ItemHeight = 12.0f;
|
||||
[SerializeField] private float m_ItemGap = 10f;
|
||||
[SerializeField] private bool m_ItemAutoColor = true;
|
||||
[SerializeField] private bool m_TextAutoColor = false;
|
||||
[SerializeField] private float m_ItemOpacity = 1;
|
||||
[SerializeField] private string m_Formatter;
|
||||
[SerializeField] protected string m_NumericFormatter = "";
|
||||
[SerializeField] private LabelStyle m_LabelStyle = new LabelStyle();
|
||||
[SerializeField] private List<string> m_Data = new List<string>();
|
||||
[SerializeField] private List<Sprite> m_Icons = new List<Sprite>();
|
||||
[SerializeField] private List<Color> m_Colors = new List<Color>();
|
||||
|
||||
public LegendContext context = new LegendContext();
|
||||
|
||||
@@ -171,19 +173,30 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetStruct(ref m_ItemAutoColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether the legend text matches the color automatically.
|
||||
/// |图例标记的文本是否自动匹配颜色。
|
||||
/// [default:false]
|
||||
/// the opacity of item color.
|
||||
/// |图例标记的图形的颜色透明度。
|
||||
/// </summary>
|
||||
public bool textAutoColor
|
||||
public float itemOpacity
|
||||
{
|
||||
get { return m_TextAutoColor; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_TextAutoColor, value)) SetComponentDirty(); }
|
||||
get { return m_ItemOpacity; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ItemOpacity, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Legend content string template formatter. Support for wrapping lines with \n. Template:{name}.
|
||||
/// Standard numeric format strings.
|
||||
/// |标准数字格式字符串。用于将数值格式化显示为字符串。
|
||||
/// 使用Axx的形式:A是格式说明符的单字符,支持C货币、D十进制、E指数、F定点数、G常规、N数字、P百分比、R往返、X十六进制的。xx是精度说明,从0-99。
|
||||
/// 参考:https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-strings
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public string numericFormatter
|
||||
{
|
||||
get { return m_NumericFormatter; }
|
||||
set { if (PropertyUtil.SetClass(ref m_NumericFormatter, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Legend content string template formatter. Support for wrapping lines with \n. Template:{value}.
|
||||
/// |图例内容字符串模版格式器。支持用 \n 换行。
|
||||
/// 模板变量为图例名称 {name}。
|
||||
/// 模板变量为图例名称 {value}。
|
||||
/// [default:null]
|
||||
/// </summary>
|
||||
public string formatter
|
||||
@@ -220,6 +233,11 @@ namespace XCharts.Runtime
|
||||
get { return m_Icons; }
|
||||
set { if (value != null) { m_Icons = value; SetComponentDirty(); } }
|
||||
}
|
||||
public List<Color> colors
|
||||
{
|
||||
get { return m_Colors; }
|
||||
set { if (value != null) { m_Colors = value; SetAllDirty(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// 图表是否需要刷新(图例组件不需要刷新图表)
|
||||
/// </summary>
|
||||
@@ -384,6 +402,14 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
public Color GetColor(int index)
|
||||
{
|
||||
if (index >= 0 && index < m_Colors.Count)
|
||||
return m_Colors[index];
|
||||
else
|
||||
return Color.white;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Callback handling when parameters change.
|
||||
/// |参数变更时的回调处理。
|
||||
@@ -392,23 +418,5 @@ namespace XCharts.Runtime
|
||||
{
|
||||
m_Location.OnChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得图例格式化后的显示内容。
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
/// <returns></returns>
|
||||
public string GetFormatterContent(string category)
|
||||
{
|
||||
if (string.IsNullOrEmpty(m_Formatter))
|
||||
return category;
|
||||
else
|
||||
{
|
||||
var content = m_Formatter.Replace("{name}", category);
|
||||
content = content.Replace("\\n", "\n");
|
||||
content = content.Replace("<br/>", "\n");
|
||||
return content;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
@@ -40,14 +39,20 @@ namespace XCharts.Runtime
|
||||
DrawLegend(vh);
|
||||
}
|
||||
|
||||
public override void OnSerieDataUpdate(int serieIndex)
|
||||
{
|
||||
if (FormatterHelper.NeedFormat(component.formatter))
|
||||
component.refreshComponent();
|
||||
}
|
||||
|
||||
private void InitLegend(Legend legend)
|
||||
{
|
||||
legend.painter = null;
|
||||
legend.refreshComponent = delegate ()
|
||||
legend.refreshComponent = delegate()
|
||||
{
|
||||
legend.OnChanged();
|
||||
var legendObject = ChartHelper.AddObject(s_LegendObjectName + legend.index, chart.transform, chart.chartMinAnchor,
|
||||
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
||||
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
||||
legend.gameObject = legendObject;
|
||||
legendObject.hideFlags = chart.chartHideFlags;
|
||||
SeriesHelper.UpdateSerieNameList(chart, ref chart.m_LegendRealShowName);
|
||||
@@ -77,10 +82,11 @@ namespace XCharts.Runtime
|
||||
for (int i = 0; i < datas.Count; i++)
|
||||
{
|
||||
if (!SeriesHelper.IsLegalLegendName(datas[i])) continue;
|
||||
string legendName = legend.GetFormatterContent(datas[i]);
|
||||
string legendName = GetFormatterContent(legend, i, datas[i]);
|
||||
var readIndex = chart.m_LegendRealShowName.IndexOf(datas[i]);
|
||||
var active = chart.IsActiveByLegend(datas[i]);
|
||||
var bgColor = LegendHelper.GetIconColor(chart, legend, readIndex, datas[i], active);
|
||||
bgColor.a = legend.itemOpacity;
|
||||
var item = LegendHelper.AddLegendItem(legend, i, datas[i], legendObject.transform, chart.theme,
|
||||
legendName, bgColor, active, readIndex);
|
||||
legend.SetButton(legendName, item, totalLegend);
|
||||
@@ -136,6 +142,20 @@ namespace XCharts.Runtime
|
||||
legend.refreshComponent();
|
||||
}
|
||||
|
||||
private string GetFormatterContent(Legend legend, int dataIndex, string category)
|
||||
{
|
||||
if (string.IsNullOrEmpty(legend.formatter))
|
||||
return category;
|
||||
else
|
||||
{
|
||||
var content = legend.formatter.Replace("{name}", category);
|
||||
content = content.Replace("{value}", category);
|
||||
var serie = chart.GetSerie(0);
|
||||
FormatterHelper.ReplaceContent(ref content, dataIndex, legend.numericFormatter, serie, chart);
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnLegendButtonClick(Legend legend, int index, string legendName, bool show)
|
||||
{
|
||||
chart.OnLegendButtonClick(index, legendName, show);
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace XCharts.Runtime
|
||||
var textStyle = legend.labelStyle.textStyle;
|
||||
if (active)
|
||||
{
|
||||
if (legend.textAutoColor) return theme.GetColor(legendIndex);
|
||||
if (legend.labelStyle.textStyle.autoColor) return theme.GetColor(legendIndex);
|
||||
else return !ChartHelper.IsClearColor(textStyle.color) ? textStyle.color : theme.legend.textColor;
|
||||
}
|
||||
else return theme.legend.unableColor;
|
||||
@@ -21,12 +21,12 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
if (legend.itemAutoColor || legend.GetIcon(readIndex) == null)
|
||||
if (legend.itemAutoColor)
|
||||
{
|
||||
return SeriesHelper.GetNameColor(chart, readIndex, legendName);
|
||||
}
|
||||
else
|
||||
return Color.white;
|
||||
return legend.GetColor(readIndex);
|
||||
}
|
||||
else return chart.theme.legend.unableColor;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ namespace XCharts.Runtime
|
||||
ChartHelper.GetOrAddComponent<Image>(iconObj);
|
||||
|
||||
var label = ChartHelper.AddChartLabel("content", btnObj.transform, legend.labelStyle, theme.legend,
|
||||
content, contentColor, TextAnchor.MiddleLeft);
|
||||
content, contentColor, TextAnchor.MiddleLeft);
|
||||
label.SetActive(true);
|
||||
|
||||
var item = new LegendItem();
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -41,7 +40,7 @@ namespace XCharts.Runtime
|
||||
private void InitMarkArea(MarkArea markArea)
|
||||
{
|
||||
markArea.painter = chart.m_PainterTop;
|
||||
markArea.refreshComponent = delegate ()
|
||||
markArea.refreshComponent = delegate()
|
||||
{
|
||||
var label = ChartHelper.AddChartLabel("label", m_MarkLineLabelRoot.transform, markArea.label, chart.theme.axis,
|
||||
component.text, Color.clear, TextAnchor.MiddleCenter);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -28,7 +27,6 @@ namespace XCharts.Runtime
|
||||
Median
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Use a line in the chart to illustrate.
|
||||
/// |图表标线。
|
||||
@@ -86,11 +84,13 @@ namespace XCharts.Runtime
|
||||
item.name = "average";
|
||||
item.type = MarkLineType.Average;
|
||||
item.lineStyle.type = LineStyle.Type.Dashed;
|
||||
item.lineStyle.color = Color.blue;
|
||||
item.lineStyle.color = Color.clear;
|
||||
item.startSymbol.show = true;
|
||||
item.startSymbol.type = SymbolType.Circle;
|
||||
item.startSymbol.size = 4;
|
||||
item.endSymbol.show = true;
|
||||
item.endSymbol.type = SymbolType.Arrow;
|
||||
item.endSymbol.size = 5;
|
||||
item.label.show = true;
|
||||
item.label.numericFormatter = "f1";
|
||||
item.label.formatter = "{c}";
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -36,6 +35,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (data.runtimeLabel != null)
|
||||
{
|
||||
data.runtimeLabel.SetActive(data.label.show);
|
||||
data.runtimeLabel.SetPosition(MarkLineHelper.GetLabelPosition(data));
|
||||
data.runtimeLabel.SetText(MarkLineHelper.GetFormatterContent(serie, data));
|
||||
}
|
||||
@@ -70,13 +70,12 @@ namespace XCharts.Runtime
|
||||
private void InitMarkLineLabel(Serie serie, MarkLineData data, Color serieColor)
|
||||
{
|
||||
data.painter = chart.m_PainterTop;
|
||||
data.refreshComponent = delegate ()
|
||||
data.refreshComponent = delegate()
|
||||
{
|
||||
var textName = string.Format("markLine_{0}_{1}", serie.index, data.index);
|
||||
var content = MarkLineHelper.GetFormatterContent(serie, data);
|
||||
var label = ChartHelper.AddChartLabel(textName, m_MarkLineLabelRoot.transform, data.label, chart.theme.axis,
|
||||
content, Color.clear, TextAnchor.MiddleCenter);
|
||||
label.SetActive(data.label.show);
|
||||
|
||||
label.SetIconActive(false);
|
||||
label.SetActive(data.label.show);
|
||||
@@ -203,7 +202,8 @@ namespace XCharts.Runtime
|
||||
for (int i = 0; i < markLine.data.Count; i++)
|
||||
{
|
||||
var data = markLine.data[i];
|
||||
data.index = i;
|
||||
// data.index = i;
|
||||
data.index = markLine.index;
|
||||
if (data.group == 0) continue;
|
||||
if (!m_TempGroupData.ContainsKey(data.group))
|
||||
{
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
@@ -18,7 +17,7 @@ namespace XCharts.Runtime
|
||||
else
|
||||
{
|
||||
var content = serieLabel.formatter;
|
||||
FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, data.runtimeValue,
|
||||
FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, serie.dataCount, data.runtimeValue,
|
||||
0, serie.serieName, data.name, data.name, Color.clear);
|
||||
return content;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
@@ -91,6 +90,7 @@ namespace XCharts.Runtime
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] private Shape m_Shape;
|
||||
[SerializeField] private float m_Radius = 100;
|
||||
@@ -281,12 +281,13 @@ namespace XCharts.Runtime
|
||||
m_Radius = 0.35f;
|
||||
m_SplitNumber = 5;
|
||||
m_Indicator = true;
|
||||
m_IndicatorList = new List<Indicator>(5){
|
||||
new Indicator(){name="indicator1",max = 0},
|
||||
new Indicator(){name="indicator2",max = 0},
|
||||
new Indicator(){name="indicator3",max = 0},
|
||||
new Indicator(){name="indicator4",max = 0},
|
||||
new Indicator(){name="indicator5",max = 0},
|
||||
m_IndicatorList = new List<Indicator>(5)
|
||||
{
|
||||
new Indicator() { name = "indicator1", max = 0 },
|
||||
new Indicator() { name = "indicator2", max = 0 },
|
||||
new Indicator() { name = "indicator3", max = 0 },
|
||||
new Indicator() { name = "indicator4", max = 0 },
|
||||
new Indicator() { name = "indicator5", max = 0 },
|
||||
};
|
||||
center[0] = 0.5f;
|
||||
center[1] = 0.4f;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user