diff --git a/Editor/Charts/BaseChartEditor.cs b/Editor/Charts/BaseChartEditor.cs index 68253684..85ad890b 100644 --- a/Editor/Charts/BaseChartEditor.cs +++ b/Editor/Charts/BaseChartEditor.cs @@ -11,6 +11,15 @@ namespace XCharts.Editor [CustomEditor(typeof(BaseChart), true)] public class BaseChartEditor : UnityEditor.Editor { + class Styles + { + public static readonly GUIContent btnAddSerie = new GUIContent("Add Serie", ""); + public static readonly GUIContent btnAddComponent = new GUIContent("Add Main Component", ""); + public static readonly GUIContent btnCovertXYAxis = new GUIContent("Covert XY Axis", ""); + public static readonly GUIContent btnRebuildChartObject = new GUIContent("Rebuild Chart Object", ""); + public static readonly GUIContent btnCheckWarning = new GUIContent("Check Warning", ""); + public static readonly GUIContent btnHideWarning = new GUIContent("Hide Warning", ""); + } protected BaseChart m_Chart; protected SerializedProperty m_Script; protected SerializedProperty m_EnableTextMeshPro; @@ -102,8 +111,6 @@ namespace XCharts.Editor m_SerieList.UpdateSeriesProperty(m_Series); } OnStartInspectorGUI(); - EditorGUILayout.Space(); - OnDebugInspectorGUI(); EditorGUILayout.Space(); serializedObject.ApplyModifiedProperties(); @@ -118,18 +125,23 @@ namespace XCharts.Editor EditorGUILayout.PropertyField(m_Script); EditorGUILayout.PropertyField(m_ChartName); EditorGUILayout.PropertyField(m_RaycastTarget); + if (XChartsMgr.IsRepeatChartName(m_Chart, m_ChartName.stringValue)) + { + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.HelpBox("chart name is repeated: " + m_ChartName.stringValue, MessageType.Error); + EditorGUILayout.EndHorizontal(); + } } EditorGUILayout.PropertyField(m_Theme); EditorGUILayout.PropertyField(m_Settings); - m_ComponentList.OnGUI(); - m_SerieList.OnGUI(); } protected virtual void OnDebugInspectorGUI() { EditorGUILayout.PropertyField(m_DebugInfo, true); + EditorGUILayout.Space(); AddSerie(); AddComponent(); CheckWarning(); @@ -175,7 +187,7 @@ namespace XCharts.Editor private void AddComponent() { - if (GUILayout.Button("Add Component")) + if (GUILayout.Button(Styles.btnAddComponent)) { var menu = new GenericMenu(); foreach (var type in GetMainComponentTypeNames()) @@ -198,7 +210,7 @@ namespace XCharts.Editor } private void AddSerie() { - if (GUILayout.Button("Add Serie")) + if (GUILayout.Button(Styles.btnAddSerie)) { var menu = new GenericMenu(); foreach (var type in GetSerieTypeNames()) @@ -261,22 +273,22 @@ namespace XCharts.Editor { if (m_Chart.HasChartComponent() && m_Chart.HasChartComponent()) { - if (GUILayout.Button("Covert XY Axis")) + if (GUILayout.Button(Styles.btnCovertXYAxis)) m_Chart.CovertXYAxis(0); } - if (GUILayout.Button("Rebuild Chart Object")) + if (GUILayout.Button(Styles.btnRebuildChartObject)) { m_Chart.RebuildChartObject(); } if (m_CheckWarning) { EditorGUILayout.BeginHorizontal(); - if (GUILayout.Button("Check Warning")) + if (GUILayout.Button(Styles.btnCheckWarning)) { m_CheckWarning = true; m_Chart.CheckWarning(); } - if (GUILayout.Button("Hide Warning")) + if (GUILayout.Button(Styles.btnHideWarning)) { m_CheckWarning = false; } @@ -297,7 +309,7 @@ namespace XCharts.Editor } else { - if (GUILayout.Button("Check warning")) + if (GUILayout.Button(Styles.btnCheckWarning)) { m_CheckWarning = true; m_Chart.CheckWarning(); diff --git a/Editor/ChildComponents/LabelStyleDrawer.cs b/Editor/ChildComponents/LabelStyleDrawer.cs index 68cfc30b..f2724cd2 100644 --- a/Editor/ChildComponents/LabelStyleDrawer.cs +++ b/Editor/ChildComponents/LabelStyleDrawer.cs @@ -18,7 +18,6 @@ namespace XCharts.Editor PropertyField(prop, "m_Position"); PropertyField(prop, "m_Offset"); PropertyField(prop, "m_AutoOffset"); - PropertyField(prop, "m_AutoColor"); PropertyField(prop, "m_Distance"); PropertyField(prop, "m_Formatter"); PropertyField(prop, "m_NumericFormatter"); diff --git a/Editor/ChildComponents/TextStyleDrawer.cs b/Editor/ChildComponents/TextStyleDrawer.cs index 40cff88f..4774a159 100644 --- a/Editor/ChildComponents/TextStyleDrawer.cs +++ b/Editor/ChildComponents/TextStyleDrawer.cs @@ -26,6 +26,7 @@ namespace XCharts.Editor PropertyField(prop, "m_Rotate"); PropertyField(prop, "m_Offset"); PropertyField(prop, "m_ExtraWidth"); + PropertyField(prop, "m_AutoColor"); PropertyField(prop, "m_Color"); PropertyField(prop, "m_AutoBackgroundColor"); PropertyField(prop, "m_BackgroundColor"); diff --git a/Runtime/Component/Background/Background.cs b/Runtime/Component/Background/Background.cs index 1e4f378f..0e3a8425 100644 --- a/Runtime/Component/Background/Background.cs +++ b/Runtime/Component/Background/Background.cs @@ -71,7 +71,7 @@ namespace XCharts.Runtime public override void SetDefaultValue() { - m_Show = false; + m_Show = true; m_Image = null; m_ImageType = Image.Type.Sliced; m_ImageColor = Color.white; diff --git a/Runtime/Component/Background/BackgroundHandler.cs b/Runtime/Component/Background/BackgroundHandler.cs index 0f978de1..cd6402f9 100644 --- a/Runtime/Component/Background/BackgroundHandler.cs +++ b/Runtime/Component/Background/BackgroundHandler.cs @@ -33,32 +33,6 @@ namespace XCharts.Runtime component.refreshComponent(); } - //protected void DrawBackground(VertexHelper vh) - //{ - //TODO: CooridateChart - // if (SeriesHelper.IsAnyClipSerie(m_Series)) - // { - // var xLineDiff = xAxis0.axisLine.GetWidth(m_Theme.axis.lineWidth); - // var yLineDiff = yAxis0.axisLine.GetWidth(m_Theme.axis.lineWidth); - // var xSplitDiff = xAxis0.splitLine.GetWidth(m_Theme.axis.splitLineWidth); - // var ySplitDiff = yAxis0.splitLine.GetWidth(m_Theme.axis.splitLineWidth); - // foreach (var grid in m_Grids) - // { - // var cpty = grid.context.runtimeY + grid.context.runtimeHeight + ySplitDiff; - // var cp1 = new Vector3(grid.context.runtimeX - yLineDiff, grid.context.runtimeY - xLineDiff); - // var cp2 = new Vector3(grid.context.runtimeX - yLineDiff, cpty); - // var cp3 = new Vector3(grid.context.runtimeX + grid.context.runtimeWidth + xSplitDiff, cpty); - // var cp4 = new Vector3(grid.context.runtimeX + grid.context.runtimeWidth + xSplitDiff, grid.context.runtimeY - xLineDiff); - // var backgroundColor = ThemeHelper.GetBackgroundColor(m_Theme, m_Background); - // UGL.DrawQuadrilateral(vh, cp1, cp2, cp3, cp4, backgroundColor); - // } - // } - // else - // { - // base.DrawBackground(vh); - // } - // } - public override void DrawBase(VertexHelper vh) { if (!component.show) diff --git a/Runtime/Component/Child/LabelStyle.cs b/Runtime/Component/Child/LabelStyle.cs index 4482ded1..fb23053a 100644 --- a/Runtime/Component/Child/LabelStyle.cs +++ b/Runtime/Component/Child/LabelStyle.cs @@ -1,6 +1,4 @@ - -using System; -using UnityEngine; +using UnityEngine; namespace XCharts.Runtime { @@ -69,7 +67,6 @@ namespace XCharts.Runtime End } - [SerializeField] private bool m_Show = true; [SerializeField] Position m_Position = Position.Outside; [SerializeField] private Vector3 m_Offset; @@ -81,7 +78,7 @@ namespace XCharts.Runtime [SerializeField] private float m_BackgroundHeight = 0; [SerializeField] private string m_NumericFormatter = ""; [SerializeField] private bool m_AutoOffset = false; - [SerializeField] private bool m_AutoColor = false; + [SerializeField] private TextStyle m_TextStyle = new TextStyle(); private SerieLabelFormatterFunction m_FormatterFunction; @@ -97,7 +94,6 @@ namespace XCharts.Runtime m_BackgroundHeight = 0; m_NumericFormatter = ""; m_AutoOffset = false; - m_AutoColor = false; } /// @@ -211,14 +207,7 @@ namespace XCharts.Runtime get { return m_AutoOffset; } set { if (PropertyUtil.SetStruct(ref m_AutoOffset, value)) SetAllDirty(); } } - /// - /// 是否开启自动颜色。当开启时,会根据已支持的serie自动设置颜色。 - /// - public bool autoColor - { - get { return m_AutoColor; } - set { if (PropertyUtil.SetStruct(ref m_AutoColor, value)) SetAllDirty(); } - } + /// /// the sytle of text. diff --git a/Runtime/Component/Child/TextStyle.cs b/Runtime/Component/Child/TextStyle.cs index 33cbeee7..5d5154e9 100644 --- a/Runtime/Component/Child/TextStyle.cs +++ b/Runtime/Component/Child/TextStyle.cs @@ -20,6 +20,7 @@ namespace XCharts.Runtime [SerializeField] private float m_Rotate = 0; [SerializeField] private float m_ExtraWidth = 0; [SerializeField] private Vector2 m_Offset = Vector2.zero; + [SerializeField] private bool m_AutoColor = false; [SerializeField] private Color m_Color = Color.clear; [SerializeField] private bool m_AutoBackgroundColor = false; [SerializeField] private Color m_BackgroundColor = Color.clear; @@ -61,9 +62,15 @@ namespace XCharts.Runtime get { return m_Offset; } set { if (PropertyUtil.SetStruct(ref m_Offset, value)) SetComponentDirty(); } } - public Vector3 offsetv3 { get { return new Vector3(m_Offset.x, m_Offset.y, 0); } } - + /// + /// 是否开启自动颜色。当开启时,会自动设置颜色。 + /// + public bool autoColor + { + get { return m_AutoColor; } + set { if (PropertyUtil.SetStruct(ref m_AutoColor, value)) SetAllDirty(); } + } /// /// the color of text. /// |文本的颜色。 @@ -207,7 +214,9 @@ namespace XCharts.Runtime font = textStyle.font; rotate = textStyle.rotate; offset = textStyle.offset; + autoColor = textStyle.autoColor; color = textStyle.color; + autoBackgroundColor = textStyle.autoBackgroundColor; backgroundColor = textStyle.backgroundColor; fontSize = textStyle.fontSize; fontStyle = textStyle.fontStyle; @@ -251,5 +260,13 @@ namespace XCharts.Runtime { return m_AutoAlign ? systemAlignment : alignment; } + + public Color32 GetBackgroundColor(Color32 chartBackgroundColor) + { + if (m_AutoColor || ChartHelper.IsClearColor(m_BackgroundColor)) + return chartBackgroundColor; + else + return m_BackgroundColor; + } } } \ No newline at end of file diff --git a/Runtime/Component/Legend/LegendHandler.cs b/Runtime/Component/Legend/LegendHandler.cs index 72ad7dd2..fce7fc36 100644 --- a/Runtime/Component/Legend/LegendHandler.cs +++ b/Runtime/Component/Legend/LegendHandler.cs @@ -198,7 +198,7 @@ namespace XCharts.Runtime UGL.DrawDiamond(vh, rect.center, radius, color); break; case Legend.Type.EmptyCircle: - var backgroundColor = chart.theme.GetBackgroundColor(chart.GetChartComponent()); + var backgroundColor = chart.GetChartBackgroundColor(); UGL.DrawEmptyCricle(vh, rect.center, radius, 2 * chart.settings.legendIconLineWidth, color, color, backgroundColor, 1f); break; diff --git a/Runtime/Component/Mark/MarkLineHandler.cs b/Runtime/Component/Mark/MarkLineHandler.cs index 134b73e4..73f107d8 100644 --- a/Runtime/Component/Mark/MarkLineHandler.cs +++ b/Runtime/Component/Mark/MarkLineHandler.cs @@ -78,12 +78,14 @@ namespace XCharts.Runtime var element = ChartHelper.AddSerieLabel(textName, m_MarkLineLabelRoot.transform, label.backgroundWidth, label.backgroundHeight, color, label.textStyle, chart.theme); var isAutoSize = label.backgroundWidth == 0 || label.backgroundHeight == 0; + var backgroundColor = label.textStyle.GetBackgroundColor(chart.GetChartBackgroundColor()); var item = ChartHelper.GetOrAddComponent(element); item.SetLabel(element, isAutoSize, label.paddingLeftRight, label.paddingTopBottom); item.SetIconActive(false); item.SetActive(data.label.show); item.SetPosition(MarkLineHelper.GetLabelPosition(data)); item.SetText(MarkLineHelper.GetFormatterContent(serie, data)); + item.color = backgroundColor; data.runtimeLabel = item; }; data.refreshComponent(); diff --git a/Runtime/Internal/BaseChart.API.cs b/Runtime/Internal/BaseChart.API.cs index fbe93157..a91a63e5 100644 --- a/Runtime/Internal/BaseChart.API.cs +++ b/Runtime/Internal/BaseChart.API.cs @@ -481,5 +481,11 @@ namespace XCharts.Runtime m_PainterTop.material = material; } } + + public Color32 GetChartBackgroundColor() + { + var background = GetChartComponent(); + return theme.GetBackgroundColor(background); + } } } diff --git a/Runtime/Internal/BaseChart.Draw.cs b/Runtime/Internal/BaseChart.Draw.cs index f47cc636..39fc132b 100644 --- a/Runtime/Internal/BaseChart.Draw.cs +++ b/Runtime/Internal/BaseChart.Draw.cs @@ -112,7 +112,7 @@ namespace XCharts.Runtime Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, Color32 borderColor, float gap, float[] cornerRadius, Vector3 startPos) { - var backgroundColor = theme.GetBackgroundColor(GetChartComponent()); + var backgroundColor = GetChartBackgroundColor(); if (ChartHelper.IsClearColor(emptyColor)) emptyColor = backgroundColor; var smoothness = settings.cicleSmoothness; diff --git a/Runtime/Internal/BaseChart.cs b/Runtime/Internal/BaseChart.cs index 4c627558..7245d879 100644 --- a/Runtime/Internal/BaseChart.cs +++ b/Runtime/Internal/BaseChart.cs @@ -597,7 +597,9 @@ namespace XCharts.Runtime protected virtual void DrawBackground(VertexHelper vh) { - if (HasChartComponent()) return; + var background = GetChartComponent(); + if (background != null && background.show) + return; Vector3 p1 = new Vector3(chartX, chartY + chartHeight); Vector3 p2 = new Vector3(chartX + chartWidth, chartY + chartHeight); Vector3 p3 = new Vector3(chartX + chartWidth, chartY); diff --git a/Runtime/Internal/XChartsMgr.cs b/Runtime/Internal/XChartsMgr.cs index 69484edc..1631fec8 100644 --- a/Runtime/Internal/XChartsMgr.cs +++ b/Runtime/Internal/XChartsMgr.cs @@ -86,6 +86,33 @@ namespace XCharts.Runtime return chartList.Contains(chart); } + public static bool IsRepeatChartName(BaseChart chart, string chartName = null) + { + if (chartName == null) + chartName = chart.chartName; + if (string.IsNullOrEmpty(chartName)) + return false; + foreach (var temp in chartList) + { + if (temp != chart && chartName.Equals(temp.chartName)) + return true; + } + return false; + } + + public static string GetRepeatChartNameInfo(BaseChart chart, string chartName) + { + if (string.IsNullOrEmpty(chartName)) + return string.Empty; + string result = ""; + foreach (var temp in chartList) + { + if (temp != chart && chartName.Equals(temp.chartName)) + result += ChartHelper.GetFullName(temp.transform) + "\n"; + } + return result; + } + public static void RemoveAllChartObject() { if (chartList.Count == 0) diff --git a/Runtime/Serie/Ring/Ring.cs b/Runtime/Serie/Ring/Ring.cs index 326fbd72..c1267827 100644 --- a/Runtime/Serie/Ring/Ring.cs +++ b/Runtime/Serie/Ring/Ring.cs @@ -16,15 +16,16 @@ namespace XCharts.Runtime serie.gap = 10; serie.radius = new float[] { 0.3f, 0.35f }; - serie.AddExtraComponent(); - serie.label.show = true; - serie.label.position = LabelStyle.Position.Center; - serie.label.formatter = "{d:f0}%"; - serie.label.textStyle.fontSize = 28; + var label = serie.AddExtraComponent(); + label.show = true; + label.position = LabelStyle.Position.Center; + label.formatter = "{d:f0}%"; + label.textStyle.autoColor = true; + label.textStyle.fontSize = 28; - serie.AddExtraComponent(); - serie.titleStyle.show = false; - serie.titleStyle.textStyle.offset = new Vector2(0, 30); + var titleStyle = serie.AddExtraComponent(); + titleStyle.show = false; + titleStyle.textStyle.offset = new Vector2(0, 30); var value = Random.Range(30, 90); var max = 100; diff --git a/Runtime/Serie/Ring/RingHandler.cs b/Runtime/Serie/Ring/RingHandler.cs index c99ca773..b798cd30 100644 --- a/Runtime/Serie/Ring/RingHandler.cs +++ b/Runtime/Serie/Ring/RingHandler.cs @@ -109,6 +109,33 @@ namespace XCharts.Runtime paramList.Add(param); } + public override Vector3 GetSerieDataLabelPosition(SerieData serieData, LabelStyle label) + { + var centerRadius = (serieData.context.outsideRadius + serieData.context.insideRadius) / 2; + var startAngle = serieData.context.startAngle; + var toAngle = serieData.context.toAngle; + switch (label.position) + { + case LabelStyle.Position.Center: + serieData.context.labelPosition = serie.context.center + label.offset; + break; + case LabelStyle.Position.Bottom: + var px1 = Mathf.Sin(startAngle * Mathf.Deg2Rad) * centerRadius; + var py1 = Mathf.Cos(startAngle * Mathf.Deg2Rad) * centerRadius; + var xDiff = serie.clockwise ? -label.distance : label.distance; + serieData.context.labelPosition = serie.context.center + new Vector3(px1 + xDiff, py1); + break; + case LabelStyle.Position.Top: + startAngle += serie.clockwise ? -label.distance : label.distance; + toAngle += serie.clockwise ? label.distance : -label.distance; + var px2 = Mathf.Sin(toAngle * Mathf.Deg2Rad) * centerRadius; + var py2 = Mathf.Cos(toAngle * Mathf.Deg2Rad) * centerRadius; + serieData.context.labelPosition = serie.context.center + new Vector3(px2, py2); + break; + } + return serieData.context.labelPosition; + } + public override void DrawSerie(VertexHelper vh) { if (!serie.show || serie.animation.HasFadeOut()) return; @@ -134,7 +161,6 @@ namespace XCharts.Runtime var itemToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, j, serieData.context.highlight); var outsideRadius = serie.context.outsideRadius - j * (ringWidth + serie.gap); var insideRadius = outsideRadius - ringWidth; - var centerRadius = (outsideRadius + insideRadius) / 2; var borderWidth = itemStyle.borderWidth; var borderColor = itemStyle.borderColor; var roundCap = serie.roundCap && insideRadius > 0; @@ -153,7 +179,6 @@ namespace XCharts.Runtime Color.clear, startDegree, toDegree, borderWidth, borderColor, 0, chart.settings.cicleSmoothness, roundCap, serie.clockwise); DrawCenter(vh, serie, serieData, insideRadius, j == data.Count - 1); - UpateLabelPosition(serie, serieData, j, startDegree, toDegree, centerRadius); } if (!serie.animation.IsFinish()) { @@ -233,34 +258,6 @@ namespace XCharts.Runtime } } - private void UpateLabelPosition(Serie serie, SerieData serieData, int index, float startAngle, - float toAngle, float centerRadius) - { - var label = serie.label; - if (label == null || !label.show) return; - if (serieData.labelObject == null) return; - switch (label.position) - { - case LabelStyle.Position.Center: - serieData.context.labelPosition = serie.context.center + label.offset; - break; - case LabelStyle.Position.Bottom: - var px1 = Mathf.Sin(startAngle * Mathf.Deg2Rad) * centerRadius; - var py1 = Mathf.Cos(startAngle * Mathf.Deg2Rad) * centerRadius; - var xDiff = serie.clockwise ? -label.distance : label.distance; - serieData.context.labelPosition = serie.context.center + new Vector3(px1 + xDiff, py1); - break; - case LabelStyle.Position.Top: - startAngle += serie.clockwise ? -label.distance : label.distance; - toAngle += serie.clockwise ? label.distance : -label.distance; - var px2 = Mathf.Sin(toAngle * Mathf.Deg2Rad) * centerRadius; - var py2 = Mathf.Cos(toAngle * Mathf.Deg2Rad) * centerRadius; - serieData.context.labelPosition = serie.context.center + new Vector3(px2, py2); - break; - } - serieData.labelObject.SetLabelPosition(serieData.context.labelPosition); - } - private void DrawBackground(VertexHelper vh, Serie serie, SerieData serieData, int index, float insideRadius, float outsideRadius) { var itemStyle = SerieHelper.GetItemStyle(serie, serieData); @@ -294,23 +291,6 @@ namespace XCharts.Runtime } } - - private void DrawRoundCap(VertexHelper vh, Serie serie, Vector3 centerPos, Color color, - float insideRadius, float outsideRadius, ref float drawStartDegree, ref float drawEndDegree) - { - if (serie.roundCap && insideRadius > 0 && drawStartDegree != drawEndDegree) - { - var width = (outsideRadius - insideRadius) / 2; - var radius = insideRadius + width; - - var diffDegree = Mathf.Asin(width / radius) * Mathf.Rad2Deg; - drawStartDegree += serie.clockwise ? diffDegree : -diffDegree; - drawEndDegree -= serie.clockwise ? diffDegree : -diffDegree; - UGL.DrawRoundCap(vh, centerPos, width, radius, drawStartDegree, serie.clockwise, color, false); - UGL.DrawRoundCap(vh, centerPos, width, radius, drawEndDegree, serie.clockwise, color, true); - } - } - private int GetRingIndex(Vector2 local) { var dist = Vector2.Distance(local, serie.context.center); diff --git a/Runtime/Serie/SerieHandler.cs b/Runtime/Serie/SerieHandler.cs index 198157de..4a3c4702 100644 --- a/Runtime/Serie/SerieHandler.cs +++ b/Runtime/Serie/SerieHandler.cs @@ -233,8 +233,10 @@ namespace XCharts.Runtime && (iconStyle == null || !iconStyle.show)) return false; + var dataAutoColor = (Color)chart.theme.GetColor(serieData.index); + var textName = ChartCached.GetSerieLabelName(s_SerieLabelObjectName, serie.index, serieData.index); - var color = chart.theme.common.textColor; + var color = serieLabel.textStyle.autoColor ? dataAutoColor : chart.theme.common.textColor; var iconWidth = iconStyle != null ? iconStyle.width : 20; var iconHeight = iconStyle != null ? iconStyle.height : 20; var labelObj = SerieLabelPool.Get(textName, serieLabelRoot.transform, serieLabel, color, @@ -246,7 +248,7 @@ namespace XCharts.Runtime item.SetIcon(iconImage); item.SetIconActive(iconStyle != null && iconStyle.show); if (serieLabel.textStyle.autoBackgroundColor) - item.color = chart.theme.GetColor(serieData.index); + item.color = dataAutoColor; else item.color = serieLabel.textStyle.backgroundColor; serieData.labelObject = item; @@ -317,7 +319,6 @@ namespace XCharts.Runtime var iconStyle = SerieHelper.GetIconStyle(serie, serieData); var isIgnore = serie.IsIgnoreIndex(serieData.index, defaultDimension); var currLabel = isHighlight && emphasisLabel != null ? emphasisLabel : serieLabel; - serieData.labelObject.UpdateIcon(iconStyle); if (serie.show && currLabel != null @@ -339,6 +340,8 @@ namespace XCharts.Runtime textColor = currLabel.textStyle.color; else if (isInsidePosition) textColor = Color.white; + if (currLabel.textStyle.autoColor && serie.useDataNameForColor) + textColor = chart.theme.GetColor(serieData.index); //text rotate var rotate = currLabel.textStyle.rotate; if (currLabel.textStyle.rotate > 0 && isInsidePosition) diff --git a/Runtime/Theme/ThemeStyle.cs b/Runtime/Theme/ThemeStyle.cs index 74d30b5b..0b8dce84 100644 --- a/Runtime/Theme/ThemeStyle.cs +++ b/Runtime/Theme/ThemeStyle.cs @@ -138,7 +138,7 @@ namespace XCharts.Runtime public Color32 GetBackgroundColor(Background background) { if (background != null && background.show && background.hideThemeBackgroundColor) - return ChartConst.clearColor32; + return background.imageColor; else return backgroundColor; }