mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-17 22:10:11 +00:00
增加customDrawCallback自定义绘制回调
This commit is contained in:
29
Demo/Scripts/Demo12_CustomDrawing.cs
Normal file
29
Demo/Scripts/Demo12_CustomDrawing.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XCharts;
|
||||
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Demo12_CustomDrawing : MonoBehaviour
|
||||
{
|
||||
LineChart chart;
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<LineChart>();
|
||||
if (chart == null) return;
|
||||
|
||||
chart.customDrawCallback = delegate (VertexHelper vh)
|
||||
{
|
||||
var dataPoints = chart.series.series[0].dataPoints;
|
||||
if (dataPoints.Count > 0)
|
||||
{
|
||||
var pos = dataPoints[3];
|
||||
var zeroPos = new Vector3(chart.coordinateX, chart.coordinateY);
|
||||
var startPos = new Vector3(pos.x, zeroPos.y);
|
||||
var endPos = new Vector3(pos.x, zeroPos.y + chart.coordinateHig);
|
||||
ChartDrawer.DrawLine(vh, startPos, endPos, 1, Color.blue);
|
||||
ChartDrawer.DrawCricle(vh,pos,5,Color.blue);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
11
Demo/Scripts/Demo12_CustomDrawing.cs.meta
Normal file
11
Demo/Scripts/Demo12_CustomDrawing.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa5ea6ac5551141c78d4031bf2aa4140
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user