From e62a3775eb57ec4a02f396963a9df7fd59744471 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sat, 16 Mar 2019 07:24:21 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E4=BB=A3=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E6=95=B4=E7=90=86=E5=9B=BE=E4=BE=8B=E5=92=8C=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=9D=A5=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Demo.cs | 55 - Demo.cs.meta | 13 - Scripts/BarChart.cs | 8 +- Scripts/BaseAxesChart.cs | 6 +- Scripts/BaseChart.cs | 115 +- Scripts/LineChart.cs | 8 +- Scripts/PieChart.cs | 23 +- Scripts/RadarChart.cs | 2 +- demo.unity | 19936 ------------------------------------- demo.unity.meta | 9 - demo_test.unity | 2081 ---- demo_test.unity.meta | 9 - 12 files changed, 93 insertions(+), 22172 deletions(-) delete mode 100644 Demo.cs delete mode 100644 Demo.cs.meta delete mode 100644 demo.unity delete mode 100644 demo.unity.meta delete mode 100644 demo_test.unity delete mode 100644 demo_test.unity.meta diff --git a/Demo.cs b/Demo.cs deleted file mode 100644 index 20694dbd..00000000 --- a/Demo.cs +++ /dev/null @@ -1,55 +0,0 @@ -using UnityEngine; -using UnityEngine.UI; -using xcharts; - -public class Demo : MonoBehaviour -{ - public Theme theme = Theme.Dark; - - private LineChart lineChart; - private float time; - private int count; - private Theme checkTheme = Theme.Dark; - - void Awake() - { - //lineChart = transform.Find("xchart/line_chart").GetComponent(); - - var xchart = transform.Find("xchart"); - GridLayoutGroup grid = xchart.GetComponent(); - RectTransform rect = xchart.GetComponent(); - var wid = rect.sizeDelta.x; - int childNum = xchart.childCount; - int numWid =(int) ((wid - grid.padding.left - grid.padding.right) / (grid.cellSize.x+grid.spacing.x)); - int numHig = (childNum + numWid - 1) / numWid; - float hig = grid.padding.top + numHig * (grid.cellSize.y+ grid.spacing.y); - rect.sizeDelta = new Vector2(wid,hig); - } - - void Update() - { - time += Time.deltaTime; - if (time >= 1) - { - time = 0; - count++; - //lineChart.AddXAxisCategory("key" + count); - //lineChart.AddData("line1", "key"+count, Random.Range(24.0f, 60.0f)); - //lineChart.AddData("line2", "key"+count, Random.Range(24.0f, 60.0f)); - } - if(checkTheme != theme) - { - checkTheme = theme; - UpdateTheme(theme); - } - } - - void UpdateTheme(Theme theme) - { - var charts = transform.Find("xchart").GetComponentsInChildren(); - foreach(var chart in charts) - { - chart.UpdateTheme(theme); - } - } -} diff --git a/Demo.cs.meta b/Demo.cs.meta deleted file mode 100644 index 21f9e4f4..00000000 --- a/Demo.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e6bd57e81d68cac47a78ccb7a452c8d7 -timeCreated: 1536708123 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/BarChart.cs b/Scripts/BarChart.cs index a4138549..a6ac4dfc 100644 --- a/Scripts/BarChart.cs +++ b/Scripts/BarChart.cs @@ -57,11 +57,11 @@ namespace xcharts } for (int i = startIndex; i < series.dataList.Count; i++) { - SeriesData data = series.dataList[i]; + float data = series.dataList[i]; float pX = zeroX + coordinate.tickness; float pY = zeroY + i * coordinateHig / (yAxis.splitNumber - 1); if (!yAxis.boundaryGap) pY -= scaleWid / 2; - float barHig = data.value / max * coordinateWid; + float barHig = data / max * coordinateWid; float space = offset + j * (barWid + barInfo.space); Vector3 p1 = new Vector3(pX, pY + space + barWid); Vector3 p2 = new Vector3(pX + barHig, pY + space + barWid); @@ -100,11 +100,11 @@ namespace xcharts } for (int i = startIndex; i < series.dataList.Count; i++) { - SeriesData data = series.dataList[i]; + float data = series.dataList[i]; float pX = zeroX + i * coordinateWid / (xAxis.splitNumber - 1); if (!xAxis.boundaryGap) pX -= scaleWid / 2; float pY = zeroY + coordinate.tickness; - float barHig = data.value / max * coordinateHig; + float barHig = data / max * coordinateHig; float space = offset + j * (barWid + barInfo.space); Vector3 p1 = new Vector3(pX + space, pY); Vector3 p2 = new Vector3(pX + space, pY + barHig); diff --git a/Scripts/BaseAxesChart.cs b/Scripts/BaseAxesChart.cs index 779700e9..accba7d7 100644 --- a/Scripts/BaseAxesChart.cs +++ b/Scripts/BaseAxesChart.cs @@ -209,7 +209,7 @@ namespace xcharts tooltip.SetActive(true); if (seriesList.Count == 1) { - string txt = tempAxis.data[index] + ": " + seriesList[0].dataList[index].value; + string txt = tempAxis.data[index] + ": " + seriesList[0].dataList[index]; tooltip.UpdateTooltipText(txt); } else @@ -218,8 +218,8 @@ namespace xcharts for(int i=0; i● ", strColor); sb.AppendFormat("{0}: {1}", key, value); diff --git a/Scripts/BaseChart.cs b/Scripts/BaseChart.cs index 54f388fc..a0358d7e 100644 --- a/Scripts/BaseChart.cs +++ b/Scripts/BaseChart.cs @@ -44,15 +44,6 @@ namespace xcharts end, } - [System.Serializable] - public class LegendData - { - public bool show = true; - public string key; - public string text; - public Button button { get; set; } - } - [System.Serializable] public class Legend { @@ -65,14 +56,58 @@ namespace xcharts public float right = 5; public float top; public float bottom; - public List dataList = new List(); + public List dataList = new List(); public int checkDataListCount { get; set; } + private List dataShowList = new List(); + private List