mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-21 16:00:24 +00:00
增加Legend的itemInactiveOpacity可设置非激活状态时的颜色透明度 (#343)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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`: 平均值。
|
||||
|
||||
@@ -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`设置层级
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace XCharts.Editor
|
||||
protected override void DrawExtendeds(SerializedProperty prop)
|
||||
{
|
||||
base.DrawExtendeds(prop);
|
||||
PropertyField(prop, "m_UnableColor");
|
||||
PropertyField(prop, "m_InactiveColor");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the opacity of item color when item is inactive.
|
||||
/// ||图例标记的图形在非激活状态下的颜色透明度。
|
||||
/// </summary>
|
||||
public float itemInactiveOpacity
|
||||
{
|
||||
get { return m_ItemInactiveOpacity; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ItemInactiveOpacity, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// No longer used, the use of LabelStyle.formatter instead.
|
||||
/// ||不再使用,使用LabelStyle.formatter代替。
|
||||
/// </summary>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// the color of text.
|
||||
/// ||文本颜色。
|
||||
/// </summary>
|
||||
[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(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color when the component is inactive.
|
||||
/// ||非激活状态时的颜色。
|
||||
/// </summary>
|
||||
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");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user