diff --git a/Documentation~/en/api.md b/Documentation~/en/api.md index db32d020..c4b3aec8 100644 --- a/Documentation~/en/api.md +++ b/Documentation~/en/api.md @@ -808,6 +808,14 @@ class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent) / Subc The axis in rectangular coordinate. +### Axis.onLabelClick + +public Action<int, string> onLabelClick + +> Since `v3.15.0` + +Callback function when click on the label. Parameters: labelIndex, labelName. + ### Axis.AddData public void AddData(string category) @@ -1078,6 +1086,14 @@ class in XCharts / Inherits from: [MainComponentHandler](#maincomponenthandler) public T component +### AxisHandler<T>.DrawTop + +// public override void DrawTop(VertexHelper vh) + +### AxisHandler<T>.OnPointerClick + +public override void OnPointerClick(PointerEventData eventData) + ## AxisHelper class in XCharts.Runtime @@ -3197,6 +3213,10 @@ public float GetTextWidth() public float GetWidth() +### ChartLabel.InRect + +public bool InRect(Vector2 local) + ### ChartLabel.IsActiveByScale public bool IsActiveByScale() @@ -5824,15 +5844,15 @@ public double runtimeValue class in XCharts.Runtime -标线类型 +Mark line type. Options: -- `None`: 标线类型 -- `Min`: 最小值。 -- `Max`: 最大值。 -- `Average`: 平均值。 -- `Median`: 中位数。 +- `Custom`: Custom. You can customize the xy coordinates or values. +- `Min`: Minimum value. +- `Max`: Maximum value. +- `Average`: Average value. +- `Median`: Median. ## MarqueeStyle diff --git a/Documentation~/en/configuration.md b/Documentation~/en/configuration.md index 9a04162c..a0dabd95 100644 --- a/Documentation~/en/configuration.md +++ b/Documentation~/en/configuration.md @@ -2661,6 +2661,12 @@ The distance between each legend, horizontal distance in horizontal layout, and Image height of legend symbol. +### Legend.itemInactiveOpacity + +`float` `1` `v3.15.0` + +the opacity of item color when item is inactive. + ### Legend.itemOpacity `float` `1` @@ -2736,11 +2742,11 @@ the limit of text. class in XCharts.Runtime / Inherits from: [ComponentTheme](#componenttheme) -### LegendTheme.unableColor +### LegendTheme.inactiveColor `Color` -the color of text. +the color when the component is inactive. ## Level @@ -3156,11 +3162,11 @@ Special label types, are used to label maximum value, minimum value and so on. Options: -- `None`: 标线类型 -- `Min`: 最小值。 -- `Max`: 最大值。 -- `Average`: 平均值。 -- `Median`: 中位数。 +- `Custom`: Custom. You can customize the xy coordinates or values. +- `Min`: Minimum value. +- `Max`: Maximum value. +- `Average`: Average value. +- `Median`: Median. ### MarkLineData.xPosition diff --git a/Documentation~/zh/api.md b/Documentation~/zh/api.md index d6d7854b..2893626f 100644 --- a/Documentation~/zh/api.md +++ b/Documentation~/zh/api.md @@ -808,6 +808,14 @@ class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent) / 子类: 直角坐标系的坐标轴组件。 +### Axis.onLabelClick + +public Action<int, string> onLabelClick + +> 从 `v3.15.0` 开始支持 + +点击文本标签回调函数。参数:labelIndex, labelName。 + ### Axis.AddData public void AddData(string category) @@ -1078,6 +1086,14 @@ class in XCharts / 继承自: [MainComponentHandler](#maincomponenthandler) public T component +### AxisHandler<T>.DrawTop + +// public override void DrawTop(VertexHelper vh) + +### AxisHandler<T>.OnPointerClick + +public override void OnPointerClick(PointerEventData eventData) + ## AxisHelper class in XCharts.Runtime @@ -3197,6 +3213,10 @@ public float GetTextWidth() public float GetWidth() +### ChartLabel.InRect + +public bool InRect(Vector2 local) + ### ChartLabel.IsActiveByScale public bool IsActiveByScale() @@ -5828,7 +5848,7 @@ class in XCharts.Runtime 可选: -- `None`: 标线类型 +- `Custom`: 自定义。可自定义xy坐标或数值。 - `Min`: 最小值。 - `Max`: 最大值。 - `Average`: 平均值。 diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index c84e891d..de99462e 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -80,6 +80,7 @@ slug: /changelog ## master +* (2025.03.27) 增加`Legend`的`itemInactiveOpacity`可设置非激活状态时的颜色透明度 (#343) * (2025.03.27) 增加`Axis`的`onLabelClick`回调事件 * (2025.03.26) 增加`Animation`的`Exchange`排序交换动画 * (2025.03.22) 增加`Comment`的`layer`设置层级 diff --git a/Documentation~/zh/configuration.md b/Documentation~/zh/configuration.md index 1a3f7d9e..dc8093de 100644 --- a/Documentation~/zh/configuration.md +++ b/Documentation~/zh/configuration.md @@ -2661,6 +2661,12 @@ class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent), [IPropert 图例标记的图形高度。 +### Legend.itemInactiveOpacity + +`float` `1` `v3.15.0` + +图例标记的图形在非激活状态下的颜色透明度。 + ### Legend.itemOpacity `float` `1` @@ -2736,11 +2742,11 @@ class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent), [IPropert class in XCharts.Runtime / 继承自: [ComponentTheme](#componenttheme) -### LegendTheme.unableColor +### LegendTheme.inactiveColor `Color` -文本颜色。 +非激活状态时的颜色。 ## Level @@ -3156,7 +3162,7 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent) 可选: -- `None`: 标线类型 +- `Custom`: 自定义。可自定义xy坐标或数值。 - `Min`: 最小值。 - `Max`: 最大值。 - `Average`: 平均值。 @@ -3166,25 +3172,25 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent) `float` -相对原点的 x 坐标,单位像素。当type为None时有效。 +相对原点的 x 坐标,单位像素。当type为Custom时有效。 ### MarkLineData.xValue `double` -X轴上的指定值。当X轴为类目轴时指定值表示类目轴数据的索引,否则为具体的值。当type为None时有效。 +X轴上的指定值。当X轴为类目轴时指定值表示类目轴数据的索引,否则为具体的值。当type为Custom时有效。 ### MarkLineData.yPosition `float` -相对原点的 y 坐标,单位像素。当type为None时有效。 +相对原点的 y 坐标,单位像素。当type为Custom时有效。 ### MarkLineData.yValue `double` -Y轴上的指定值。当Y轴为类目轴时指定值表示类目轴数据的索引,否则为具体的值。当type为None时有效。 +Y轴上的指定值。当Y轴为类目轴时指定值表示类目轴数据的索引,否则为具体的值。当type为Custom时有效。 ### MarkLineData.zeroPosition diff --git a/Editor/ChildComponents/ComponentThemeDrawer.cs b/Editor/ChildComponents/ComponentThemeDrawer.cs index 128f0f9e..61410ab4 100644 --- a/Editor/ChildComponents/ComponentThemeDrawer.cs +++ b/Editor/ChildComponents/ComponentThemeDrawer.cs @@ -102,7 +102,7 @@ namespace XCharts.Editor protected override void DrawExtendeds(SerializedProperty prop) { base.DrawExtendeds(prop); - PropertyField(prop, "m_UnableColor"); + PropertyField(prop, "m_InactiveColor"); } } diff --git a/Editor/MainComponents/LegendEditor.cs b/Editor/MainComponents/LegendEditor.cs index e65bad00..dc3d25f2 100644 --- a/Editor/MainComponents/LegendEditor.cs +++ b/Editor/MainComponents/LegendEditor.cs @@ -15,6 +15,7 @@ namespace XCharts.Editor PropertyField("m_ItemGap"); PropertyField("m_ItemAutoColor"); PropertyField("m_ItemOpacity"); + PropertyField("m_ItemInactiveOpacity"); PropertyField("m_SelectedMode"); PropertyField("m_Orient"); PropertyField("m_Location"); diff --git a/Runtime/Component/Legend/Legend.cs b/Runtime/Component/Legend/Legend.cs index 5e34113a..3b55f8eb 100644 --- a/Runtime/Component/Legend/Legend.cs +++ b/Runtime/Component/Legend/Legend.cs @@ -79,6 +79,7 @@ namespace XCharts.Runtime [SerializeField] private float m_ItemGap = 10f; [SerializeField] private bool m_ItemAutoColor = true; [SerializeField] private float m_ItemOpacity = 1; + [SerializeField][Since("v3.15.0")] private float m_ItemInactiveOpacity = 1; [SerializeField] private string m_Formatter; [SerializeField] private LabelStyle m_LabelStyle = new LabelStyle(); [SerializeField][Since("v3.10.0")] private TextLimit m_TextLimit = new TextLimit(); @@ -182,6 +183,15 @@ namespace XCharts.Runtime set { if (PropertyUtil.SetStruct(ref m_ItemOpacity, value)) SetComponentDirty(); } } /// + /// the opacity of item color when item is inactive. + /// ||图例标记的图形在非激活状态下的颜色透明度。 + /// + public float itemInactiveOpacity + { + get { return m_ItemInactiveOpacity; } + set { if (PropertyUtil.SetStruct(ref m_ItemInactiveOpacity, value)) SetComponentDirty(); } + } + /// /// No longer used, the use of LabelStyle.formatter instead. /// ||不再使用,使用LabelStyle.formatter代替。 /// diff --git a/Runtime/Component/Legend/LegendHandler.cs b/Runtime/Component/Legend/LegendHandler.cs index f098c929..d21804b3 100644 --- a/Runtime/Component/Legend/LegendHandler.cs +++ b/Runtime/Component/Legend/LegendHandler.cs @@ -92,15 +92,15 @@ namespace XCharts.Runtime { if (!SeriesHelper.IsLegalLegendName(datas[i])) continue; string legendName = datas[i]; - var serieIndex = isAnySerieColorByData ? 0 : i; - var dataIndex = isAnySerieColorByData ? i : 0; + var serieIndex = isAnySerieColorByData ? 0 : i; + var dataIndex = isAnySerieColorByData ? i : 0; var legendContent = GetFormatterContent(legend, dataIndex, datas[i], serieIndex); if (legend.textLimit.enable) legendContent = legend.textLimit.GetLimitContent(legendContent); var readIndex = chart.m_LegendRealShowName.IndexOf(datas[i]); var active = chart.IsActiveByLegend(datas[i]); var bgColor = LegendHelper.GetIconColor(chart, legend, readIndex, datas[i], active); - bgColor.a = legend.itemOpacity; + bgColor.a = active ? legend.itemOpacity : legend.itemInactiveOpacity; var item = LegendHelper.AddLegendItem(chart, legend, i, legendName, legendObject.transform, chart.theme, legendContent, bgColor, active, readIndex); legend.SetButton(legendName, item, totalLegend); diff --git a/Runtime/Component/Legend/LegendHelper.cs b/Runtime/Component/Legend/LegendHelper.cs index ffc55f36..f5293a32 100644 --- a/Runtime/Component/Legend/LegendHelper.cs +++ b/Runtime/Component/Legend/LegendHelper.cs @@ -16,7 +16,7 @@ namespace XCharts.Runtime else return !ChartHelper.IsClearColor(textStyle.color) ? textStyle.color : theme.legend.textColor; } - else return theme.legend.unableColor; + else return theme.legend.inactiveColor; } public static Color GetIconColor(BaseChart chart, Legend legend, int readIndex, string legendName, bool active) @@ -30,7 +30,7 @@ namespace XCharts.Runtime else return legend.GetColor(readIndex); } - else return chart.theme.legend.unableColor; + else return chart.theme.legend.inactiveColor; } public static LegendItem AddLegendItem(BaseChart chart, Legend legend, int i, string legendName, Transform parent, diff --git a/Runtime/Serie/Pie/PieHandler.cs b/Runtime/Serie/Pie/PieHandler.cs index 66b3f6ed..ba3a6400 100644 --- a/Runtime/Serie/Pie/PieHandler.cs +++ b/Runtime/Serie/Pie/PieHandler.cs @@ -358,7 +358,7 @@ namespace XCharts.Runtime { var itemStyle = SerieHelper.GetItemStyle(serie, null); var fillColor = ChartHelper.IsClearColor(itemStyle.backgroundColor) ? - (Color32)chart.theme.legend.unableColor : itemStyle.backgroundColor; + (Color32)chart.theme.legend.inactiveColor : itemStyle.backgroundColor; UGL.DrawDoughnut(vh, serie.context.center, serie.context.insideRadius, serie.context.outsideRadius, fillColor, fillColor, Color.clear, 0, 360, itemStyle.borderWidth, itemStyle.borderColor, serie.gap / 2, chart.settings.cicleSmoothness, diff --git a/Runtime/Theme/LegendTheme.cs b/Runtime/Theme/LegendTheme.cs index 044c77d5..9cd33d6d 100644 --- a/Runtime/Theme/LegendTheme.cs +++ b/Runtime/Theme/LegendTheme.cs @@ -1,5 +1,6 @@ using System; using UnityEngine; +using UnityEngine.Serialization; #if dUI_TextMeshPro using TMPro; #endif @@ -9,27 +10,37 @@ namespace XCharts.Runtime [Serializable] public class LegendTheme : ComponentTheme { - [SerializeField] protected Color m_UnableColor; + [SerializeField][FormerlySerializedAs("m_UnableColor")] protected Color m_InactiveColor; /// /// the color of text. /// ||文本颜色。 /// + [Obsolete("Use inactiveColor instead.", true)] public Color unableColor { - get { return m_UnableColor; } - set { if (PropertyUtil.SetColor(ref m_UnableColor, value)) SetComponentDirty(); } + get { return m_InactiveColor; } + set { if (PropertyUtil.SetColor(ref m_InactiveColor, value)) SetComponentDirty(); } + } + /// + /// the color when the component is inactive. + /// ||非激活状态时的颜色。 + /// + public Color inactiveColor + { + get { return m_InactiveColor; } + set { if (PropertyUtil.SetColor(ref m_InactiveColor, value)) SetComponentDirty(); } } public void Copy(LegendTheme theme) { base.Copy(theme); - m_UnableColor = theme.unableColor; + m_InactiveColor = theme.inactiveColor; } public LegendTheme(ThemeType theme) : base(theme) { - m_UnableColor = ColorUtil.GetColor("#cccccc"); + m_InactiveColor = ColorUtil.GetColor("#cccccc"); } }