当前位置:网站首页>Using unity to do simulation, I don't allow this chart plug-in, you don't know
Using unity to do simulation, I don't allow this chart plug-in, you don't know
2022-07-24 16:52:00 【InfoQ】
- CSDN Home page
- GitHub Open source address
- Unity3D Plug in sharing
- Jane book address
- My personal blog
- QQ Group :1040082875
One 、 Preface
Two 、 original text
- The plug-in Github Address :XCharts Home page
- common problem :XCharts Question and answer
- Plugin Download :unitypackage Package download
- Interface document :API manual
- Parameter configuration :Parameter configuration manual
- Novice tutorial :5 Minutes to go XCharts
3、 ... and 、 Quick start
3-1、 First download the installation package
unitypackage Package download

3-2、 Import resource packs into Unity in

3-3、Demo There are various chart effects in , As shown in the figure below :

3-4、 Build a simple scene

- LineChart: Broken line diagram
- BarChart: Histogram
- PieChart: The pie chart
- RadarChart: Radar map
- ScatterChart: Scatter plot
- HeatmapChart: Heat map
- GaugeChart: The dashboard
- RingChart: Trend chart
- PolarChart: Polar map
- LiquidChart: Liquid level diagram



3-5、 Modify the parameters





Four 、 Use code to build diagrams
4-1、 Code
using System.Collections.Generic;
using UnityEngine;
using XCharts;
public class XchartsDemo : MonoBehaviour
{
public GameObject chart;
void Start()
{
CreateChart();
}
// Create a chart
private void CreateChart()
{
List<string> xAxisValue = new List<string>();
xAxisValue.Add(" Monday ");
xAxisValue.Add(" Tuesday ");
xAxisValue.Add(" Wednesday ");
xAxisValue.Add(" Thursday ");
xAxisValue.Add(" Friday ");
List<float> yAxisValue = new List<float>();
yAxisValue.Add(8);
yAxisValue.Add(7);
yAxisValue.Add(5);
yAxisValue.Add(7);
yAxisValue.Add(8);
CreateChart(chart, " Broken line diagram ", " Weeks ", " working hours ", SerieType.Line, LineType.Normal, xAxisValue, yAxisValue);
}
/// <summary>
/// Generate charts
/// </summary>
/// <param name="_chart"> Chart components </param>
/// <param name="_title"> Chart header </param>
/// <param name="_boundarygap"> Whether the coordinate axis is left blank </param>
/// <param name="xAxisName">x Axis name of the axis </param>
/// <param name="yAxisName">y Axis name of the axis </param>
/// <param name="_serietype"> Set what type of chart </param>
/// <param name="_linetype"> What type of line segment </param>
/// <param name="xAxisValue">x The value of the shaft </param>
/// <param name="yAxisValue">y The value of the shaft </param>
public void CreateChart(GameObject _chart, string _title, string xAxisName, string yAxisName, SerieType _serietype,
LineType _linetype, List<string> xAxisValue, List<float> yAxisValue)
{
var chart = _chart.GetComponent<LineChart>();
// Header settings
chart.title.show = true;
chart.title.text = _title;
// Background map
chart.background.gameObject.SetActive(chart.background.show);
// Prompt box
chart.tooltip.show = true;
chart.tooltip.titleFormatter = " ";
// Legend components
chart.legend.show = false;
//x Axis setting
chart.xAxis0.show = true;
chart.xAxis0.type = Axis.AxisType.Category;
chart.xAxis0.splitNumber = 11;
chart.xAxis0.boundaryGap = false;
chart.xAxis0.axisName.show = true;
chart.xAxis0.axisName.name = xAxisName;
chart.xAxis1.show = false;
//y Axis setting
chart.yAxis0.show = true;
chart.yAxis0.type = Axis.AxisType.Value;
chart.yAxis0.show = true;
chart.yAxis0.splitNumber = 10;
chart.yAxis0.interval = 1;
chart.yAxis0.axisLabel.show = true;
chart.yAxis0.axisName.show = true;
chart.yAxis0.axisName.name = yAxisName;
chart.yAxis1.show = false;
// The figure of the mark
SerieSymbol sy = new SerieSymbol();
sy.show = true;
sy.type = SerieSymbolType.Circle;
sy.gap = 2;
sy.sizeType = SerieSymbolSizeType.Custom;
sy.size = 7;
// Style settings of line segments
LineStyle ls = new LineStyle();
ls.show = true;
ls.type = LineStyle.Type.Solid;
ls.toColor = new Color32(18, 240, 111, 255);
ls.toColor2 = new Color32(244, 29, 140, 255);
ls.width = 2.5f;
// The style of the text label on the chart
SerieLabel sl = new SerieLabel();
sl.show = true;
sl.position = SerieLabel.Position.Outside;
sl.offset = new Vector3(0, 20, 0);
sl.lineWidth = 25;
// Chart animation
SerieAnimation sa = new SerieAnimation();
sa.enable = true;
//y Setting of axis value
chart.series.list[0].animation = sa;
chart.series.list[0].label = sl;
chart.series.list[0].lineStyle = ls;
chart.series.list[0].symbol = sy;
chart.series.list[0].name = "";
chart.series.list[0].lineType = _linetype;
// Empty value
chart.RemoveData();
chart.AddSerie(_serietype);
// add to x The value of the shaft
for (int i = 0; i < xAxisValue.Count; i++)
{
chart.AddXAxisData(xAxisValue[i]);
}
// add to y The value of the shaft
foreach (float item in yAxisValue)
{
chart.AddData(0, item);
}
}
}
4-2、 design sketch

5、 ... and 、 an account of happenings after the event being told
边栏推荐
- JS, call in the for loop is asynchronously converted to synchronous execution
- Long awaited full platform support - Open Source im project uniapp update of openim
- 【技术】uniapp 之 在线选座 demo
- Codeforces round 690 (Div. 3) C. unique number conventional solution
- QT embed Notepad under win10
- JUC source code learning note 3 - AQS waiting queue and cyclicbarrier, BlockingQueue
- EF LINQ Miscellany
- Zhao Ming, CEO of glory: it is difficult for a single manufacturer to achieve full scene product coverage
- Codeworks round 693 (Div. 3) C. long jumps problem solution
- [zero basis] fully understand webgl (VIII)
猜你喜欢

TCP protocol debugging tool tcpengine v1.3.0 tutorial

我们为什么要推出Getaverse?

Jing Wei PS tutorial: basic part a

Buffer overflow vulnerability lab experiment record

Custom types: Enumeration

Meeting OA project progress (II)

Comparison of array and object merging methods assign, merge, defaults, defaultsdeep in lodash

PS pull out logo

Logisim group experiment 10 single cycle MIPS CPU

Getting started with ARP
随机推荐
QT design simulation robot controller
双亲委派机制
SS-Paper【1】:Fully Convolutional Networks for Semantic Segmentation
Topic 6 - message queue for client communication
ZCMU--5083: ly的数对(C语言)
【技术】uniapp 之 在线选座 demo
Wechat applet list (list rendering of data rendering)
QT embed Notepad under win10
Mcd12q1 data shows multiple classifications in envi
15. ARM embedded system: how to debug single board with PC
AMD锐龙7000预计9月15日上市 3D缓存版还要再等等
2019q1 global smartphone shipments: Huawei vivo increased significantly, while Apple plummeted 30.2%!
Interview question 01.02. determine whether it is character rearrangement
Educational codeforces round 100 (rated for Div. 2) B. find the array solution
Codeforces round 690 (Div. 3) C. unique number conventional solution
PS pull out logo
MODIS 16 day data monthly / quarterly synthesis
查数据库实际数据增长情况
Programming language exercises (I)
804. Unique Morse code word