2019-10-22 04:09:04 +08:00
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
2022-02-19 22:37:57 +08:00
|
|
|
using XCharts.Runtime;
|
2022-05-22 22:17:38 +08:00
|
|
|
using XUGL;
|
2019-10-22 04:09:04 +08:00
|
|
|
|
2021-12-24 13:33:09 +08:00
|
|
|
namespace XCharts.Example
|
2019-10-22 04:09:04 +08:00
|
|
|
{
|
|
|
|
|
[DisallowMultipleComponent]
|
|
|
|
|
[ExecuteInEditMode]
|
2020-05-15 06:52:40 +08:00
|
|
|
public class Example12_CustomDrawing : MonoBehaviour
|
2019-10-22 04:09:04 +08:00
|
|
|
{
|
|
|
|
|
LineChart chart;
|
|
|
|
|
void Awake()
|
|
|
|
|
{
|
|
|
|
|
chart = gameObject.GetComponent<LineChart>();
|
|
|
|
|
if (chart == null) return;
|
|
|
|
|
|
2022-05-22 22:17:38 +08:00
|
|
|
chart.onDraw = delegate(VertexHelper vh) { };
|
2021-03-29 20:27:21 +08:00
|
|
|
// or
|
2022-05-22 22:17:38 +08:00
|
|
|
chart.onDrawBeforeSerie = delegate(VertexHelper vh, Serie serie) { };
|
2021-03-29 20:28:53 +08:00
|
|
|
// or
|
2022-05-22 22:17:38 +08:00
|
|
|
chart.onDrawAfterSerie = delegate(VertexHelper vh, Serie serie)
|
2021-03-29 20:27:21 +08:00
|
|
|
{
|
|
|
|
|
if (serie.index != 0) return;
|
2021-12-08 13:36:02 +08:00
|
|
|
var dataPoints = serie.context.dataPoints;
|
2019-10-22 04:09:04 +08:00
|
|
|
if (dataPoints.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var pos = dataPoints[3];
|
2021-11-23 13:20:07 +08:00
|
|
|
var grid = chart.GetChartComponent<GridCoord>();
|
|
|
|
|
var zeroPos = new Vector3(grid.context.x, grid.context.y);
|
2019-10-22 04:09:04 +08:00
|
|
|
var startPos = new Vector3(pos.x, zeroPos.y);
|
2021-11-23 13:20:07 +08:00
|
|
|
var endPos = new Vector3(pos.x, zeroPos.y + grid.context.height);
|
2021-01-12 13:11:15 +08:00
|
|
|
UGL.DrawLine(vh, startPos, endPos, chart.theme.serie.lineWidth, Color.blue);
|
2021-01-11 08:54:28 +08:00
|
|
|
UGL.DrawCricle(vh, pos, 5, Color.blue);
|
2019-10-22 04:09:04 +08:00
|
|
|
}
|
|
|
|
|
};
|
2021-03-29 20:27:21 +08:00
|
|
|
// or
|
2022-05-22 22:17:38 +08:00
|
|
|
chart.onDrawTop = delegate(VertexHelper vh) { };
|
2019-10-22 04:09:04 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|