Skip to content

Commit

Permalink
修复Pie在设置ItemStyleopacity时颜色不对的问题 (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
monitor1394 committed Mar 19, 2024
1 parent fe867d1 commit 78a07aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Documentation~/zh/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ slug: /changelog

## master

* (2024.03.19) 修复`Pie`在设置`ItemStyle``opacity`时颜色不对的问题 (#309)

## v3.10.2

* (2024.03.11) 发布`v3.10.2`版本
Expand Down
20 changes: 12 additions & 8 deletions Runtime/Serie/SerieHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public static void GetItemColor(out Color32 color, out Color32 toColor,
{
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:
Expand All @@ -342,7 +342,7 @@ public static void GetItemColor(out Color32 color, out Color32 toColor,
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);
}
}

Expand All @@ -359,7 +359,7 @@ public static void GetItemColor(out Color32 color, out Color32 toColor, out Colo
{
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)
{
Expand All @@ -383,7 +383,7 @@ public static void GetItemColor(out Color32 color, out Color32 toColor, out Colo
{
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);
}
}

Expand Down Expand Up @@ -580,7 +580,7 @@ public static bool GetAreaColor(out Color32 color, out Color32 toColor, out bool
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:
Expand All @@ -606,7 +606,7 @@ public static bool GetAreaColor(out Color32 color, out Color32 toColor, out bool
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
{
Expand Down Expand Up @@ -646,10 +646,14 @@ public static Color32 GetLineColor(Serie serie, SerieData serieData, ThemeStyle
}

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);
}
Expand Down

0 comments on commit 78a07aa

Please sign in to comment.