From 5fa155ab37ff599cb47b78d5c64010bf9b638491 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Wed, 12 Feb 2020 19:13:44 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`Radar`=E7=9A=84`splitLin?= =?UTF-8?q?e`=E5=8F=82=E6=95=B0=E9=85=8D=E7=BD=AE=E5=88=86=E5=89=B2?= =?UTF-8?q?=E7=BA=BF=EF=BC=8C=E5=8E=BB=E6=8E=89`lineStyle`=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + Documentation/XCharts配置项手册.md | 6 ++-- Editor/PropertyDrawers/RadarDrawer.cs | 10 +++---- Editor/PropertyDrawers/SerieDrawer.cs | 3 ++ Runtime/API/RadarChart_API.cs | 2 +- Runtime/Component/Main/Radar.cs | 13 +++++---- Runtime/Component/Sub/AxisSplitLine.cs | 2 +- Runtime/Component/Sub/LineStyle.cs | 2 +- Runtime/GaugeChart.cs | 4 +-- Runtime/Internal/BaseChart.cs | 25 +++++++++++++++++ Runtime/Internal/CoordinateChart.cs | 37 ++++--------------------- Runtime/RadarChart.cs | 38 +++++++++----------------- 12 files changed, 70 insertions(+), 73 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8fc55ab..d5fa1199 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # 更新日志 +* (2020.02.11) 增加`Radar`的`splitLine`参数配置分割线,去掉`lineStyle`参数 * (2020.02.11) 增加`Tooltip`的`backgroundImage`参数配置背景图 * (2020.02.11) 增加`Tooltip`的`paddingLeftRight`和`paddingTopBottom`参数配置文字和边框的间距 * (2020.02.11) 增加`Tooltip`的`lineStyle`参数配置指示线样式 diff --git a/Documentation/XCharts配置项手册.md b/Documentation/XCharts配置项手册.md index 89ecafd9..bfd30455 100644 --- a/Documentation/XCharts配置项手册.md +++ b/Documentation/XCharts配置项手册.md @@ -31,6 +31,7 @@ * [AxisLabel 坐标轴刻度标签](#AxisLabel) * [AxisLine 坐标轴轴线](#AxisLine) * [AxisName 坐标轴名称](#AxisName) +* [AxisSplitLine 坐标轴分割线条](#AxisSplitLine) * [AxisSplitArea 坐标轴分割区域](#AxisSplitArea) * [AxisTick 坐标轴刻度](#AxisTick) * [Emphasis 高亮样式](#Emphasis) @@ -143,7 +144,7 @@ * `Between`:显示在顶点之间。 * `radius`:雷达图的半径。 * `center`:雷达图的中心点。数组的第一项是横坐标,第二项是纵坐标。当值为0-1之间时表示百分比,设置成百分比时第一项是相对于容器宽度,第二项是相对于容器高度。 -* `lineStyle`:线条样式 [LineStyle](#LineStyle)。 +* `splitLine`:分割线条 [AxisSplitLine](#AxisSplitLine)。 * `splitArea`:分割区域 [AxisSplitArea](#AxisSplitArea)。 * `indicator`:是否显示指示器。 * `indicatorGap`:指示器和雷达的间距。 @@ -539,6 +540,7 @@ * `name`:系列名称。用于 `tooltip` 的显示,`legend` 的图例筛选。 * `radarIndex`:雷达图所使用的 `radar` 组件的 `index`。 * `symbol`:标记的图形 [SerieSymbol](#SerieSymbol)。 +* `lineStyle`:线条样式 [LineStyle](#LineStyle)。 * `animation`:起始动画 [SerieAnimation](#SerieAnimation)。 * `data`:系列中的数据项 [SerieData](#SerieData) 数组,可以设置`1`到`n`维数据。 @@ -714,7 +716,7 @@ ## `LineStyle` -* `show`:是否显示线条。在折线图中无效。 +* `show`:是否显示线条。当作为子组件,它的父组件有参数控制是否显示时,改参数无效。 * `type`:线条类型。支持以下五种类型: * `None`:不显示分割线。 * `Solid`:实线。 diff --git a/Editor/PropertyDrawers/RadarDrawer.cs b/Editor/PropertyDrawers/RadarDrawer.cs index f1132d85..994cb1b0 100644 --- a/Editor/PropertyDrawers/RadarDrawer.cs +++ b/Editor/PropertyDrawers/RadarDrawer.cs @@ -19,7 +19,7 @@ namespace XCharts SerializedProperty m_Radius; SerializedProperty m_SplitNumber; SerializedProperty m_Center; - SerializedProperty m_LineStyle; + SerializedProperty m_SplitLine; SerializedProperty m_SplitArea; SerializedProperty m_Indicator; SerializedProperty m_IndicatorGap; @@ -39,7 +39,7 @@ namespace XCharts m_Radius = prop.FindPropertyRelative("m_Radius"); m_SplitNumber = prop.FindPropertyRelative("m_SplitNumber"); m_Center = prop.FindPropertyRelative("m_Center"); - m_LineStyle = prop.FindPropertyRelative("m_LineStyle"); + m_SplitLine = prop.FindPropertyRelative("m_SplitLine"); m_SplitArea = prop.FindPropertyRelative("m_SplitArea"); m_Indicator = prop.FindPropertyRelative("m_Indicator"); m_IndicatorGap = prop.FindPropertyRelative("m_IndicatorGap"); @@ -85,8 +85,8 @@ namespace XCharts EditorGUI.PropertyField(drawRect, m_SplitNumber); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - EditorGUI.PropertyField(drawRect, m_LineStyle); - drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle); + EditorGUI.PropertyField(drawRect, m_SplitLine); + drawRect.y += EditorGUI.GetPropertyHeight(m_SplitLine); EditorGUI.PropertyField(drawRect, m_SplitArea); drawRect.y += EditorGUI.GetPropertyHeight(m_SplitArea); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; @@ -112,7 +112,7 @@ namespace XCharts propNum += 7; if (m_IndicatorJsonAreaToggle) propNum += 4; float height = propNum * EditorGUIUtility.singleLineHeight + (propNum - 1) * EditorGUIUtility.standardVerticalSpacing; - height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle")); + height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_SplitLine")); height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_SplitArea")); if (ChartEditorHelper.IsToggle(m_IndicatorToggle, prop)) diff --git a/Editor/PropertyDrawers/SerieDrawer.cs b/Editor/PropertyDrawers/SerieDrawer.cs index abe0624b..476f8064 100644 --- a/Editor/PropertyDrawers/SerieDrawer.cs +++ b/Editor/PropertyDrawers/SerieDrawer.cs @@ -194,6 +194,8 @@ namespace XCharts drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.PropertyField(drawRect, m_Symbol); drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol); + EditorGUI.PropertyField(drawRect, m_LineStyle); + drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle); EditorGUI.PropertyField(drawRect, m_AreaStyle); drawRect.y += EditorGUI.GetPropertyHeight(m_AreaStyle); break; @@ -451,6 +453,7 @@ namespace XCharts case SerieType.Radar: height += 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing; height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Symbol")); + height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle")); height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_AreaStyle")); height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis")); height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation")); diff --git a/Runtime/API/RadarChart_API.cs b/Runtime/API/RadarChart_API.cs index df8908fa..1c42afac 100644 --- a/Runtime/API/RadarChart_API.cs +++ b/Runtime/API/RadarChart_API.cs @@ -68,7 +68,7 @@ namespace XCharts radar.center[0] = center.x; radar.center[1] = center.y; radar.splitArea.show = showSplitArea; - radar.lineStyle.width = lineWidth; + radar.splitLine.lineStyle.width = lineWidth; m_Radars.Add(radar); return radar; } diff --git a/Runtime/Component/Main/Radar.cs b/Runtime/Component/Main/Radar.cs index a2e629c1..6aa3713a 100644 --- a/Runtime/Component/Main/Radar.cs +++ b/Runtime/Component/Main/Radar.cs @@ -126,7 +126,7 @@ namespace XCharts [SerializeField] private float m_Radius = 100; [SerializeField] private int m_SplitNumber = 5; [SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.5f }; - [SerializeField] private LineStyle m_LineStyle = new LineStyle(); + [SerializeField] private AxisSplitLine m_SplitLine = AxisSplitLine.defaultSplitLine; [SerializeField] private AxisSplitArea m_SplitArea = AxisSplitArea.defaultSplitArea; [SerializeField] private bool m_Indicator = true; [SerializeField] private PositionType m_PositionType = PositionType.Vertice; @@ -155,10 +155,10 @@ namespace XCharts /// public float[] center { get { return m_Center; } set { m_Center = value; } } /// - /// the line style of radar. - /// 线条样式。 + /// split line. + /// 分割线。 /// - public LineStyle lineStyle { get { return m_LineStyle; } set { m_LineStyle = value; } } + public AxisSplitLine splitLine { get { return m_SplitLine; } set { m_SplitLine = value; } } /// /// Split area of axis in grid area. /// 分割区域。 @@ -220,8 +220,9 @@ namespace XCharts }; radar.center[0] = 0.5f; radar.center[1] = 0.45f; + radar.splitLine.show = true; radar.splitArea.show = true; - radar.lineStyle.width = 0.6f; + radar.splitLine.lineStyle.width = 0.6f; return radar; } } @@ -234,6 +235,8 @@ namespace XCharts m_Center[0] = other.center[0]; m_Center[1] = other.center[1]; m_Indicator = other.indicator; + //m_SplitLine.Copy(other.splitLine); + //m_SplitArea.Copy(other.splitArea); indicatorList.Clear(); foreach (var d in other.indicatorList) indicatorList.Add(d.Clone()); } diff --git a/Runtime/Component/Sub/AxisSplitLine.cs b/Runtime/Component/Sub/AxisSplitLine.cs index 3ddb9062..6acd95d0 100644 --- a/Runtime/Component/Sub/AxisSplitLine.cs +++ b/Runtime/Component/Sub/AxisSplitLine.cs @@ -85,7 +85,7 @@ namespace XCharts internal bool NeedShow(int index) { - return interval == 0 || index % (interval + 1) == 0; + return show && (interval == 0 || index % (interval + 1) == 0); } } } \ No newline at end of file diff --git a/Runtime/Component/Sub/LineStyle.cs b/Runtime/Component/Sub/LineStyle.cs index 67064716..aa0a1dd9 100644 --- a/Runtime/Component/Sub/LineStyle.cs +++ b/Runtime/Component/Sub/LineStyle.cs @@ -52,7 +52,7 @@ namespace XCharts /// /// Whether show line. - /// 是否显示线条。在折线图中无效。 + /// 是否显示线条。当作为子组件,它的父组件有参数控制是否显示时,改参数无效。 /// public bool show { get { return m_Show; } set { m_Show = value; } } /// diff --git a/Runtime/GaugeChart.cs b/Runtime/GaugeChart.cs index 0ade3e77..684732d7 100644 --- a/Runtime/GaugeChart.cs +++ b/Runtime/GaugeChart.cs @@ -137,7 +137,7 @@ namespace XCharts DrawProgressBar(vh, serie, currAngle); DrawStageColor(vh, serie); - DrawSplitLine(vh, serie); + DrawLineStyle(vh, serie); DrawAxisTick(vh, serie); DrawPointer(vh, serie, currAngle); UpdateTitle(serie); @@ -215,7 +215,7 @@ namespace XCharts ChartDrawer.DrawPolygon(vh, p1, p3, p2, p4, pointerColor); } - private void DrawSplitLine(VertexHelper vh, Serie serie) + private void DrawLineStyle(VertexHelper vh, Serie serie) { if (serie.gaugeType != GaugeType.Pointer) return; if (!serie.gaugeAxis.show || !serie.gaugeAxis.splitLine.show) return; diff --git a/Runtime/Internal/BaseChart.cs b/Runtime/Internal/BaseChart.cs index 67bfc0d1..a1e101a4 100644 --- a/Runtime/Internal/BaseChart.cs +++ b/Runtime/Internal/BaseChart.cs @@ -787,6 +787,31 @@ namespace XCharts } } + protected void DrawLineStyle(VertexHelper vh, LineStyle lineStyle, + Vector3 startPos, Vector3 endPos, Color color) + { + var type = lineStyle.type; + var width = lineStyle.width; + switch (type) + { + case LineStyle.Type.Dashed: + ChartDrawer.DrawDashLine(vh, startPos, endPos, width, color); + break; + case LineStyle.Type.Dotted: + ChartDrawer.DrawDotLine(vh, startPos, endPos, width, color); + break; + case LineStyle.Type.Solid: + ChartDrawer.DrawLine(vh, startPos, endPos, width, color); + break; + case LineStyle.Type.DashDot: + ChartDrawer.DrawDashDotLine(vh, startPos, endPos, width, color); + break; + case LineStyle.Type.DashDotDot: + ChartDrawer.DrawDashDotDotLine(vh, startPos, endPos, width, color); + break; + } + } + protected void DrawLabelBackground(VertexHelper vh, Serie serie, SerieData serieData) { var labelHalfWid = serieData.GetLabelWidth() / 2; diff --git a/Runtime/Internal/CoordinateChart.cs b/Runtime/Internal/CoordinateChart.cs index 25ad8557..1668f5f0 100644 --- a/Runtime/Internal/CoordinateChart.cs +++ b/Runtime/Internal/CoordinateChart.cs @@ -980,7 +980,7 @@ namespace XCharts { if (yAxis.splitLine.NeedShow(i)) { - DrawSplitLine(vh, yAxis.splitLine.lineStyle, new Vector3(coordinateX, pY), + DrawLineStyle(vh, yAxis.splitLine.lineStyle, new Vector3(coordinateX, pY), new Vector3(coordinateX + coordinateWidth, pY), yAxis.splitLine.GetColor(m_ThemeInfo)); } } @@ -1070,7 +1070,7 @@ namespace XCharts { if (xAxis.splitLine.NeedShow(i)) { - DrawSplitLine(vh, xAxis.splitLine.lineStyle, new Vector3(pX, coordinateY), + DrawLineStyle(vh, xAxis.splitLine.lineStyle, new Vector3(pX, coordinateY), new Vector3(pX, coordinateY + coordinateHeight), xAxis.splitLine.GetColor(m_ThemeInfo)); } } @@ -1230,31 +1230,6 @@ namespace XCharts } } - protected void DrawSplitLine(VertexHelper vh, LineStyle lineStyle, - Vector3 startPos, Vector3 endPos, Color color) - { - var type = lineStyle.type; - var width = lineStyle.width; - switch (type) - { - case LineStyle.Type.Dashed: - ChartDrawer.DrawDashLine(vh, startPos, endPos, width, color); - break; - case LineStyle.Type.Dotted: - ChartDrawer.DrawDotLine(vh, startPos, endPos, width, color); - break; - case LineStyle.Type.Solid: - ChartDrawer.DrawLine(vh, startPos, endPos, width, color); - break; - case LineStyle.Type.DashDot: - ChartDrawer.DrawDashDotLine(vh, startPos, endPos, width, color); - break; - case LineStyle.Type.DashDotDot: - ChartDrawer.DrawDashDotDotLine(vh, startPos, endPos, width, color); - break; - } - } - protected void DrawXTooltipIndicator(VertexHelper vh) { if (!m_Tooltip.show || !m_Tooltip.IsSelected()) return; @@ -1275,12 +1250,12 @@ namespace XCharts if (xAxis.IsValue()) pX = m_Tooltip.runtimePointerPos.x; Vector2 sp = new Vector2(pX, coordinateY); Vector2 ep = new Vector2(pX, coordinateY + coordinateHeight); - DrawSplitLine(vh, m_Tooltip.lineStyle, sp, ep, m_Tooltip.GetLineColor(m_ThemeInfo)); + DrawLineStyle(vh, m_Tooltip.lineStyle, sp, ep, m_Tooltip.GetLineColor(m_ThemeInfo)); if (m_Tooltip.type == Tooltip.Type.Corss) { sp = new Vector2(coordinateX, m_Tooltip.runtimePointerPos.y); ep = new Vector2(coordinateX + coordinateWidth, m_Tooltip.runtimePointerPos.y); - DrawSplitLine(vh, m_Tooltip.lineStyle, sp, ep, m_Tooltip.GetLineColor(m_ThemeInfo)); + DrawLineStyle(vh, m_Tooltip.lineStyle, sp, ep, m_Tooltip.GetLineColor(m_ThemeInfo)); } break; case Tooltip.Type.Shadow: @@ -1318,12 +1293,12 @@ namespace XCharts float pY = coordinateY + m_Tooltip.runtimeYValues[i] * splitWidth + (yAxis.boundaryGap ? splitWidth / 2 : 0); Vector2 sp = new Vector2(coordinateX, pY); Vector2 ep = new Vector2(coordinateX + coordinateWidth, pY); - DrawSplitLine(vh, m_Tooltip.lineStyle, sp, ep, m_Tooltip.GetLineColor(m_ThemeInfo)); + DrawLineStyle(vh, m_Tooltip.lineStyle, sp, ep, m_Tooltip.GetLineColor(m_ThemeInfo)); if (m_Tooltip.type == Tooltip.Type.Corss) { sp = new Vector2(coordinateX, m_Tooltip.runtimePointerPos.y); ep = new Vector2(coordinateX + coordinateWidth, m_Tooltip.runtimePointerPos.y); - DrawSplitLine(vh, m_Tooltip.lineStyle, sp, ep, m_Tooltip.GetLineColor(m_ThemeInfo)); + DrawLineStyle(vh, m_Tooltip.lineStyle, sp, ep, m_Tooltip.GetLineColor(m_ThemeInfo)); } break; case Tooltip.Type.Shadow: diff --git a/Runtime/RadarChart.cs b/Runtime/RadarChart.cs index 91916f67..6d2525fb 100644 --- a/Runtime/RadarChart.cs +++ b/Runtime/RadarChart.cs @@ -276,7 +276,7 @@ namespace XCharts } if (serie.lineStyle.show) { - ChartDrawer.DrawLine(vh, startPoint, toPoint, serie.lineStyle.width, lineColor); + DrawLineStyle(vh, serie.lineStyle, startPoint, toPoint, lineColor); } startPoint = toPoint; } @@ -288,7 +288,7 @@ namespace XCharts } if (serie.lineStyle.show) { - ChartDrawer.DrawLine(vh, startPoint, firstPoint, serie.lineStyle.width, lineColor); + DrawLineStyle(vh, serie.lineStyle, startPoint, firstPoint, lineColor); } if (serie.symbol.type != SerieSymbolType.None) { @@ -318,7 +318,7 @@ namespace XCharts private void DrawRadar(VertexHelper vh, Radar radar) { - if (!radar.lineStyle.show && !radar.splitArea.show) + if (!radar.splitLine.show && !radar.splitArea.show) { return; } @@ -346,9 +346,9 @@ namespace XCharts { ChartDrawer.DrawPolygon(vh, p1, p2, p3, p4, color); } - if (radar.lineStyle.show) + if (radar.splitLine.NeedShow(i)) { - ChartDrawer.DrawLine(vh, p2, p3, radar.lineStyle.width, lineColor); + DrawLineStyle(vh, radar.splitLine.lineStyle, p2, p3, lineColor); } p1 = p4; p2 = p3; @@ -360,16 +360,16 @@ namespace XCharts float currAngle = j * angle; p3 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle), p.y + outsideRadius * Mathf.Cos(currAngle)); - if (radar.lineStyle.show) + if (radar.splitLine.show) { - ChartDrawer.DrawLine(vh, p, p3, radar.lineStyle.width / 2, lineColor); + DrawLineStyle(vh, radar.splitLine.lineStyle, p, p3, lineColor); } } } private void DrawCricleRadar(VertexHelper vh, Radar radar) { - if (!radar.lineStyle.show && !radar.splitArea.show) + if (!radar.splitLine.show && !radar.splitArea.show) { return; } @@ -389,9 +389,9 @@ namespace XCharts ChartDrawer.DrawDoughnut(vh, p, insideRadius, outsideRadius, color, Color.clear, m_Settings.cicleSmoothness, 0, 360); } - if (radar.lineStyle.show) + if (radar.splitLine.show) { - ChartDrawer.DrawEmptyCricle(vh, p, outsideRadius, radar.lineStyle.width, lineColor, + ChartDrawer.DrawEmptyCricle(vh, p, outsideRadius, radar.splitLine.lineStyle.width, lineColor, Color.clear, m_Settings.cicleSmoothness); } insideRadius = outsideRadius; @@ -401,30 +401,18 @@ namespace XCharts float currAngle = j * angle; p1 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle), p.y + outsideRadius * Mathf.Cos(currAngle)); - if (radar.lineStyle.show) + if (radar.splitLine.show) { - ChartDrawer.DrawLine(vh, p, p1, radar.lineStyle.width / 2, lineColor); + ChartDrawer.DrawLine(vh, p, p1, radar.splitLine.lineStyle.width / 2, lineColor); } } } private Color GetLineColor(Radar radar) { - if (radar.lineStyle.color != Color.clear) - { - var color = radar.lineStyle.color; - color.a *= radar.lineStyle.opacity; - return color; - } - else - { - var color = (Color)m_ThemeInfo.axisLineColor; - color.a *= radar.lineStyle.opacity; - return color; - } + return radar.splitLine.GetColor(m_ThemeInfo); } - protected override void CheckTootipArea(Vector2 local) { if (m_IsEnterLegendButtom) return; From ff777465f4eb0e6d4a25b1a296791089954f7392 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Thu, 13 Feb 2020 09:23:30 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`TextStyle`=E7=9A=84`line?= =?UTF-8?q?Spacing`=E5=8F=82=E6=95=B0=E9=85=8D=E7=BD=AE=E8=A1=8C=E9=97=B4?= =?UTF-8?q?=E8=B7=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 ++ Documentation/XChartsAPI.md | 1 + Documentation/XCharts配置项手册.md | 4 +- Editor/PropertyDrawers/TextStyleDrawer.cs | 58 ++++++++++++----------- Editor/PropertyDrawers/TitleDrawer.cs | 13 ++--- Editor/PropertyDrawers/TooltipDrawer.cs | 14 +++--- Runtime/API/BaseChart_API.cs | 8 ++++ Runtime/Component/Main/Serie.cs | 4 +- Runtime/Component/Main/Tooltip.cs | 26 +++++----- Runtime/Component/Sub/TextStyle.cs | 9 ++++ Runtime/HeatmapChart.cs | 2 +- Runtime/Internal/BaseChart.cs | 23 +++++---- Runtime/Internal/CoordinateChart.cs | 8 ++-- Runtime/Internal/SerieLabelPool.cs | 5 +- Runtime/PieChart.cs | 6 +-- Runtime/RadarChart.cs | 8 ++-- Runtime/Utility/ChartHelper.cs | 19 ++++---- Runtime/Utility/XChartsMgr.cs | 2 +- 18 files changed, 121 insertions(+), 92 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5fa1199..a6c7891f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # 更新日志 +* (2020.02.13) 增加`BaseChart.RefreshTooltip()`接口立即重新初始化`Tooltip`组件 +* (2020.02.13) 增加`Tooltip`的`textStyle`参数配置内容文本样式,去掉`fontSize`和`fontStyle`参数 +* (2020.02.13) 增加`TextStyle`的`lineSpacing`参数配置行间距 * (2020.02.11) 增加`Radar`的`splitLine`参数配置分割线,去掉`lineStyle`参数 * (2020.02.11) 增加`Tooltip`的`backgroundImage`参数配置背景图 * (2020.02.11) 增加`Tooltip`的`paddingLeftRight`和`paddingTopBottom`参数配置文字和边框的间距 diff --git a/Documentation/XChartsAPI.md b/Documentation/XChartsAPI.md index 2d0a464b..c8361dc0 100644 --- a/Documentation/XChartsAPI.md +++ b/Documentation/XChartsAPI.md @@ -40,6 +40,7 @@ * `BaseChart.IsActiveByLegend(string legendName)`:获得指定图例名字的系列是否显示。 * `BaseChart.RefreshChart()`:在下一帧刷新图表。 * `BaseChart.RefreshLabel()`:在下一帧刷新文本标签。 +* `BaseChart.RefreshTooltip()`:立即刷新`Tooltip`组件。 * `BaseChart.UpdateTheme(Theme theme)`:切换图表主题。 * `BaseChart.AnimationEnable(bool flag)`:启用或关闭起始动画。 * `BaseChart.AnimationStart()`:开始初始动画。 diff --git a/Documentation/XCharts配置项手册.md b/Documentation/XCharts配置项手册.md index bfd30455..427b6177 100644 --- a/Documentation/XCharts配置项手册.md +++ b/Documentation/XCharts配置项手册.md @@ -171,6 +171,7 @@ * `color`:颜色。 * `fontSize`:字体大小。 * `fontStyle`:字体风格。 +* `lineSpacing`:行间距。 ## `Tooltip` @@ -197,11 +198,10 @@ * `minHeight`:最小高度。当同时设置 f`ixedHeight` 和 `minHeight` 时,`fixedHeight` 比 `minHeight` 优先级高。 * `paddingLeftRight`:文字和边框的左右边距。 * `paddingTopBottom`:文字和边框的上下边距。 -* `fontSize`:文字的字体大小。 -* `fontStyle`:文字的字体风格。 * `backgroundImage`:提示框的背景图。 * `forceENotation`:是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。 * `lineStyle`:指示器线条样式 [LineStyle](#LineStyle)。 +* `textStyle`:显示内容文本样式 [TextStyle](#TextStyle)。 ## `DataZoom` diff --git a/Editor/PropertyDrawers/TextStyleDrawer.cs b/Editor/PropertyDrawers/TextStyleDrawer.cs index 38f9713e..3af4bb76 100644 --- a/Editor/PropertyDrawers/TextStyleDrawer.cs +++ b/Editor/PropertyDrawers/TextStyleDrawer.cs @@ -14,7 +14,7 @@ namespace XCharts [CustomPropertyDrawer(typeof(TextStyle), true)] public class TextStyleDrawer : PropertyDrawer { - //private Dictionary m_TextStyleToggle = new Dictionary(); + private Dictionary m_TextStyleToggle = new Dictionary(); public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label) { @@ -25,38 +25,40 @@ namespace XCharts SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize"); SerializedProperty m_FontStyle = prop.FindPropertyRelative("m_FontStyle"); SerializedProperty m_Offset = prop.FindPropertyRelative("m_Offset"); - // ChartEditorHelper.MakeFoldout(ref drawRect, ref m_TextStyleToggle, prop, "Text Style"); - // drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - // if (ChartEditorHelper.IsToggle(m_TextStyleToggle, prop)) - // { - // ++EditorGUI.indentLevel; - EditorGUI.PropertyField(drawRect, m_Rotate); + SerializedProperty m_LineSpacing = prop.FindPropertyRelative("m_LineSpacing"); + ChartEditorHelper.MakeFoldout(ref drawRect, ref m_TextStyleToggle, prop, null,null,false); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - EditorGUI.PropertyField(drawRect, m_Offset); - drawRect.y += EditorGUI.GetPropertyHeight(m_Offset); - EditorGUI.PropertyField(drawRect, m_Color); - drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - EditorGUI.PropertyField(drawRect, m_FontSize); - drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - EditorGUI.PropertyField(drawRect, m_FontStyle); - drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - // --EditorGUI.indentLevel; - // } + if (ChartEditorHelper.IsToggle(m_TextStyleToggle, prop)) + { + ++EditorGUI.indentLevel; + EditorGUI.PropertyField(drawRect, m_Rotate); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, m_Offset); + drawRect.y += EditorGUI.GetPropertyHeight(m_Offset); + EditorGUI.PropertyField(drawRect, m_Color); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, m_FontSize); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, m_FontStyle); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, m_LineSpacing); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + --EditorGUI.indentLevel; + } } public override float GetPropertyHeight(SerializedProperty prop, GUIContent label) { - // float height = 0; - // if (ChartEditorHelper.IsToggle(m_TextStyleToggle, prop)) - // { - // height += 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing; - // } - // else - // { - // height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing; - // } - float height = 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing; - height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Offset")); + float height = 0; + if (ChartEditorHelper.IsToggle(m_TextStyleToggle, prop)) + { + height += 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing; + height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Offset")); + } + else + { + height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing; + } return height; } } diff --git a/Editor/PropertyDrawers/TitleDrawer.cs b/Editor/PropertyDrawers/TitleDrawer.cs index 7e7cb324..0b774860 100644 --- a/Editor/PropertyDrawers/TitleDrawer.cs +++ b/Editor/PropertyDrawers/TitleDrawer.cs @@ -34,19 +34,16 @@ namespace XCharts { EditorGUI.PropertyField(drawRect, text); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - ++EditorGUI.indentLevel; - EditorGUI.PropertyField(drawRect, m_TextStyle); - drawRect.y += EditorGUI.GetPropertyHeight(m_TextStyle); - --EditorGUI.indentLevel; EditorGUI.PropertyField(drawRect, subText); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - ++EditorGUI.indentLevel; - EditorGUI.PropertyField(drawRect, m_SubTextStyle); - drawRect.y += EditorGUI.GetPropertyHeight(m_SubTextStyle); - --EditorGUI.indentLevel; EditorGUI.PropertyField(drawRect, m_ItemGap, new GUIContent("Item Gap")); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.PropertyField(drawRect, location); + drawRect.y += EditorGUI.GetPropertyHeight(location); + EditorGUI.PropertyField(drawRect, m_TextStyle); + drawRect.y += EditorGUI.GetPropertyHeight(m_TextStyle); + EditorGUI.PropertyField(drawRect, m_SubTextStyle); + drawRect.y += EditorGUI.GetPropertyHeight(m_SubTextStyle); } --EditorGUI.indentLevel; } diff --git a/Editor/PropertyDrawers/TooltipDrawer.cs b/Editor/PropertyDrawers/TooltipDrawer.cs index 50fe7255..77edf907 100644 --- a/Editor/PropertyDrawers/TooltipDrawer.cs +++ b/Editor/PropertyDrawers/TooltipDrawer.cs @@ -28,13 +28,12 @@ namespace XCharts SerializedProperty m_FixedHeight = prop.FindPropertyRelative("m_FixedHeight"); SerializedProperty m_MinWidth = prop.FindPropertyRelative("m_MinWidth"); SerializedProperty m_MinHeight = prop.FindPropertyRelative("m_MinHeight"); - SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize"); - SerializedProperty m_FontStyle = prop.FindPropertyRelative("m_FontStyle"); SerializedProperty m_ForceENotation = prop.FindPropertyRelative("m_ForceENotation"); SerializedProperty m_PaddingLeftRight = prop.FindPropertyRelative("m_PaddingLeftRight"); SerializedProperty m_PaddingTopBottom = prop.FindPropertyRelative("m_PaddingTopBottom"); SerializedProperty m_BackgroundImage = prop.FindPropertyRelative("m_BackgroundImage"); SerializedProperty m_LineStyle = prop.FindPropertyRelative("m_LineStyle"); + SerializedProperty m_TextStyle = prop.FindPropertyRelative("m_TextStyle"); ChartEditorHelper.MakeFoldout(ref drawRect, ref m_TooltipModuleToggle, "Tooltip", show); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; @@ -61,16 +60,14 @@ namespace XCharts drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.PropertyField(drawRect, m_PaddingTopBottom); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - EditorGUI.PropertyField(drawRect, m_FontSize); - drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - EditorGUI.PropertyField(drawRect, m_FontStyle); - drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.PropertyField(drawRect, m_BackgroundImage); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.PropertyField(drawRect, m_ForceENotation); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.PropertyField(drawRect, m_LineStyle); drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle); + EditorGUI.PropertyField(drawRect, m_TextStyle); + drawRect.y += EditorGUI.GetPropertyHeight(m_TextStyle); EditorGUI.indentLevel--; } } @@ -78,8 +75,9 @@ namespace XCharts public override float GetPropertyHeight(SerializedProperty prop, GUIContent label) { if (m_TooltipModuleToggle) - return 15 * EditorGUIUtility.singleLineHeight + 14 * EditorGUIUtility.standardVerticalSpacing + - EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle")); + return 13 * EditorGUIUtility.singleLineHeight + 12 * EditorGUIUtility.standardVerticalSpacing + + EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle")) + + EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TextStyle")); else return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; } diff --git a/Runtime/API/BaseChart_API.cs b/Runtime/API/BaseChart_API.cs index faf23efd..9c78b82c 100644 --- a/Runtime/API/BaseChart_API.cs +++ b/Runtime/API/BaseChart_API.cs @@ -482,6 +482,14 @@ namespace XCharts m_ReinitLabel = true; } + /// + /// 刷新Tooltip组件。 + /// + public void RefreshTooltip() + { + InitTooltip(); + } + /// /// Update chart theme. /// 切换图表主题。 diff --git a/Runtime/Component/Main/Serie.cs b/Runtime/Component/Main/Serie.cs index 737983f7..57b3b28c 100644 --- a/Runtime/Component/Main/Serie.cs +++ b/Runtime/Component/Main/Serie.cs @@ -194,7 +194,7 @@ namespace XCharts [System.Serializable] public class Serie : MainComponent { - [SerializeField] [DefaultValue("true")] private bool m_Show = true; + [SerializeField] private bool m_Show = true; [SerializeField] private SerieType m_Type; [SerializeField] private string m_Name; [SerializeField] private string m_Stack; @@ -246,7 +246,7 @@ namespace XCharts [SerializeField] [Range(1, 10)] private int m_ShowDataDimension; [SerializeField] private bool m_ShowDataName; [SerializeField] private bool m_ShowDataIcon; - [SerializeField] private bool m_Clip = false; + [SerializeField] private bool m_Clip = true; [SerializeField] private List m_Data = new List(); diff --git a/Runtime/Component/Main/Tooltip.cs b/Runtime/Component/Main/Tooltip.cs index e7b081ed..6661c454 100644 --- a/Runtime/Component/Main/Tooltip.cs +++ b/Runtime/Component/Main/Tooltip.cs @@ -1,4 +1,5 @@ -/******************************************/ +using System.Collections.ObjectModel; +/******************************************/ /* */ /* Copyright (c) 2018 monitor1394 */ /* https://github.com/monitor1394 */ @@ -8,6 +9,8 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; +using System; +using UnityEngine.EventSystems; namespace XCharts { @@ -55,12 +58,11 @@ namespace XCharts [SerializeField] private float m_FixedHeight = 0; [SerializeField] private float m_MinWidth = 0; [SerializeField] private float m_MinHeight = 0; - [SerializeField] private int m_FontSize = 18; - [SerializeField] private FontStyle m_FontStyle = FontStyle.Normal; [SerializeField] private bool m_ForceENotation = false; [SerializeField] private float m_PaddingLeftRight = 5f; [SerializeField] private float m_PaddingTopBottom = 5f; [SerializeField] private Sprite m_BackgroundImage; + [SerializeField] private TextStyle m_TextStyle = new TextStyle(18, FontStyle.Normal); [SerializeField] private LineStyle m_LineStyle = new LineStyle(LineStyle.Type.Solid, 0.7f); private GameObject m_GameObject; @@ -138,16 +140,10 @@ namespace XCharts /// 最小高度。如若 fixedHeight 设有值,优先取 fixedHeight。 /// public float minHeight { get { return m_MinHeight; } set { m_MinHeight = value; } } - /// - /// font size. - /// 文字的字体大小。 - /// - public int fontSize { get { return m_FontSize; } set { m_FontSize = value; } } - /// - /// font style. - /// 文字的字体风格。 - /// - public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } } + [Obsolete("Use Tooltip.textStyle.fontSize instead.", true)] + public int fontSize { get; set; } + [Obsolete("Use Tooltip.textStyle.fontStyle instead.", true)] + public FontStyle fontStyle { get; set; } /// /// 是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。 /// @@ -168,6 +164,10 @@ namespace XCharts /// public Sprite backgroundImage { get { return m_BackgroundImage; } set { m_BackgroundImage = value; SetBackground(m_BackgroundImage); } } /// + /// 提示框内容文本样式。 + /// + public TextStyle textStyle { get { return m_TextStyle; } set { if (value != null) m_TextStyle = value; } } + /// /// 指示线样式。 /// public LineStyle lineStyle { get { return m_LineStyle; } set { if (value != null) m_LineStyle = value; } } diff --git a/Runtime/Component/Sub/TextStyle.cs b/Runtime/Component/Sub/TextStyle.cs index 79518a4a..787f0803 100644 --- a/Runtime/Component/Sub/TextStyle.cs +++ b/Runtime/Component/Sub/TextStyle.cs @@ -23,6 +23,7 @@ namespace XCharts [SerializeField] private Color m_Color = Color.clear; [SerializeField] private int m_FontSize = 18; [SerializeField] private FontStyle m_FontStyle = FontStyle.Normal; + [SerializeField] private float m_LineSpacing = 1; /// /// Rotation of text. @@ -52,6 +53,11 @@ namespace XCharts /// 文本字体的风格。 /// public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } } + /// + /// text line spacing. + /// 行间距。 + /// + public float lineSpacing { get { return m_LineSpacing; } set { m_LineSpacing = value; } } public TextStyle() { @@ -90,6 +96,7 @@ namespace XCharts this.color = style.color; this.rotate = style.rotate; this.offset = style.offset; + this.lineSpacing = style.lineSpacing; } public TextStyle Clone() @@ -100,6 +107,7 @@ namespace XCharts textStyle.fontSize = fontSize; textStyle.fontStyle = fontStyle; textStyle.offset = offset; + textStyle.lineSpacing = lineSpacing; return textStyle; } @@ -129,6 +137,7 @@ namespace XCharts fontSize == other.fontSize && fontStyle == other.fontStyle && offset == other.offset && + lineSpacing == other.lineSpacing && ChartHelper.IsValueEqualsColor(m_Color, other.color); } diff --git a/Runtime/HeatmapChart.cs b/Runtime/HeatmapChart.cs index a38c40ae..edb1fd21 100644 --- a/Runtime/HeatmapChart.cs +++ b/Runtime/HeatmapChart.cs @@ -85,7 +85,7 @@ namespace XCharts } #endif - protected override void RefreshTooltip() + protected override void UpdateTooltip() { var xData = m_Tooltip.runtimeXValues[0]; var yData = m_Tooltip.runtimeYValues[0]; diff --git a/Runtime/Internal/BaseChart.cs b/Runtime/Internal/BaseChart.cs index a1e101a4..37bb7ec3 100644 --- a/Runtime/Internal/BaseChart.cs +++ b/Runtime/Internal/BaseChart.cs @@ -142,6 +142,11 @@ namespace XCharts m_Series = Series.defaultSeries; Awake(); } + + protected override void OnValidate() + { + //TODO: + } #endif protected override void OnDestroy() @@ -170,8 +175,8 @@ namespace XCharts Text titleText = ChartHelper.AddTextObject(s_TitleObjectName, titleObject.transform, m_ThemeInfo.font, m_ThemeInfo.titleTextColor, anchor, anchorMin, anchorMax, pivot, - new Vector2(titleWid, m_Title.textStyle.fontSize), m_Title.textStyle.fontSize, m_Title.textStyle.rotate, - m_Title.textStyle.fontStyle); + new Vector2(titleWid, m_Title.textStyle.fontSize), m_Title.textStyle.fontSize, + m_Title.textStyle.rotate, m_Title.textStyle.fontStyle, m_Title.textStyle.lineSpacing); titleText.alignment = anchor; titleText.gameObject.SetActive(m_Title.show); @@ -181,7 +186,7 @@ namespace XCharts Text subText = ChartHelper.AddTextObject(s_TitleObjectName + "_sub", titleObject.transform, m_ThemeInfo.font, m_ThemeInfo.titleSubTextColor, anchor, anchorMin, anchorMax, pivot, new Vector2(titleWid, m_Title.subTextStyle.fontSize), m_Title.subTextStyle.fontSize, - m_Title.subTextStyle.rotate, m_Title.subTextStyle.fontStyle); + m_Title.subTextStyle.rotate, m_Title.subTextStyle.fontStyle, m_Title.subTextStyle.lineSpacing); subText.alignment = anchor; subText.gameObject.SetActive(m_Title.show && !string.IsNullOrEmpty(m_Title.subText)); @@ -232,7 +237,7 @@ namespace XCharts var objName = s_LegendObjectName + "_" + i + "_" + datas[i]; Button btn = ChartHelper.AddButtonObject(objName, legendObject.transform, m_ThemeInfo.font, m_Legend.itemFontSize, m_ThemeInfo.legendTextColor, anchor, - anchorMin, anchorMax, pivot, new Vector2(m_Legend.itemWidth, m_Legend.itemHeight)); + anchorMin, anchorMax, pivot, new Vector2(m_Legend.itemWidth, m_Legend.itemHeight), 1); var bgColor = IsActiveByLegend(datas[i]) ? m_ThemeInfo.GetColor(readIndex) : m_ThemeInfo.legendUnableColor; m_Legend.SetButton(legendName, btn, totalLegend); @@ -349,8 +354,9 @@ namespace XCharts var pivot = new Vector2(0.5f, 0.5f); var fontSize = 10; var sizeDelta = new Vector2(50, fontSize + 2); - var txt = ChartHelper.AddTextObject("title_" + i, titleObject.transform, m_ThemeInfo.font, color, TextAnchor.MiddleCenter, - anchorMin, anchorMax, pivot, sizeDelta, textStyle.fontSize, textStyle.rotate, textStyle.fontStyle); + var txt = ChartHelper.AddTextObject("title_" + i, titleObject.transform, m_ThemeInfo.font, color, + TextAnchor.MiddleCenter, anchorMin, anchorMax, pivot, sizeDelta, textStyle.fontSize, textStyle.rotate, + textStyle.fontStyle, textStyle.lineSpacing); txt.text = ""; txt.transform.localPosition = new Vector2(0, 0); txt.transform.localEulerAngles = Vector2.zero; @@ -372,9 +378,10 @@ namespace XCharts tooltipObject.transform.localPosition = Vector3.zero; DestroyImmediate(tooltipObject.GetComponent()); var parent = tooltipObject.transform; + var textStyle = m_Tooltip.textStyle; ChartHelper.HideAllObject(tooltipObject.transform); GameObject content = ChartHelper.AddTooltipContent("content", parent, m_ThemeInfo.font, - m_Tooltip.fontSize, m_Tooltip.fontStyle); + textStyle.fontSize, textStyle.fontStyle, textStyle.lineSpacing); m_Tooltip.SetObj(tooltipObject); m_Tooltip.SetContentObj(content); m_Tooltip.SetContentBackgroundColor(m_ThemeInfo.tooltipBackgroundColor); @@ -687,7 +694,7 @@ namespace XCharts return show; } - protected virtual void RefreshTooltip() + protected virtual void UpdateTooltip() { } diff --git a/Runtime/Internal/CoordinateChart.cs b/Runtime/Internal/CoordinateChart.cs index 1668f5f0..675f91ec 100644 --- a/Runtime/Internal/CoordinateChart.cs +++ b/Runtime/Internal/CoordinateChart.cs @@ -194,7 +194,7 @@ namespace XCharts if (!IsInCooridate(local)) { m_Tooltip.ClearValue(); - RefreshTooltip(); + UpdateTooltip(); } else { @@ -306,7 +306,7 @@ namespace XCharts if (m_Tooltip.IsSelected()) { m_Tooltip.UpdateContentPos(new Vector2(local.x + 18, local.y - 25)); - RefreshTooltip(); + UpdateTooltip(); if (m_Tooltip.IsDataIndexChanged() || m_Tooltip.type == Tooltip.Type.Corss) { m_Tooltip.UpdateLastDataIndex(); @@ -321,9 +321,9 @@ namespace XCharts } protected StringBuilder sb = new StringBuilder(100); - protected override void RefreshTooltip() + protected override void UpdateTooltip() { - base.RefreshTooltip(); + base.UpdateTooltip(); int index; Axis tempAxis; bool isCartesian = IsValue(); diff --git a/Runtime/Internal/SerieLabelPool.cs b/Runtime/Internal/SerieLabelPool.cs index 041e3e83..155a4702 100644 --- a/Runtime/Internal/SerieLabelPool.cs +++ b/Runtime/Internal/SerieLabelPool.cs @@ -15,14 +15,15 @@ namespace XCharts { private static readonly Stack m_Stack = new Stack(200); - public static GameObject Get(string name, Transform parent, SerieLabel label, Font font, Color color, float iconWidth, float iconHeight) + public static GameObject Get(string name, Transform parent, SerieLabel label, Font font, Color color, + float iconWidth, float iconHeight) { GameObject element; if (m_Stack.Count == 0 || !Application.isPlaying) { element = ChartHelper.AddSerieLabel(name, parent, font, color, label.backgroundColor, label.fontSize, label.fontStyle, label.rotate, - label.backgroundWidth, label.backgroundHeight); + label.backgroundWidth, label.backgroundHeight, 1); ChartHelper.AddIcon("Icon", element.transform, iconWidth, iconHeight); } else diff --git a/Runtime/PieChart.cs b/Runtime/PieChart.cs index 3e67ee9f..a99de3eb 100644 --- a/Runtime/PieChart.cs +++ b/Runtime/PieChart.cs @@ -531,7 +531,7 @@ namespace XCharts if (selected) { m_Tooltip.UpdateContentPos(new Vector2(local.x + 18, local.y - 25)); - RefreshTooltip(); + UpdateTooltip(); } else if (m_Tooltip.IsActive()) { @@ -570,9 +570,9 @@ namespace XCharts } StringBuilder sb = new StringBuilder(); - protected override void RefreshTooltip() + protected override void UpdateTooltip() { - base.RefreshTooltip(); + base.UpdateTooltip(); bool showTooltip = false; foreach (var serie in m_Series.list) { diff --git a/Runtime/RadarChart.cs b/Runtime/RadarChart.cs index 6d2525fb..948a125a 100644 --- a/Runtime/RadarChart.cs +++ b/Runtime/RadarChart.cs @@ -97,7 +97,7 @@ namespace XCharts var textColor = textStyle.color == Color.clear ? (Color)m_ThemeInfo.axisTextColor : textStyle.color; var txt = ChartHelper.AddTextObject(INDICATOR_TEXT + "_" + n + "_" + i, transform, m_ThemeInfo.font, textColor, anchor, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), - new Vector2(txtWid, txtHig), textStyle.fontSize, textStyle.rotate, textStyle.fontStyle); + new Vector2(txtWid, txtHig), textStyle.fontSize, textStyle.rotate, textStyle.fontStyle, textStyle.lineSpacing); txt.text = radar.indicatorList[i].name; txt.gameObject.SetActive(radar.indicator); var txtWidth = txt.preferredWidth; @@ -459,14 +459,14 @@ namespace XCharts else { m_Tooltip.UpdateContentPos(new Vector2(local.x + 18, local.y - 25)); - RefreshTooltip(); + UpdateTooltip(); RefreshChart(); } } - protected override void RefreshTooltip() + protected override void UpdateTooltip() { - base.RefreshTooltip(); + base.UpdateTooltip(); int serieIndex = m_Tooltip.runtimeDataIndex[0]; if (serieIndex < 0) { diff --git a/Runtime/Utility/ChartHelper.cs b/Runtime/Utility/ChartHelper.cs index c123814a..f8e8e288 100644 --- a/Runtime/Utility/ChartHelper.cs +++ b/Runtime/Utility/ChartHelper.cs @@ -163,7 +163,7 @@ namespace XCharts public static Text AddTextObject(string name, Transform parent, Font font, Color color, TextAnchor anchor, Vector2 anchorMin, Vector2 anchorMax, Vector2 pivot, Vector2 sizeDelta, - int fontSize = 14, float rotate = 0, FontStyle fontStyle = FontStyle.Normal) + int fontSize = 14, float rotate = 0, FontStyle fontStyle = FontStyle.Normal, float lineSpacing = 1) { GameObject txtObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta); Text txt = GetOrAddComponent(txtObj); @@ -175,6 +175,7 @@ namespace XCharts txt.horizontalOverflow = HorizontalWrapMode.Overflow; txt.verticalOverflow = VerticalWrapMode.Overflow; txt.color = color; + txt.lineSpacing = lineSpacing; txtObj.transform.localEulerAngles = new Vector3(0, 0, rotate); RectTransform rect = GetOrAddComponent(txtObj); @@ -188,20 +189,21 @@ namespace XCharts public static Button AddButtonObject(string name, Transform parent, Font font, int fontSize, Color color, TextAnchor anchor, Vector2 anchorMin, Vector2 anchorMax, Vector2 pivot, - Vector2 sizeDelta) + Vector2 sizeDelta, float lineSpacing) { GameObject btnObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta); GetOrAddComponent(btnObj); GetOrAddComponent