mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-24 09:50:15 +00:00
优化LineChart密集数据的绘制表现
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
* (2020.08.08) Optimize the rendering performance of `LineChart` dense data
|
||||||
* (2020.07.30) Added `LineChart` to configure gradient through `VisualMap` or `ItemStyle`#78
|
* (2020.07.30) Added `LineChart` to configure gradient through `VisualMap` or `ItemStyle`#78
|
||||||
* (2020.07.25) Fixed a problem with `LineChart` emerging abnormal in animation drawing#79
|
* (2020.07.25) Fixed a problem with `LineChart` emerging abnormal in animation drawing#79
|
||||||
* (2020.07.25) Fixed a problem with gradual discoloration on `LiquidChart` at `100%`#80
|
* (2020.07.25) Fixed a problem with gradual discoloration on `LiquidChart` at `100%`#80
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
* (2020.08.08) 优化`LineChart`密集数据的绘制表现
|
||||||
* (2020.07.30) 增加`LineChart`可通过`VisualMap`或`ItemStyle`配置渐变#78
|
* (2020.07.30) 增加`LineChart`可通过`VisualMap`或`ItemStyle`配置渐变#78
|
||||||
* (2020.07.25) 修复`LineChart`渐出动画绘制异常的问题#79
|
* (2020.07.25) 修复`LineChart`渐出动画绘制异常的问题#79
|
||||||
* (2020.07.25) 修复`LiquidChart`在`100%`时渐变色会失效的问题#80
|
* (2020.07.25) 修复`LiquidChart`在`100%`时渐变色会失效的问题#80
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Runtime.InteropServices.ComTypes;
|
||||||
/******************************************/
|
/******************************************/
|
||||||
/* */
|
/* */
|
||||||
/* Copyright (c) 2018 monitor1394 */
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
@@ -5,7 +6,6 @@
|
|||||||
/* */
|
/* */
|
||||||
/******************************************/
|
/******************************************/
|
||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@@ -650,9 +650,8 @@ namespace XCharts
|
|||||||
var isSecond = dataIndex == startIndex + 1;
|
var isSecond = dataIndex == startIndex + 1;
|
||||||
var isTheLastPos = np == nnp;
|
var isTheLastPos = np == nnp;
|
||||||
bool isYAxis = axis is YAxis;
|
bool isYAxis = axis is YAxis;
|
||||||
|
var isTurnBack = IsInRightOrUp(isYAxis, np, lp);
|
||||||
var lineWidth = serie.lineStyle.width;
|
var lineWidth = serie.lineStyle.width;
|
||||||
var ySmall = Mathf.Abs(lp.y - np.y) < lineWidth * 3;
|
|
||||||
var xSmall = Mathf.Abs(lp.x - np.x) < lineWidth * 3;
|
|
||||||
|
|
||||||
Vector3 dnPos, upPos1, upPos2, dir1v, dir2v;
|
Vector3 dnPos, upPos1, upPos2, dir1v, dir2v;
|
||||||
bool isDown;
|
bool isDown;
|
||||||
@@ -687,36 +686,37 @@ namespace XCharts
|
|||||||
stPos1 = lp - dir1v * serie.lineStyle.width;
|
stPos1 = lp - dir1v * serie.lineStyle.width;
|
||||||
stPos2 = lp + dir1v * serie.lineStyle.width;
|
stPos2 = lp + dir1v * serie.lineStyle.width;
|
||||||
}
|
}
|
||||||
if ((isYAxis && ySmall) || (!isYAxis && xSmall))
|
|
||||||
{
|
|
||||||
if (serie.animation.CheckDetailBreak(np, isYAxis)) return false;
|
|
||||||
CheckClipAndDrawLine(vh, lp, np, serie.lineStyle.width, lineColor, serie.clip);
|
|
||||||
if (serie.areaStyle.show)
|
|
||||||
{
|
|
||||||
DrawPolygonToZero(vh, lp, np, axis, zeroPos, areaColor, areaToColor, Vector3.zero);
|
|
||||||
}
|
|
||||||
stPos1 = isDown ? upPos2 : dnPos;
|
|
||||||
stPos2 = isDown ? dnPos : upPos2;
|
|
||||||
lastDnPos = dnPos;
|
|
||||||
lastIsDown = isDown;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
var smoothPoints = serie.GetUpSmoothList(dataIndex);
|
var smoothPoints = serie.GetUpSmoothList(dataIndex);
|
||||||
var smoothDownPoints = serie.GetDownSmoothList(dataIndex);
|
var smoothDownPoints = serie.GetDownSmoothList(dataIndex);
|
||||||
var dist = Vector3.Distance(lp, np);
|
var dist = Vector3.Distance(lp, np);
|
||||||
|
var lastSmoothPoint = Vector3.zero;
|
||||||
|
var lastSmoothDownPoint = Vector3.zero;
|
||||||
int segment = (int)(dist / m_Settings.lineSegmentDistance);
|
int segment = (int)(dist / m_Settings.lineSegmentDistance);
|
||||||
if (segment <= 3) segment = (int)(dist / lineWidth);
|
if (segment <= 3) segment = (int)(dist / lineWidth);
|
||||||
|
if (segment < 2) segment = 2;
|
||||||
|
if (dataIndex > startIndex)
|
||||||
|
{
|
||||||
|
lastSmoothPoint = ChartHelper.GetLastPoint(serie.GetUpSmoothList(dataIndex - 1));
|
||||||
|
lastSmoothDownPoint = ChartHelper.GetLastPoint(serie.GetDownSmoothList(dataIndex - 1));
|
||||||
|
}
|
||||||
smoothPoints.Clear();
|
smoothPoints.Clear();
|
||||||
smoothDownPoints.Clear();
|
smoothDownPoints.Clear();
|
||||||
smoothPoints.Add(stPos1);
|
if (!TryAddToList(isTurnBack, isYAxis, smoothPoints, lastSmoothPoint, stPos1, false))
|
||||||
smoothDownPoints.Add(stPos2);
|
{
|
||||||
|
smoothPoints.Add(lastSmoothPoint);
|
||||||
|
}
|
||||||
|
if (!TryAddToList(isTurnBack, isYAxis, smoothDownPoints, lastSmoothDownPoint, stPos2, false))
|
||||||
|
{
|
||||||
|
smoothDownPoints.Add(lastSmoothDownPoint);
|
||||||
|
}
|
||||||
var start = lp;
|
var start = lp;
|
||||||
Vector3 ltp1 = Vector3.zero, ltp2 = Vector3.zero;
|
Vector3 ltp1 = stPos1, ltp2 = stPos2;
|
||||||
bool isBreak = false;
|
bool isBreak = false;
|
||||||
bool isStart = false;
|
bool isStart = false;
|
||||||
|
bool isShort = false;
|
||||||
for (int i = 1; i < segment; i++)
|
for (int i = 1; i < segment; i++)
|
||||||
{
|
{
|
||||||
|
var isEndPos = i == segment - 1;
|
||||||
var cp = lp + dir1 * (dist * i / segment);
|
var cp = lp + dir1 * (dist * i / segment);
|
||||||
if (serie.animation.CheckDetailBreak(cp, isYAxis)) isBreak = true;
|
if (serie.animation.CheckDetailBreak(cp, isYAxis)) isBreak = true;
|
||||||
var tp1 = cp - dir1v * serie.lineStyle.width;
|
var tp1 = cp - dir1v * serie.lineStyle.width;
|
||||||
@@ -728,9 +728,19 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
if (!isStart)
|
if (!isStart)
|
||||||
{
|
{
|
||||||
if (isSecond || IsValue() ||
|
if (isEndPos)
|
||||||
(lastIsDown && ((isYAxis && tp2.y > lastDnPos.y) || (!isYAxis && tp2.x > lastDnPos.x))) ||
|
{
|
||||||
(!lastIsDown && ((isYAxis && tp1.y > lastDnPos.y) || (!isYAxis && tp1.x > lastDnPos.x))))
|
isShort = true;
|
||||||
|
isStart = true;
|
||||||
|
CheckClipAndDrawPolygon(vh, stPos1, upPos1, upPos2, stPos2, lineColor, serie.clip);
|
||||||
|
CheckClipAndDrawTriangle(vh, stPos2, upPos2, dnPos, lineColor, serie.clip);
|
||||||
|
TryAddToList(isTurnBack, isYAxis, smoothPoints, lastSmoothPoint, stPos1, isEndPos);
|
||||||
|
TryAddToList(isTurnBack, isYAxis, smoothPoints, lastSmoothPoint, upPos1, isEndPos);
|
||||||
|
TryAddToList(isTurnBack, isYAxis, smoothDownPoints, lastSmoothDownPoint, dnPos, isEndPos);
|
||||||
|
}
|
||||||
|
else if (isSecond || isTurnBack ||
|
||||||
|
(lastIsDown && IsInRightOrUp(isYAxis, lastDnPos, tp2)) ||
|
||||||
|
(!lastIsDown && IsInRightOrUp(isYAxis, lastDnPos, tp1)))
|
||||||
{
|
{
|
||||||
isStart = true;
|
isStart = true;
|
||||||
CheckClipAndDrawPolygon(vh, stPos1, tp1, tp2, stPos2, lineColor, serie.clip);
|
CheckClipAndDrawPolygon(vh, stPos1, tp1, tp2, stPos2, lineColor, serie.clip);
|
||||||
@@ -738,18 +748,21 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (i == segment - 1)
|
if (isEndPos)
|
||||||
{
|
{
|
||||||
if (np != nnp)
|
if (np != nnp)
|
||||||
{
|
{
|
||||||
CheckClipAndDrawPolygon(vh, ltp1, upPos1, dnPos, ltp2, lineColor, serie.clip);
|
CheckClipAndDrawPolygon(vh, ltp1, upPos1, dnPos, ltp2, lineColor, serie.clip);
|
||||||
CheckClipAndDrawTriangle(vh, upPos1, upPos2, dnPos, lineColor, serie.clip);
|
CheckClipAndDrawTriangle(vh, upPos1, upPos2, dnPos, lineColor, serie.clip);
|
||||||
}
|
}
|
||||||
else CheckClipAndDrawPolygon(vh, ltp1, upPos1, upPos2, ltp2, lineColor, serie.clip);
|
else
|
||||||
|
{
|
||||||
|
CheckClipAndDrawPolygon(vh, ltp1, upPos1, upPos2, ltp2, lineColor, serie.clip);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((isYAxis && tp2.y < dnPos.y) || (!isYAxis && tp2.x < dnPos.x) || IsValue())
|
if (IsInRightOrUp(isYAxis, tp2, dnPos) || isTurnBack)
|
||||||
{
|
{
|
||||||
CheckClipAndDrawLine(vh, start, cp, serie.lineStyle.width, lineColor, serie.clip);
|
CheckClipAndDrawLine(vh, start, cp, serie.lineStyle.width, lineColor, serie.clip);
|
||||||
}
|
}
|
||||||
@@ -760,12 +773,14 @@ namespace XCharts
|
|||||||
i = segment;
|
i = segment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (IsValue() || (IsInRightOrUp(isYAxis, tp1, dnPos) && IsInRightOrUp(isYAxis, lastDnPos, tp1)))
|
if (!isShort)
|
||||||
smoothPoints.Add(tp1);
|
{
|
||||||
if (IsValue() || (IsInRightOrUp(isYAxis, tp2, dnPos) && IsInRightOrUp(isYAxis, stPos2, tp2)))
|
TryAddToList(isTurnBack, isYAxis, smoothPoints, lastSmoothPoint, tp1, isEndPos);
|
||||||
smoothDownPoints.Add(tp2);
|
TryAddToList(isTurnBack, isYAxis, smoothDownPoints, lastSmoothDownPoint, tp2, isEndPos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -773,9 +788,24 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
if (!isStart)
|
if (!isStart)
|
||||||
{
|
{
|
||||||
if (isSecond || IsValue() ||
|
if (isEndPos)
|
||||||
(lastIsDown && ((isYAxis && tp2.y > lastDnPos.y) || (!isYAxis && tp2.x > lastDnPos.x))) ||
|
{
|
||||||
(!lastIsDown && ((isYAxis && tp1.y > lastDnPos.y) || (!isYAxis && tp1.x > lastDnPos.x))))
|
isStart = true;
|
||||||
|
isShort = true;
|
||||||
|
if (np == nnp)
|
||||||
|
CheckClipAndDrawPolygon(vh, stPos1, dnPos, upPos2, stPos2, lineColor, serie.clip);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CheckClipAndDrawPolygon(vh, stPos1, dnPos, upPos1, stPos2, lineColor, serie.clip);
|
||||||
|
CheckClipAndDrawTriangle(vh, dnPos, upPos1, upPos2, lineColor, serie.clip);
|
||||||
|
}
|
||||||
|
TryAddToList(isTurnBack, isYAxis, smoothPoints, lastSmoothPoint, dnPos, isEndPos);
|
||||||
|
TryAddToList(isTurnBack, isYAxis, smoothDownPoints, lastSmoothDownPoint, stPos2, isEndPos);
|
||||||
|
TryAddToList(isTurnBack, isYAxis, smoothDownPoints, lastSmoothDownPoint, upPos2, isEndPos);
|
||||||
|
}
|
||||||
|
else if (isSecond || isTurnBack ||
|
||||||
|
(lastIsDown && IsInRightOrUp(isYAxis, lastDnPos, tp2)) ||
|
||||||
|
(!lastIsDown && IsInRightOrUp(isYAxis, lastDnPos, tp1)))
|
||||||
{
|
{
|
||||||
isStart = true;
|
isStart = true;
|
||||||
if (stPos2 != Vector3.zero)
|
if (stPos2 != Vector3.zero)
|
||||||
@@ -786,7 +816,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (i == segment - 1)
|
if (isEndPos)
|
||||||
{
|
{
|
||||||
if (np != nnp)
|
if (np != nnp)
|
||||||
{
|
{
|
||||||
@@ -797,7 +827,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((isYAxis && tp1.y < dnPos.y) || (!isYAxis && tp1.x < dnPos.x) || IsValue())
|
if (IsInRightOrUp(isYAxis, tp1, dnPos) || isTurnBack)
|
||||||
{
|
{
|
||||||
CheckClipAndDrawLine(vh, start, cp, serie.lineStyle.width, lineColor, serie.clip);
|
CheckClipAndDrawLine(vh, start, cp, serie.lineStyle.width, lineColor, serie.clip);
|
||||||
}
|
}
|
||||||
@@ -810,43 +840,43 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (IsValue() || (IsInRightOrUp(isYAxis, tp1, dnPos) && IsInRightOrUp(isYAxis, lastDnPos, tp1)))
|
if (!isShort)
|
||||||
smoothPoints.Add(tp1);
|
{
|
||||||
if (IsValue() || IsInRightOrUp(isYAxis, lastDnPos, tp2))
|
TryAddToList(isTurnBack, isYAxis, smoothPoints, lastSmoothPoint, tp1, isEndPos);
|
||||||
smoothDownPoints.Add(tp2);
|
TryAddToList(isTurnBack, isYAxis, smoothDownPoints, lastSmoothDownPoint, tp2, isEndPos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
start = cp;
|
start = cp;
|
||||||
ltp1 = tp1;
|
ltp1 = tp1;
|
||||||
ltp2 = tp2;
|
ltp2 = tp2;
|
||||||
}
|
}
|
||||||
if (!isBreak)
|
if (!isBreak && !isShort)
|
||||||
{
|
{
|
||||||
if (isDown)
|
if (isDown)
|
||||||
{
|
{
|
||||||
smoothPoints.Add(upPos1);
|
TryAddToList(isTurnBack, isYAxis, smoothPoints, lastSmoothPoint, upPos1, true);
|
||||||
smoothPoints.Add(upPos2);
|
TryAddToList(isTurnBack, isYAxis, smoothPoints, lastSmoothPoint, upPos2, true);
|
||||||
smoothDownPoints.Add(dnPos);
|
TryAddToList(isTurnBack, isYAxis, smoothDownPoints, lastSmoothDownPoint, dnPos, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
smoothPoints.Add(dnPos);
|
TryAddToList(isTurnBack, isYAxis, smoothPoints, lastSmoothPoint, dnPos, true);
|
||||||
if (isYAxis)
|
if (isYAxis)
|
||||||
{
|
{
|
||||||
smoothDownPoints.Add(isTheLastPos ? upPos1 : upPos2);
|
TryAddToList(isTurnBack, isYAxis, smoothDownPoints, lastSmoothDownPoint, isTheLastPos ? upPos1 : upPos2, true);
|
||||||
smoothDownPoints.Add(isTheLastPos ? upPos2 : upPos1);
|
TryAddToList(isTurnBack, isYAxis, smoothDownPoints, lastSmoothDownPoint, isTheLastPos ? upPos2 : upPos1, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (isTheLastPos)
|
if (isTheLastPos)
|
||||||
{
|
{
|
||||||
smoothDownPoints.Add(upPos2);
|
TryAddToList(isTurnBack, isYAxis, smoothDownPoints, lastSmoothDownPoint, upPos2, true);
|
||||||
if (IsInRightOrUp(isYAxis, upPos2, upPos1))
|
TryAddToList(isTurnBack, isYAxis, smoothDownPoints, lastSmoothDownPoint, upPos1, true);
|
||||||
smoothDownPoints.Add(upPos1);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
smoothDownPoints.Add(upPos1);
|
TryAddToList(isTurnBack, isYAxis, smoothDownPoints, lastSmoothDownPoint, upPos1, true);
|
||||||
smoothDownPoints.Add(upPos2);
|
TryAddToList(isTurnBack, isYAxis, smoothDownPoints, lastSmoothDownPoint, upPos2, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -993,6 +1023,35 @@ namespace XCharts
|
|||||||
return !isBreak;
|
return !isBreak;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool TryAddToList(bool isTurnBack, bool isYAxis, List<Vector3> list, Vector3 lastPos, Vector3 pos, bool ignoreClose = false)
|
||||||
|
{
|
||||||
|
if (pos == Vector3.zero) return false;
|
||||||
|
if (isTurnBack)
|
||||||
|
{
|
||||||
|
list.Add(pos);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (lastPos != Vector3.zero && IsInRightOrUp(isYAxis, pos, lastPos))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (list.Count <= 0)
|
||||||
|
{
|
||||||
|
list.Add(pos);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var end = list[list.Count - 1];
|
||||||
|
if (IsInRightOrUp(isYAxis, end, pos) && (!ignoreClose || !WasTooClose(isYAxis, end, pos, ignoreClose)))
|
||||||
|
{
|
||||||
|
list.Add(pos);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void CheckLineGradientColor(Vector3 cp, ItemStyle itemStyle, Axis axis, Color defaultLineColor, ref Color lineColor)
|
private void CheckLineGradientColor(Vector3 cp, ItemStyle itemStyle, Axis axis, Color defaultLineColor, ref Color lineColor)
|
||||||
{
|
{
|
||||||
if (VisualMapHelper.IsNeedGradient(m_VisualMap))
|
if (VisualMapHelper.IsNeedGradient(m_VisualMap))
|
||||||
@@ -1001,24 +1060,19 @@ namespace XCharts
|
|||||||
lineColor = VisualMapHelper.GetItemStyleGradientColor(itemStyle, cp, this, axis, defaultLineColor);
|
lineColor = VisualMapHelper.GetItemStyleGradientColor(itemStyle, cp, this, axis, defaultLineColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsInRightOrUp(bool isYAxis, bool isLastDown, Vector3 dnPos, Vector3 checkPos)
|
|
||||||
{
|
|
||||||
if ((isLastDown && ((isYAxis && checkPos.y <= dnPos.y) || (!isYAxis && checkPos.x <= dnPos.x))) ||
|
|
||||||
(!isLastDown && ((isYAxis && checkPos.y <= dnPos.y) || (!isYAxis && checkPos.x <= dnPos.x))))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool IsInRightOrUp(bool isYAxis, Vector3 lp, Vector3 rp)
|
private bool IsInRightOrUp(bool isYAxis, Vector3 lp, Vector3 rp)
|
||||||
{
|
{
|
||||||
return lp == Vector3.zero || ((isYAxis && rp.y > lp.y) || (!isYAxis && rp.x > lp.x));
|
return lp == Vector3.zero || ((isYAxis && rp.y > lp.y) || (!isYAxis && rp.x > lp.x));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool WasTooClose(bool isYAxis, Vector3 lp, Vector3 rp, bool ignore)
|
||||||
|
{
|
||||||
|
if (ignore) return false;
|
||||||
|
if (lp == Vector3.zero || rp == Vector3.zero) return false;
|
||||||
|
if (isYAxis) return Mathf.Abs(rp.y - lp.y) < 1f;
|
||||||
|
else return Mathf.Abs(rp.x - lp.x) < 1f;
|
||||||
|
}
|
||||||
|
|
||||||
private void DrawPolygonToZero(VertexHelper vh, Vector3 sp, Vector3 ep, Axis axis, Vector3 zeroPos,
|
private void DrawPolygonToZero(VertexHelper vh, Vector3 sp, Vector3 ep, Axis axis, Vector3 zeroPos,
|
||||||
Color areaColor, Color areaToColor, Vector3 areaDiff, bool clip = false)
|
Color areaColor, Color areaToColor, Vector3 areaDiff, bool clip = false)
|
||||||
{
|
{
|
||||||
@@ -1100,9 +1154,19 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
var defaultLineColor = lineColor;
|
var defaultLineColor = lineColor;
|
||||||
bool isYAxis = xAxis is YAxis;
|
bool isYAxis = xAxis is YAxis;
|
||||||
|
var isTurnBack = IsInRightOrUp(isYAxis, np, lp);
|
||||||
var lineWidth = serie.lineStyle.width;
|
var lineWidth = serie.lineStyle.width;
|
||||||
var smoothPoints = serie.GetUpSmoothList(dataIndex);
|
var smoothPoints = serie.GetUpSmoothList(dataIndex);
|
||||||
var smoothDownPoints = serie.GetDownSmoothList(dataIndex);
|
var smoothDownPoints = serie.GetDownSmoothList(dataIndex);
|
||||||
|
var lastSmoothPoint = Vector3.zero;
|
||||||
|
var lastSmoothDownPoint = Vector3.zero;
|
||||||
|
if (dataIndex > startIndex)
|
||||||
|
{
|
||||||
|
lastSmoothPoint = ChartHelper.GetLastPoint(serie.GetUpSmoothList(dataIndex - 1));
|
||||||
|
lastSmoothDownPoint = ChartHelper.GetLastPoint(serie.GetDownSmoothList(dataIndex - 1));
|
||||||
|
TryAddToList(isTurnBack, isYAxis, smoothPoints, lastSmoothPoint, lastSmoothPoint, true);
|
||||||
|
TryAddToList(isTurnBack, isYAxis, smoothDownPoints, lastSmoothDownPoint, lastSmoothDownPoint, true);
|
||||||
|
}
|
||||||
if (isYAxis) ChartHelper.GetBezierListVertical(ref bezierPoints, lp, np, m_Settings.lineSmoothness, m_Settings.lineSmoothStyle);
|
if (isYAxis) ChartHelper.GetBezierListVertical(ref bezierPoints, lp, np, m_Settings.lineSmoothness, m_Settings.lineSmoothStyle);
|
||||||
else ChartHelper.GetBezierList(ref bezierPoints, lp, np, llp, nnp, m_Settings.lineSmoothness, m_Settings.lineSmoothStyle);
|
else ChartHelper.GetBezierList(ref bezierPoints, lp, np, llp, nnp, m_Settings.lineSmoothness, m_Settings.lineSmoothStyle);
|
||||||
|
|
||||||
@@ -1139,21 +1203,21 @@ namespace XCharts
|
|||||||
CheckLineGradientColor(lp, serie.itemStyle, xAxis, defaultLineColor, ref lineColor);
|
CheckLineGradientColor(lp, serie.itemStyle, xAxis, defaultLineColor, ref lineColor);
|
||||||
CheckClipAndDrawTriangle(vh, smoothStartPosUp, startUp, lp, lineColor, serie.clip);
|
CheckClipAndDrawTriangle(vh, smoothStartPosUp, startUp, lp, lineColor, serie.clip);
|
||||||
CheckClipAndDrawTriangle(vh, smoothStartPosDn, startDn, lp, lineColor, serie.clip);
|
CheckClipAndDrawTriangle(vh, smoothStartPosDn, startDn, lp, lineColor, serie.clip);
|
||||||
|
TryAddToList(isTurnBack, isYAxis, smoothPoints, lastSmoothPoint, smoothStartPosUp, false);
|
||||||
|
TryAddToList(isTurnBack, isYAxis, smoothDownPoints, lastSmoothDownPoint, smoothStartPosDn, false);
|
||||||
}
|
}
|
||||||
smoothPoints.Add(smoothStartPosUp);
|
|
||||||
smoothDownPoints.Add(smoothStartPosDn);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
smoothPoints.Add(startUp);
|
TryAddToList(isTurnBack, isYAxis, smoothPoints, lastSmoothPoint, startUp, false);
|
||||||
smoothDownPoints.Add(startDn);
|
TryAddToList(isTurnBack, isYAxis, smoothDownPoints, lastSmoothDownPoint, startDn, false);
|
||||||
}
|
}
|
||||||
var sourAreaColor = areaColor;
|
var sourAreaColor = areaColor;
|
||||||
var lastAreaDownEndPos = GetLastSmoothPos(serie.GetDownSmoothList(dataIndex - 1), isYAxis);
|
var bezierPointsCount = bezierPoints.Count;
|
||||||
var lastAreaUpEndPos = GetLastSmoothPos(serie.GetUpSmoothList(dataIndex - 1), isYAxis);
|
for (int k = 1; k < bezierPointsCount; k++)
|
||||||
for (int k = 1; k < bezierPoints.Count; k++)
|
|
||||||
{
|
{
|
||||||
|
var isEndPos = k == bezierPointsCount - 1;
|
||||||
to = bezierPoints[k];
|
to = bezierPoints[k];
|
||||||
if (serie.animation.CheckDetailBreak(to, isYAxis))
|
if (serie.animation.CheckDetailBreak(to, isYAxis))
|
||||||
{
|
{
|
||||||
@@ -1168,60 +1232,46 @@ namespace XCharts
|
|||||||
CheckLineGradientColor(to, serie.itemStyle, xAxis, defaultLineColor, ref lineColor);
|
CheckLineGradientColor(to, serie.itemStyle, xAxis, defaultLineColor, ref lineColor);
|
||||||
if (isYAxis) CheckClipAndDrawPolygon(vh, startDn, toDn, toUp, startUp, lineColor, serie.clip);
|
if (isYAxis) CheckClipAndDrawPolygon(vh, startDn, toDn, toUp, startUp, lineColor, serie.clip);
|
||||||
else CheckClipAndDrawPolygon(vh, startUp, toUp, toDn, startDn, lineColor, serie.clip);
|
else CheckClipAndDrawPolygon(vh, startUp, toUp, toDn, startDn, lineColor, serie.clip);
|
||||||
smoothPoints.Add(toUp);
|
TryAddToList(isTurnBack, isYAxis, smoothPoints, lastSmoothPoint, toUp, true);
|
||||||
smoothDownPoints.Add(toDn);
|
TryAddToList(isTurnBack, isYAxis, smoothDownPoints, lastSmoothDownPoint, toDn, true);
|
||||||
if (k == bezierPoints.Count - 1)
|
if (isEndPos)
|
||||||
{
|
{
|
||||||
smoothStartPosUp = toUp;
|
smoothStartPosUp = toUp;
|
||||||
smoothStartPosDn = toDn;
|
smoothStartPosDn = toDn;
|
||||||
}
|
}
|
||||||
if (serie.areaStyle.show && (serie.index == 0 || !isStack))
|
|
||||||
{
|
|
||||||
var isAllLessthen0 = IsAllLessthen0(isYAxis, zeroPos, start, to);
|
|
||||||
areaColor = isYAxis ? GetYLerpColor(sourAreaColor, areaToColor, start) : GetXLerpColor(sourAreaColor, areaToColor, start);
|
|
||||||
if (startAreaDn == Vector3.zero)
|
|
||||||
{
|
|
||||||
if (IsInRightOrUp(isYAxis, lastAreaDownEndPos, startDn) && IsInRightOrUp(isYAxis, lastAreaDownEndPos, toDn))
|
|
||||||
{
|
|
||||||
startAreaDn = startDn;
|
|
||||||
if (lastAreaDownEndPos != Vector3.zero && !isAllLessthen0)
|
|
||||||
{
|
|
||||||
DrawPolygonToZero(vh, lastAreaDownEndPos, startAreaDn, xAxis, zeroPos, areaColor, areaToColor, Vector3.zero);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (startAreaUp == Vector3.zero)
|
|
||||||
{
|
|
||||||
if (IsInRightOrUp(isYAxis, lastAreaUpEndPos, startUp) && IsInRightOrUp(isYAxis, lastAreaUpEndPos, toUp))
|
|
||||||
{
|
|
||||||
startAreaUp = startUp;
|
|
||||||
if (lastAreaUpEndPos != Vector3.zero && isAllLessthen0)
|
|
||||||
{
|
|
||||||
DrawPolygonToZero(vh, lastAreaUpEndPos, startAreaUp, xAxis, zeroPos, areaColor, areaToColor, Vector3.zero);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (startAreaDn != Vector3.zero)
|
|
||||||
{
|
|
||||||
if (!isAllLessthen0 && IsInRightOrUp(isYAxis, startAreaDn, toDn))
|
|
||||||
{
|
|
||||||
DrawPolygonToZero(vh, startAreaDn, toDn, xAxis, zeroPos, areaColor, areaToColor, Vector3.zero);
|
|
||||||
}
|
|
||||||
startAreaDn = toDn;
|
|
||||||
}
|
|
||||||
if (startAreaUp != Vector3.zero)
|
|
||||||
{
|
|
||||||
if (isAllLessthen0 && IsInRightOrUp(isYAxis, startAreaUp, toUp))
|
|
||||||
{
|
|
||||||
DrawPolygonToZero(vh, startAreaUp, toUp, xAxis, zeroPos, areaColor, areaToColor, Vector3.zero);
|
|
||||||
}
|
|
||||||
startAreaUp = toUp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
start = to;
|
start = to;
|
||||||
startUp = toUp;
|
startUp = toUp;
|
||||||
startDn = toDn;
|
startDn = toDn;
|
||||||
}
|
}
|
||||||
|
if (serie.areaStyle.show && (serie.index == 0 || !isStack))
|
||||||
|
{
|
||||||
|
if (smoothDownPoints.Count > 0)
|
||||||
|
{
|
||||||
|
start = smoothDownPoints[0];
|
||||||
|
for (int i = 1; i < smoothDownPoints.Count; i++)
|
||||||
|
{
|
||||||
|
to = smoothDownPoints[i];
|
||||||
|
if (IsInRightOrUp(!isYAxis, zeroPos, to))
|
||||||
|
{
|
||||||
|
DrawPolygonToZero(vh, start, to, xAxis, zeroPos, areaColor, areaToColor, Vector3.zero);
|
||||||
|
}
|
||||||
|
start = to;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (smoothPoints.Count > 0)
|
||||||
|
{
|
||||||
|
start = smoothPoints[smoothPoints.Count - 1];
|
||||||
|
for (int i = smoothPoints.Count - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
to = smoothPoints[i];
|
||||||
|
if (!IsInRightOrUp(!isYAxis, zeroPos, to))
|
||||||
|
{
|
||||||
|
DrawPolygonToZero(vh, to, start, xAxis, zeroPos, areaColor, areaToColor, Vector3.zero);
|
||||||
|
}
|
||||||
|
start = to;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (serie.areaStyle.show)
|
if (serie.areaStyle.show)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -808,5 +808,11 @@ namespace XCharts
|
|||||||
return check;
|
return check;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Vector3 GetLastPoint(List<Vector3> list)
|
||||||
|
{
|
||||||
|
if (list.Count <= 0) return Vector3.zero;
|
||||||
|
else return list[list.Count - 1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user