mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-28 03:58:49 +00:00
增加SmoothDash平滑虚线的支持
This commit is contained in:
@@ -73,11 +73,16 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
Normal,
|
Normal,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the normal line chart,
|
/// the smooth line chart,
|
||||||
/// 平滑曲线。
|
/// 平滑曲线。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Smooth,
|
Smooth,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// the smooth-dash line chart,
|
||||||
|
/// 平滑虚线。
|
||||||
|
/// </summary>
|
||||||
|
SmoothDash,
|
||||||
|
/// <summary>
|
||||||
/// step line.
|
/// step line.
|
||||||
/// 阶梯线图:当前点。
|
/// 阶梯线图:当前点。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@@ -131,6 +130,29 @@ namespace XCharts
|
|||||||
float currDetailProgress = lp.x;
|
float currDetailProgress = lp.x;
|
||||||
float totalDetailProgress = serie.dataPoints[dataCount - 1].x;
|
float totalDetailProgress = serie.dataPoints[dataCount - 1].x;
|
||||||
serie.animation.InitProgress(dataCount, currDetailProgress, totalDetailProgress);
|
serie.animation.InitProgress(dataCount, currDetailProgress, totalDetailProgress);
|
||||||
|
|
||||||
|
Vector3 firstLastPos = Vector3.zero, lastNextPos = Vector3.zero;
|
||||||
|
if (serie.minShow > 0 && serie.minShow < showData.Count)
|
||||||
|
{
|
||||||
|
i = serie.minShow - 1;
|
||||||
|
float yValue = showData[i].data[1];
|
||||||
|
GetDataPoint(xAxis, yAxis, showData, yValue, startX, i, scaleWid, 0, ref firstLastPos);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
firstLastPos = lp;
|
||||||
|
}
|
||||||
|
if (serie.maxShow > 0 && serie.maxShow < showData.Count)
|
||||||
|
{
|
||||||
|
i = serie.maxShow;
|
||||||
|
float yValue = showData[i].data[1];
|
||||||
|
GetDataPoint(xAxis, yAxis, showData, yValue, startX, i, scaleWid, 0, ref lastNextPos);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lastNextPos = serie.dataPoints[serie.dataPoints.Count - 1];
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 1; i < serie.dataPoints.Count; i++)
|
for (i = 1; i < serie.dataPoints.Count; i++)
|
||||||
{
|
{
|
||||||
np = serie.dataPoints[i];
|
np = serie.dataPoints[i];
|
||||||
@@ -145,8 +167,9 @@ namespace XCharts
|
|||||||
areaColor, areaToColor, zeroPos);
|
areaColor, areaToColor, zeroPos);
|
||||||
break;
|
break;
|
||||||
case LineType.Smooth:
|
case LineType.Smooth:
|
||||||
llp = i > 1 ? serie.dataPoints[i - 2] : lp;
|
case LineType.SmoothDash:
|
||||||
nnp = i < serie.dataPoints.Count - 1 ? serie.dataPoints[i + 1] : np;
|
llp = i > 1 ? serie.dataPoints[i - 2] : firstLastPos;
|
||||||
|
nnp = i < serie.dataPoints.Count - 1 ? serie.dataPoints[i + 1] : lastNextPos;
|
||||||
isFinish = DrawSmoothLine(vh, serieIndex, serie, xAxis, lp, np, llp, nnp, i,
|
isFinish = DrawSmoothLine(vh, serieIndex, serie, xAxis, lp, np, llp, nnp, i,
|
||||||
lineColor, areaColor, areaToColor, isStack, zeroPos);
|
lineColor, areaColor, areaToColor, isStack, zeroPos);
|
||||||
break;
|
break;
|
||||||
@@ -401,6 +424,7 @@ namespace XCharts
|
|||||||
areaColor, areaToColor, zeroPos);
|
areaColor, areaToColor, zeroPos);
|
||||||
break;
|
break;
|
||||||
case LineType.Smooth:
|
case LineType.Smooth:
|
||||||
|
case LineType.SmoothDash:
|
||||||
llp = i > 1 ? serie.dataPoints[i - 2] : lp;
|
llp = i > 1 ? serie.dataPoints[i - 2] : lp;
|
||||||
nnp = i < serie.dataPoints.Count - 1 ? serie.dataPoints[i + 1] : np;
|
nnp = i < serie.dataPoints.Count - 1 ? serie.dataPoints[i + 1] : np;
|
||||||
isFinish = DrawSmoothLine(vh, serieIndex, serie, yAxis, lp, np, llp, nnp, i,
|
isFinish = DrawSmoothLine(vh, serieIndex, serie, yAxis, lp, np, llp, nnp, i,
|
||||||
@@ -844,6 +868,16 @@ namespace XCharts
|
|||||||
else ChartHelper.GetBezierList(ref bezierPoints, vh, lp, np, llp, nnp, fine, lineSmoothStyle);
|
else ChartHelper.GetBezierList(ref bezierPoints, vh, lp, np, llp, nnp, fine, lineSmoothStyle);
|
||||||
|
|
||||||
Vector3 start, to;
|
Vector3 start, to;
|
||||||
|
if (serie.lineType == LineType.SmoothDash)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < bezierPoints.Count - 2; i += 2)
|
||||||
|
{
|
||||||
|
start = bezierPoints[i];
|
||||||
|
to = bezierPoints[i + 1];
|
||||||
|
ChartHelper.DrawLine(vh, start, to, lineWidth, lineColor);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
start = bezierPoints[0];
|
start = bezierPoints[0];
|
||||||
|
|
||||||
var dir = bezierPoints[1] - start;
|
var dir = bezierPoints[1] - start;
|
||||||
|
|||||||
@@ -522,7 +522,8 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
if (nep == ep) cp2 = ep;
|
if (nep == ep) cp2 = ep;
|
||||||
else cp2 = ep - (nep - sp).normalized * diff;
|
else cp2 = ep - (nep - sp).normalized * diff;
|
||||||
int segment = (int)(dist / (fine ? 3f : 7f));
|
dist = Vector3.Distance(sp, ep);
|
||||||
|
int segment = (int)(dist / (fine ? 2f : 6f));
|
||||||
if (segment < 1) segment = (int)(dist / 0.5f);
|
if (segment < 1) segment = (int)(dist / 0.5f);
|
||||||
if (segment < 4) segment = 4;
|
if (segment < 4) segment = 4;
|
||||||
GetBezierList2(ref posList, sp, ep, segment, cp1, cp2);
|
GetBezierList2(ref posList, sp, ep, segment, cp1, cp2);
|
||||||
|
|||||||
Reference in New Issue
Block a user