From 6aa11249c57b9062f0da4afd4e197b9a3d64a568 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sun, 14 Jan 2024 10:56:36 +0800 Subject: [PATCH] =?UTF-8?q?Editor=E4=B8=8A=E6=B7=BB=E5=8A=A0=E7=AC=AC?= =?UTF-8?q?=E4=BA=8C=E4=B8=AAX=E8=BD=B4=E6=88=96Y=E8=BD=B4=E6=97=B6?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E8=AE=BE=E7=BD=AE=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MainComponents/MainComponentListEditor.cs | 21 ++++++++++++++++++- Editor/Windows/XChartsEditor.LineChart.cs | 8 +++++++ Runtime/Chart/LineChart.cs | 11 ++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Editor/MainComponents/MainComponentListEditor.cs b/Editor/MainComponents/MainComponentListEditor.cs index 751904d7..065ea98f 100644 --- a/Editor/MainComponents/MainComponentListEditor.cs +++ b/Editor/MainComponents/MainComponentListEditor.cs @@ -133,7 +133,26 @@ namespace XCharts.Editor public void AddChartComponent(Type type) { - chart.AddChartComponent(type); + var component = chart.AddChartComponent(type); + if (component != null) + { + if (component is YAxis) + { + var yAxis = component as YAxis; + if (yAxis.index == 1) + { + yAxis.position = Axis.AxisPosition.Right; + } + } + else if (component is XAxis) + { + var xAxis = component as XAxis; + if (xAxis.index == 1) + { + xAxis.position = Axis.AxisPosition.Top; + } + } + } m_ComponentsProperty = m_BaseEditor.RefreshComponent(); RefreshEditors(); EditorUtility.SetDirty(chart); diff --git a/Editor/Windows/XChartsEditor.LineChart.cs b/Editor/Windows/XChartsEditor.LineChart.cs index 4052d4e4..d41cc4f7 100644 --- a/Editor/Windows/XChartsEditor.LineChart.cs +++ b/Editor/Windows/XChartsEditor.LineChart.cs @@ -83,5 +83,13 @@ namespace XCharts.Editor var chart = AddChart("LineChart_Time", "Time Line"); chart.DefaultTimeLineChart(); } + + [MenuItem("XCharts/LineChart/Log Line", priority = 44)] + [MenuItem("GameObject/XCharts/LineChart/Log Line", priority = 44)] + public static void AddLineChart_Log() + { + var chart = AddChart("LineChart_Log", "Log Line"); + chart.DefaultLogLineChart(); + } } } \ No newline at end of file diff --git a/Runtime/Chart/LineChart.cs b/Runtime/Chart/LineChart.cs index 974968f1..a051226f 100644 --- a/Runtime/Chart/LineChart.cs +++ b/Runtime/Chart/LineChart.cs @@ -131,5 +131,16 @@ namespace XCharts.Runtime var xAxis = GetChartComponent(); xAxis.type = Axis.AxisType.Time; } + + /// + /// default logarithmic line chart. + /// || 默认对数轴折线图。 + /// + public void DefaultLogLineChart() + { + CheckChartInit(); + var yAxis = GetChartComponent(); + yAxis.type = Axis.AxisType.Log; + } } } \ No newline at end of file