From aede354af494f6dcf30aac0d297209dd6091d848 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sun, 16 May 2021 23:38:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=BD=E7=A6=BB=E7=94=98=E7=89=B9=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG-EN.md | 6 +- CHANGELOG.md | 6 +- Editor/GanttChartEditor.cs | 25 --- Editor/GanttChartEditor.cs.meta | 11 -- Editor/PropertyDrawers/SerieDrawer.cs | 75 +++----- Editor/XChartEditor.cs | 7 +- Examples/Runtime/Example100_Gantt_Category.cs | 79 -------- .../Runtime/Example100_Gantt_Category.cs.meta | 11 -- Examples/Runtime/Example101_Gantt_Time.cs | 99 ---------- .../Runtime/Example101_Gantt_Time.cs.meta | 11 -- Runtime/API/BaseChart_API.cs | 26 ++- Runtime/Component/ChartComponent.cs | 8 +- Runtime/Component/Main/Axis.cs | 10 +- Runtime/Component/Main/DataZoom.cs | 1 + Runtime/Component/Main/Legend.cs | 2 +- Runtime/Component/Main/Serie.cs | 12 +- Runtime/Component/Main/Series.cs | 2 +- Runtime/Component/Main/Title.cs | 2 +- Runtime/Component/Main/Tooltip.cs | 2 +- Runtime/Component/Main/VisualMap.cs | 24 +-- Runtime/Component/Sub/AxisLabel.cs | 2 +- Runtime/Component/Sub/AxisSplitLine.cs | 2 +- Runtime/Component/Sub/Emphasis.cs | 4 +- Runtime/Component/Sub/TitleStyle.cs | 2 +- Runtime/GanttChart.cs | 136 -------------- Runtime/GanttChart.cs.meta | 11 -- Runtime/Helper/TooltipHelper.cs | 11 -- Runtime/Internal/CoordinateChart.cs | 21 +-- Runtime/Internal/CoordinateChart_DrawGantt.cs | 177 ------------------ .../CoordinateChart_DrawGantt.cs.meta | 11 -- Runtime/Internal/Utility/ChartDrawer.cs | 11 +- Runtime/Template/SerieTemplate.cs | 30 --- 32 files changed, 102 insertions(+), 735 deletions(-) delete mode 100644 Editor/GanttChartEditor.cs delete mode 100644 Editor/GanttChartEditor.cs.meta delete mode 100644 Examples/Runtime/Example100_Gantt_Category.cs delete mode 100644 Examples/Runtime/Example100_Gantt_Category.cs.meta delete mode 100644 Examples/Runtime/Example101_Gantt_Time.cs delete mode 100644 Examples/Runtime/Example101_Gantt_Time.cs.meta delete mode 100644 Runtime/GanttChart.cs delete mode 100644 Runtime/GanttChart.cs.meta delete mode 100644 Runtime/Internal/CoordinateChart_DrawGantt.cs delete mode 100644 Runtime/Internal/CoordinateChart_DrawGantt.cs.meta diff --git a/CHANGELOG-EN.md b/CHANGELOG-EN.md index 823c9891..53bdea47 100644 --- a/CHANGELOG-EN.md +++ b/CHANGELOG-EN.md @@ -1,7 +1,7 @@ # 更新日志 -[Latest](#Latest) +[Latest](#master) [v2.1.1](#v2.1.1) [v2.1.0](#v2.1.0) [v2.0.1](#v2.0.1) @@ -32,8 +32,10 @@ [v0.5.0](#v0.5.0) [v0.1.0](#v0.1.0) -## Latest +## master +* (2021.05.16) Pull out the `Ganttchart` chart and provide it as an extension module +* (2021.05.11) Added support for `VisualMap` to set color by `Piecewise` * (2021.05.09) Fixed an issue where `RingChart` could not set the background color of the ring #141 * (2021.05.08) Added `Liquidchart` support for `Rect` shape * (2021.05.07) Improved the `Axis` scale performance #135 diff --git a/CHANGELOG.md b/CHANGELOG.md index fe51b4b8..de13c2cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # 更新日志 -[Latest](#Latest) +[Latest](#master) [v2.1.1](#v2.1.1) [v2.1.0](#v2.1.0) [v2.0.1](#v2.0.1) @@ -32,8 +32,10 @@ [v0.5.0](#v0.5.0) [v0.1.0](#v0.1.0) -## Latest +## master +* (2021.05.16) 抽离`GanttChart`甘特图,通过扩展模块的方式来提供 +* (2021.05.11) 增加`VisualMap`对`Piecewise`分段设置颜色的支持 * (2021.05.09) 修复`RingChart`无法设置环形的背景色的问题 #141 * (2021.05.08) 增加`LiquidChart`的方形水位图支持 * (2021.05.07) 优化`Axis`的刻度表现 #135 diff --git a/Editor/GanttChartEditor.cs b/Editor/GanttChartEditor.cs deleted file mode 100644 index d1a33604..00000000 --- a/Editor/GanttChartEditor.cs +++ /dev/null @@ -1,25 +0,0 @@ -/************************************************/ -/* */ -/* Copyright (c) 2018 - 2021 monitor1394 */ -/* https://github.com/monitor1394 */ -/* */ -/************************************************/ - -using UnityEditor; - -namespace XCharts -{ - /// - /// Editor class used to edit UI GanttChart. - /// - [CustomEditor(typeof(GanttChart), false)] - public class GanttChartEditor : CoordinateChartEditor - { - protected override void OnEnable() - { - base.OnEnable(); - if(target == null) return; - m_Chart = (GanttChart)target; - } - } -} \ No newline at end of file diff --git a/Editor/GanttChartEditor.cs.meta b/Editor/GanttChartEditor.cs.meta deleted file mode 100644 index 336d56c4..00000000 --- a/Editor/GanttChartEditor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c1b5a1dfca8e5476b98c807c66783d85 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Editor/PropertyDrawers/SerieDrawer.cs b/Editor/PropertyDrawers/SerieDrawer.cs index 7044b3e9..14945037 100644 --- a/Editor/PropertyDrawers/SerieDrawer.cs +++ b/Editor/PropertyDrawers/SerieDrawer.cs @@ -21,7 +21,9 @@ namespace XCharts { pos.width -= 9; base.OnGUI(pos, prop, label); + var chart = prop.serializedObject.targetObject as BaseChart; var type = prop.FindPropertyRelative("m_Type"); + var serieType = (SerieType)type.enumValueIndex; if (!MakeFoldout(prop, "m_Show")) { var orderButton = 48; @@ -29,15 +31,18 @@ namespace XCharts var drawRect = pos; drawRect.x += EditorGUIUtility.labelWidth + gap; drawRect.width = pos.width - drawRect.x + ChartEditorHelper.BOOL_WIDTH - orderButton; - EditorGUI.PropertyField(drawRect, type, GUIContent.none); + type.enumValueIndex = EditorGUI.Popup(drawRect, (int)serieType, GetChartSerieTypeNames(chart)); } else { - var chart = prop.serializedObject.targetObject as BaseChart; m_IsPolar = chart is PolarChart; - var serieType = (SerieType)type.enumValueIndex; ++EditorGUI.indentLevel; - PropertyField(prop, "m_Type"); + + type.enumValueIndex = EditorGUI.Popup(m_DrawRect, "Type", (int)serieType, GetChartSerieTypeNames(chart)); + var hig = EditorGUI.GetPropertyHeight(prop); + m_DrawRect.y += hig; + m_Heights[m_KeyName] += hig; + PropertyField(prop, "m_Name"); switch (serieType) { @@ -68,10 +73,7 @@ namespace XCharts PropertyField(prop, "m_Symbol"); PropertyField(prop, "m_LineStyle"); PropertyField(prop, "m_LineArrow"); - PropertyField(prop, "m_ItemStyle"); PropertyField(prop, "m_AreaStyle"); - PropertyField(prop, "m_Label"); - PropertyField(prop, "m_Emphasis"); break; case SerieType.Bar: PropertyField(prop, "m_Stack"); @@ -99,9 +101,6 @@ namespace XCharts PropertyField(prop, "m_ShowAsPositiveNumber"); PropertyField(prop, "m_Large"); PropertyField(prop, "m_LargeThreshold"); - PropertyField(prop, "m_ItemStyle"); - PropertyField(prop, "m_Label"); - PropertyField(prop, "m_Emphasis"); break; case SerieType.Pie: PropertyField(prop, "m_RoseType"); @@ -113,9 +112,6 @@ namespace XCharts PropertyField(prop, "m_Ignore"); PropertyField(prop, "m_IgnoreValue"); PropertyField(prop, "m_AvoidLabelOverlap"); - PropertyField(prop, "m_ItemStyle"); - PropertyField(prop, "m_Label"); - PropertyField(prop, "m_Emphasis"); break; case SerieType.Ring: PropertyTwoFiled(prop, "m_Center"); @@ -125,34 +121,22 @@ namespace XCharts PropertyField(prop, "m_RoundCap"); PropertyField(prop, "m_Clockwise"); PropertyField(prop, "m_TitleStyle"); - PropertyField(prop, "m_ItemStyle"); - PropertyField(prop, "m_Label"); - PropertyField(prop, "m_Emphasis"); break; case SerieType.Radar: PropertyField(prop, "m_RadarType"); PropertyField(prop, "m_RadarIndex"); PropertyField(prop, "m_Symbol"); PropertyField(prop, "m_LineStyle"); - PropertyField(prop, "m_ItemStyle"); PropertyField(prop, "m_AreaStyle"); - PropertyField(prop, "m_Label"); - PropertyField(prop, "m_Emphasis"); break; case SerieType.Scatter: case SerieType.EffectScatter: PropertyField(prop, "m_Clip"); PropertyField(prop, "m_Symbol"); - PropertyField(prop, "m_ItemStyle"); - PropertyField(prop, "m_Label"); - PropertyField(prop, "m_Emphasis"); break; case SerieType.Heatmap: PropertyField(prop, "m_Ignore"); PropertyField(prop, "m_IgnoreValue"); - PropertyField(prop, "m_ItemStyle"); - PropertyField(prop, "m_Label"); - PropertyField(prop, "m_Emphasis"); break; case SerieType.Gauge: PropertyField(prop, "m_GaugeType"); @@ -167,9 +151,6 @@ namespace XCharts PropertyField(prop, "m_TitleStyle"); PropertyField(prop, "m_GaugeAxis"); PropertyField(prop, "m_GaugePointer"); - PropertyField(prop, "m_ItemStyle"); - PropertyField(prop, "m_Label"); - PropertyField(prop, "m_Emphasis"); break; case SerieType.Liquid: PropertyField(prop, "m_VesselIndex"); @@ -179,8 +160,6 @@ namespace XCharts PropertyField(prop, "m_WaveHeight"); PropertyField(prop, "m_WaveSpeed"); PropertyField(prop, "m_WaveOffset"); - PropertyField(prop, "m_ItemStyle"); - PropertyField(prop, "m_Label"); break; case SerieType.Candlestick: PropertyField(prop, "m_XAxisIndex"); @@ -193,20 +172,6 @@ namespace XCharts PropertyField(prop, "m_ShowAsPositiveNumber"); PropertyField(prop, "m_Large"); PropertyField(prop, "m_LargeThreshold"); - PropertyField(prop, "m_ItemStyle"); - PropertyField(prop, "m_Label"); - PropertyField(prop, "m_Emphasis"); - break; - case SerieType.Gantt: - PropertyField(prop, "m_XAxisIndex"); - PropertyField(prop, "m_YAxisIndex"); - PropertyField(prop, "m_BarWidth"); - PropertyField(prop, "m_Clip"); - PropertyField(prop, "m_Large"); - PropertyField(prop, "m_LargeThreshold"); - PropertyField(prop, "m_ItemStyle"); - PropertyField(prop, "m_Label"); - PropertyField(prop, "m_Emphasis"); break; case SerieType.Custom: var fileds = chart.GetCustomSerieInspectorShowFileds(); @@ -217,16 +182,34 @@ namespace XCharts PropertyField(prop, filed); } } - PropertyField(prop, "m_ItemStyle"); - PropertyField(prop, "m_Label"); break; } + PropertyField(prop, "m_ItemStyle"); + PropertyField(prop, "m_Label"); + PropertyField(prop, "m_Emphasis"); PropertyField(prop, "m_Animation"); DrawData(pos, prop, serieType, ref m_DrawRect); --EditorGUI.indentLevel; } } + private string[] GetChartSerieTypeNames(BaseChart chart) + { + var list = System.Enum.GetNames(typeof(SerieType)); + for (int i = 0; i < list.Length; i++) + { + if (list[i].Equals("Custom")) + { + var customName = chart.GetCustomSerieTypeName(); + if (!string.IsNullOrEmpty(customName)) + { + list[i] = customName; + } + } + } + return list; + } + private void DrawData(Rect pos, SerializedProperty prop, SerieType serieType, ref Rect drawRect) { SerializedProperty m_Datas = prop.FindPropertyRelative("m_Data"); diff --git a/Editor/XChartEditor.cs b/Editor/XChartEditor.cs index 22a756a0..9e0bdf2e 100644 --- a/Editor/XChartEditor.cs +++ b/Editor/XChartEditor.cs @@ -142,12 +142,7 @@ namespace XCharts AddChart("LiquidChart"); } - [MenuItem("XCharts/GanttChart", priority = 54)] - [MenuItem("GameObject/XCharts/GanttChart", priority = 54)] - public static void AddGanttChart() - { - AddChart("GanttChart"); - } + [MenuItem("XCharts/Themes Reload")] public static void ReloadTheme() diff --git a/Examples/Runtime/Example100_Gantt_Category.cs b/Examples/Runtime/Example100_Gantt_Category.cs deleted file mode 100644 index 183d0113..00000000 --- a/Examples/Runtime/Example100_Gantt_Category.cs +++ /dev/null @@ -1,79 +0,0 @@ -/************************************************/ -/* */ -/* Copyright (c) 2018 - 2021 monitor1394 */ -/* https://github.com/monitor1394 */ -/* */ -/************************************************/ - - -using UnityEngine; - -namespace XCharts.Examples -{ - [DisallowMultipleComponent] - [ExecuteInEditMode] - public class Example100_Gantt_Category : MonoBehaviour - { - private GanttChart chart; - private float updateTime; - public int dayCount = 10; - public int taskCount = 5; - - void Awake() - { - chart = gameObject.GetComponent(); - if (chart == null) - { - chart = gameObject.AddComponent(); - } - GenerateCategoryData(); - } - - void Update() - { - if (Input.GetKeyDown(KeyCode.Space)) - { - AddData(); - } - } - - void AddData() - { - for (int i = 0; i < taskCount; i++) - { - var startIndex = Random.Range(0, (int)(dayCount * 2.0f / 3)); - var endIndex = Random.Range(startIndex, dayCount); - chart.UpdateData(0, i, 0, startIndex); - chart.UpdateData(0, i, 1, endIndex); - } - } - - void GenerateCategoryData() - { - chart.RemoveData(); - - chart.grid.left = 100; - chart.xAxis0.type = Axis.AxisType.Category; - chart.xAxis0.boundaryGap = false; - chart.xAxis0.splitNumber = dayCount; - - chart.yAxis0.type = Axis.AxisType.Category; - chart.yAxis0.boundaryGap = true; - chart.yAxis0.splitNumber = 0; - - for (int i = 0; i < dayCount; i++) - { - chart.AddXAxisData("day" + (i + 1)); - } - - chart.AddSerie(SerieType.Gantt, "任务进度表"); - for (int i = 0; i < taskCount; i++) - { - var taskName = "task-" + (i + 1); - var startIndex = Random.Range(0, (int)(dayCount * 2.0f / 3)); - var endIndex = Random.Range(startIndex, dayCount); - chart.AddData(0, startIndex, endIndex, taskName); - } - } - } -} \ No newline at end of file diff --git a/Examples/Runtime/Example100_Gantt_Category.cs.meta b/Examples/Runtime/Example100_Gantt_Category.cs.meta deleted file mode 100644 index 1c2b67ac..00000000 --- a/Examples/Runtime/Example100_Gantt_Category.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c383c3eae67ed461693e18a807b2e599 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Examples/Runtime/Example101_Gantt_Time.cs b/Examples/Runtime/Example101_Gantt_Time.cs deleted file mode 100644 index b100d28b..00000000 --- a/Examples/Runtime/Example101_Gantt_Time.cs +++ /dev/null @@ -1,99 +0,0 @@ -/************************************************/ -/* */ -/* Copyright (c) 2018 - 2021 monitor1394 */ -/* https://github.com/monitor1394 */ -/* */ -/************************************************/ - - -using UnityEngine; - -namespace XCharts.Examples -{ - [DisallowMultipleComponent] - [ExecuteInEditMode] - public class Example101_Gantt_Time : MonoBehaviour - { - private GanttChart chart; - private float updateTime; - public int taskCount = 5; - - void Awake() - { - chart = gameObject.GetComponent(); - if (chart == null) - { - chart = gameObject.AddComponent(); - } - GenerateTimeData(); - } - - void Update() - { - if (Input.GetKeyDown(KeyCode.Space)) - { - AddData(); - } - } - - void AddData() - { - chart.ClearData(); - for (int i = 0; i < taskCount; i++) - { - var taskName = "张三-任务-" + (i + 1); - var nowTimestamp = DateTimeUtil.GetTimestamp(); - var startTimestamp = nowTimestamp + Random.Range(1, 6) * 3600 * 24; - var endTimestamp = startTimestamp + Random.Range(1, 10) * 3600 * 24; - chart.AddData(0, startTimestamp, endTimestamp, taskName); - } - chart.AddSerie(SerieType.Gantt, "李四"); - for (int i = 0; i < taskCount; i++) - { - var taskName = "李四-任务-" + (i + 1); - var nowTimestamp = DateTimeUtil.GetTimestamp(); - var startTimestamp = nowTimestamp + Random.Range(1, 6) * 3600 * 24; - var endTimestamp = startTimestamp + Random.Range(1, 10) * 3600 * 24; - chart.AddData(1, startTimestamp, endTimestamp, taskName); - } - } - - void GenerateTimeData() - { - chart.RemoveData(); - - chart.grid.left = 100; - chart.xAxis0.type = Axis.AxisType.Time; - chart.xAxis0.boundaryGap = false; - chart.xAxis0.splitNumber = 5; - - chart.xAxis0.axisLabel.numericFormatter = "HH:mm:ss"; - chart.xAxis0.axisLabel.formatter = "time:{value}"; - - chart.yAxis0.type = Axis.AxisType.Category; - chart.yAxis0.boundaryGap = true; - chart.yAxis0.splitNumber = 0; - - - var serie1 = chart.AddSerie(SerieType.Gantt, "张三"); - serie1.label.show = true; - for (int i = 0; i < taskCount; i++) - { - var taskName = "张三-任务-" + (i + 1); - var nowTimestamp = DateTimeUtil.GetTimestamp(); - var startTimestamp = nowTimestamp + Random.Range(1, 6) * 3600 * 24; - var endTimestamp = startTimestamp + Random.Range(1, 10) * 3600 * 24; - chart.AddData(0, startTimestamp, endTimestamp, taskName); - } - chart.AddSerie(SerieType.Gantt, "李四"); - for (int i = 0; i < taskCount; i++) - { - var taskName = "李四-任务-" + (i + 1); - var nowTimestamp = DateTimeUtil.GetTimestamp(); - var startTimestamp = nowTimestamp + Random.Range(1, 6) * 3600 * 24; - var endTimestamp = startTimestamp + Random.Range(1, 10) * 3600 * 24; - chart.AddData(1, startTimestamp, endTimestamp, taskName); - } - } - } -} \ No newline at end of file diff --git a/Examples/Runtime/Example101_Gantt_Time.cs.meta b/Examples/Runtime/Example101_Gantt_Time.cs.meta deleted file mode 100644 index 8adb651e..00000000 --- a/Examples/Runtime/Example101_Gantt_Time.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d546ff7dfa6104a739c1accdb415ef54 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/API/BaseChart_API.cs b/Runtime/API/BaseChart_API.cs index 51021012..9d7c67ff 100644 --- a/Runtime/API/BaseChart_API.cs +++ b/Runtime/API/BaseChart_API.cs @@ -201,6 +201,25 @@ namespace XCharts return m_Series.AddSerie(type, serieName); } + /// + /// Add a serie to serie list. + /// 通过字符串类型的serieType添加一个系列到系列列表中。如果serieType不是已定义的SerieType类型,则设置为Custom类型。 + /// + /// + /// + /// + /// + public virtual Serie AddSerie(string serieType, string serieName = null, bool show = true) + { + var type = SerieType.Custom; + var list = Enum.GetNames(typeof(SerieType)); + foreach (var t in list) + { + if (t.Equals(serieType)) type = (SerieType)Enum.Parse(typeof(SerieType), t); + } + return AddSerie(type, serieName, show); + } + /// /// Add a data to serie. /// If serieName doesn't exist in legend,will be add to legend. @@ -733,7 +752,7 @@ namespace XCharts return SeriesHelper.ContainsSerie(m_Series, serieType); } - public virtual bool AddDefaultCustomSerie(string serieName) + public virtual bool AddDefaultCustomSerie(string serieName, int dataCount = 5) { return false; } @@ -747,6 +766,11 @@ namespace XCharts return null; } + public virtual string GetCustomSerieTypeName() + { + return null; + } + public int GetLegendRealShowNameIndex(string name) { return m_LegendRealShowName.IndexOf(name); diff --git a/Runtime/Component/ChartComponent.cs b/Runtime/Component/ChartComponent.cs index f49c6107..91e83549 100644 --- a/Runtime/Component/ChartComponent.cs +++ b/Runtime/Component/ChartComponent.cs @@ -31,22 +31,22 @@ namespace XCharts public Action refreshComponent { get; set; } public GameObject gameObject { get; set; } - internal virtual void SetVerticesDirty() + public virtual void SetVerticesDirty() { m_VertsDirty = true; } - internal virtual void ClearVerticesDirty() + public virtual void ClearVerticesDirty() { m_VertsDirty = false; } - internal virtual void SetComponentDirty() + public virtual void SetComponentDirty() { m_ComponentDirty = true; } - internal virtual void ClearComponentDirty() + public virtual void ClearComponentDirty() { m_ComponentDirty = false; } diff --git a/Runtime/Component/Main/Axis.cs b/Runtime/Component/Main/Axis.cs index 998c79d0..cf500b05 100644 --- a/Runtime/Component/Main/Axis.cs +++ b/Runtime/Component/Main/Axis.cs @@ -348,14 +348,14 @@ namespace XCharts { get { return m_ComponentDirty || axisName.anyDirty || axisLabel.anyDirty; } } - internal override void ClearComponentDirty() + public override void ClearComponentDirty() { base.ClearComponentDirty(); axisName.ClearComponentDirty(); axisLabel.ClearComponentDirty(); } - internal override void ClearVerticesDirty() + public override void ClearVerticesDirty() { base.ClearVerticesDirty(); axisLine.ClearVerticesDirty(); @@ -411,9 +411,9 @@ namespace XCharts public float runtimeZeroYOffset { get; internal set; } public int runtimeMinLogIndex { get { return logBaseE ? (int)Mathf.Log(runtimeMinValue) : (int)Mathf.Log(runtimeMinValue, logBase); } } public int runtimeMaxLogIndex { get { return logBaseE ? (int)Mathf.Log(runtimeMaxValue) : (int)Mathf.Log(runtimeMaxValue, logBase); } } - internal bool runtimeLastCheckInverse { get; set; } - internal double runtimeMinMaxRange { get { return m_MinMaxValueRange; } set { m_MinMaxValueRange = value; } } - internal List runtimeData { get { return m_RuntimeData; } } + public bool runtimeLastCheckInverse { get; set; } + public double runtimeMinMaxRange { get { return m_MinMaxValueRange; } set { m_MinMaxValueRange = value; } } + public List runtimeData { get { return m_RuntimeData; } } public float runtimeScaleWidth { get; internal set; } private int filterStart; private int filterEnd; diff --git a/Runtime/Component/Main/DataZoom.cs b/Runtime/Component/Main/DataZoom.cs index 47a01029..5d84a0df 100644 --- a/Runtime/Component/Main/DataZoom.cs +++ b/Runtime/Component/Main/DataZoom.cs @@ -656,6 +656,7 @@ namespace XCharts public void Update() { + if (chart == null) return; foreach (var dataZoom in chart.dataZooms) { CheckDataZoomScale(dataZoom); diff --git a/Runtime/Component/Main/Legend.cs b/Runtime/Component/Main/Legend.cs index a20e273b..387a0505 100644 --- a/Runtime/Component/Main/Legend.cs +++ b/Runtime/Component/Main/Legend.cs @@ -228,7 +228,7 @@ namespace XCharts get { return m_ComponentDirty || location.componentDirty || textStyle.componentDirty; } } - internal override void ClearComponentDirty() + public override void ClearComponentDirty() { base.ClearComponentDirty(); location.ClearComponentDirty(); diff --git a/Runtime/Component/Main/Serie.cs b/Runtime/Component/Main/Serie.cs index 7b372c23..79b2f053 100644 --- a/Runtime/Component/Main/Serie.cs +++ b/Runtime/Component/Main/Serie.cs @@ -65,10 +65,6 @@ namespace XCharts /// Candlestick, /// - /// 甘特图。甘特图的data至少包含两个数据:[start, end] - /// - Gantt, - /// /// 自定义。 /// Custom, @@ -195,6 +191,7 @@ namespace XCharts /// Single } + /// /// 采样类型 /// @@ -799,7 +796,7 @@ namespace XCharts /// /// 数据项里的数据维数。 /// - public int showDataDimension { get { return m_ShowDataDimension; } internal set { m_ShowDataDimension = value; } } + public int showDataDimension { get { return m_ShowDataDimension; } set { m_ShowDataDimension = value; } } /// /// 在Editor的inpsector上是否显示name参数 /// @@ -954,7 +951,7 @@ namespace XCharts } public override bool componentDirty { get { return m_ComponentDirty || titleStyle.componentDirty; } } - internal override void ClearVerticesDirty() + public override void ClearVerticesDirty() { base.ClearVerticesDirty(); symbol.ClearVerticesDirty(); @@ -969,7 +966,7 @@ namespace XCharts titleStyle.ClearVerticesDirty(); } - internal override void ClearComponentDirty() + public override void ClearComponentDirty() { base.ClearComponentDirty(); symbol.ClearComponentDirty(); @@ -1751,7 +1748,6 @@ namespace XCharts || type == SerieType.Bar || type == SerieType.Scatter || type == SerieType.Heatmap - || type == SerieType.Gantt || type == SerieType.Candlestick; } diff --git a/Runtime/Component/Main/Series.cs b/Runtime/Component/Main/Series.cs index bd7cb1fe..22b873c5 100644 --- a/Runtime/Component/Main/Series.cs +++ b/Runtime/Component/Main/Series.cs @@ -67,7 +67,7 @@ namespace XCharts m_LabelDirty = true; } - internal override void ClearVerticesDirty() + public override void ClearVerticesDirty() { base.ClearVerticesDirty(); foreach (var serie in m_Series) diff --git a/Runtime/Component/Main/Title.cs b/Runtime/Component/Main/Title.cs index efb3fdf0..f1c2c055 100644 --- a/Runtime/Component/Main/Title.cs +++ b/Runtime/Component/Main/Title.cs @@ -91,7 +91,7 @@ namespace XCharts get { return m_ComponentDirty || location.componentDirty || textStyle.componentDirty || subTextStyle.componentDirty; } } - internal override void ClearComponentDirty() + public override void ClearComponentDirty() { base.ClearComponentDirty(); location.ClearComponentDirty(); diff --git a/Runtime/Component/Main/Tooltip.cs b/Runtime/Component/Main/Tooltip.cs index de0c02b3..57ccca25 100644 --- a/Runtime/Component/Main/Tooltip.cs +++ b/Runtime/Component/Main/Tooltip.cs @@ -237,7 +237,7 @@ namespace XCharts get { return m_ComponentDirty || lineStyle.componentDirty || textStyle.componentDirty; } } - internal override void ClearComponentDirty() + public override void ClearComponentDirty() { base.ClearComponentDirty(); lineStyle.ClearComponentDirty(); diff --git a/Runtime/Component/Main/VisualMap.cs b/Runtime/Component/Main/VisualMap.cs index c35d0d2e..209ee3a0 100644 --- a/Runtime/Component/Main/VisualMap.cs +++ b/Runtime/Component/Main/VisualMap.cs @@ -339,13 +339,13 @@ namespace XCharts } public override bool vertsDirty { get { return m_VertsDirty || location.anyDirty; } } - internal override void ClearVerticesDirty() + public override void ClearVerticesDirty() { base.ClearVerticesDirty(); location.ClearVerticesDirty(); } - internal override void ClearComponentDirty() + public override void ClearComponentDirty() { base.ClearComponentDirty(); location.ClearComponentDirty(); @@ -676,16 +676,18 @@ namespace XCharts public void Draw(VertexHelper vh) { - var visualMap = chart.visualMap; - if (!visualMap.enable || !visualMap.show) return; - switch (visualMap.type) + foreach (var visualMap in chart.visualMaps) { - case VisualMap.Type.Continuous: - DrawContinuousVisualMap(vh, visualMap); - break; - case VisualMap.Type.Piecewise: - //DrawPiecewiseVisualMap(vh, visualMap); - break; + if (!visualMap.enable || !visualMap.show) continue; + switch (visualMap.type) + { + case VisualMap.Type.Continuous: + DrawContinuousVisualMap(vh, visualMap); + break; + case VisualMap.Type.Piecewise: + //DrawPiecewiseVisualMap(vh, visualMap); + break; + } } } diff --git a/Runtime/Component/Sub/AxisLabel.cs b/Runtime/Component/Sub/AxisLabel.cs index 822776e4..c8164aaf 100644 --- a/Runtime/Component/Sub/AxisLabel.cs +++ b/Runtime/Component/Sub/AxisLabel.cs @@ -127,7 +127,7 @@ namespace XCharts } public override bool componentDirty { get { return m_ComponentDirty || m_TextLimit.componentDirty; } } - internal override void ClearComponentDirty() + public override void ClearComponentDirty() { base.ClearComponentDirty(); textLimit.ClearComponentDirty(); diff --git a/Runtime/Component/Sub/AxisSplitLine.cs b/Runtime/Component/Sub/AxisSplitLine.cs index 2e0dcbec..c0ffc2d4 100644 --- a/Runtime/Component/Sub/AxisSplitLine.cs +++ b/Runtime/Component/Sub/AxisSplitLine.cs @@ -26,7 +26,7 @@ namespace XCharts } public override bool vertsDirty { get { return m_VertsDirty || m_LineStyle.anyDirty; } } - internal override void ClearVerticesDirty() + public override void ClearVerticesDirty() { base.ClearVerticesDirty(); m_LineStyle.ClearVerticesDirty(); diff --git a/Runtime/Component/Sub/Emphasis.cs b/Runtime/Component/Sub/Emphasis.cs index 1e5310a9..0eeede12 100644 --- a/Runtime/Component/Sub/Emphasis.cs +++ b/Runtime/Component/Sub/Emphasis.cs @@ -56,14 +56,14 @@ namespace XCharts public override bool componentDirty { get { return m_ComponentDirty || label.componentDirty; } } - internal override void ClearVerticesDirty() + public override void ClearVerticesDirty() { base.ClearVerticesDirty(); label.ClearVerticesDirty(); itemStyle.ClearVerticesDirty(); } - internal override void ClearComponentDirty() + public override void ClearComponentDirty() { base.ClearComponentDirty(); label.ClearComponentDirty(); diff --git a/Runtime/Component/Sub/TitleStyle.cs b/Runtime/Component/Sub/TitleStyle.cs index a460d9bd..9254156d 100644 --- a/Runtime/Component/Sub/TitleStyle.cs +++ b/Runtime/Component/Sub/TitleStyle.cs @@ -46,7 +46,7 @@ namespace XCharts public override bool componentDirty { get { return m_ComponentDirty || textStyle.componentDirty; } } - internal override void ClearComponentDirty() + public override void ClearComponentDirty() { base.ClearComponentDirty(); textStyle.ClearComponentDirty(); diff --git a/Runtime/GanttChart.cs b/Runtime/GanttChart.cs deleted file mode 100644 index 4b706168..00000000 --- a/Runtime/GanttChart.cs +++ /dev/null @@ -1,136 +0,0 @@ - -/************************************************/ -/* */ -/* Copyright (c) 2018 - 2021 monitor1394 */ -/* https://github.com/monitor1394 */ -/* */ -/************************************************/ - -using UnityEngine; - -namespace XCharts -{ - [AddComponentMenu("XCharts/GanttChart", 22)] - [ExecuteInEditMode] - [RequireComponent(typeof(RectTransform))] - [DisallowMultipleComponent] - public partial class GanttChart : CoordinateChart - { - -#if UNITY_EDITOR - protected override void Reset() - { - base.Reset(); - title.text = "GanttChart"; - var xCount = 5; - var yCount = 5; - - m_Grids[0].left = 60; - m_Grids[0].right = 50; - m_XAxes[0].type = Axis.AxisType.Time; - m_XAxes[0].boundaryGap = false; - m_XAxes[0].splitNumber = xCount; - m_YAxes[0].type = Axis.AxisType.Category; - m_YAxes[0].boundaryGap = true; - m_YAxes[0].splitNumber = 0; - - RemoveData(); - SerieTemplate.AddDefaultTimeGanttSerie(this, "task", yCount); - } -#endif - protected override void GetSeriesMinMaxValue(Axis axis, int axisIndex, out float tempMinValue, out float tempMaxValue) - { - tempMinValue = float.MaxValue; - tempMaxValue = float.MinValue; - foreach (var serie in m_Series.list) - { - if (serie.type != SerieType.Gantt) continue; - if (serie.xAxisIndex != axis.index) continue; - foreach (var serieData in serie.data) - { - if (serieData.data.Count >= 2) - { - var xData = serieData.data[0]; - var yData = serieData.data[1]; - if (xData < tempMinValue) tempMinValue = xData; - if (yData > tempMaxValue) tempMaxValue = yData; - } - } - } - if (tempMinValue == float.MaxValue) tempMinValue = 0; - if (tempMaxValue == float.MinValue) tempMaxValue = 0; - } - - protected override void OnRefreshLabel() - { - for (int i = 0; i < m_Series.Count; i++) - { - var serie = m_Series.GetSerie(i); - if (serie.IsPerformanceMode()) continue; - if (serie.type != SerieType.Gantt) continue; - foreach (var serieData in serie.data) - { - if (serieData.labelObject == null) continue; - var serieLabel = SerieHelper.GetSerieLabel(serie, serieData); - var labelShow = serie.show && serieLabel.show; - serieData.SetLabelActive(labelShow); - if (labelShow) - { - var labelColor = serieLabel.textStyle.GetColor(m_Theme.axis.textColor); - var labelPos = serieData.runtimePosition; - SerieLabelHelper.ResetLabel(serieData.labelObject.label, serieLabel, m_Theme, i); - serieData.labelObject.SetPosition(labelPos); - serieData.labelObject.SetLabelColor(labelColor); - serieData.labelObject.SetText(serieData.name); - } - } - } - } - - protected override void UpdateTooltipValue(Vector2 local) - { - var grid = GetGrid(tooltip.runtimeGridIndex); - if (grid == null) return; - tooltip.runtimeDataIndex.Clear(); - foreach (var serie in m_Series.list) - { - var serieGrid = GetSerieGridOrDefault(serie); - if (grid.index != serieGrid.index) continue; - for (int i = 0; i < serie.data.Count; i++) - { - var serieData = serie.GetSerieData(i); - var highlight = serieData.runtimeRect.Contains(local); - serieData.highlighted = highlight; - if (highlight) - { - - tooltip.runtimeDataIndex.Add(serie.index); - tooltip.runtimeDataIndex.Add(i); - return; - } - } - } - } - - protected override void UpdateTooltip() - { - if (tooltip.runtimeDataIndex.Count == 0) - { - if (tooltip.IsActive()) - { - tooltip.SetActive(false); - RefreshChart(); - } - return; - } - var serieIndex = tooltip.runtimeDataIndex[0]; - var dataIndex = tooltip.runtimeDataIndex[1]; - var serie = m_Series.GetSerie(serieIndex); - if (serie == null) return; - var serieData = serie.GetSerieData(dataIndex); - var category = serieData == null ? serie.name : serieData.name; - TooltipHelper.SetContentAndPosition(tooltip, category, chartRect); - tooltip.SetActive(true); - } - } -} diff --git a/Runtime/GanttChart.cs.meta b/Runtime/GanttChart.cs.meta deleted file mode 100644 index 2b699350..00000000 --- a/Runtime/GanttChart.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d20186b31c74d4711870603e97fd65bc -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Helper/TooltipHelper.cs b/Runtime/Helper/TooltipHelper.cs index dd9629d9..3c32ca39 100644 --- a/Runtime/Helper/TooltipHelper.cs +++ b/Runtime/Helper/TooltipHelper.cs @@ -234,14 +234,6 @@ namespace XCharts } } - private static void InitGanttTooltip(ref StringBuilder sb, Tooltip tooltip, Serie serie, int index, - ChartTheme theme) - { - //if (tooltip.runtimeGridIndex >= 0) return; - //if (serie.index != index || serie.type != SerieType.Gantt) return; - sb.Append(serie.name); - } - private static void InitDefaultContent(ref StringBuilder sb, Tooltip tooltip, Serie serie, int index, BaseChart chart, DataZoom dataZoom = null, bool isCartesian = false, Radar radar = null) @@ -271,9 +263,6 @@ namespace XCharts case SerieType.Gauge: InitGaugeTooltip(ref sb, tooltip, serie, index, chart.theme); break; - case SerieType.Gantt: - InitGanttTooltip(ref sb, tooltip, serie, index, chart.theme); - break; case SerieType.Custom: chart.InitCustomSerieTooltip(ref sb, serie, index); break; diff --git a/Runtime/Internal/CoordinateChart.cs b/Runtime/Internal/CoordinateChart.cs index 84fe4244..b9099bf1 100644 --- a/Runtime/Internal/CoordinateChart.cs +++ b/Runtime/Internal/CoordinateChart.cs @@ -173,10 +173,6 @@ namespace XCharts serie.dataPoints.Clear(); DrawCandlestickSerie(vh, colorIndex, serie); break; - case SerieType.Gantt: - serie.dataPoints.Clear(); - DrawGanttSerie(vh, colorIndex, serie); - break; } } @@ -636,23 +632,8 @@ namespace XCharts yAxis.refreshComponent(); } - private void InitAxisRuntimeData(Axis axis) + protected virtual void InitAxisRuntimeData(Axis axis) { - if (axis.type != Axis.AxisType.Category) return; - if (axis.data.Count > 0) return; - if (this is GanttChart) - { - axis.runtimeData.Clear(); - for (int i = 0; i < m_Series.Count; i++) - { - var serie = m_Series.GetSerie(i); - if (serie.yAxisIndex != axis.index) continue; - for (int j = serie.data.Count - 1; j >= 0; j--) - { - axis.runtimeData.Add(serie.data[j].name); - } - } - } } internal void InitAxisX() diff --git a/Runtime/Internal/CoordinateChart_DrawGantt.cs b/Runtime/Internal/CoordinateChart_DrawGantt.cs deleted file mode 100644 index 171f7d80..00000000 --- a/Runtime/Internal/CoordinateChart_DrawGantt.cs +++ /dev/null @@ -1,177 +0,0 @@ -/************************************************/ -/* */ -/* Copyright (c) 2018 - 2021 monitor1394 */ -/* https://github.com/monitor1394 */ -/* */ -/************************************************/ - -using UnityEngine; -using UnityEngine.UI; -using XUGL; - -namespace XCharts -{ - public partial class CoordinateChart - { - protected void DrawGanttSerie(VertexHelper vh, int colorIndex, Serie serie) - { - if (!IsActive(serie.index)) return; - if (serie.animation.HasFadeOut()) return; - var showData = serie.GetDataList(null); - var yAxis = m_YAxes[serie.yAxisIndex]; - var xAxis = m_XAxes[serie.xAxisIndex]; - var grid = GetSerieGridOrDefault(serie); - var xCategoryWidth = AxisHelper.GetDataWidth(xAxis, grid.runtimeWidth, showData.Count, dataZoom); - var yCategoryWidth = AxisHelper.GetDataWidth(yAxis, grid.runtimeHeight, showData.Count, dataZoom); - var barWidth = serie.GetBarWidth(yCategoryWidth); - var space = (yCategoryWidth - barWidth) / 2; - var dataChanging = false; - var dataChangeDuration = serie.animation.GetUpdateAnimationDuration(); - var minValue = xAxis.GetCurrMinValue(dataChangeDuration); - var maxValue = xAxis.GetCurrMaxValue(dataChangeDuration); - var pX = grid.runtimeX + (xAxis.boundaryGap ? xCategoryWidth / 2 : 0); - var pY = 0f; - var startY = grid.runtimeY - (yAxis.boundaryGap ? 0 : yCategoryWidth / 2); - var isTime = xAxis.type == Axis.AxisType.Time; - - var categoryIndex = GetGanttSerieCategoryIndex(serie, grid.index); - var dataCount = serie.data.Count; - for (int i = 0; i < dataCount; i++) - { - var serieData = serie.data[i]; - pY = startY + (categoryIndex - 1 - i) * yCategoryWidth; - DrawSerieData(vh, grid, serie, serieData, colorIndex, pX, pY, space, barWidth, isTime, minValue, - maxValue, xCategoryWidth); - } - if (dataChanging) - { - RefreshPainter(serie); - } - } - - private void DrawSerieData(VertexHelper vh, Grid grid, Serie serie, SerieData serieData, int colorIndex, - float pX, float pY, float space, float barWidth, bool isTime, float minValue, float maxValue, - float xCategoryWidth) - { - var xStart = 0f; - var xEnd = 0f; - var xActualStart = 0f; - var xActualEnd = 0f; - var start = (int)serieData.GetData(0); - var end = (int)serieData.GetData(1); - var actualStart = (int)serieData.GetData(2); - var actualEnd = (int)serieData.GetData(3); - var enableActual = actualStart > 0 && actualEnd > 0; - if (isTime) - { - var valueTotal = maxValue - minValue; - xStart = pX + (start - minValue) / valueTotal * grid.runtimeWidth; - xEnd = pX + (end - minValue) / valueTotal * grid.runtimeWidth; - if (enableActual) - { - xActualStart = pX + (actualStart - minValue) / valueTotal * grid.runtimeWidth; - xActualEnd = pX + (actualEnd - minValue) / valueTotal * grid.runtimeWidth; - } - } - else - { - xStart = pX + start * xCategoryWidth; - xEnd = pX + end * xCategoryWidth; - if (enableActual) - { - xActualStart = pX + actualStart * xCategoryWidth; - xActualEnd = pX + actualEnd * xCategoryWidth; - } - } - var highlight = (serieData != null && serieData.highlighted) - || serie.highlighted; - var itemStyle = SerieHelper.GetItemStyle(serie, serieData, highlight); - var color = SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, highlight); - var borderWidth = itemStyle.borderWidth; - - var rect = DrawGanttBar(vh, grid, serie, serieData, itemStyle, color, pY, pY, space, barWidth, xStart, - xEnd); - if (enableActual) - { - var defaultActualColor = SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, true); - var actualColor = SerieHelper.GetItemColor0(serie, serieData, m_Theme, highlight, defaultActualColor); - var rect2 = DrawGanttBar(vh, grid, serie, serieData, itemStyle, actualColor, pY, pY, space, barWidth, - xActualStart, xActualEnd); - var rect3X = Mathf.Min(rect.x, rect2.x); - var rect3Width = Mathf.Max(rect.x + rect.width, rect2.x + rect2.width) - rect3X; - var rect3 = new Rect(rect3X, rect.y, rect3Width, rect.height); - serie.dataPoints.Add(rect3.center); - serieData.runtimePosition = rect3.center; - serieData.labelPosition = rect3.center; - serieData.runtimeRect = rect3; - } - else - { - serie.dataPoints.Add(rect.center); - serieData.runtimePosition = rect.center; - serieData.labelPosition = rect.center; - serieData.runtimeRect = rect; - } - } - - private Rect DrawGanttBar(VertexHelper vh, Grid grid, Serie serie, SerieData serieData, ItemStyle itemStyle, - Color32 color, float pX, float pY, float space, float barWidth, float xStart, float xEnd) - { - - var borderWidth = itemStyle.borderWidth; - var plb = new Vector3(xStart + borderWidth, pY + space + borderWidth); - var plt = new Vector3(xStart + borderWidth, pY + space + barWidth - borderWidth); - var prt = new Vector3(xEnd - borderWidth, pY + space + barWidth - borderWidth); - var prb = new Vector3(xEnd - borderWidth, pY + space + borderWidth); - var center = new Vector3((plb.x + prt.x) / 2, (plt.y + prb.y) / 2); - var itemWidth = Mathf.Abs(prt.x - plb.x); - var itemHeight = Mathf.Abs(plt.y - prb.y); - if (serie.clip) - { - plb = ClampInGrid(grid, plb); - plt = ClampInGrid(grid, plt); - prt = ClampInGrid(grid, prt); - prb = ClampInGrid(grid, prb); - center = ClampInGrid(grid, center); - } - if (ItemStyleHelper.IsNeedCorner(itemStyle)) - { - UGL.DrawRoundRectangle(vh, center, itemWidth, itemHeight, color, color, 0, - itemStyle.cornerRadius, true, 0.5f); - } - else - { - Internal_CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, color, color, - serie.clip, grid); - } - if (borderWidth != 0) - { - UGL.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, itemStyle.borderColor, - itemStyle.borderToColor, 0, itemStyle.cornerRadius, true, 0.5f); - } - return new Rect(plb.x, plb.y, xEnd - xStart, barWidth); - } - - private int GetGanttSerieCategoryIndex(Serie currSerie, int gridIndex) - { - var count = m_Series.Count; - var index = 0; - for (int i = 0; i < count; i++) - { - var serie = m_Series.GetSerie(i); - if (serie.type != SerieType.Gantt) continue; - var grid = GetSerieGridOrDefault(serie); - if (grid.index != gridIndex) continue; - foreach (var serieData in serie.data) - { - index++; - } - if (serie.index == currSerie.index) - { - return index; - } - } - return index; - } - } -} \ No newline at end of file diff --git a/Runtime/Internal/CoordinateChart_DrawGantt.cs.meta b/Runtime/Internal/CoordinateChart_DrawGantt.cs.meta deleted file mode 100644 index b779eed2..00000000 --- a/Runtime/Internal/CoordinateChart_DrawGantt.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 81895b3c97e684e8090572c7e64b396e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Internal/Utility/ChartDrawer.cs b/Runtime/Internal/Utility/ChartDrawer.cs index 2a13fe40..8e40f5c8 100644 --- a/Runtime/Internal/Utility/ChartDrawer.cs +++ b/Runtime/Internal/Utility/ChartDrawer.cs @@ -80,19 +80,12 @@ namespace XCharts } } - // public static void DrawLineStyle(VertexHelper vh, LineStyle lineStyle, - // Vector3 startPos, Vector3 endPos, Color32 color, float themeWidth) - // { - // var type = lineStyle.type; - // var width = lineStyle.GetWidth(themeWidth); - // DrawLineStyle(vh, type, width, startPos, endPos, color); - // } - public static void DrawLineStyle(VertexHelper vh, LineStyle lineStyle, - Vector3 startPos, Vector3 endPos, Color32 color, float themeWidth, LineStyle.Type themeType) + Vector3 startPos, Vector3 endPos, Color32 defaultColor, float themeWidth, LineStyle.Type themeType) { var type = lineStyle.GetType(themeType); var width = lineStyle.GetWidth(themeWidth); + var color = lineStyle.GetColor(defaultColor); DrawLineStyle(vh, type, width, startPos, endPos, color); } diff --git a/Runtime/Template/SerieTemplate.cs b/Runtime/Template/SerieTemplate.cs index fe7fc0d1..f5815c9a 100644 --- a/Runtime/Template/SerieTemplate.cs +++ b/Runtime/Template/SerieTemplate.cs @@ -28,7 +28,6 @@ namespace XCharts case SerieType.Gauge: AddDefaultGaugeSerie(chart, serieName); break; case SerieType.Ring: AddDefaultRingSerie(chart, serieName); break; case SerieType.Candlestick: AddDefaultCandlestickSerie(chart, serieName); break; - case SerieType.Gantt: AddDefaultCategoryGanttSerie(chart, serieName); break; case SerieType.Custom: chart.AddDefaultCustomSerie(serieName); break; default: Debug.LogError("AddDefaultSerie: not support serieType yet:" + serieType); break; } @@ -185,34 +184,5 @@ namespace XCharts } return defaultDataCount; } - - public static Serie AddDefaultCategoryGanttSerie(BaseChart chart, string serieName, int dataCount = 0, int min = 0, int max = 0) - { - var serie = chart.AddSerie(SerieType.Gantt, serieName); - serie.showDataName = true; - serie.showDataDimension = 2; - for (int i = 0; i < dataCount; i++) - { - var start = Random.Range(min, max); - var end = Random.Range(start + 1, max); - serie.AddXYData(start, end, "task-" + (i + 1)); - } - return serie; - } - - public static Serie AddDefaultTimeGanttSerie(BaseChart chart, string serieName, int dataCount = 0) - { - var serie = chart.AddSerie(SerieType.Gantt, serieName); - serie.showDataName = true; - serie.showDataDimension = 2; - var timestamp = DateTimeUtil.GetTimestamp(); - for (int i = 0; i < dataCount; i++) - { - var start = timestamp + Random.Range(1, 6) * 3600 * 24; - var end = start + Random.Range(1, 10) * 3600 * 24; - serie.AddXYData(start, end, "task-" + (i + 1)); - } - return serie; - } } } \ No newline at end of file