mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-22 17:00:08 +00:00
增加曲线图和区域图
This commit is contained in:
@@ -8,6 +8,8 @@ namespace xcharts
|
||||
[System.Serializable]
|
||||
public class LineData
|
||||
{
|
||||
public bool smooth = false;
|
||||
public bool area = false;
|
||||
public float pointWid = 1;
|
||||
public float tickness = 0.8f;
|
||||
}
|
||||
@@ -48,7 +50,27 @@ namespace xcharts
|
||||
np = new Vector3(startX + i * scaleWid, zeroY + data.value * coordinateHig / max);
|
||||
if (i > 0)
|
||||
{
|
||||
ChartUtils.DrawLine(vh, lp, np, lineData.tickness, color);
|
||||
if (lineData.smooth)
|
||||
{
|
||||
var list = ChartUtils.GetBezierList(lp, np);
|
||||
Vector3 start, to;
|
||||
start = list[0];
|
||||
for(int k = 1; k < list.Count; k++)
|
||||
{
|
||||
to = list[k];
|
||||
ChartUtils.DrawLine(vh, start, to, lineData.tickness, color);
|
||||
start = to;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ChartUtils.DrawLine(vh, lp, np, lineData.tickness, color);
|
||||
if (lineData.area)
|
||||
{
|
||||
ChartUtils.DrawPolygon(vh, lp, np, new Vector3(np.x, zeroY), new Vector3(lp.x, zeroY), color);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
lp = np;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user