mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-30 05:08:48 +00:00
3.0 - optimize vert
This commit is contained in:
@@ -4,7 +4,7 @@ using UnityEngine;
|
|||||||
namespace XCharts.Example
|
namespace XCharts.Example
|
||||||
{
|
{
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
[ExecuteInEditMode]
|
//[ExecuteInEditMode]
|
||||||
[RequireComponent(typeof(BaseChart))]
|
[RequireComponent(typeof(BaseChart))]
|
||||||
public class Example_LargeData : MonoBehaviour
|
public class Example_LargeData : MonoBehaviour
|
||||||
{
|
{
|
||||||
@@ -25,21 +25,25 @@ namespace XCharts.Example
|
|||||||
chart.GetChartComponent<Title>().text = maxCacheDataNumber + "数据";
|
chart.GetChartComponent<Title>().text = maxCacheDataNumber + "数据";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double lastValue = 0d;
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
if (initCount < maxCacheDataNumber)
|
if (initCount < maxCacheDataNumber)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
initCount++;
|
initCount++;
|
||||||
if (initCount > maxCacheDataNumber) break;
|
if (initCount > maxCacheDataNumber) break;
|
||||||
chart.GetChartComponent<Title>().text = initCount + "数据";
|
chart.GetChartComponent<Title>().text = initCount + "数据";
|
||||||
|
|
||||||
timeNow = timeNow.AddSeconds(1);
|
timeNow = timeNow.AddSeconds(1);
|
||||||
float xvalue = Mathf.PI / 180 * initCount;
|
if (lastValue < 20)
|
||||||
float yvalue = Mathf.Sin(xvalue);
|
lastValue += UnityEngine.Random.Range(0, 5);
|
||||||
|
else
|
||||||
|
lastValue += UnityEngine.Random.Range(-5f, 5f);
|
||||||
|
chart.AddData(0, lastValue);
|
||||||
|
|
||||||
chart.AddData(0, 15 + yvalue * 2);
|
|
||||||
chart.AddXAxisData(timeNow.ToString("hh:mm:ss"));
|
chart.AddXAxisData(timeNow.ToString("hh:mm:ss"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ namespace XCharts
|
|||||||
ref ntp, ref nbp,
|
ref ntp, ref nbp,
|
||||||
ref itp, ref ibp,
|
ref itp, ref ibp,
|
||||||
ref clp, ref crp,
|
ref clp, ref crp,
|
||||||
ref bitp, ref bibp);
|
ref bitp, ref bibp, i);
|
||||||
|
|
||||||
if (i == 1)
|
if (i == 1)
|
||||||
{
|
{
|
||||||
@@ -283,8 +283,16 @@ namespace XCharts
|
|||||||
|
|
||||||
if (bitp == bibp)
|
if (bitp == bibp)
|
||||||
{
|
{
|
||||||
|
if (bitp)
|
||||||
AddLineVertToVertexHelper(vh, itp, ibp, lineColor, isVisualMapGradient, isLineStyleGradient,
|
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,
|
||||||
|
visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
|
||||||
|
AddLineVertToVertexHelper(vh, ltp, crp, lineColor, isVisualMapGradient, isLineStyleGradient,
|
||||||
|
visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using XUGL;
|
|
||||||
|
|
||||||
namespace XCharts
|
namespace XCharts
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1360,7 +1360,7 @@ namespace XUGL
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DrawTriangle(vh, realCenter, p2, p3, toColor, color, color);
|
AddVertToVertexHelper(vh, p3, realCenter, color, toColor, i > 0);
|
||||||
}
|
}
|
||||||
p2 = p3;
|
p2 = p3;
|
||||||
|
|
||||||
@@ -1628,19 +1628,28 @@ namespace XUGL
|
|||||||
center.y + outsideRadius * Mathf.Cos(currAngle));
|
center.y + outsideRadius * Mathf.Cos(currAngle));
|
||||||
p4 = new Vector3(center.x + insideRadius * Mathf.Sin(currAngle),
|
p4 = new Vector3(center.x + insideRadius * Mathf.Sin(currAngle),
|
||||||
center.y + insideRadius * Mathf.Cos(currAngle));
|
center.y + insideRadius * Mathf.Cos(currAngle));
|
||||||
if (!UGLHelper.IsClearColor(emptyColor)) DrawTriangle(vh, center, p1, p4, emptyColor);
|
|
||||||
if (isGradient)
|
if (isGradient)
|
||||||
{
|
{
|
||||||
var tcolor = Color32.Lerp(color, toColor, i * 1.0f / segments);
|
var tcolor = Color32.Lerp(color, toColor, i * 1.0f / segments);
|
||||||
DrawQuadrilateral(vh, p2, p3, p4, p1, tcolor, tcolor);
|
AddVertToVertexHelper(vh, p3, p4, tcolor, tcolor, i > 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DrawQuadrilateral(vh, p2, p3, p4, p1, color, color);
|
AddVertToVertexHelper(vh, p3, p4, color, color, i > 0);
|
||||||
}
|
}
|
||||||
p1 = p4;
|
p1 = p4;
|
||||||
p2 = p3;
|
p2 = p3;
|
||||||
}
|
}
|
||||||
|
if (!UGLHelper.IsClearColor(emptyColor))
|
||||||
|
{
|
||||||
|
for (int i = 0; i <= segments; i++)
|
||||||
|
{
|
||||||
|
float currAngle = realStartInAngle + i * segmentAngle;
|
||||||
|
p4 = new Vector3(center.x + insideRadius * Mathf.Sin(currAngle),
|
||||||
|
center.y + insideRadius * Mathf.Cos(currAngle));
|
||||||
|
AddVertToVertexHelper(vh, center, p4, emptyColor, emptyColor, i > 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (needBorder || needSpace || roundCap)
|
if (needBorder || needSpace || roundCap)
|
||||||
{
|
{
|
||||||
if (clockwise)
|
if (clockwise)
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ namespace XUGL
|
|||||||
ref Vector3 ntp, ref Vector3 nbp,
|
ref Vector3 ntp, ref Vector3 nbp,
|
||||||
ref Vector3 itp, ref Vector3 ibp,
|
ref Vector3 itp, ref Vector3 ibp,
|
||||||
ref Vector3 clp, ref Vector3 crp,
|
ref Vector3 clp, ref Vector3 crp,
|
||||||
ref bool bitp, ref bool bibp
|
ref bool bitp, ref bool bibp, int debugIndex = 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
var dir1 = (cp - lp).normalized;
|
var dir1 = (cp - lp).normalized;
|
||||||
@@ -319,6 +319,12 @@ namespace XUGL
|
|||||||
crp = cp + dir2v * width;
|
crp = cp + dir2v * width;
|
||||||
bibp = false;
|
bibp = false;
|
||||||
}
|
}
|
||||||
|
if (bitp == false && bibp == false && cp == np)
|
||||||
|
{
|
||||||
|
ltp = cp - dir1v * width;
|
||||||
|
clp = cp + dir1v * width;
|
||||||
|
crp = cp + dir1v * width;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user