修复Pie在设置ItemStyleopacity时颜色不对的问题 (#309)

This commit is contained in:
monitor1394
2024-03-19 22:33:19 +08:00
parent 0990b11c1c
commit 4b8374b1ae
2 changed files with 13 additions and 8 deletions

View File

@@ -74,6 +74,7 @@ slug: /changelog
## master
* (2024.03.20) 增加`Tooltip``triggerOn`设置触发条件
* (2024.03.19) 修复`Pie`在设置`ItemStyle``opacity`时颜色不对的问题 (#309)
## v3.10.2

View File

@@ -320,7 +320,7 @@ namespace XCharts.Runtime
{
var style = GetItemStyle(serie, serieData, SerieState.Normal);
GetColor(ref color, style.color, style.color, style.opacity, theme, index, opacity);
GetColor(ref toColor, style.toColor, color, style.opacity, theme, index, opacity);
GetColor(ref toColor, style.toColor, color, style.opacity, theme, index, opacity, true);
switch (state)
{
case SerieState.Emphasis:
@@ -342,7 +342,7 @@ namespace XCharts.Runtime
else
{
GetColor(ref color, stateStyle.itemStyle.color, stateStyle.itemStyle.color, stateStyle.itemStyle.opacity, theme, index, opacity);
GetColor(ref toColor, stateStyle.itemStyle.toColor, color, stateStyle.itemStyle.opacity, theme, index, opacity);
GetColor(ref toColor, stateStyle.itemStyle.toColor, color, stateStyle.itemStyle.opacity, theme, index, opacity, true);
}
}
@@ -359,7 +359,7 @@ namespace XCharts.Runtime
{
var style = GetItemStyle(serie, serieData, SerieState.Normal);
GetColor(ref color, style.color, style.color, style.opacity, theme, index, opacity);
GetColor(ref toColor, style.toColor, color, style.opacity, theme, index, opacity);
GetColor(ref toColor, style.toColor, color, style.opacity, theme, index, opacity, true);
backgroundColor = style.backgroundColor;
switch (state)
{
@@ -383,7 +383,7 @@ namespace XCharts.Runtime
{
backgroundColor = stateStyle.itemStyle.backgroundColor;
GetColor(ref color, stateStyle.itemStyle.color, stateStyle.itemStyle.color, stateStyle.itemStyle.opacity, theme, index, opacity);
GetColor(ref toColor, stateStyle.itemStyle.toColor, color, stateStyle.itemStyle.opacity, theme, index, opacity);
GetColor(ref toColor, stateStyle.itemStyle.toColor, color, stateStyle.itemStyle.opacity, theme, index, opacity, true);
}
}
@@ -580,7 +580,7 @@ namespace XCharts.Runtime
innerFill = areaStyle.innerFill;
toTop = areaStyle.toTop;
GetColor(ref color, areaStyle.color, serie.itemStyle.color, areaStyle.opacity, theme, index);
GetColor(ref toColor, areaStyle.toColor, color, areaStyle.opacity, theme, index);
GetColor(ref toColor, areaStyle.toColor, color, areaStyle.opacity, theme, index, true);
switch (state)
{
case SerieState.Emphasis:
@@ -606,7 +606,7 @@ namespace XCharts.Runtime
innerFill = stateStyle.areaStyle.innerFill;
toTop = stateStyle.areaStyle.toTop;
GetColor(ref color, stateStyle.areaStyle.color, stateStyle.itemStyle.color, stateStyle.areaStyle.opacity, theme, index);
GetColor(ref toColor, stateStyle.areaStyle.toColor, color, stateStyle.areaStyle.opacity, theme, index);
GetColor(ref toColor, stateStyle.areaStyle.toColor, color, stateStyle.areaStyle.opacity, theme, index, true, true);
}
else
{
@@ -646,10 +646,14 @@ namespace XCharts.Runtime
}
public static void GetColor(ref Color32 color, Color32 checkColor, Color32 itemColor,
float opacity, ThemeStyle theme, int colorIndex, bool setOpacity = true)
float opacity, ThemeStyle theme, int colorIndex, bool setOpacity = true, bool resetOpacity = false)
{
if (!ChartHelper.IsClearColor(checkColor)) color = checkColor;
else if (!ChartHelper.IsClearColor(itemColor)) color = itemColor;
else if (!ChartHelper.IsClearColor(itemColor))
{
color = itemColor;
if (resetOpacity) opacity = 1;
}
if (ChartHelper.IsClearColor(color) && colorIndex >= 0) color = theme.GetColor(colorIndex);
if (setOpacity) ChartHelper.SetColorOpacity(ref color, opacity);
}