Files
XCharts/Examples/Runtime/Example12_CustomDrawing.cs

40 lines
1.3 KiB
C#
Raw Normal View History

2021-01-11 08:54:28 +08:00
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
using UnityEngine.UI;
2021-01-11 08:54:28 +08:00
using XUGL;
namespace XCharts.Examples
{
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Example12_CustomDrawing : MonoBehaviour
{
LineChart chart;
void Awake()
{
chart = gameObject.GetComponent<LineChart>();
if (chart == null) return;
2020-05-16 20:33:01 +08:00
chart.onCustomDraw = delegate (VertexHelper vh)
{
var dataPoints = chart.series.list[0].dataPoints;
if (dataPoints.Count > 0)
{
var pos = dataPoints[3];
2021-01-11 08:54:28 +08:00
var zeroPos = new Vector3(chart.grid.runtimeX, chart.grid.runtimeY);
var startPos = new Vector3(pos.x, zeroPos.y);
2021-01-12 13:11:15 +08:00
var endPos = new Vector3(pos.x, zeroPos.y + chart.grid.runtimeHeight);
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);
}
};
}
}
}