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