XCharts 2.0

This commit is contained in:
monitor1394
2021-01-11 08:54:28 +08:00
parent ed8d0687f7
commit 489095865d
304 changed files with 14799 additions and 12503 deletions

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections;
using System.Collections.Generic;
@@ -207,7 +207,6 @@ namespace XCharts.Examples
chart.dataZoom.enable = true;
chart.dataZoom.supportInside = true;
chart.dataZoom.supportSlider = true;
chart.dataZoom.height = 30;
chart.dataZoom.start = 0;
chart.dataZoom.end = 100;
@@ -279,7 +278,7 @@ namespace XCharts.Examples
chart.visualMap.inRange.Clear();
foreach (var str in colors)
{
chart.visualMap.inRange.Add(ThemeInfo.GetColor(str));
chart.visualMap.inRange.Add(ChartTheme.GetColor(str));
}
chart.grid.left = 80;
chart.grid.bottom = 100;

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
using UnityEngine.EventSystems;

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections;
using UnityEngine;
@@ -225,8 +225,8 @@ namespace XCharts.Examples
chart.RefreshChart();
yield return new WaitForSeconds(1);
serie.label.color = Color.white;
serie.label.backgroundColor = Color.grey;
serie.label.textStyle.color = Color.white;
serie.label.textStyle.backgroundColor = Color.grey;
chart.RefreshLabel();
chart.RefreshChart();
yield return new WaitForSeconds(1);

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
@@ -20,27 +20,26 @@ namespace XCharts.Examples
void Awake()
{
chart = gameObject.GetComponent<LineChart>();
if (chart != null)
if (chart == null)
{
GameObject.DestroyImmediate(chart);
chart = gameObject.AddComponent<LineChart>();
}
chart = gameObject.AddComponent<LineChart>();
chart.title.show = true;
chart.title.text = "Sin Curve";
chart.tooltip.show = true;
chart.legend.show = false;
chart.xAxises[0].show = true;
chart.xAxises[1].show = false;
chart.yAxises[0].show = true;
chart.yAxises[1].show = false;
chart.xAxes[0].show = true;
chart.xAxes[1].show = false;
chart.yAxes[0].show = true;
chart.yAxes[1].show = false;
chart.xAxises[0].type = Axis.AxisType.Value;
chart.yAxises[0].type = Axis.AxisType.Value;
chart.xAxes[0].type = Axis.AxisType.Value;
chart.yAxes[0].type = Axis.AxisType.Value;
chart.xAxises[0].boundaryGap = false;
chart.xAxises[0].maxCache = 0;
chart.xAxes[0].boundaryGap = false;
chart.xAxes[0].maxCache = 0;
chart.series.list[0].maxCache = 0;
chart.RemoveData();

View File

@@ -1,12 +1,13 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
using UnityEngine.UI;
using XUGL;
namespace XCharts.Examples
@@ -27,11 +28,11 @@ namespace XCharts.Examples
if (dataPoints.Count > 0)
{
var pos = dataPoints[3];
var zeroPos = new Vector3(chart.coordinateX, chart.coordinateY);
var zeroPos = new Vector3(chart.grid.runtimeX, chart.grid.runtimeY);
var startPos = new Vector3(pos.x, zeroPos.y);
var endPos = new Vector3(pos.x, zeroPos.y + chart.coordinateHeight);
ChartDrawer.DrawLine(vh, startPos, endPos, 1, Color.blue);
ChartDrawer.DrawCricle(vh, pos, 5, Color.blue);
var endPos = new Vector3(pos.x, zeroPos.y + chart.grid.runtimeWidth);
UGL.DrawLine(vh, startPos, endPos, 1, Color.blue);
UGL.DrawCricle(vh, pos, 5, Color.blue);
}
};
}

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
@@ -27,20 +27,20 @@ namespace XCharts.Examples
chart.tooltip.show = true;
chart.legend.show = false;
chart.xAxises[0].show = true;
chart.xAxises[1].show = false;
chart.yAxises[0].show = true;
chart.yAxises[1].show = false;
chart.xAxises[0].type = Axis.AxisType.Category;
chart.yAxises[0].type = Axis.AxisType.Value;
chart.xAxes[0].show = true;
chart.xAxes[1].show = false;
chart.yAxes[0].show = true;
chart.yAxes[1].show = false;
chart.xAxes[0].type = Axis.AxisType.Category;
chart.yAxes[0].type = Axis.AxisType.Value;
chart.xAxises[0].splitNumber = 10;
chart.xAxises[0].boundaryGap = true;
chart.xAxes[0].splitNumber = 10;
chart.xAxes[0].boundaryGap = true;
chart.RemoveData();
chart.AddSerie(SerieType.Line);
chart.AddSerie(SerieType.Line);
for (int i = 0; i < 10; i++)
for (int i = 0; i < 2000; i++)
{
chart.AddXAxisData("x" + i);
chart.AddData(0, Random.Range(10, 20));

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections;
using UnityEngine;
@@ -150,13 +150,13 @@ namespace XCharts.Examples
serie.label.show = true;
serie.label.position = SerieLabel.Position.Center;
serie.label.border = false;
serie.label.color = Color.white;
serie.label.textStyle.color = Color.white;
serie.label.formatter = "{d:f0}%";
serie2.label.show = true;
serie2.label.position = SerieLabel.Position.Center;
serie2.label.border = false;
serie2.label.color = Color.white;
serie2.label.textStyle.color = Color.white;
serie2.label.formatter = "{d:f0}%";
chart.RefreshLabel();

View File

@@ -1,12 +1,13 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections;
using UnityEngine;
using UnityEngine.EventSystems;
namespace XCharts.Examples
{
@@ -76,6 +77,10 @@ namespace XCharts.Examples
chart.AddData(0, 135, "视频广告");
chart.AddData(0, 1548, "搜索引擎");
chart.RefreshLabel();
chart.onPointerClickPie = delegate(PointerEventData e, int serieIndex, int dataIndex){
};
yield return new WaitForSeconds(1);
}
@@ -148,8 +153,8 @@ namespace XCharts.Examples
serie1.label.show = true;
serie1.label.position = SerieLabel.Position.Inside;
serie1.label.color = Color.white;
serie1.label.fontSize = 14;
serie1.label.textStyle.color = Color.white;
serie1.label.textStyle.fontSize = 14;
serie1.label.border = false;
chart.RefreshLabel();
@@ -166,7 +171,7 @@ namespace XCharts.Examples
serie1.radius = serie.radius = new float[2] { 0, 80 };
serie1.label.position = SerieLabel.Position.Outside;
serie1.label.lineType = SerieLabel.LineType.Curves;
serie1.label.color = Color.clear;
serie1.label.textStyle.color = Color.clear;
for (int i = 0; i < 2; i++)
{
chart.AddData(i, 10, "rose1");

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
using UnityEngine.UI;

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections;
using System.Collections.Generic;

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
using UnityEngine.UI;

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections.Generic;
using UnityEngine;

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections.Generic;
using UnityEngine;
@@ -29,14 +29,14 @@ namespace XCharts.Examples
chart.grid.right = 60;
chart.grid.bottom = 60;
//目前只支持Category
chart.xAxises[0].type = Axis.AxisType.Category;
chart.yAxises[0].type = Axis.AxisType.Category;
chart.xAxes[0].type = Axis.AxisType.Category;
chart.yAxes[0].type = Axis.AxisType.Category;
chart.xAxises[0].boundaryGap = true;
chart.xAxises[0].boundaryGap = true;
chart.xAxes[0].boundaryGap = true;
chart.xAxes[0].boundaryGap = true;
chart.xAxises[0].splitNumber = 10;
chart.yAxises[0].splitNumber = 10;
chart.xAxes[0].splitNumber = 10;
chart.yAxes[0].splitNumber = 10;
//清空数据重新添加
chart.RemoveData();
@@ -68,13 +68,13 @@ namespace XCharts.Examples
chart.visualMap.inRange.Clear();
var heatmapGridWid = 10f;
int xSplitNumber = (int)(chart.coordinateWidth / heatmapGridWid);
int ySplitNumber = (int)(chart.coordinateHeight / heatmapGridWid);
int xSplitNumber = (int)(chart.grid.runtimeWidth / heatmapGridWid);
int ySplitNumber = (int)(chart.grid.runtimeHeight / heatmapGridWid);
var colors = new List<string>{"#313695", "#4575b4", "#74add1", "#abd9e9", "#e0f3f8", "#ffffbf",
"#fee090", "#fdae61", "#f46d43", "#d73027", "#a50026"};
foreach (var str in colors)
{
chart.visualMap.inRange.Add(ThemeInfo.GetColor(str));
chart.visualMap.inRange.Add(ChartTheme.GetColor(str));
}
//添加xAxis的数据
for (int i = 0; i < xSplitNumber; i++)

View File

@@ -1,10 +1,10 @@
using System.Runtime.InteropServices;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
@@ -47,7 +47,7 @@ namespace XCharts.Examples
serie.label.offset = new Vector3(0, -20);
serie.gaugeAxis.show = true;
serie.gaugeAxis.axisLine.width = 15;
serie.gaugeAxis.axisLine.lineStyle.width = 15;
serie.gaugePointer.show = true;
serie.gaugePointer.width = 15;

View File

@@ -1,10 +1,10 @@
using System.Runtime.InteropServices;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System;
using UnityEngine;
@@ -33,7 +33,7 @@ namespace XCharts.Examples
var serie = chart.AddSerie(SerieType.Line);
serie.symbol.show = false;
serie.maxCache = maxCacheDataNumber;
chart.xAxises[0].maxCache = maxCacheDataNumber;
chart.xAxes[0].maxCache = maxCacheDataNumber;
timeNow = DateTime.Now;
timeNow = timeNow.AddSeconds(-maxCacheDataNumber);
}

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
using UnityEngine.UI;
@@ -14,10 +14,10 @@ namespace XCharts.Examples
[ExecuteInEditMode]
public class Example_Test : MonoBehaviour
{
BaseChart chart;
LineChart chart;
void Awake()
{
chart = gameObject.GetComponent<BaseChart>();
chart = gameObject.GetComponent<LineChart>();
var btnTrans = transform.parent.Find("Button");
if (btnTrans)
{
@@ -29,14 +29,16 @@ namespace XCharts.Examples
{
if (Input.GetKeyDown(KeyCode.Space))
{
AddData();
//AddData();
OnTestBtn();
}
}
void OnTestBtn()
{
//chart.ClearData();
chart.SetSize(800,400);
int index = Random.Range(0, chart.series.Count);
var serie = chart.series.GetSerie(index);
chart.UpdateData(index, Random.Range(0, serie.dataCount), Random.Range(50, 100));
}
void AddData()