mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-26 10:50:08 +00:00
3.0
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
@@ -13,7 +12,15 @@ namespace XCharts.Runtime
|
||||
typeof(EndLabelStyle),
|
||||
typeof(LineArrow),
|
||||
typeof(AreaStyle),
|
||||
typeof(Emphasis))]
|
||||
typeof(EmphasisItemStyle),
|
||||
typeof(EmphasisLabelStyle))]
|
||||
[SerieDataExtraComponent(
|
||||
typeof(ItemStyle),
|
||||
typeof(LabelStyle),
|
||||
typeof(SerieSymbol),
|
||||
typeof(EmphasisItemStyle),
|
||||
typeof(EmphasisLabelStyle))]
|
||||
[SerieDataExtraField("m_Ignore")]
|
||||
public class Line : Serie, INeedSerieContainer
|
||||
{
|
||||
public int containerIndex { get; internal set; }
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
@@ -14,13 +13,12 @@ namespace XCharts.Runtime
|
||||
{
|
||||
List<List<SerieData>> m_StackSerieData = new List<List<SerieData>>();
|
||||
private GridCoord m_SerieGrid;
|
||||
private float m_LastLineWidth = 0f;
|
||||
|
||||
public override Vector3 GetSerieDataLabelOffset(SerieData serieData, LabelStyle label)
|
||||
{
|
||||
var invert = label.autoOffset
|
||||
&& SerieHelper.IsDownPoint(serie, serieData.index)
|
||||
&& (serie.areaStyle == null || !serie.areaStyle.show);
|
||||
var invert = label.autoOffset &&
|
||||
SerieHelper.IsDownPoint(serie, serieData.index) &&
|
||||
(serie.areaStyle == null || !serie.areaStyle.show);
|
||||
if (invert)
|
||||
{
|
||||
var offset = label.GetOffset(serie.context.insideRadius);
|
||||
@@ -37,7 +35,7 @@ namespace XCharts.Runtime
|
||||
if (m_SerieGrid == null)
|
||||
return;
|
||||
var lineWidth = serie.lineStyle.GetWidth(chart.theme.serie.lineWidth);
|
||||
var needCheck = (chart.isPointerInChart && m_SerieGrid.IsPointerEnter()) || m_LegendEnter || m_LastLineWidth != lineWidth;
|
||||
var needCheck = (chart.isPointerInChart && m_SerieGrid.IsPointerEnter()) || m_LegendEnter;
|
||||
if (!needCheck)
|
||||
{
|
||||
if (m_LastCheckContextFlag != needCheck)
|
||||
@@ -45,10 +43,10 @@ namespace XCharts.Runtime
|
||||
m_LastCheckContextFlag = needCheck;
|
||||
serie.context.pointerItemDataIndex = -1;
|
||||
serie.context.pointerEnter = false;
|
||||
serie.highlight = false;
|
||||
serie.ResetInteract();
|
||||
foreach (var serieData in serie.data)
|
||||
{
|
||||
serieData.interact.Reset();
|
||||
}
|
||||
serieData.context.highlight = false;
|
||||
if (SeriesHelper.IsStack(chart.series))
|
||||
chart.RefreshTopPainter();
|
||||
else
|
||||
@@ -56,7 +54,6 @@ namespace XCharts.Runtime
|
||||
}
|
||||
return;
|
||||
}
|
||||
m_LastLineWidth = lineWidth;
|
||||
m_LastCheckContextFlag = needCheck;
|
||||
var themeSymbolSize = chart.theme.serie.lineSymbolSize;
|
||||
var themeSymbolSelectedSize = chart.theme.serie.lineSymbolSelectedSize;
|
||||
@@ -146,6 +143,23 @@ namespace XCharts.Runtime
|
||||
var theme = chart.theme;
|
||||
var interacting = false;
|
||||
var lineArrow = serie.lineArrow;
|
||||
var visualMap = chart.GetVisualMapOfSerie(serie);
|
||||
var isVisualMapGradient = VisualMapHelper.IsNeedLineGradient(visualMap);
|
||||
var isY = ComponentHelper.IsAnyCategoryOfYAxis(chart.components);
|
||||
|
||||
Axis axis;
|
||||
Axis relativedAxis;
|
||||
|
||||
if (isY)
|
||||
{
|
||||
axis = chart.GetChartComponent<YAxis>(serie.yAxisIndex);
|
||||
relativedAxis = chart.GetChartComponent<XAxis>(serie.xAxisIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
axis = chart.GetChartComponent<XAxis>(serie.xAxisIndex);
|
||||
relativedAxis = chart.GetChartComponent<YAxis>(serie.yAxisIndex);
|
||||
}
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var serieData = serie.GetSerieData(i);
|
||||
@@ -172,20 +186,26 @@ namespace XCharts.Runtime
|
||||
continue;
|
||||
|
||||
var highlight = serie.data[i].context.highlight || serie.highlight;
|
||||
var symbolSize = highlight
|
||||
? theme.serie.lineSymbolSelectedSize
|
||||
: theme.serie.lineSymbolSize;
|
||||
var symbolSize = highlight ?
|
||||
theme.serie.lineSymbolSelectedSize :
|
||||
theme.serie.lineSymbolSize;
|
||||
if (!serieData.interact.TryGetValue(ref symbolSize, ref interacting))
|
||||
{
|
||||
symbolSize = highlight
|
||||
? symbol.GetSelectedSize(serieData.data, symbolSize)
|
||||
: symbol.GetSize(serieData.data, symbolSize);
|
||||
symbolSize = highlight ?
|
||||
symbol.GetSelectedSize(serieData.data, symbolSize) :
|
||||
symbol.GetSize(serieData.data, symbolSize);
|
||||
serieData.interact.SetValue(ref interacting, symbolSize);
|
||||
symbolSize = serie.animation.GetSysmbolSize(symbolSize);
|
||||
}
|
||||
var symbolColor = SerieHelper.GetItemColor(serie, serieData, theme, serie.index, highlight);
|
||||
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, theme, serie.index, highlight);
|
||||
var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, serie.index, highlight, false);
|
||||
|
||||
if (isVisualMapGradient)
|
||||
{
|
||||
symbolColor = VisualMapHelper.GetLineGradientColor(visualMap, pos, m_SerieGrid, axis, relativedAxis, symbolColor);
|
||||
symbolToColor = symbolColor;
|
||||
}
|
||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, highlight);
|
||||
var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, theme, highlight);
|
||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
|
||||
@@ -289,13 +309,13 @@ namespace XCharts.Runtime
|
||||
var axisLength = isY ? m_SerieGrid.context.height : m_SerieGrid.context.width;
|
||||
var scaleWid = AxisHelper.GetDataWidth(axis, axisLength, showData.Count, dataZoom);
|
||||
|
||||
int maxCount = serie.maxShow > 0
|
||||
? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
||||
: showData.Count;
|
||||
int maxCount = serie.maxShow > 0 ?
|
||||
(serie.maxShow > showData.Count ? showData.Count : serie.maxShow) :
|
||||
showData.Count;
|
||||
int rate = LineHelper.GetDataAverageRate(serie, m_SerieGrid, maxCount, false);
|
||||
var totalAverage = serie.sampleAverage > 0
|
||||
? serie.sampleAverage
|
||||
: DataHelper.DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
|
||||
var totalAverage = serie.sampleAverage > 0 ?
|
||||
serie.sampleAverage :
|
||||
DataHelper.DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
|
||||
var dataChanging = false;
|
||||
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XUGL;
|
||||
@@ -76,7 +75,7 @@ namespace XCharts.Runtime
|
||||
var serieData = serie.data[i];
|
||||
var angle0 = serieData.context.angle;
|
||||
var angle1 = i >= serie.dataCount - 1 ? angle0 : serie.data[i + 1].context.angle;
|
||||
|
||||
|
||||
if (pointerAngle >= angle0 && pointerAngle < angle1)
|
||||
{
|
||||
serie.context.pointerItemDataIndex = i;
|
||||
@@ -146,7 +145,7 @@ namespace XCharts.Runtime
|
||||
|
||||
cp = GetPolarPos(m_SeriePolar, m_AngleAxis, datas[i], min, max, radius);
|
||||
var np = i == datas.Count - 1 ? cp :
|
||||
GetPolarPos(m_SeriePolar, m_AngleAxis, datas[i + 1], min, max, radius);
|
||||
GetPolarPos(m_SeriePolar, m_AngleAxis, datas[i + 1], min, max, radius);
|
||||
|
||||
UGLHelper.GetLinePoints(lp, cp, np, lineWidth,
|
||||
ref ltp, ref lbp,
|
||||
@@ -214,13 +213,13 @@ namespace XCharts.Runtime
|
||||
continue;
|
||||
|
||||
bool highlight = serieData.context.highlight || serie.highlight;
|
||||
if ((!symbol.show || !symbol.ShowSymbol(i, count) || serie.IsPerformanceMode())
|
||||
&& !serieData.context.highlight)
|
||||
if ((!symbol.show || !symbol.ShowSymbol(i, count) || serie.IsPerformanceMode()) &&
|
||||
!serieData.context.highlight)
|
||||
continue;
|
||||
|
||||
var symbolSize = highlight
|
||||
? symbol.GetSelectedSize(serieData.data, chart.theme.serie.lineSymbolSize)
|
||||
: symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize);
|
||||
var symbolSize = highlight ?
|
||||
symbol.GetSelectedSize(serieData.data, chart.theme.serie.lineSymbolSize) :
|
||||
symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize);
|
||||
|
||||
var symbolColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, n, highlight);
|
||||
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, n, highlight);
|
||||
@@ -243,15 +242,15 @@ namespace XCharts.Runtime
|
||||
|
||||
if (!m_AngleAxis.clockwise)
|
||||
{
|
||||
angle = m_AngleAxis.GetValueAngle((float)serieData.GetData(1));
|
||||
angle = m_AngleAxis.GetValueAngle((float) serieData.GetData(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
angle = m_AngleAxis.GetValueAngle((float)serieData.GetData(1));
|
||||
angle = m_AngleAxis.GetValueAngle((float) serieData.GetData(1));
|
||||
}
|
||||
|
||||
var value = serieData.GetData(0);
|
||||
var radius = (float)((value - min) / (max - min) * polarRadius);
|
||||
var radius = (float) ((value - min) / (max - min) * polarRadius);
|
||||
|
||||
angle = (angle + 360) % 360;
|
||||
serieData.context.angle = angle;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
@@ -69,7 +68,7 @@ namespace XCharts.Runtime
|
||||
var endLabelList = m_SerieGrid.context.endLabelList;
|
||||
if (endLabelList.Count <= 1) return;
|
||||
|
||||
endLabelList.Sort(delegate (ChartLabel a, ChartLabel b)
|
||||
endLabelList.Sort(delegate(ChartLabel a, ChartLabel b)
|
||||
{
|
||||
if (a == null || b == null) return 1;
|
||||
return b.transform.position.y.CompareTo(a.transform.position.y);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -16,7 +15,7 @@ namespace XCharts.Runtime
|
||||
var rate = 0;
|
||||
var width = isYAxis ? grid.context.height : grid.context.width;
|
||||
if (sampleDist > 0)
|
||||
rate = (int)((maxCount - serie.minShow) / (width / sampleDist));
|
||||
rate = (int) ((maxCount - serie.minShow) / (width / sampleDist));
|
||||
if (rate < 1)
|
||||
rate = 1;
|
||||
return rate;
|
||||
@@ -69,12 +68,12 @@ namespace XCharts.Runtime
|
||||
var lp = Vector3.zero;
|
||||
var isVisualMapGradient = VisualMapHelper.IsNeedAreaGradient(visualMap);
|
||||
var areaLerp = !ChartHelper.IsValueEqualsColor(areaColor, areaToColor);
|
||||
var zsp = isY
|
||||
? new Vector3(zero, points[0].position.y)
|
||||
: new Vector3(points[0].position.x, zero);
|
||||
var zep = isY
|
||||
? new Vector3(zero, points[count - 1].position.y)
|
||||
: new Vector3(points[count - 1].position.x, zero);
|
||||
var zsp = isY ?
|
||||
new Vector3(zero, points[0].position.y) :
|
||||
new Vector3(points[0].position.x, zero);
|
||||
var zep = isY ?
|
||||
new Vector3(zero, points[count - 1].position.y) :
|
||||
new Vector3(points[count - 1].position.x, zero);
|
||||
|
||||
var lastDataIsIgnore = false;
|
||||
for (int i = 0; i < points.Count; i++)
|
||||
@@ -189,8 +188,8 @@ namespace XCharts.Runtime
|
||||
var ip = Vector3.zero;
|
||||
|
||||
if (UGLHelper.GetIntersection(ltp, tp,
|
||||
new Vector3(progress, -10000),
|
||||
new Vector3(progress, 10000), ref ip))
|
||||
new Vector3(progress, -10000),
|
||||
new Vector3(progress, 10000), ref ip))
|
||||
tp = ip;
|
||||
else
|
||||
tp = new Vector3(progress, tp.y);
|
||||
@@ -203,8 +202,8 @@ namespace XCharts.Runtime
|
||||
var ip = Vector3.zero;
|
||||
|
||||
if (UGLHelper.GetIntersection(lbp, bp,
|
||||
new Vector3(progress, -10000),
|
||||
new Vector3(progress, 10000), ref ip))
|
||||
new Vector3(progress, -10000),
|
||||
new Vector3(progress, 10000), ref ip))
|
||||
bp = ip;
|
||||
else
|
||||
bp = new Vector3(progress, bp.y);
|
||||
@@ -335,7 +334,7 @@ namespace XCharts.Runtime
|
||||
if (dataCount == 2 || isBreak)
|
||||
{
|
||||
AddLineVertToVertexHelper(vh, clp, crp, lineColor, isVisualMapGradient, isLineStyleGradient,
|
||||
visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
|
||||
visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
|
||||
serie.context.lineEndPostion = cp;
|
||||
serie.context.lineEndValue = AxisHelper.GetAxisPositionValue(grid, relativedAxis, cp);
|
||||
break;
|
||||
@@ -346,7 +345,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (bitp)
|
||||
AddLineVertToVertexHelper(vh, itp, ibp, lineColor, isVisualMapGradient, isLineStyleGradient,
|
||||
visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
|
||||
visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
|
||||
else
|
||||
{
|
||||
AddLineVertToVertexHelper(vh, ltp, clp, lineColor, isVisualMapGradient, isLineStyleGradient,
|
||||
@@ -455,7 +454,7 @@ namespace XCharts.Runtime
|
||||
var ignore = serie.context.dataIgnores[i];
|
||||
var dir = (ep - sp).normalized;
|
||||
var dist = Vector3.Distance(sp, ep);
|
||||
var segment = (int)(dist / setting.lineSegmentDistance);
|
||||
var segment = (int) (dist / setting.lineSegmentDistance);
|
||||
serie.context.drawPoints.Add(new PointInfo(sp, ignore));
|
||||
for (int j = 1; j < segment; j++)
|
||||
{
|
||||
@@ -516,8 +515,8 @@ namespace XCharts.Runtime
|
||||
{
|
||||
var cp = points[i];
|
||||
var ignore = serie.context.dataIgnores[i];
|
||||
if ((isY && Mathf.Abs(lp.x - cp.x) <= lineWidth)
|
||||
|| (!isY && Mathf.Abs(lp.y - cp.y) <= lineWidth))
|
||||
if ((isY && Mathf.Abs(lp.x - cp.x) <= lineWidth) ||
|
||||
(!isY && Mathf.Abs(lp.y - cp.y) <= lineWidth))
|
||||
{
|
||||
serie.context.drawPoints.Add(new PointInfo(cp, ignore));
|
||||
lp = cp;
|
||||
@@ -526,22 +525,22 @@ namespace XCharts.Runtime
|
||||
switch (serie.lineType)
|
||||
{
|
||||
case LineType.StepStart:
|
||||
serie.context.drawPoints.Add(new PointInfo(isY
|
||||
? new Vector3(cp.x, lp.y)
|
||||
: new Vector3(lp.x, cp.y), ignore));
|
||||
serie.context.drawPoints.Add(new PointInfo(isY ?
|
||||
new Vector3(cp.x, lp.y) :
|
||||
new Vector3(lp.x, cp.y), ignore));
|
||||
break;
|
||||
case LineType.StepMiddle:
|
||||
serie.context.drawPoints.Add(new PointInfo(isY
|
||||
? new Vector3(lp.x, (lp.y + cp.y) / 2)
|
||||
: new Vector3((lp.x + cp.x) / 2, lp.y), ignore));
|
||||
serie.context.drawPoints.Add(new PointInfo(isY
|
||||
? new Vector3(cp.x, (lp.y + cp.y) / 2)
|
||||
: new Vector3((lp.x + cp.x) / 2, cp.y), ignore));
|
||||
serie.context.drawPoints.Add(new PointInfo(isY ?
|
||||
new Vector3(lp.x, (lp.y + cp.y) / 2) :
|
||||
new Vector3((lp.x + cp.x) / 2, lp.y), ignore));
|
||||
serie.context.drawPoints.Add(new PointInfo(isY ?
|
||||
new Vector3(cp.x, (lp.y + cp.y) / 2) :
|
||||
new Vector3((lp.x + cp.x) / 2, cp.y), ignore));
|
||||
break;
|
||||
case LineType.StepEnd:
|
||||
serie.context.drawPoints.Add(new PointInfo(isY
|
||||
? new Vector3(lp.x, cp.y)
|
||||
: new Vector3(cp.x, lp.y), ignore));
|
||||
serie.context.drawPoints.Add(new PointInfo(isY ?
|
||||
new Vector3(lp.x, cp.y) :
|
||||
new Vector3(cp.x, lp.y), ignore));
|
||||
break;
|
||||
}
|
||||
serie.context.drawPoints.Add(new PointInfo(cp, ignore));
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -10,6 +9,8 @@ namespace XCharts.Runtime
|
||||
[CoordOptions(typeof(GridCoord))]
|
||||
[DefaultAnimation(AnimationType.LeftToRight)]
|
||||
[SerieExtraComponent(typeof(AreaStyle))]
|
||||
[SerieDataExtraComponent()]
|
||||
[SerieDataExtraField()]
|
||||
public class SimplifiedLine : Serie, INeedSerieContainer, ISimplifiedSerie
|
||||
{
|
||||
public int containerIndex { get; internal set; }
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -183,13 +182,13 @@ namespace XCharts.Runtime
|
||||
var axisLength = isY ? m_SerieGrid.context.height : m_SerieGrid.context.width;
|
||||
var scaleWid = AxisHelper.GetDataWidth(axis, axisLength, showData.Count, dataZoom);
|
||||
|
||||
int maxCount = serie.maxShow > 0
|
||||
? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
||||
: showData.Count;
|
||||
int maxCount = serie.maxShow > 0 ?
|
||||
(serie.maxShow > showData.Count ? showData.Count : serie.maxShow) :
|
||||
showData.Count;
|
||||
int rate = LineHelper.GetDataAverageRate(serie, m_SerieGrid, maxCount, false);
|
||||
var totalAverage = serie.sampleAverage > 0
|
||||
? serie.sampleAverage
|
||||
: DataHelper.DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
|
||||
var totalAverage = serie.sampleAverage > 0 ?
|
||||
serie.sampleAverage :
|
||||
DataHelper.DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
|
||||
var dataChanging = false;
|
||||
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user