diff --git a/CHANGELOG.md b/CHANGELOG.md index d2e2ad00..d2153382 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,10 @@ ## master +* (2022.07.24) 增加`Serie`和`SerieData`的`state`设置默认状态 +* (2022.07.22) 增加`Serie`的三种状态`EmphasisStyle`,`BlurStyle`,`SelectStyle` +* (2022.07.22) 去掉`AreaStyle`的`m_HighlightColor`和`m_HighlightToColor`配置 +* (2022.07.22) 去掉`Emphasis`,`EmphasisItemStyle`,`EmphasisLabelStyle`,`EmphasisLabelLine`组件 * (2022.07.20) 文档支持用`Since`标识类从哪个版本开始支持 * (2022.07.20) 修复`Axis`在`Value`轴时,`AxisLabel`的`showStartLabel`和`showEndLabel`参数设置不生效的问题 * (2022.07.19) 增加`Axis`的`MinorSplitLine`设置坐标轴次分割线 diff --git a/Documentation/XChartsAPI-EN.md b/Documentation/XChartsAPI-EN.md index ea59ea32..3db0e1bb 100644 --- a/Documentation/XChartsAPI-EN.md +++ b/Documentation/XChartsAPI-EN.md @@ -190,8 +190,9 @@ Inherits or Implemented: [BaseGraph](#BaseGraph),[ISerializationCallbackReceiver | `GetDataZoomOfSerie()` |public void GetDataZoomOfSerie(Serie serie, out DataZoom xDataZoom, out DataZoom yDataZoom)
| | `GetGrid()` |public GridCoord GetGrid(Vector2 local)
| | `GetGridOfDataZoom()` |public GridCoord GetGridOfDataZoom(DataZoom dataZoom)
| -| `GetItemColor()` |public Color32 GetItemColor(Serie serie, bool highlight = false)
| -| `GetItemColor()` |public Color32 GetItemColor(Serie serie, SerieData serieData, bool highlight = false)
| +| `GetItemColor()` |public Color32 GetItemColor(Serie serie)
| +| `GetItemColor()` |public Color32 GetItemColor(Serie serie, SerieData serieData)
| +| `GetItemColor()` |public Color32 GetItemColor(Serie serie, SerieData serieData, int colorIndex)
| | `GetLegendRealShowNameColor()` |public Color32 GetLegendRealShowNameColor(string name)
| | `GetLegendRealShowNameIndex()` |public int GetLegendRealShowNameIndex(string name)
| | `GetPainter()` |public Painter GetPainter(int index)
| @@ -340,6 +341,7 @@ Inherits or Implemented: [BaseChart](#BaseChart) | `DestroyAllChildren()` |public static void DestroyAllChildren(Transform parent)
| | `GetActualValue()` |public static float GetActualValue(float valueOrRate, float total, float maxRate = 1.5f)
| | `GetAngle360()` |public static float GetAngle360(Vector2 from, Vector2 to)
获得0-360的角度(12点钟方向为0度) | +| `GetBlurColor()` |public static Color32 GetBlurColor(Color32 color, float a = 0.3f)
| | `GetColor()` |public static Color32 GetColor(string hexColorStr)
| | `GetDire()` |public static Vector3 GetDire(float angle, bool isDegree = false)
| | `GetFloatAccuracy()` |public static int GetFloatAccuracy(double value)
| @@ -353,6 +355,7 @@ Inherits or Implemented: [BaseChart](#BaseChart) | `GetPointList()` |public static void GetPointList(ref List posList, Vector3 sp, Vector3 ep, float k = 30f)
| | `GetPos()` |public static Vector3 GetPos(Vector3 center, float radius, float angle, bool isDegree = false)
| | `GetPosition()` |public static Vector3 GetPosition(Vector3 center, float angle, float radius)
| +| `GetSelectColor()` |public static Color32 GetSelectColor(Color32 color, float rate = 0.7f)
| | `GetVertialDire()` |public static Vector3 GetVertialDire(Vector3 dire)
| | `HideAllObject()` |public static void HideAllObject(GameObject obj, string match = null)
| | `HideAllObject()` |public static void HideAllObject(Transform parent, string match = null)
| @@ -828,18 +831,15 @@ Inherits or Implemented: [Attribute](#Attribute) |--|--| | `CopySerie()` |public static void CopySerie(Serie oldSerie, Serie newSerie)
| | `GetAllMinMaxData()` |public static void GetAllMinMaxData(Serie serie, double ceilRate = 0, DataZoom dataZoom = null)
| -| `GetAreaColor()` |public static Color32 GetAreaColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight)
| | `GetAreaStyle()` |public static AreaStyle GetAreaStyle(Serie serie, SerieData serieData)
| -| `GetAreaToColor()` |public static Color32 GetAreaToColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight)
| | `GetAverageData()` |public static double GetAverageData(Serie serie, int dimension = 1, DataZoom dataZoom = null)
| -| `GetItemColor()` |public static Color32 GetItemColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight, bool opacity = true)
| -| `GetItemColor0()` |public static Color32 GetItemColor0(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight, Color32 defaultColor)
| +| `GetBlurStyle()` |public static BlurStyle GetBlurStyle(Serie serie, SerieData serieData)
| +| `GetEmphasisStyle()` |public static EmphasisStyle GetEmphasisStyle(Serie serie, SerieData serieData)
| +| `GetItemColor()` |public static Color32 GetItemColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, SerieState state = SerieState.Auto, bool opacity = true)
| | `GetItemFormatter()` |public static string GetItemFormatter(Serie serie, SerieData serieData, string defaultFormatter = null)
| | `GetItemMarker()` |public static string GetItemMarker(Serie serie, SerieData serieData, string defaultMarker = null)
| -| `GetItemStyle()` |public static ItemStyle GetItemStyle(Serie serie, SerieData serieData, bool highlight = false)
| -| `GetItemStyleEmphasis()` |public static ItemStyle GetItemStyleEmphasis(Serie serie, SerieData serieData)
| -| `GetItemToColor()` |public static Color32 GetItemToColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight, bool opacity = true)
| -| `GetLineColor()` |public static Color32 GetLineColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight)
| +| `GetItemStyle()` |public static ItemStyle GetItemStyle(Serie serie, SerieData serieData, SerieState state = SerieState.Auto)
| +| `GetLineColor()` |public static Color32 GetLineColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, SerieState state = SerieState.Auto)
| | `GetLineStyle()` |public static LineStyle GetLineStyle(Serie serie, SerieData serieData)
| | `GetMaxData()` |public static double GetMaxData(Serie serie, int dimension = 1, DataZoom dataZoom = null)
| | `GetMaxSerieData()` |public static SerieData GetMaxSerieData(Serie serie, int dimension = 1, DataZoom dataZoom = null)
| @@ -848,14 +848,16 @@ Inherits or Implemented: [Attribute](#Attribute) | `GetMinMaxData()` |public static void GetMinMaxData(Serie serie, out double min, out double max, DataZoom dataZoom = null, int dimension = 0)
Gets the maximum and minimum values of all data in the serie. | | `GetMinSerieData()` |public static SerieData GetMinSerieData(Serie serie, int dimension = 1, DataZoom dataZoom = null)
| | `GetNumericFormatter()` |public static string GetNumericFormatter(Serie serie, SerieData serieData, string defaultFormatter = null)
| -| `GetSerieEmphasisLabel()` |public static LabelStyle GetSerieEmphasisLabel(Serie serie, SerieData serieData)
| -| `GetSerieLabel()` |public static LabelStyle GetSerieLabel(Serie serie, SerieData serieData, bool highlight = false)
| -| `GetSerieLabelLine()` |public static LabelLine GetSerieLabelLine(Serie serie, SerieData serieData, bool highlight = false)
| +| `GetSelectStyle()` |public static SelectStyle GetSelectStyle(Serie serie, SerieData serieData)
| +| `GetSerieLabel()` |public static LabelStyle GetSerieLabel(Serie serie, SerieData serieData, SerieState state = SerieState.Auto)
| +| `GetSerieLabelLine()` |public static LabelLine GetSerieLabelLine(Serie serie, SerieData serieData, SerieState state = SerieState.Auto)
| +| `GetSerieState()` |public static SerieState GetSerieState(Serie serie)
| +| `GetSerieState()` |public static SerieState GetSerieState(Serie serie, SerieData serieData)
| | `GetSerieSymbol()` |public static SerieSymbol GetSerieSymbol(Serie serie, SerieData serieData)
| -| `GetSymbolBorder()` |public static float GetSymbolBorder(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight)
| -| `GetSymbolBorder()` |public static float GetSymbolBorder(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight, float defaultWidth)
| -| `GetSymbolBorderColor()` |public static Color32 GetSymbolBorderColor(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight)
| -| `GetSymbolCornerRadius()` |public static float[] GetSymbolCornerRadius(Serie serie, SerieData serieData, bool highlight)
| +| `GetStateStyle()` |public static StateStyle GetStateStyle(Serie serie, SerieData serieData, SerieState state)
| +| `GetSymbolBorder()` |public static float GetSymbolBorder(Serie serie, SerieData serieData, ThemeStyle theme, SerieState state = SerieState.Auto)
| +| `GetSymbolBorderColor()` |public static Color32 GetSymbolBorderColor(Serie serie, SerieData serieData, ThemeStyle theme, SerieState state = SerieState.Auto)
| +| `GetSymbolCornerRadius()` |public static float[] GetSymbolCornerRadius(Serie serie, SerieData serieData, SerieState state = SerieState.Auto)
| | `GetTitleStyle()` |public static TitleStyle GetTitleStyle(Serie serie, SerieData serieData)
| | `IsAllZeroValue()` |public static bool IsAllZeroValue(Serie serie, int dimension = 1)
Whether the data for the specified dimension of serie are all 0. | | `IsDownPoint()` |public static bool IsDownPoint(Serie serie, int index)
| diff --git a/Documentation/XChartsAPI-ZH.md b/Documentation/XChartsAPI-ZH.md index 9d8218e4..abf352a5 100644 --- a/Documentation/XChartsAPI-ZH.md +++ b/Documentation/XChartsAPI-ZH.md @@ -190,8 +190,9 @@ Inherits or Implemented: [BaseGraph](#BaseGraph),[ISerializationCallbackReceiver | `GetDataZoomOfSerie()` |public void GetDataZoomOfSerie(Serie serie, out DataZoom xDataZoom, out DataZoom yDataZoom)
| | `GetGrid()` |public GridCoord GetGrid(Vector2 local)
| | `GetGridOfDataZoom()` |public GridCoord GetGridOfDataZoom(DataZoom dataZoom)
| -| `GetItemColor()` |public Color32 GetItemColor(Serie serie, bool highlight = false)
| -| `GetItemColor()` |public Color32 GetItemColor(Serie serie, SerieData serieData, bool highlight = false)
| +| `GetItemColor()` |public Color32 GetItemColor(Serie serie)
| +| `GetItemColor()` |public Color32 GetItemColor(Serie serie, SerieData serieData)
| +| `GetItemColor()` |public Color32 GetItemColor(Serie serie, SerieData serieData, int colorIndex)
| | `GetLegendRealShowNameColor()` |public Color32 GetLegendRealShowNameColor(string name)
| | `GetLegendRealShowNameIndex()` |public int GetLegendRealShowNameIndex(string name)
| | `GetPainter()` |public Painter GetPainter(int index)
| @@ -340,6 +341,7 @@ Inherits or Implemented: [BaseChart](#BaseChart) | `DestroyAllChildren()` |public static void DestroyAllChildren(Transform parent)
| | `GetActualValue()` |public static float GetActualValue(float valueOrRate, float total, float maxRate = 1.5f)
| | `GetAngle360()` |public static float GetAngle360(Vector2 from, Vector2 to)
获得0-360的角度(12点钟方向为0度) | +| `GetBlurColor()` |public static Color32 GetBlurColor(Color32 color, float a = 0.3f)
| | `GetColor()` |public static Color32 GetColor(string hexColorStr)
| | `GetDire()` |public static Vector3 GetDire(float angle, bool isDegree = false)
| | `GetFloatAccuracy()` |public static int GetFloatAccuracy(double value)
| @@ -353,6 +355,7 @@ Inherits or Implemented: [BaseChart](#BaseChart) | `GetPointList()` |public static void GetPointList(ref List posList, Vector3 sp, Vector3 ep, float k = 30f)
| | `GetPos()` |public static Vector3 GetPos(Vector3 center, float radius, float angle, bool isDegree = false)
| | `GetPosition()` |public static Vector3 GetPosition(Vector3 center, float angle, float radius)
| +| `GetSelectColor()` |public static Color32 GetSelectColor(Color32 color, float rate = 0.7f)
| | `GetVertialDire()` |public static Vector3 GetVertialDire(Vector3 dire)
| | `HideAllObject()` |public static void HideAllObject(GameObject obj, string match = null)
| | `HideAllObject()` |public static void HideAllObject(Transform parent, string match = null)
| @@ -828,18 +831,15 @@ Inherits or Implemented: [Attribute](#Attribute) |--|--| | `CopySerie()` |public static void CopySerie(Serie oldSerie, Serie newSerie)
| | `GetAllMinMaxData()` |public static void GetAllMinMaxData(Serie serie, double ceilRate = 0, DataZoom dataZoom = null)
| -| `GetAreaColor()` |public static Color32 GetAreaColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight)
| | `GetAreaStyle()` |public static AreaStyle GetAreaStyle(Serie serie, SerieData serieData)
| -| `GetAreaToColor()` |public static Color32 GetAreaToColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight)
| | `GetAverageData()` |public static double GetAverageData(Serie serie, int dimension = 1, DataZoom dataZoom = null)
| -| `GetItemColor()` |public static Color32 GetItemColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight, bool opacity = true)
| -| `GetItemColor0()` |public static Color32 GetItemColor0(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight, Color32 defaultColor)
| +| `GetBlurStyle()` |public static BlurStyle GetBlurStyle(Serie serie, SerieData serieData)
| +| `GetEmphasisStyle()` |public static EmphasisStyle GetEmphasisStyle(Serie serie, SerieData serieData)
| +| `GetItemColor()` |public static Color32 GetItemColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, SerieState state = SerieState.Auto, bool opacity = true)
| | `GetItemFormatter()` |public static string GetItemFormatter(Serie serie, SerieData serieData, string defaultFormatter = null)
| | `GetItemMarker()` |public static string GetItemMarker(Serie serie, SerieData serieData, string defaultMarker = null)
| -| `GetItemStyle()` |public static ItemStyle GetItemStyle(Serie serie, SerieData serieData, bool highlight = false)
| -| `GetItemStyleEmphasis()` |public static ItemStyle GetItemStyleEmphasis(Serie serie, SerieData serieData)
| -| `GetItemToColor()` |public static Color32 GetItemToColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight, bool opacity = true)
| -| `GetLineColor()` |public static Color32 GetLineColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight)
| +| `GetItemStyle()` |public static ItemStyle GetItemStyle(Serie serie, SerieData serieData, SerieState state = SerieState.Auto)
| +| `GetLineColor()` |public static Color32 GetLineColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, SerieState state = SerieState.Auto)
| | `GetLineStyle()` |public static LineStyle GetLineStyle(Serie serie, SerieData serieData)
| | `GetMaxData()` |public static double GetMaxData(Serie serie, int dimension = 1, DataZoom dataZoom = null)
| | `GetMaxSerieData()` |public static SerieData GetMaxSerieData(Serie serie, int dimension = 1, DataZoom dataZoom = null)
| @@ -848,14 +848,16 @@ Inherits or Implemented: [Attribute](#Attribute) | `GetMinMaxData()` |public static void GetMinMaxData(Serie serie, out double min, out double max, DataZoom dataZoom = null, int dimension = 0)
获得系列所有数据的最大最小值。 | | `GetMinSerieData()` |public static SerieData GetMinSerieData(Serie serie, int dimension = 1, DataZoom dataZoom = null)
| | `GetNumericFormatter()` |public static string GetNumericFormatter(Serie serie, SerieData serieData, string defaultFormatter = null)
| -| `GetSerieEmphasisLabel()` |public static LabelStyle GetSerieEmphasisLabel(Serie serie, SerieData serieData)
| -| `GetSerieLabel()` |public static LabelStyle GetSerieLabel(Serie serie, SerieData serieData, bool highlight = false)
| -| `GetSerieLabelLine()` |public static LabelLine GetSerieLabelLine(Serie serie, SerieData serieData, bool highlight = false)
| +| `GetSelectStyle()` |public static SelectStyle GetSelectStyle(Serie serie, SerieData serieData)
| +| `GetSerieLabel()` |public static LabelStyle GetSerieLabel(Serie serie, SerieData serieData, SerieState state = SerieState.Auto)
| +| `GetSerieLabelLine()` |public static LabelLine GetSerieLabelLine(Serie serie, SerieData serieData, SerieState state = SerieState.Auto)
| +| `GetSerieState()` |public static SerieState GetSerieState(Serie serie)
| +| `GetSerieState()` |public static SerieState GetSerieState(Serie serie, SerieData serieData)
| | `GetSerieSymbol()` |public static SerieSymbol GetSerieSymbol(Serie serie, SerieData serieData)
| -| `GetSymbolBorder()` |public static float GetSymbolBorder(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight)
| -| `GetSymbolBorder()` |public static float GetSymbolBorder(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight, float defaultWidth)
| -| `GetSymbolBorderColor()` |public static Color32 GetSymbolBorderColor(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight)
| -| `GetSymbolCornerRadius()` |public static float[] GetSymbolCornerRadius(Serie serie, SerieData serieData, bool highlight)
| +| `GetStateStyle()` |public static StateStyle GetStateStyle(Serie serie, SerieData serieData, SerieState state)
| +| `GetSymbolBorder()` |public static float GetSymbolBorder(Serie serie, SerieData serieData, ThemeStyle theme, SerieState state = SerieState.Auto)
| +| `GetSymbolBorderColor()` |public static Color32 GetSymbolBorderColor(Serie serie, SerieData serieData, ThemeStyle theme, SerieState state = SerieState.Auto)
| +| `GetSymbolCornerRadius()` |public static float[] GetSymbolCornerRadius(Serie serie, SerieData serieData, SerieState state = SerieState.Auto)
| | `GetTitleStyle()` |public static TitleStyle GetTitleStyle(Serie serie, SerieData serieData)
| | `IsAllZeroValue()` |public static bool IsAllZeroValue(Serie serie, int dimension = 1)
系列指定维数的数据是否全部为0。 | | `IsDownPoint()` |public static bool IsDownPoint(Serie serie, int index)
| diff --git a/Documentation/XChartsConfiguration-EN.md b/Documentation/XChartsConfiguration-EN.md index f60e4b3c..4fabb276 100644 --- a/Documentation/XChartsConfiguration-EN.md +++ b/Documentation/XChartsConfiguration-EN.md @@ -85,14 +85,12 @@ - [AxisTick](#AxisTick) - [BaseAxisTheme](#BaseAxisTheme) - [BaseLine](#BaseLine) +- [BlurStyle](#BlurStyle) - [CommentItem](#CommentItem) - [CommentMarkStyle](#CommentMarkStyle) - [ComponentTheme](#ComponentTheme) - [DataZoomTheme](#DataZoomTheme) -- [Emphasis](#Emphasis) -- [EmphasisItemStyle](#EmphasisItemStyle) -- [EmphasisLabelLine](#EmphasisLabelLine) -- [EmphasisLabelStyle](#EmphasisLabelStyle) +- [EmphasisStyle](#EmphasisStyle) - [EndLabelStyle](#EndLabelStyle) - [IconStyle](#IconStyle) - [ImageStyle](#ImageStyle) @@ -111,10 +109,12 @@ - [PolarAxisTheme](#PolarAxisTheme) - [RadarAxisTheme](#RadarAxisTheme) - [RadiusAxisTheme](#RadiusAxisTheme) +- [SelectStyle](#SelectStyle) - [SerieData](#SerieData) - [SerieSymbol](#SerieSymbol) - [SerieTheme](#SerieTheme) - [StageColor](#StageColor) +- [StateStyle](#StateStyle) - [SubTitleTheme](#SubTitleTheme) - [SymbolStyle](#SymbolStyle) - [TextLimit](#TextLimit) @@ -130,28 +130,26 @@ ## ISerieExtraComponent - [AreaStyle](#AreaStyle) -- [Emphasis](#Emphasis) -- [EmphasisItemStyle](#EmphasisItemStyle) -- [EmphasisLabelLine](#EmphasisLabelLine) -- [EmphasisLabelStyle](#EmphasisLabelStyle) +- [BlurStyle](#BlurStyle) +- [EmphasisStyle](#EmphasisStyle) - [ImageStyle](#ImageStyle) - [LabelLine](#LabelLine) - [LabelStyle](#LabelStyle) - [LineArrow](#LineArrow) +- [SelectStyle](#SelectStyle) - [TitleStyle](#TitleStyle) ## ISerieDataComponent - [AreaStyle](#AreaStyle) -- [Emphasis](#Emphasis) -- [EmphasisItemStyle](#EmphasisItemStyle) -- [EmphasisLabelLine](#EmphasisLabelLine) -- [EmphasisLabelStyle](#EmphasisLabelStyle) +- [BlurStyle](#BlurStyle) +- [EmphasisStyle](#EmphasisStyle) - [ImageStyle](#ImageStyle) - [ItemStyle](#ItemStyle) - [LabelLine](#LabelLine) - [LabelStyle](#LabelStyle) - [LineStyle](#LineStyle) +- [SelectStyle](#SelectStyle) - [SerieSymbol](#SerieSymbol) - [TitleStyle](#TitleStyle) @@ -217,8 +215,6 @@ The style of area. |`color`|||the color of area,default use serie color. |`toColor`|||Gradient color, start color to toColor. |`opacity`|0.6f||Opacity of the component. Supports value from 0 to 1, and the component will not be drawn when set to 0. -|`highlightColor`|||the color of area,default use serie color. -|`highlightToColor`|||Gradient color, start highlightColor to highlightToColor. ## `ArrowStyle` @@ -440,6 +436,15 @@ Inherits or Implemented: [Serie](#Serie),[INeedSerieContainer](#INeedSerieContai ## `BaseSerie` +## `BlurStyle` + +Inherits or Implemented: [StateStyle](#StateStyle),[ISerieExtraComponent](#ISerieExtraComponent),[ISerieDataComponent](#ISerieDataComponent) + +> Since `v3.2.0` + +Configurations of blur state. + + ## `CalendarCoord` Inherits or Implemented: [CoordSystem](#CoordSystem),[IUpdateRuntimeData](#IUpdateRuntimeData),[ISerieContainer](#ISerieContainer) @@ -581,39 +586,19 @@ Inherits or Implemented: [ComponentTheme](#ComponentTheme) Inherits or Implemented: [BaseScatter](#BaseScatter) -## `Emphasis` +## `EmphasisStyle` -Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieExtraComponent](#ISerieExtraComponent),[ISerieDataComponent](#ISerieDataComponent) +Inherits or Implemented: [StateStyle](#StateStyle),[ISerieExtraComponent](#ISerieExtraComponent),[ISerieDataComponent](#ISerieDataComponent) -高亮的图形样式和文本标签样式。 +> Since `v3.2.0` + +Configurations of emphasis state. |field|default|since|comment| |--|--|--|--| -|`show`|||是否启用高亮样式。 -|`label`|||图形文本标签。 [LabelStyle](#LabelStyle)| -|`labelLine`|||图形文本引导线样式。 [LabelLine](#LabelLine)| -|`itemStyle`|||图形样式。 [ItemStyle](#ItemStyle)| - -## `EmphasisItemStyle` - -Inherits or Implemented: [ItemStyle](#ItemStyle),[ISerieExtraComponent](#ISerieExtraComponent),[ISerieDataComponent](#ISerieDataComponent) - -高亮的图形样式 - - -## `EmphasisLabelLine` - -Inherits or Implemented: [LabelLine](#LabelLine),[ISerieExtraComponent](#ISerieExtraComponent),[ISerieDataComponent](#ISerieDataComponent) - -高亮的标签引导线样式 - - -## `EmphasisLabelStyle` - -Inherits or Implemented: [LabelStyle](#LabelStyle),[ISerieExtraComponent](#ISerieExtraComponent),[ISerieDataComponent](#ISerieDataComponent) - -高亮的标签样式 - +|`scale`|1.1f||Whether to scale to highlight the data in emphasis state. 高亮时的缩放倍数。 +|`focus`|||When the data is highlighted, whether to fade out of other data to focus the highlighted.
`EmphasisStyle.FocusType`:
- `None`: Do not fade out other data, it's by default.
- `Self`: Only focus (not fade out) the element of the currently highlighted data.
- `Series`: Focus on all elements of the series which the currently highlighted data belongs to.
| +|`blurScope`|||The range of fade out when focus is enabled.
`EmphasisStyle.BlurScope`:
- `GridCoord`: coordinate system.
- `Series`: series.
- `Global`: global.
| ## `EndLabelStyle` @@ -1063,6 +1048,15 @@ Inherits or Implemented: [Serie](#Serie) Inherits or Implemented: [BaseScatter](#BaseScatter) +## `SelectStyle` + +Inherits or Implemented: [StateStyle](#StateStyle),[ISerieExtraComponent](#ISerieExtraComponent),[ISerieDataComponent](#ISerieDataComponent) + +> Since `v3.2.0` + +Configurations of select state. + + ## `Serie` Inherits or Implemented: [BaseSerie](#BaseSerie),[IComparable](#IComparable) @@ -1076,6 +1070,7 @@ Inherits or Implemented: [BaseSerie](#BaseSerie),[IComparable](#IComparable) |`coordSystem`|||the chart coord system of serie. |`serieType`|||the type of serie. |`serieName`|||Series name used for displaying in tooltip and filtering with legend. +|`state`||v3.2.0|The default state of a serie.
`SerieState`:
- `Normal`: Normal state.
- `Emphasis`: Emphasis state.
- `Blur`: Blur state.
- `Select`: Select state.
- `Auto`: Auto state.
| |`stack`|||If stack the value. On the same category axis, the series with the same stack name would be put on top of each other. |`xAxisIndex`|0||the index of XAxis. |`yAxisIndex`|0||the index of YAxis. @@ -1153,6 +1148,7 @@ A data item of serie. |`ignore`|||是否忽略数据。当为 true 时,数据不进行绘制。 |`selected`|||Whether the data item is selected. |`radius`|||自定义半径。可用在饼图中自定义某个数据项的半径。 +|`state`||v3.2.0|the state of serie data.
`SerieState`:
- `Normal`: Normal state.
- `Emphasis`: Emphasis state.
- `Blur`: Blur state.
- `Select`: Select state.
- `Auto`: Auto state.
| |`data`|||An arbitrary dimension data list of data item. ## `SerieSymbol` @@ -1261,6 +1257,23 @@ Inherits or Implemented: [ChildComponent](#ChildComponent) |`percent`|||结束位置百分比。 |`color`|||颜色。 +## `StateStyle` + +Inherits or Implemented: [ChildComponent](#ChildComponent) + +> Since `v3.2.0` + +the state style of serie. + +|field|default|since|comment| +|--|--|--|--| +|`show`|true||是否启用高亮样式。 +|`label`|||图形文本标签。 [LabelStyle](#LabelStyle)| +|`labelLine`|||图形文本引导线样式。 [LabelLine](#LabelLine)| +|`itemStyle`|||图形样式。 [ItemStyle](#ItemStyle)| +|`lineStyle`|||折线样式。 [LineStyle](#LineStyle)| +|`areaStyle`|||区域样式。 [AreaStyle](#AreaStyle)| + ## `SubTitleTheme` Inherits or Implemented: [ComponentTheme](#ComponentTheme) diff --git a/Documentation/XChartsConfiguration-ZH.md b/Documentation/XChartsConfiguration-ZH.md index 2de92c74..54869840 100644 --- a/Documentation/XChartsConfiguration-ZH.md +++ b/Documentation/XChartsConfiguration-ZH.md @@ -85,14 +85,12 @@ - [AxisTick](#AxisTick) - [BaseAxisTheme](#BaseAxisTheme) - [BaseLine](#BaseLine) +- [BlurStyle](#BlurStyle) - [CommentItem](#CommentItem) - [CommentMarkStyle](#CommentMarkStyle) - [ComponentTheme](#ComponentTheme) - [DataZoomTheme](#DataZoomTheme) -- [Emphasis](#Emphasis) -- [EmphasisItemStyle](#EmphasisItemStyle) -- [EmphasisLabelLine](#EmphasisLabelLine) -- [EmphasisLabelStyle](#EmphasisLabelStyle) +- [EmphasisStyle](#EmphasisStyle) - [EndLabelStyle](#EndLabelStyle) - [IconStyle](#IconStyle) - [ImageStyle](#ImageStyle) @@ -111,10 +109,12 @@ - [PolarAxisTheme](#PolarAxisTheme) - [RadarAxisTheme](#RadarAxisTheme) - [RadiusAxisTheme](#RadiusAxisTheme) +- [SelectStyle](#SelectStyle) - [SerieData](#SerieData) - [SerieSymbol](#SerieSymbol) - [SerieTheme](#SerieTheme) - [StageColor](#StageColor) +- [StateStyle](#StateStyle) - [SubTitleTheme](#SubTitleTheme) - [SymbolStyle](#SymbolStyle) - [TextLimit](#TextLimit) @@ -130,28 +130,26 @@ ## ISerieExtraComponent Serie额外组件 - [AreaStyle](#AreaStyle) -- [Emphasis](#Emphasis) -- [EmphasisItemStyle](#EmphasisItemStyle) -- [EmphasisLabelLine](#EmphasisLabelLine) -- [EmphasisLabelStyle](#EmphasisLabelStyle) +- [BlurStyle](#BlurStyle) +- [EmphasisStyle](#EmphasisStyle) - [ImageStyle](#ImageStyle) - [LabelLine](#LabelLine) - [LabelStyle](#LabelStyle) - [LineArrow](#LineArrow) +- [SelectStyle](#SelectStyle) - [TitleStyle](#TitleStyle) ## ISerieDataComponent SerieData额外组件 - [AreaStyle](#AreaStyle) -- [Emphasis](#Emphasis) -- [EmphasisItemStyle](#EmphasisItemStyle) -- [EmphasisLabelLine](#EmphasisLabelLine) -- [EmphasisLabelStyle](#EmphasisLabelStyle) +- [BlurStyle](#BlurStyle) +- [EmphasisStyle](#EmphasisStyle) - [ImageStyle](#ImageStyle) - [ItemStyle](#ItemStyle) - [LabelLine](#LabelLine) - [LabelStyle](#LabelStyle) - [LineStyle](#LineStyle) +- [SelectStyle](#SelectStyle) - [SerieSymbol](#SerieSymbol) - [TitleStyle](#TitleStyle) @@ -217,8 +215,6 @@ Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieExtraComponent |`color`|||区域填充的颜色,如果toColor不是默认值,则表示渐变色的起点颜色。 |`toColor`|||渐变色的终点颜色。 |`opacity`|0.6f||图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。 -|`highlightColor`|||高亮时区域填充的颜色,如果highlightToColor不是默认值,则表示渐变色的起点颜色。 -|`highlightToColor`|||高亮时渐变色的终点颜色。 ## `ArrowStyle` @@ -440,6 +436,15 @@ Inherits or Implemented: [Serie](#Serie),[INeedSerieContainer](#INeedSerieContai ## `BaseSerie` +## `BlurStyle` + +Inherits or Implemented: [StateStyle](#StateStyle),[ISerieExtraComponent](#ISerieExtraComponent),[ISerieDataComponent](#ISerieDataComponent) + +> 从 `v3.2.0` 开始支持 + +淡出状态样式。 + + ## `CalendarCoord` Inherits or Implemented: [CoordSystem](#CoordSystem),[IUpdateRuntimeData](#IUpdateRuntimeData),[ISerieContainer](#ISerieContainer) @@ -581,39 +586,19 @@ Inherits or Implemented: [ComponentTheme](#ComponentTheme) Inherits or Implemented: [BaseScatter](#BaseScatter) -## `Emphasis` +## `EmphasisStyle` -Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieExtraComponent](#ISerieExtraComponent),[ISerieDataComponent](#ISerieDataComponent) +Inherits or Implemented: [StateStyle](#StateStyle),[ISerieExtraComponent](#ISerieExtraComponent),[ISerieDataComponent](#ISerieDataComponent) -高亮的图形样式和文本标签样式。 +> 从 `v3.2.0` 开始支持 + +高亮状态样式。 |field|default|since|comment| |--|--|--|--| -|`show`|||是否启用高亮样式。 -|`label`|||图形文本标签。 [LabelStyle](#LabelStyle)| -|`labelLine`|||图形文本引导线样式。 [LabelLine](#LabelLine)| -|`itemStyle`|||图形样式。 [ItemStyle](#ItemStyle)| - -## `EmphasisItemStyle` - -Inherits or Implemented: [ItemStyle](#ItemStyle),[ISerieExtraComponent](#ISerieExtraComponent),[ISerieDataComponent](#ISerieDataComponent) - -高亮的图形样式 - - -## `EmphasisLabelLine` - -Inherits or Implemented: [LabelLine](#LabelLine),[ISerieExtraComponent](#ISerieExtraComponent),[ISerieDataComponent](#ISerieDataComponent) - -高亮的标签引导线样式 - - -## `EmphasisLabelStyle` - -Inherits or Implemented: [LabelStyle](#LabelStyle),[ISerieExtraComponent](#ISerieExtraComponent),[ISerieDataComponent](#ISerieDataComponent) - -高亮的标签样式 - +|`scale`|1.1f||Whether to scale to highlight the data in emphasis state. 高亮时的缩放倍数。 +|`focus`|||在高亮图形时,是否淡出其它数据的图形已达到聚焦的效果。
`EmphasisStyle.FocusType`:
- `None`: 不淡出其它图形,默认使用该配置。
- `Self`: 只聚焦(不淡出)当前高亮的数据的图形。
- `Series`: 聚焦当前高亮的数据所在的系列的所有图形。
| +|`blurScope`|||在开启focus的时候,可以通过blurScope配置淡出的范围。
`EmphasisStyle.BlurScope`:
- `GridCoord`: 淡出范围为坐标系,默认使用该配置。
- `Series`: 淡出范围为系列。
- `Global`: 淡出范围为全局。
| ## `EndLabelStyle` @@ -1063,6 +1048,15 @@ Inherits or Implemented: [Serie](#Serie) Inherits or Implemented: [BaseScatter](#BaseScatter) +## `SelectStyle` + +Inherits or Implemented: [StateStyle](#StateStyle),[ISerieExtraComponent](#ISerieExtraComponent),[ISerieDataComponent](#ISerieDataComponent) + +> 从 `v3.2.0` 开始支持 + +选中状态样式。 + + ## `Serie` Inherits or Implemented: [BaseSerie](#BaseSerie),[IComparable](#IComparable) @@ -1076,6 +1070,7 @@ Inherits or Implemented: [BaseSerie](#BaseSerie),[IComparable](#IComparable) |`coordSystem`|||使用的坐标系。 |`serieType`|||系列类型。 |`serieName`|||系列名称,用于 tooltip 的显示,legend 的图例筛选。 +|`state`||v3.2.0|系列的默认状态。
`SerieState`:
- `Normal`: 正常状态。
- `Emphasis`: 高亮状态。
- `Blur`: 淡出状态。
- `Select`: 选中状态。
- `Auto`: 自动保持和父节点一致。一般用在SerieData。
| |`stack`|||数据堆叠,同个类目轴上系列配置相同的stack值后,后一个系列的值会在前一个系列的值上相加。 |`xAxisIndex`|0||使用X轴的index。 |`yAxisIndex`|0||使用Y轴的index。 @@ -1153,6 +1148,7 @@ Inherits or Implemented: [ChildComponent](#ChildComponent) |`ignore`|||是否忽略数据。当为 true 时,数据不进行绘制。 |`selected`|||该数据项是否被选中。 |`radius`|||自定义半径。可用在饼图中自定义某个数据项的半径。 +|`state`||v3.2.0|数据项的默认状态。
`SerieState`:
- `Normal`: 正常状态。
- `Emphasis`: 高亮状态。
- `Blur`: 淡出状态。
- `Select`: 选中状态。
- `Auto`: 自动保持和父节点一致。一般用在SerieData。
| |`data`|||可指定任意维数的数值列表。 ## `SerieSymbol` @@ -1261,6 +1257,23 @@ Inherits or Implemented: [ChildComponent](#ChildComponent) |`percent`|||结束位置百分比。 |`color`|||颜色。 +## `StateStyle` + +Inherits or Implemented: [ChildComponent](#ChildComponent) + +> 从 `v3.2.0` 开始支持 + +Serie的状态样式。Serie的状态有正常,高亮,淡出,选中四种状态。 + +|field|default|since|comment| +|--|--|--|--| +|`show`|true||是否启用高亮样式。 +|`label`|||图形文本标签。 [LabelStyle](#LabelStyle)| +|`labelLine`|||图形文本引导线样式。 [LabelLine](#LabelLine)| +|`itemStyle`|||图形样式。 [ItemStyle](#ItemStyle)| +|`lineStyle`|||折线样式。 [LineStyle](#LineStyle)| +|`areaStyle`|||区域样式。 [AreaStyle](#AreaStyle)| + ## `SubTitleTheme` Inherits or Implemented: [ComponentTheme](#ComponentTheme) diff --git a/Editor/ChildComponents/AreaStyleDrawer.cs b/Editor/ChildComponents/AreaStyleDrawer.cs index 25aa9bc5..f586e226 100644 --- a/Editor/ChildComponents/AreaStyleDrawer.cs +++ b/Editor/ChildComponents/AreaStyleDrawer.cs @@ -17,8 +17,6 @@ namespace XCharts.Editor PropertyField(prop, "m_Origin"); PropertyField(prop, "m_Color"); PropertyField(prop, "m_ToColor"); - PropertyField(prop, "m_HighlightColor"); - PropertyField(prop, "m_HighlightToColor"); PropertyField(prop, "m_Opacity"); --EditorGUI.indentLevel; } diff --git a/Editor/ChildComponents/EmphasisStyleDrawer.cs b/Editor/ChildComponents/EmphasisStyleDrawer.cs deleted file mode 100644 index 89377f3d..00000000 --- a/Editor/ChildComponents/EmphasisStyleDrawer.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Collections.Generic; -using UnityEditor; -using UnityEngine; -using XCharts.Runtime; - -namespace XCharts.Editor -{ - [CustomPropertyDrawer(typeof(Emphasis), true)] - public class EmphasisDrawer : BasePropertyDrawer - { - public override string ClassName { get { return "Emphasis"; } } - public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label) - { - base.OnGUI(pos, prop, label); - if (MakeComponentFoldout(prop, "m_Show", true)) - { - ++EditorGUI.indentLevel; - PropertyField(prop, "m_Label"); - PropertyField(prop, "m_LabelLine"); - PropertyField(prop, "m_ItemStyle"); - --EditorGUI.indentLevel; - } - } - } - - [CustomPropertyDrawer(typeof(EmphasisItemStyle), true)] - public class EmphasisItemStyleDrawer : ItemStyleDrawer - { - public override string ClassName { get { return "EmphasisItemStyle"; } } - } - - [CustomPropertyDrawer(typeof(EmphasisLabelStyle), true)] - public class EmphasisLabelStyleDrawer : LabelStyleDrawer - { - public override string ClassName { get { return "EmphasisLabel"; } } - } - - [CustomPropertyDrawer(typeof(EmphasisLabelLine), true)] - public class EmphasisLabelLineDrawer : LabelLineDrawer - { - public override string ClassName { get { return "EmphasisLabelLine"; } } - } -} \ No newline at end of file diff --git a/Editor/ChildComponents/StateStyleDrawer.cs b/Editor/ChildComponents/StateStyleDrawer.cs new file mode 100644 index 00000000..ca0f746e --- /dev/null +++ b/Editor/ChildComponents/StateStyleDrawer.cs @@ -0,0 +1,54 @@ +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; +using XCharts.Runtime; + +namespace XCharts.Editor +{ + [CustomPropertyDrawer(typeof(StateStyle), true)] + public class StateStyleDrawer : BasePropertyDrawer + { + public override string ClassName { get { return "StateStyle"; } } + public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label) + { + base.OnGUI(pos, prop, label); + if (MakeComponentFoldout(prop, "m_Show", true)) + { + ++EditorGUI.indentLevel; + OnCustomGUI(prop); + PropertyField(prop, "m_ItemStyle"); + PropertyField(prop, "m_Label"); + PropertyField(prop, "m_LabelLine"); + PropertyField(prop, "m_LineStyle"); + PropertyField(prop, "m_AreaStyle"); + --EditorGUI.indentLevel; + } + } + + protected virtual void OnCustomGUI(SerializedProperty prop) { } + } + + [CustomPropertyDrawer(typeof(EmphasisStyle), true)] + public class EmphasisStyleDrawer : StateStyleDrawer + { + public override string ClassName { get { return "EmphasisStyle"; } } + protected override void OnCustomGUI(SerializedProperty prop) + { + PropertyField(prop, "m_Scale"); + PropertyField(prop, "m_Focus"); + PropertyField(prop, "m_BlurScope"); + } + } + + [CustomPropertyDrawer(typeof(BlurStyle), true)] + public class BlurStyleDrawer : StateStyleDrawer + { + public override string ClassName { get { return "BlurStyle"; } } + } + + [CustomPropertyDrawer(typeof(SelectStyle), true)] + public class SelectStyleDrawer : StateStyleDrawer + { + public override string ClassName { get { return "SelectStyle"; } } + } +} \ No newline at end of file diff --git a/Runtime/Component/Emphasis/Emphasis.cs.meta b/Editor/ChildComponents/StateStyleDrawer.cs.meta similarity index 83% rename from Runtime/Component/Emphasis/Emphasis.cs.meta rename to Editor/ChildComponents/StateStyleDrawer.cs.meta index 8aeb0946..38f810f7 100644 --- a/Runtime/Component/Emphasis/Emphasis.cs.meta +++ b/Editor/ChildComponents/StateStyleDrawer.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6e0b1690532674b24952a87e0aead6fa +guid: 3aad8ee99115742729ec5a963274fae0 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Editor/Series/SerieEditor.cs b/Editor/Series/SerieEditor.cs index 9b410ea8..1d07a793 100644 --- a/Editor/Series/SerieEditor.cs +++ b/Editor/Series/SerieEditor.cs @@ -16,7 +16,6 @@ namespace XCharts.Editor public override void OnInspectorGUI() { ++EditorGUI.indentLevel; - //PropertyField("m_InsertDataToHead"); PropertyField("m_SerieName"); if (m_CoordOptionsNames != null && m_CoordOptionsNames.Count > 1) { @@ -28,6 +27,7 @@ namespace XCharts.Editor serie.coordSystem = m_CoordOptionsDic[typeName].Name; } } + PropertyField("m_State"); OnCustomInspectorGUI(); OnExtraInspectorGUI(); PropertyFieldData(); @@ -189,9 +189,8 @@ namespace XCharts.Editor { EditorGUI.indentLevel++; var serieData = m_Datas.GetArrayElementAtIndex(index); - var m_Name = serieData.FindPropertyRelative("m_Name"); - - PropertyField(m_Name); + PropertyField(serieData.FindPropertyRelative("m_Name")); + PropertyField(serieData.FindPropertyRelative("m_State")); if (serie.GetType().IsDefined(typeof(SerieDataExtraFieldAttribute), false)) { var attribute = serie.GetType().GetAttribute(); diff --git a/Examples/Example60_Heatmap.cs b/Examples/Example60_Heatmap.cs index 96273243..2e89d4c3 100644 --- a/Examples/Example60_Heatmap.cs +++ b/Examples/Example60_Heatmap.cs @@ -47,10 +47,10 @@ namespace XCharts.Example serie.itemStyle.borderColor = Color.clear; //设置高亮样式 - serie.AddExtraComponent(); - serie.emphasisItemStyle.show = true; - serie.emphasisItemStyle.borderWidth = 1; - serie.emphasisItemStyle.borderColor = Color.black; + var emphasisStyle = serie.AddExtraComponent(); + emphasisStyle.itemStyle.show = true; + emphasisStyle.itemStyle.borderWidth = 1; + emphasisStyle.itemStyle.borderColor = Color.black; //设置视觉映射组件 var visualMap = chart.GetChartComponent(); diff --git a/Runtime/Component/Child/AreaStyle.cs b/Runtime/Component/Child/AreaStyle.cs index f7d1e0a4..a035f95a 100644 --- a/Runtime/Component/Child/AreaStyle.cs +++ b/Runtime/Component/Child/AreaStyle.cs @@ -37,8 +37,6 @@ namespace XCharts.Runtime [SerializeField] private Color32 m_Color; [SerializeField] private Color32 m_ToColor; [SerializeField][Range(0, 1)] private float m_Opacity = 0.6f; - [SerializeField] private Color32 m_HighlightColor; - [SerializeField] private Color32 m_HighlightToColor; /// /// Set this to false to prevent the areafrom showing. @@ -85,24 +83,6 @@ namespace XCharts.Runtime get { return m_Opacity; } set { if (PropertyUtil.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); } } - /// - /// the color of area,default use serie color. - /// |高亮时区域填充的颜色,如果highlightToColor不是默认值,则表示渐变色的起点颜色。 - /// - public Color32 highlightColor - { - get { return m_HighlightColor; } - set { if (PropertyUtil.SetColor(ref m_HighlightColor, value)) SetVerticesDirty(); } - } - /// - /// Gradient color, start highlightColor to highlightToColor. - /// |高亮时渐变色的终点颜色。 - /// - public Color32 highlightToColor - { - get { return m_HighlightToColor; } - set { if (PropertyUtil.SetColor(ref m_HighlightToColor, value)) SetVerticesDirty(); } - } public Color32 GetColor() { diff --git a/Runtime/Component/Emphasis/EmphasisItemStyle.cs b/Runtime/Component/Emphasis/EmphasisItemStyle.cs deleted file mode 100644 index ca5ad8e4..00000000 --- a/Runtime/Component/Emphasis/EmphasisItemStyle.cs +++ /dev/null @@ -1,11 +0,0 @@ -using UnityEngine; - -namespace XCharts.Runtime -{ - /// - /// 高亮的图形样式 - /// - [System.Serializable] - public class EmphasisItemStyle : ItemStyle, ISerieExtraComponent, ISerieDataComponent - { } -} \ No newline at end of file diff --git a/Runtime/Component/Emphasis/EmphasisLabelLine.cs b/Runtime/Component/Emphasis/EmphasisLabelLine.cs deleted file mode 100644 index 9a132ad9..00000000 --- a/Runtime/Component/Emphasis/EmphasisLabelLine.cs +++ /dev/null @@ -1,11 +0,0 @@ -using UnityEngine; - -namespace XCharts.Runtime -{ - /// - /// 高亮的标签引导线样式 - /// - [System.Serializable] - public class EmphasisLabelLine : LabelLine, ISerieExtraComponent, ISerieDataComponent - { } -} \ No newline at end of file diff --git a/Runtime/Component/Emphasis/EmphasisLabelStyle.cs b/Runtime/Component/Emphasis/EmphasisLabelStyle.cs deleted file mode 100644 index 0279fc6c..00000000 --- a/Runtime/Component/Emphasis/EmphasisLabelStyle.cs +++ /dev/null @@ -1,11 +0,0 @@ -using UnityEngine; - -namespace XCharts.Runtime -{ - /// - /// 高亮的标签样式 - /// - [System.Serializable] - public class EmphasisLabelStyle : LabelStyle, ISerieExtraComponent, ISerieDataComponent - { } -} \ No newline at end of file diff --git a/Runtime/Component/Emphasis/EmphasisLabelStyle.cs.meta b/Runtime/Component/Emphasis/EmphasisLabelStyle.cs.meta deleted file mode 100644 index 77199ddc..00000000 --- a/Runtime/Component/Emphasis/EmphasisLabelStyle.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3e025b0f4be6d4141aa08bdad0102aa7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Component/Mark/MarkAreaHandler.cs b/Runtime/Component/Mark/MarkAreaHandler.cs index f7939418..f4329a68 100644 --- a/Runtime/Component/Mark/MarkAreaHandler.cs +++ b/Runtime/Component/Mark/MarkAreaHandler.cs @@ -62,7 +62,7 @@ namespace XCharts.Runtime UpdateRuntimeData(markArea); var colorIndex = chart.GetLegendRealShowNameIndex(serie.legendName); - var serieColor = SerieHelper.GetLineColor(serie, null, chart.theme, colorIndex, false); + var serieColor = SerieHelper.GetLineColor(serie, null, chart.theme, colorIndex, SerieState.Normal); var areaColor = markArea.itemStyle.GetColor(serieColor); UGL.DrawRectangle(vh, markArea.runtimeRect, areaColor, areaColor); } diff --git a/Runtime/Component/Mark/MarkLineHandler.cs b/Runtime/Component/Mark/MarkLineHandler.cs index cafbdcf2..813b294e 100644 --- a/Runtime/Component/Mark/MarkLineHandler.cs +++ b/Runtime/Component/Mark/MarkLineHandler.cs @@ -100,7 +100,7 @@ namespace XCharts.Runtime var sp = Vector3.zero; var ep = Vector3.zero; var colorIndex = chart.GetLegendRealShowNameIndex(serie.serieName); - var serieColor = SerieHelper.GetLineColor(serie, null, chart.theme, colorIndex, false); + var serieColor = SerieHelper.GetLineColor(serie, null, chart.theme, colorIndex, SerieState.Normal); animation.InitProgress(0, 1f); ResetTempMarkLineGroupData(markLine); if (m_TempGroupData.Count > 0) @@ -242,9 +242,9 @@ namespace XCharts.Runtime private void DrawMarkLineSymbol(VertexHelper vh, SymbolStyle symbol, Serie serie, GridCoord grid, ThemeStyle theme, Vector3 pos, Vector3 startPos, Color32 lineColor) { - var tickness = SerieHelper.GetSymbolBorder(serie, null, theme, false); - var borderColor = SerieHelper.GetSymbolBorderColor(serie, null, theme, false); - var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, null, false); + var tickness = SerieHelper.GetSymbolBorder(serie, null, theme); + var borderColor = SerieHelper.GetSymbolBorderColor(serie, null, theme); + var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, null); chart.DrawClipSymbol(vh, symbol.type, symbol.size, tickness, pos, lineColor, lineColor, ColorUtil.clearColor32, borderColor, symbol.gap, true, cornerRadius, grid, startPos); } diff --git a/Runtime/Component/Emphasis.meta b/Runtime/Component/State.meta similarity index 77% rename from Runtime/Component/Emphasis.meta rename to Runtime/Component/State.meta index 68dbdad5..1e539fd1 100644 --- a/Runtime/Component/Emphasis.meta +++ b/Runtime/Component/State.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 4cd4074bb11fc40059363dd78b9ee98d +guid: ca1088963feb54117bce8be6bceb64de folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Runtime/Component/State/BlurStyle.cs b/Runtime/Component/State/BlurStyle.cs new file mode 100644 index 00000000..75c0de29 --- /dev/null +++ b/Runtime/Component/State/BlurStyle.cs @@ -0,0 +1,13 @@ +using UnityEngine; + +namespace XCharts.Runtime +{ + /// + /// Configurations of blur state. + /// |淡出状态样式。 + /// + [System.Serializable] + [Since("v3.2.0")] + public class BlurStyle : StateStyle, ISerieExtraComponent, ISerieDataComponent + { } +} \ No newline at end of file diff --git a/Editor/ChildComponents/EmphasisStyleDrawer.cs.meta b/Runtime/Component/State/BlurStyle.cs.meta similarity index 83% rename from Editor/ChildComponents/EmphasisStyleDrawer.cs.meta rename to Runtime/Component/State/BlurStyle.cs.meta index a6cdfc46..545be0c1 100644 --- a/Editor/ChildComponents/EmphasisStyleDrawer.cs.meta +++ b/Runtime/Component/State/BlurStyle.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 7de9b5e4c5d474fdd88ebb89f0924305 +guid: 4e3f901db80454f89800a84977289535 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/Component/State/EmphasisStyle.cs b/Runtime/Component/State/EmphasisStyle.cs new file mode 100644 index 00000000..e3602d20 --- /dev/null +++ b/Runtime/Component/State/EmphasisStyle.cs @@ -0,0 +1,90 @@ +using UnityEngine; + +namespace XCharts.Runtime +{ + /// + /// Configurations of emphasis state. + /// |高亮状态样式。 + /// + [System.Serializable] + [Since("v3.2.0")] + public class EmphasisStyle : StateStyle, ISerieExtraComponent, ISerieDataComponent + { + /// + /// focus type. + /// |聚焦类型。 + /// + public enum FocusType + { + /// + /// Do not fade out other data, it's by default. + /// |不淡出其它图形,默认使用该配置。 + /// + None, + /// + /// Only focus (not fade out) the element of the currently highlighted data. + /// |只聚焦(不淡出)当前高亮的数据的图形。 + /// + Self, + /// + /// Focus on all elements of the series which the currently highlighted data belongs to. + /// |聚焦当前高亮的数据所在的系列的所有图形。 + /// + Series + } + /// + /// blur scope. + /// |淡出范围。 + /// + public enum BlurScope + { + /// + /// coordinate system. + /// |淡出范围为坐标系,默认使用该配置。 + /// + GridCoord, + /// + /// series. + /// |淡出范围为系列。 + /// + Series, + /// + /// global. + /// |淡出范围为全局。 + /// + Global + } + + [SerializeField] private float m_Scale = 1.1f; + [SerializeField] private FocusType m_Focus = FocusType.None; + [SerializeField] private BlurScope m_BlurScope = BlurScope.GridCoord; + + /// + /// Whether to scale to highlight the data in emphasis state. + /// |高亮时的缩放倍数。 + /// + public float scale + { + get { return m_Scale; } + set { if (PropertyUtil.SetStruct(ref m_Scale, value)) SetVerticesDirty(); } + } + /// + /// When the data is highlighted, whether to fade out of other data to focus the highlighted. + /// |在高亮图形时,是否淡出其它数据的图形已达到聚焦的效果。 + /// + public FocusType focus + { + get { return m_Focus; } + set { if (PropertyUtil.SetStruct(ref m_Focus, value)) SetVerticesDirty(); } + } + /// + /// The range of fade out when focus is enabled. + /// |在开启focus的时候,可以通过blurScope配置淡出的范围。 + /// + public BlurScope blurScope + { + get { return m_BlurScope; } + set { if (PropertyUtil.SetStruct(ref m_BlurScope, value)) SetVerticesDirty(); } + } + } +} \ No newline at end of file diff --git a/Runtime/Component/Emphasis/EmphasisLabelLine.cs.meta b/Runtime/Component/State/EmphasisStyle.cs.meta similarity index 83% rename from Runtime/Component/Emphasis/EmphasisLabelLine.cs.meta rename to Runtime/Component/State/EmphasisStyle.cs.meta index b6bd83fa..c75a637b 100644 --- a/Runtime/Component/Emphasis/EmphasisLabelLine.cs.meta +++ b/Runtime/Component/State/EmphasisStyle.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a0d9ff3b8e09d464e9b5ea996b941314 +guid: 91a31f424478042418811c32bb8aa2d5 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/Component/State/SelectStyle.cs b/Runtime/Component/State/SelectStyle.cs new file mode 100644 index 00000000..093274ac --- /dev/null +++ b/Runtime/Component/State/SelectStyle.cs @@ -0,0 +1,13 @@ +using UnityEngine; + +namespace XCharts.Runtime +{ + /// + /// Configurations of select state. + /// |选中状态样式。 + /// + [System.Serializable] + [Since("v3.2.0")] + public class SelectStyle : StateStyle, ISerieExtraComponent, ISerieDataComponent + { } +} \ No newline at end of file diff --git a/Runtime/Component/Emphasis/EmphasisItemStyle.cs.meta b/Runtime/Component/State/SelectStyle.cs.meta similarity index 83% rename from Runtime/Component/Emphasis/EmphasisItemStyle.cs.meta rename to Runtime/Component/State/SelectStyle.cs.meta index 73b33639..c4a851cd 100644 --- a/Runtime/Component/Emphasis/EmphasisItemStyle.cs.meta +++ b/Runtime/Component/State/SelectStyle.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 5d1095175540449f99bb9da27a5aaf04 +guid: 986a9b6da6fdd48c49a9b665450dd605 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/Component/Emphasis/Emphasis.cs b/Runtime/Component/State/StateStyle.cs similarity index 50% rename from Runtime/Component/Emphasis/Emphasis.cs rename to Runtime/Component/State/StateStyle.cs index 90d64640..9c1304ce 100644 --- a/Runtime/Component/Emphasis/Emphasis.cs +++ b/Runtime/Component/State/StateStyle.cs @@ -3,15 +3,19 @@ using UnityEngine; namespace XCharts.Runtime { /// - /// 高亮的图形样式和文本标签样式。 + /// the state style of serie. + /// |Serie的状态样式。Serie的状态有正常,高亮,淡出,选中四种状态。 /// [System.Serializable] - public class Emphasis : ChildComponent, ISerieExtraComponent, ISerieDataComponent + [Since("v3.2.0")] + public class StateStyle : ChildComponent { - [SerializeField] private bool m_Show; + [SerializeField] private bool m_Show = true; [SerializeField] private LabelStyle m_Label = new LabelStyle(); [SerializeField] private LabelLine m_LabelLine = new LabelLine(); [SerializeField] private ItemStyle m_ItemStyle = new ItemStyle(); + [SerializeField] private LineStyle m_LineStyle = new LineStyle(); + [SerializeField] private AreaStyle m_AreaStyle = new AreaStyle(); public void Reset() { @@ -53,22 +57,57 @@ namespace XCharts.Runtime get { return m_ItemStyle; } set { if (PropertyUtil.SetClass(ref m_ItemStyle, value, true)) SetVerticesDirty(); } } + /// + /// 折线样式。 + /// + public LineStyle lineStyle + { + get { return m_LineStyle; } + set { if (PropertyUtil.SetClass(ref m_LineStyle, value, true)) SetVerticesDirty(); } + } + /// + /// 区域样式。 + /// + public AreaStyle areaStyle + { + get { return m_AreaStyle; } + set { if (PropertyUtil.SetClass(ref m_AreaStyle, value, true)) SetVerticesDirty(); } + } - public override bool vertsDirty { get { return m_VertsDirty || label.vertsDirty || itemStyle.vertsDirty; } } + public override bool vertsDirty + { + get + { + return m_VertsDirty || + m_Label.vertsDirty || + m_ItemStyle.vertsDirty || + m_LineStyle.vertsDirty || + m_AreaStyle.vertsDirty; + } + } - public override bool componentDirty { get { return m_ComponentDirty || label.componentDirty; } } + public override bool componentDirty + { + get + { + return m_ComponentDirty || + m_Label.componentDirty; + } + } public override void ClearVerticesDirty() { base.ClearVerticesDirty(); - label.ClearVerticesDirty(); - itemStyle.ClearVerticesDirty(); + m_Label.ClearVerticesDirty(); + m_ItemStyle.ClearVerticesDirty(); + m_LineStyle.ClearVerticesDirty(); + m_AreaStyle.ClearVerticesDirty(); } public override void ClearComponentDirty() { base.ClearComponentDirty(); - label.ClearComponentDirty(); + m_Label.ClearComponentDirty(); } } } \ No newline at end of file diff --git a/Runtime/Component/State/StateStyle.cs.meta b/Runtime/Component/State/StateStyle.cs.meta new file mode 100644 index 00000000..fed3381b --- /dev/null +++ b/Runtime/Component/State/StateStyle.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 921539f841914493a90f748c6c6662dc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Internal/BaseChart.API.cs b/Runtime/Internal/BaseChart.API.cs index 3459b54a..7c1c2a2b 100644 --- a/Runtime/Internal/BaseChart.API.cs +++ b/Runtime/Internal/BaseChart.API.cs @@ -544,17 +544,25 @@ namespace XCharts.Runtime return theme.GetBackgroundColor(background); } - public Color32 GetItemColor(Serie serie, SerieData serieData, bool highlight = false) + public Color32 GetItemColor(Serie serie, SerieData serieData) { - var colorIndex = serieData == null || !serie.useDataNameForColor ? - GetLegendRealShowNameIndex(serie.legendName) : - GetLegendRealShowNameIndex(serieData.legendName); - return SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, highlight); + Color32 color, toColor; + SerieHelper.GetItemColor(out color, out toColor, serie, serieData, m_Theme); + return color; } - public Color32 GetItemColor(Serie serie, bool highlight = false) + public Color32 GetItemColor(Serie serie, SerieData serieData, int colorIndex) { - return SerieHelper.GetItemColor(serie, null, m_Theme, serie.context.colorIndex, highlight); + Color32 color, toColor; + SerieHelper.GetItemColor(out color, out toColor, serie, serieData, m_Theme, colorIndex); + return color; + } + + public Color32 GetItemColor(Serie serie) + { + Color32 color, toColor; + SerieHelper.GetItemColor(out color, out toColor, serie, null, m_Theme); + return color; } } } \ No newline at end of file diff --git a/Runtime/Internal/Basic/BaseSerie.cs b/Runtime/Internal/Basic/BaseSerie.cs index 57c992a3..087b4111 100644 --- a/Runtime/Internal/Basic/BaseSerie.cs +++ b/Runtime/Internal/Basic/BaseSerie.cs @@ -27,6 +27,28 @@ namespace XCharts.Runtime public SerieHandler handler { get; set; } + public static void ClearVerticesDirty(ChildComponent component) + { + if (component != null) + component.ClearVerticesDirty(); + } + + public static void ClearComponentDirty(ChildComponent component) + { + if (component != null) + component.ClearComponentDirty(); + } + + public static bool IsVertsDirty(ChildComponent component) + { + return component == null?false : component.vertsDirty; + } + + public static bool IsComponentDirty(ChildComponent component) + { + return component == null?false : component.componentDirty; + } + public virtual void SetVerticesDirty() { m_VertsDirty = true; @@ -47,8 +69,7 @@ namespace XCharts.Runtime m_ComponentDirty = false; } - public virtual void ClearData() - { } + public virtual void ClearData() { } public virtual void ClearDirty() { @@ -68,11 +89,9 @@ namespace XCharts.Runtime handler.RemoveComponent(); } - public virtual void OnDataUpdate() - { } + public virtual void OnDataUpdate() { } - public virtual void OnBeforeSerialize() - { } + public virtual void OnBeforeSerialize() { } public virtual void OnAfterDeserialize() { diff --git a/Runtime/Internal/Basic/ChildComponent.cs b/Runtime/Internal/Basic/ChildComponent.cs index 90bca35c..ce89da2f 100644 --- a/Runtime/Internal/Basic/ChildComponent.cs +++ b/Runtime/Internal/Basic/ChildComponent.cs @@ -28,6 +28,28 @@ namespace XCharts.Runtime public Action refreshComponent { get; set; } public GameObject gameObject { get; set; } + public static void ClearVerticesDirty(ChildComponent component) + { + if (component != null) + component.ClearVerticesDirty(); + } + + public static void ClearComponentDirty(ChildComponent component) + { + if (component != null) + component.ClearComponentDirty(); + } + + public static bool IsVertsDirty(ChildComponent component) + { + return component == null?false : component.vertsDirty; + } + + public static bool IsComponentDirty(ChildComponent component) + { + return component == null?false : component.componentDirty; + } + public virtual void SetVerticesDirty() { m_VertsDirty = true; diff --git a/Runtime/Internal/Utilities/ChartHelper.cs b/Runtime/Internal/Utilities/ChartHelper.cs index 47c56e04..1c3f8968 100644 --- a/Runtime/Internal/Utilities/ChartHelper.cs +++ b/Runtime/Internal/Utilities/ChartHelper.cs @@ -845,6 +845,22 @@ namespace XCharts.Runtime return newColor; } + public static Color32 GetBlurColor(Color32 color, float a = 0.3f) + { + var newColor = color; + newColor.a = (byte) (a * 255); + return newColor; + } + + public static Color32 GetSelectColor(Color32 color, float rate = 0.7f) + { + var newColor = color; + newColor.r = (byte) (color.r * rate); + newColor.g = (byte) (color.g * rate); + newColor.b = (byte) (color.b * rate); + return newColor; + } + public static bool IsPointInQuadrilateral(Vector3 P, Vector3 A, Vector3 B, Vector3 C, Vector3 D) { Vector3 v0 = Vector3.Cross(A - D, P - D); diff --git a/Runtime/Serie/Bar/Bar.cs b/Runtime/Serie/Bar/Bar.cs index 89ed7024..c02e83cb 100644 --- a/Runtime/Serie/Bar/Bar.cs +++ b/Runtime/Serie/Bar/Bar.cs @@ -5,8 +5,8 @@ namespace XCharts.Runtime [SerieConvert(typeof(Line), typeof(Pie))] [RequireChartComponent(typeof(GridCoord))] [DefaultAnimation(AnimationType.BottomToTop)] - [SerieExtraComponent(typeof(LabelStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))] - [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))] + [SerieExtraComponent(typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))] + [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))] [SerieDataExtraField("m_Ignore")] public class Bar : Serie, INeedSerieContainer { diff --git a/Runtime/Serie/Bar/BarHandler.cs b/Runtime/Serie/Bar/BarHandler.cs index 0e1d4df8..fabb1576 100644 --- a/Runtime/Serie/Bar/BarHandler.cs +++ b/Runtime/Serie/Bar/BarHandler.cs @@ -81,14 +81,14 @@ namespace XCharts.Runtime return; } m_LastCheckContextFlag = needCheck; + Color32 color, toColor; if (m_LegendEnter) { serie.context.pointerEnter = true; foreach (var serieData in serie.data) { - var barColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, serie.context.colorIndex, true); - var barToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serie.context.colorIndex, true); - serieData.interact.SetColor(ref needInteract, barColor, barToColor); + SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme); + serieData.interact.SetColor(ref needInteract, color, toColor); } } else @@ -103,18 +103,14 @@ namespace XCharts.Runtime serie.context.pointerItemDataIndex = serieData.index; serie.context.pointerEnter = true; serieData.context.highlight = true; - - var barColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, serie.context.colorIndex, true); - var barToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serie.context.colorIndex, true); - serieData.interact.SetColor(ref needInteract, barColor, barToColor); + SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, SerieState.Emphasis); } else { serieData.context.highlight = false; - var barColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, serie.context.colorIndex, false); - var barToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serie.context.colorIndex, false); - serieData.interact.SetColor(ref needInteract, barColor, barToColor); + SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, SerieState.Normal); } + serieData.interact.SetColor(ref needInteract, color, toColor); } } if (needInteract) @@ -190,18 +186,18 @@ namespace XCharts.Runtime if (serieData.IsDataChanged()) dataChanging = true; - var highlight = serieData.context.highlight || serie.highlight; - var itemStyle = SerieHelper.GetItemStyle(serie, serieData, highlight); + var state = SerieHelper.GetSerieState(serie, serieData); + var itemStyle = SerieHelper.GetItemStyle(serie, serieData, state); var value = axis.IsCategory() ? i : serieData.GetData(0, axis.inverse); var relativedValue = serieData.GetCurrData(1, dataChangeDuration, relativedAxis.inverse, yMinValue, yMaxValue); var borderWidth = relativedValue == 0 ? 0 : itemStyle.runtimeBorderWidth; var borderGap = relativedValue == 0 ? 0 : itemStyle.borderGap; var borderGapAndWidth = borderWidth + borderGap; + var backgroundColor = itemStyle.backgroundColor; if (!serieData.interact.TryGetColor(ref areaColor, ref areaToColor, ref interacting)) { - areaColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, highlight); - areaToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, colorIndex, highlight); + SerieHelper.GetItemColor(out areaColor, out areaToColor, serie, serieData, chart.theme); serieData.interact.SetColor(ref interacting, areaColor, areaToColor); } @@ -242,11 +238,11 @@ namespace XCharts.Runtime { case BarType.Normal: case BarType.Capsule: - DrawNormalBar(vh, serie, serieData, itemStyle, colorIndex, highlight, gap, barWidth, + DrawNormalBar(vh, serie, serieData, itemStyle, backgroundColor, gap, barWidth, pX, pY, plb, plt, prt, prb, isY, m_SerieGrid, axis, areaColor, areaToColor, relativedValue); break; case BarType.Zebra: - DrawZebraBar(vh, serie, serieData, itemStyle, colorIndex, highlight, gap, barWidth, + DrawZebraBar(vh, serie, serieData, itemStyle, backgroundColor, gap, barWidth, pX, pY, plb, plt, prt, prb, isY, m_SerieGrid, axis, areaColor, areaToColor); break; } @@ -366,12 +362,11 @@ namespace XCharts.Runtime } } - private void DrawNormalBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex, - bool highlight, float gap, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt, + private void DrawNormalBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, Color32 backgroundColor, + float gap, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt, Vector3 prb, bool isYAxis, GridCoord grid, Axis axis, Color32 areaColor, Color32 areaToColor, double value) { var borderWidth = itemStyle.runtimeBorderWidth; - var backgroundColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, colorIndex, highlight, false); var cornerRadius = serie.barType == BarType.Capsule && !itemStyle.IsNeedCorner() ? m_CapusleDefaultCornerRadius : itemStyle.cornerRadius; @@ -395,11 +390,10 @@ namespace XCharts.Runtime } } - private void DrawZebraBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex, - bool highlight, float gap, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt, + private void DrawZebraBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, Color32 backgroundColor, + float gap, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt, Vector3 prb, bool isYAxis, GridCoord grid, Axis axis, Color32 barColor, Color32 barToColor) { - var backgroundColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, colorIndex, highlight, false); if (!ChartHelper.IsClearColor(backgroundColor)) { UGL.DrawRoundRectangle(vh, serieData.context.backgroundRect, backgroundColor, backgroundColor, 0, diff --git a/Runtime/Serie/Bar/SimplifiedBarHandler.cs b/Runtime/Serie/Bar/SimplifiedBarHandler.cs index fffb5779..ca4a92ce 100644 --- a/Runtime/Serie/Bar/SimplifiedBarHandler.cs +++ b/Runtime/Serie/Bar/SimplifiedBarHandler.cs @@ -37,6 +37,7 @@ namespace XCharts.Runtime var needCheck = (chart.isPointerInChart && m_SerieGrid.IsPointerEnter()) || m_LegendEnter; var needInteract = false; + Color32 color, toColor; if (!needCheck) { if (m_LastCheckContextFlag != needCheck) @@ -46,9 +47,8 @@ namespace XCharts.Runtime serie.context.pointerEnter = false; foreach (var serieData in serie.data) { - var barColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, serie.context.colorIndex, false); - var barToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serie.context.colorIndex, false); - serieData.interact.SetColor(ref needInteract, barColor, barToColor); + SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, SerieState.Normal); + serieData.interact.SetColor(ref needInteract, color, toColor); } if (needInteract) { @@ -63,9 +63,8 @@ namespace XCharts.Runtime serie.context.pointerEnter = true; foreach (var serieData in serie.data) { - var barColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, serie.context.colorIndex, true); - var barToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serie.context.colorIndex, true); - serieData.interact.SetColor(ref needInteract, barColor, barToColor); + SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, SerieState.Emphasis); + serieData.interact.SetColor(ref needInteract, color, toColor); } } else @@ -80,16 +79,14 @@ namespace XCharts.Runtime serie.context.pointerEnter = true; serieData.context.highlight = true; - var barColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, serie.context.colorIndex, true); - var barToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serie.context.colorIndex, true); - serieData.interact.SetColor(ref needInteract, barColor, barToColor); + SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, SerieState.Emphasis); + serieData.interact.SetColor(ref needInteract, color, toColor); } else { serieData.context.highlight = false; - var barColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, serie.context.colorIndex, false); - var barToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serie.context.colorIndex, false); - serieData.interact.SetColor(ref needInteract, barColor, barToColor); + SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, SerieState.Normal); + serieData.interact.SetColor(ref needInteract, color, toColor); } } } @@ -162,15 +159,14 @@ namespace XCharts.Runtime dataChanging = true; var highlight = serieData.context.highlight || serie.highlight; - var itemStyle = SerieHelper.GetItemStyle(serie, serieData, highlight); + var itemStyle = SerieHelper.GetItemStyle(serie, serieData); var value = axis.IsCategory() ? i : serieData.GetData(0, axis.inverse); var relativedValue = serieData.GetCurrData(1, dataChangeDuration, relativedAxis.inverse, yMinValue, yMaxValue); var borderWidth = relativedValue == 0 ? 0 : itemStyle.runtimeBorderWidth; if (!serieData.interact.TryGetColor(ref areaColor, ref areaToColor, ref interacting)) { - areaColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, highlight); - areaToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, colorIndex, highlight); + SerieHelper.GetItemColor(out areaColor, out areaToColor, serie, serieData, chart.theme); serieData.interact.SetColor(ref interacting, areaColor, areaToColor); } diff --git a/Runtime/Serie/Candlestick/Candlestick.cs b/Runtime/Serie/Candlestick/Candlestick.cs index 6ac985ec..16da2b14 100644 --- a/Runtime/Serie/Candlestick/Candlestick.cs +++ b/Runtime/Serie/Candlestick/Candlestick.cs @@ -6,7 +6,7 @@ namespace XCharts.Runtime [SerieHandler(typeof(CandlestickHandler), true)] [DefaultAnimation(AnimationType.LeftToRight)] [SerieExtraComponent()] - [SerieDataExtraComponent(typeof(ItemStyle), typeof(EmphasisItemStyle))] + [SerieDataExtraComponent(typeof(ItemStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))] [SerieDataExtraField()] public class Candlestick : Serie, INeedSerieContainer { diff --git a/Runtime/Serie/Candlestick/CandlestickHandler.cs b/Runtime/Serie/Candlestick/CandlestickHandler.cs index 7955f60f..3eafef1b 100644 --- a/Runtime/Serie/Candlestick/CandlestickHandler.cs +++ b/Runtime/Serie/Candlestick/CandlestickHandler.cs @@ -29,7 +29,7 @@ namespace XCharts.Runtime title = category; - var color = SerieHelper.GetItemColor(serie, serieData, chart.theme, serie.context.colorIndex, false); + var color = chart.GetItemColor(serie, serieData); var newMarker = SerieHelper.GetItemMarker(serie, serieData, marker); var newItemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter); var newNumericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter); @@ -113,8 +113,8 @@ namespace XCharts.Runtime serie.context.dataPoints.Add(Vector3.zero); continue; } - var highlight = serie.data[i].context.highlight || serie.highlight; - var itemStyle = SerieHelper.GetItemStyle(serie, serieData, highlight); + var state = SerieHelper.GetSerieState(serie, serieData); + var itemStyle = SerieHelper.GetItemStyle(serie, serieData, state); var open = serieData.GetCurrData(0, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue); var close = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue); var lowest = serieData.GetCurrData(2, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue); diff --git a/Runtime/Serie/Candlestick/SimplifiedCandlestickHandler.cs b/Runtime/Serie/Candlestick/SimplifiedCandlestickHandler.cs index 455f6005..0bbb90dd 100644 --- a/Runtime/Serie/Candlestick/SimplifiedCandlestickHandler.cs +++ b/Runtime/Serie/Candlestick/SimplifiedCandlestickHandler.cs @@ -29,7 +29,7 @@ namespace XCharts.Runtime title = category; - var color = SerieHelper.GetItemColor(serie, serieData, chart.theme, serie.context.colorIndex, false); + var color = chart.GetItemColor(serie, serieData); var newMarker = SerieHelper.GetItemMarker(serie, serieData, marker); var newItemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter); var newNumericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter); diff --git a/Runtime/Serie/Heatmap/Heatmap.cs b/Runtime/Serie/Heatmap/Heatmap.cs index 9d713569..ea1ccd72 100644 --- a/Runtime/Serie/Heatmap/Heatmap.cs +++ b/Runtime/Serie/Heatmap/Heatmap.cs @@ -6,8 +6,8 @@ namespace XCharts.Runtime [SerieHandler(typeof(HeatmapHandler), true)] [DefaultAnimation(AnimationType.LeftToRight)] [RequireChartComponent(typeof(VisualMap))] - [SerieExtraComponent(typeof(LabelStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))] - [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))] + [SerieExtraComponent(typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))] + [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))] [SerieDataExtraField()] public class Heatmap : Serie, INeedSerieContainer { @@ -20,10 +20,11 @@ namespace XCharts.Runtime serie.itemStyle.borderWidth = 1; serie.itemStyle.borderColor = Color.clear; - var emphasis = serie.AddExtraComponent(); + var emphasis = serie.AddExtraComponent(); emphasis.show = true; - emphasis.borderWidth = 1; - emphasis.borderColor = Color.black; + emphasis.itemStyle.show = true; + emphasis.itemStyle.borderWidth = 1; + emphasis.itemStyle.borderColor = Color.black; return serie; } } diff --git a/Runtime/Serie/Heatmap/HeatmapHandler.cs b/Runtime/Serie/Heatmap/HeatmapHandler.cs index 517033fa..51aade31 100644 --- a/Runtime/Serie/Heatmap/HeatmapHandler.cs +++ b/Runtime/Serie/Heatmap/HeatmapHandler.cs @@ -130,7 +130,7 @@ namespace XCharts.Runtime xAxis.boundaryGap = true; yAxis.boundaryGap = true; var visualMap = chart.GetVisualMapOfSerie(serie); - var emphasisItemStyle = serie.emphasisItemStyle; + var emphasisStyle = serie.emphasisStyle; var xCount = xAxis.data.Count; var yCount = yAxis.data.Count; var xWidth = m_SerieGrid.context.width / xCount; @@ -209,9 +209,10 @@ namespace XCharts.Runtime { UGL.DrawBorder(vh, pos, rectWid, rectHig, borderWidth, borderColor, borderToColor); } - if (visualMap.hoverLink && highlight && emphasisItemStyle != null && - emphasisItemStyle.borderWidth > 0) + if (visualMap.hoverLink && highlight && emphasisStyle != null && + emphasisStyle.itemStyle.borderWidth > 0) { + var emphasisItemStyle = emphasisStyle.itemStyle; var emphasisBorderWidth = emphasisItemStyle.borderWidth; var emphasisBorderColor = emphasisItemStyle.opacity > 0 ? emphasisItemStyle.borderColor : ChartConst.clearColor32; diff --git a/Runtime/Serie/Line/Line.cs b/Runtime/Serie/Line/Line.cs index d504f13c..3b13b9ef 100644 --- a/Runtime/Serie/Line/Line.cs +++ b/Runtime/Serie/Line/Line.cs @@ -12,15 +12,17 @@ namespace XCharts.Runtime typeof(EndLabelStyle), typeof(LineArrow), typeof(AreaStyle), - typeof(EmphasisItemStyle), - typeof(EmphasisLabelStyle))] + typeof(EmphasisStyle), + typeof(BlurStyle), + typeof(SelectStyle))] [SerieDataExtraComponent( typeof(ItemStyle), typeof(LabelStyle), typeof(SerieSymbol), - typeof(EmphasisItemStyle), - typeof(EmphasisLabelStyle))] - [SerieDataExtraField("m_Ignore")] + typeof(EmphasisStyle), + typeof(BlurStyle), + typeof(SelectStyle))] + [SerieDataExtraField("m_State", "m_Ignore")] public class Line : Serie, INeedSerieContainer { public int containerIndex { get; internal set; } diff --git a/Runtime/Serie/Line/LineHandler.GridCoord.cs b/Runtime/Serie/Line/LineHandler.GridCoord.cs index 7c24bf37..f1b6c6f8 100644 --- a/Runtime/Serie/Line/LineHandler.GridCoord.cs +++ b/Runtime/Serie/Line/LineHandler.GridCoord.cs @@ -187,18 +187,18 @@ namespace XCharts.Runtime serieData.interact.SetValue(ref interacting, symbolSize); symbolSize = serie.animation.GetSysmbolSize(symbolSize); } - var symbolColor = SerieHelper.GetItemColor(serie, serieData, theme, serie.index, highlight); - var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, theme, serie.index, highlight); - var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, serie.index, highlight, false); + var state = SerieHelper.GetSerieState(serie, serieData); + Color32 symbolColor, symbolToColor,symbolEmptyColor; + SerieHelper.GetItemColor(out symbolColor, out symbolToColor,out symbolEmptyColor, serie, serieData, theme, serie.index, state); if (isVisualMapGradient) { symbolColor = VisualMapHelper.GetLineGradientColor(visualMap, pos, m_SerieGrid, axis, relativedAxis, symbolColor); symbolToColor = symbolColor; } - var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, highlight); - var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, theme, highlight); - var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight); + var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, state); + var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, theme, state); + var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, state); chart.DrawClipSymbol(vh, symbol.type, symbolSize, symbolBorder, pos, symbolColor, symbolToColor, symbolEmptyColor, borderColor, symbol.gap, clip, cornerRadius, m_SerieGrid, i > 0 ? serie.context.dataPoints[i - 1] : m_SerieGrid.context.position); @@ -220,7 +220,7 @@ namespace XCharts.Runtime if (serie.context.dataPoints.Count < 2) return; - var lineColor = SerieHelper.GetLineColor(serie, null, chart.theme, serie.index, false); + var lineColor = SerieHelper.GetLineColor(serie, null, chart.theme, serie.index); var startPos = Vector3.zero; var arrowPos = Vector3.zero; var lineArrow = serie.lineArrow.arrow; diff --git a/Runtime/Serie/Line/LineHandler.PolarCoord.cs b/Runtime/Serie/Line/LineHandler.PolarCoord.cs index ea5b5698..24410e0c 100644 --- a/Runtime/Serie/Line/LineHandler.PolarCoord.cs +++ b/Runtime/Serie/Line/LineHandler.PolarCoord.cs @@ -120,7 +120,7 @@ namespace XCharts.Runtime var firstSerieData = datas[0]; var lp = GetPolarPos(m_SeriePolar, m_AngleAxis, firstSerieData, min, max, radius); var cp = Vector3.zero; - var lineColor = SerieHelper.GetLineColor(serie, null, chart.theme, serie.index, serie.highlight); + var lineColor = SerieHelper.GetLineColor(serie, null, chart.theme, serie.index); var lineWidth = serie.lineStyle.GetWidth(chart.theme.serie.lineWidth); var currDetailProgress = 0f; var totalDetailProgress = datas.Count; @@ -205,6 +205,7 @@ namespace XCharts.Runtime continue; var count = serie.dataCount; + Color32 symbolColor, symbolToColor,symbolEmptyColor; for (int i = 0; i < count; i++) { var serieData = serie.GetSerieData(i); @@ -220,13 +221,11 @@ namespace XCharts.Runtime var symbolSize = highlight ? symbol.GetSelectedSize(serieData.data, chart.theme.serie.lineSymbolSize) : symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize); - - var symbolColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, n, highlight); - var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, n, highlight); - var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, n, highlight, false); - var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, highlight); - var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, chart.theme, highlight); - var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight); + var state = SerieHelper.GetSerieState(serie, serieData); + SerieHelper.GetItemColor(out symbolColor, out symbolToColor,out symbolEmptyColor, serie, serieData, chart.theme, n); + var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, state); + var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, chart.theme, state); + var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, state); symbolSize = serie.animation.GetSysmbolSize(symbolSize); chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, serieData.context.position, diff --git a/Runtime/Serie/Line/LineHelper.cs b/Runtime/Serie/Line/LineHelper.cs index 831a52b4..d99132a1 100644 --- a/Runtime/Serie/Line/LineHelper.cs +++ b/Runtime/Serie/Line/LineHelper.cs @@ -24,11 +24,11 @@ namespace XCharts.Runtime public static void DrawSerieLineArea(VertexHelper vh, Serie serie, Serie lastStackSerie, ThemeStyle theme, VisualMap visualMap, bool isY, Axis axis, Axis relativedAxis, GridCoord grid) { - if (serie.areaStyle == null || !serie.areaStyle.show) + Color32 srcAreaColor, srcAreaToColor; + if (!SerieHelper.GetAreaColor(out srcAreaColor, out srcAreaToColor, serie, null, theme, serie.context.colorIndex)) + { return; - - var srcAreaColor = SerieHelper.GetAreaColor(serie, null, theme, serie.context.colorIndex, false); - var srcAreaToColor = SerieHelper.GetAreaToColor(serie, null, theme, serie.context.colorIndex, false); + } var gridXY = (isY ? grid.context.x : grid.context.y); if (lastStackSerie == null) { @@ -263,7 +263,7 @@ namespace XCharts.Runtime var isLineStyleGradient = serie.lineStyle.IsNeedGradient(); //var highlight = serie.highlight || serie.context.pointerEnter; - var lineColor = SerieHelper.GetLineColor(serie, null, theme, serie.context.colorIndex, false); + var lineColor = SerieHelper.GetLineColor(serie, null, theme, serie.context.colorIndex); var lastDataIsIgnore = datas[0].isIgnoreBreak; var smooth = serie.lineType == LineType.Smooth; diff --git a/Runtime/Serie/Parallel/Parallel.cs b/Runtime/Serie/Parallel/Parallel.cs index 9d6b7528..721f9f91 100644 --- a/Runtime/Serie/Parallel/Parallel.cs +++ b/Runtime/Serie/Parallel/Parallel.cs @@ -6,7 +6,7 @@ namespace XCharts.Runtime [System.Serializable] [SerieHandler(typeof(ParallelHandler), true)] [RequireChartComponent(typeof(ParallelCoord))] - [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))] + [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))] [SerieDataExtraField()] public class Parallel : Serie, INeedSerieContainer { diff --git a/Runtime/Serie/Parallel/ParallelHandler.cs b/Runtime/Serie/Parallel/ParallelHandler.cs index c56c4d41..717a0ad2 100644 --- a/Runtime/Serie/Parallel/ParallelHandler.cs +++ b/Runtime/Serie/Parallel/ParallelHandler.cs @@ -38,7 +38,7 @@ namespace XCharts.Runtime var animationIndex = serie.animation.GetCurrIndex(); var isHorizonal = parallel.orient == Orient.Horizonal; - var lineColor = SerieHelper.GetLineColor(serie, null, chart.theme, serie.context.colorIndex, false); + var lineColor = SerieHelper.GetLineColor(serie, null, chart.theme, serie.context.colorIndex); var lineWidth = serie.lineStyle.GetWidth(chart.theme.serie.lineWidth); float currDetailProgress = !isHorizonal ? diff --git a/Runtime/Serie/Pie/Pie.cs b/Runtime/Serie/Pie/Pie.cs index 39278796..fdfb6edb 100644 --- a/Runtime/Serie/Pie/Pie.cs +++ b/Runtime/Serie/Pie/Pie.cs @@ -4,8 +4,8 @@ namespace XCharts.Runtime [SerieConvert(typeof(Line), typeof(Bar))] [SerieHandler(typeof(PieHandler), true)] [DefaultAnimation(AnimationType.Clockwise)] - [SerieExtraComponent(typeof(LabelStyle), typeof(LabelLine), typeof(TitleStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle), typeof(EmphasisLabelLine))] - [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(LabelLine), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle), typeof(EmphasisLabelLine))] + [SerieExtraComponent(typeof(LabelStyle), typeof(LabelLine), typeof(TitleStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))] + [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(LabelLine), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))] [SerieDataExtraField("m_Ignore", "m_Selected", "m_Radius")] public class Pie : Serie { diff --git a/Runtime/Serie/Pie/PieHandler.cs b/Runtime/Serie/Pie/PieHandler.cs index b1c545e3..e7ec59bd 100644 --- a/Runtime/Serie/Pie/PieHandler.cs +++ b/Runtime/Serie/Pie/PieHandler.cs @@ -108,6 +108,7 @@ namespace XCharts.Runtime { var needCheck = m_LegendEnter || (chart.isPointerInChart && PointerIsInPieSerie(serie, chart.pointerPos)); var needInteract = false; + Color32 color, toColor; if (!needCheck) { if (m_LastCheckContextFlag != needCheck) @@ -118,8 +119,7 @@ namespace XCharts.Runtime foreach (var serieData in serie.data) { var colorIndex = chart.GetLegendRealShowNameIndex(serieData.legendName); - var color = SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, false); - var toColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, colorIndex, false); + SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, colorIndex, SerieState.Normal); serieData.context.highlight = false; serieData.interact.SetValueAndColor(ref needInteract, serieData.context.outsideRadius, color, toColor); } @@ -142,8 +142,7 @@ namespace XCharts.Runtime serieData.context.highlight = true; var colorIndex = chart.GetLegendRealShowNameIndex(serieData.legendName); - var color = SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, true); - var toColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, colorIndex, true); + SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, colorIndex, SerieState.Emphasis); var value = serieData.context.outsideRadius + chart.theme.serie.pieTooltipExtraRadius; serieData.interact.SetValueAndColor(ref needInteract, value, color, toColor); } @@ -151,8 +150,7 @@ namespace XCharts.Runtime { serieData.context.highlight = false; var colorIndex = chart.GetLegendRealShowNameIndex(serieData.legendName); - var color = SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, false); - var toColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, colorIndex, false); + SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, colorIndex, SerieState.Normal); serieData.interact.SetValueAndColor(ref needInteract, serieData.context.outsideRadius, color, toColor); } } @@ -322,7 +320,7 @@ namespace XCharts.Runtime if (serieData.IsDataChanged()) dataChanging = true; - var itemStyle = SerieHelper.GetItemStyle(serie, serieData, serieData.context.highlight); + var itemStyle = SerieHelper.GetItemStyle(serie, serieData); var colorIndex = chart.GetLegendRealShowNameIndex(serieData.legendName); var outsideRadius = 0f; @@ -334,8 +332,7 @@ namespace XCharts.Runtime //if (!serieData.interact.TryGetValueAndColor(ref outsideRadius, ref color, ref toColor, ref interacting)) { - color = SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, serieData.context.highlight); - toColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, colorIndex, serieData.context.highlight); + SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, colorIndex); outsideRadius = serieData.context.outsideRadius * progress; serieData.interact.SetValueAndColor(ref interacting, outsideRadius, color, toColor); } diff --git a/Runtime/Serie/Radar/Radar.cs b/Runtime/Serie/Radar/Radar.cs index dc44ec02..7271acc7 100644 --- a/Runtime/Serie/Radar/Radar.cs +++ b/Runtime/Serie/Radar/Radar.cs @@ -6,8 +6,8 @@ namespace XCharts.Runtime [System.Serializable] [SerieHandler(typeof(RadarHandler), true)] [RequireChartComponent(typeof(RadarCoord))] - [SerieExtraComponent(typeof(LabelStyle), typeof(AreaStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))] - [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(AreaStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))] + [SerieExtraComponent(typeof(LabelStyle), typeof(AreaStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))] + [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(AreaStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))] [SerieDataExtraField()] public class Radar : Serie, INeedSerieContainer { diff --git a/Runtime/Serie/Radar/RadarHandler.cs b/Runtime/Serie/Radar/RadarHandler.cs index 5bda0afb..17c587dc 100644 --- a/Runtime/Serie/Radar/RadarHandler.cs +++ b/Runtime/Serie/Radar/RadarHandler.cs @@ -54,7 +54,8 @@ namespace XCharts.Runtime if (serieData == null) return; - var color = SerieHelper.GetItemColor(serie, serieData, chart.theme, dataIndex, false);; + Color32 color, toColor; + SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, dataIndex, SerieState.Normal); title = serieData.name; for (int i = 0; i < serieData.data.Count; i++) { @@ -96,6 +97,7 @@ namespace XCharts.Runtime needHideAll = true; } m_LastCheckContextFlag = needCheck; + serie.highlight = false; serie.context.pointerEnter = false; serie.context.pointerItemDataIndex = -1; var areaStyle = serie.areaStyle; @@ -120,6 +122,7 @@ namespace XCharts.Runtime { if (Vector3.Distance(chart.pointerPos, pos) < symbolSize * 2) { + serie.highlight = true; serie.context.pointerEnter = true; serie.context.pointerItemDataIndex = i; serieData.context.highlight = true; @@ -136,6 +139,7 @@ namespace XCharts.Runtime var p2 = n >= dataPoints.Count - 1 ? dataPoints[0] : dataPoints[n + 1]; if (UGLHelper.IsPointInTriangle(p1, center, p2, chart.pointerPos)) { + serie.highlight = true; serie.context.pointerEnter = true; serie.context.pointerItemDataIndex = i; serieData.context.highlight = true; @@ -154,6 +158,7 @@ namespace XCharts.Runtime serieData.index = i; if (Vector3.Distance(chart.pointerPos, serieData.context.position) < serie.symbol.size * 2) { + serie.highlight = true; serie.context.pointerEnter = true; serie.context.pointerItemDataIndex = i; return; @@ -169,6 +174,7 @@ namespace XCharts.Runtime var p2 = n >= dataPoints.Count - 1 ? dataPoints[0] : dataPoints[n + 1]; if (UGLHelper.IsPointInTriangle(p1.context.position, center, p2.context.position, chart.pointerPos)) { + serie.highlight = true; serie.context.pointerEnter = true; serie.context.pointerItemDataIndex = n; p1.context.highlight = true; @@ -209,6 +215,7 @@ namespace XCharts.Runtime var interacting = false; var dataChangeDuration = serie.animation.GetUpdateAnimationDuration(); SerieHelper.GetAllMinMaxData(serie, m_RadarCoord.ceilRate); + Color32 areaColor, areaToColor; for (int j = 0; j < serie.data.Count; j++) { var serieData = serie.data[j]; @@ -218,13 +225,12 @@ namespace XCharts.Runtime continue; } var lineStyle = SerieHelper.GetLineStyle(serie, serieData); - var areaStyle = SerieHelper.GetAreaStyle(serie, serieData); var symbol = SerieHelper.GetSerieSymbol(serie, serieData); var isHighlight = serieData.context.highlight; + var serieState = SerieHelper.GetSerieState(serie, serieData); var colorIndex = chart.GetLegendRealShowNameIndex(serieData.legendName); - var areaColor = SerieHelper.GetAreaColor(serie, serieData, chart.theme, colorIndex, isHighlight); - var areaToColor = SerieHelper.GetAreaToColor(serie, serieData, chart.theme, colorIndex, isHighlight); - var lineColor = SerieHelper.GetLineColor(serie, serieData, chart.theme, colorIndex, isHighlight); + var showArea = SerieHelper.GetAreaColor(out areaColor, out areaToColor, serie, serieData, chart.theme, colorIndex); + var lineColor = SerieHelper.GetLineColor(serie, serieData, chart.theme, colorIndex); var lineWidth = lineStyle.GetWidth(chart.theme.serie.lineWidth); int dataCount = m_RadarCoord.indicatorList.Count; serieData.context.dataPoints.Clear(); @@ -262,7 +268,7 @@ namespace XCharts.Runtime { toPoint = new Vector3(centerPos.x + radius * Mathf.Sin(currAngle), centerPos.y + radius * Mathf.Cos(currAngle)); - if (areaStyle != null && areaStyle.show && !serie.smooth) + if (showArea && !serie.smooth) { UGL.DrawTriangle(vh, startPoint, toPoint, centerPos, areaColor, areaColor, areaToColor); } @@ -274,7 +280,7 @@ namespace XCharts.Runtime } serieData.context.dataPoints.Add(startPoint); } - if (areaStyle != null && areaStyle.show && !serie.smooth) + if (showArea && !serie.smooth) { UGL.DrawTriangle(vh, startPoint, firstPoint, centerPos, areaColor, areaColor, areaToColor); } @@ -308,12 +314,11 @@ namespace XCharts.Runtime serieData.interact.SetValue(ref interacting, symbolSize); symbolSize = serie.animation.GetSysmbolSize(symbolSize); } - var symbolColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, j, isHighlight); - var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, j, isHighlight); - var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, j, isHighlight, false); - var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight); - var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, chart.theme, isHighlight); - var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight); + Color32 symbolColor, symbolToColor, symbolEmptyColor; + SerieHelper.GetItemColor(out symbolColor, out symbolToColor, out symbolEmptyColor, serie, serieData, chart.theme, j, serieState); + var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, serieState); + var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, chart.theme, serieState); + var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, serieState); chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, point, symbolColor, symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius); } @@ -369,11 +374,9 @@ namespace XCharts.Runtime continue; } var lineStyle = SerieHelper.GetLineStyle(serie, serieData); - var areaStyle = SerieHelper.GetAreaStyle(serie, serieData); - var isHighlight = serie.context.pointerEnter; - var areaColor = SerieHelper.GetAreaColor(serie, serieData, chart.theme, j, isHighlight); - var areaToColor = SerieHelper.GetAreaToColor(serie, serieData, chart.theme, j, isHighlight); - var lineColor = SerieHelper.GetLineColor(serie, serieData, chart.theme, j, isHighlight); + Color32 areaColor, areaToColor; + var showArea = SerieHelper.GetAreaColor(out areaColor, out areaToColor, serie, serieData, chart.theme, j); + var lineColor = SerieHelper.GetLineColor(serie, serieData, chart.theme, j); int dataCount = radar.indicatorList.Count; var index = serieData.index; var p = radar.context.center; @@ -404,7 +407,7 @@ namespace XCharts.Runtime { toPoint = new Vector3(p.x + radius * Mathf.Sin(currAngle), p.y + radius * Mathf.Cos(currAngle)); - if (areaStyle != null && areaStyle.show && !serie.smooth) + if (showArea && !serie.smooth) { UGL.DrawTriangle(vh, startPoint, toPoint, p, areaColor, areaColor, areaToColor); } @@ -423,7 +426,7 @@ namespace XCharts.Runtime serieData.context.position = startPoint; serieData.context.labelPosition = startPoint; - if (areaStyle != null && areaStyle.show && j == endIndex && !serie.smooth) + if (showArea && j == endIndex && !serie.smooth) { UGL.DrawTriangle(vh, startPoint, firstPoint, centerPos, areaColor, areaColor, areaToColor); } @@ -439,7 +442,7 @@ namespace XCharts.Runtime if (serie.smooth) { var lineWidth = serie.lineStyle.GetWidth(chart.theme.serie.lineWidth); - var lineColor = SerieHelper.GetLineColor(serie, null, chart.theme, serie.context.colorIndex, false); + var lineColor = SerieHelper.GetLineColor(serie, null, chart.theme, serie.context.colorIndex); UGL.DrawCurves(vh, serie.context.dataPoints, lineWidth, lineColor, chart.settings.lineSmoothStyle, chart.settings.lineSmoothness, @@ -452,17 +455,16 @@ namespace XCharts.Runtime { var serieData = serie.data[j]; if (!serieData.show) continue; - var isHighlight = serie.highlight || serieData.context.highlight || serie.context.pointerEnter; + var state = SerieHelper.GetSerieState(serie, serieData); var serieIndex = serieData.index; - var symbolSize = isHighlight ? + var symbolSize = state == SerieState.Emphasis ? serie.symbol.GetSelectedSize(serieData.data, chart.theme.serie.lineSymbolSelectedSize) : serie.symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize); - var symbolColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, serieIndex, isHighlight); - var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieIndex, isHighlight); - var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serieIndex, isHighlight, false); - var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight); - var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, chart.theme, isHighlight); - var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight); + Color32 symbolColor, symbolToColor,symbolEmptyColor; + SerieHelper.GetItemColor(out symbolColor, out symbolToColor,out symbolEmptyColor, serie, serieData, chart.theme, serieIndex, state); + var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, state); + var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, chart.theme, state); + var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, state); if (!radar.IsInIndicatorRange(j, serieData.GetData(1))) { symbolColor = radar.outRangeColor; @@ -499,27 +501,5 @@ namespace XCharts.Runtime } return 0; } - - private void DrawRadarSymbol(VertexHelper vh, Serie serie, SerieData serieData, int serieIndex, bool isHighlight, - List pointList) - { - if (serie.symbol.show && serie.symbol.type != SymbolType.None) - { - var symbolSize = isHighlight ? - serie.symbol.GetSelectedSize(serieData.data, chart.theme.serie.lineSymbolSelectedSize) : - serie.symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize); - var symbolColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, serieIndex, isHighlight); - var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieIndex, isHighlight); - var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serieIndex, isHighlight, false); - var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight); - var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, chart.theme, isHighlight); - var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight); - foreach (var point in pointList) - { - chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, point, symbolColor, - symbolToColor, symbolEmptyColor, borderColor, serie.symbol.gap, cornerRadius); - } - } - } } } \ No newline at end of file diff --git a/Runtime/Serie/Ring/Ring.cs b/Runtime/Serie/Ring/Ring.cs index d97cdb40..f448f783 100644 --- a/Runtime/Serie/Ring/Ring.cs +++ b/Runtime/Serie/Ring/Ring.cs @@ -4,8 +4,8 @@ namespace XCharts.Runtime { [System.Serializable] [SerieHandler(typeof(RingHandler), true)] - [SerieExtraComponent(typeof(LabelStyle), typeof(TitleStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))] - [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(TitleStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))] + [SerieExtraComponent(typeof(LabelStyle), typeof(TitleStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))] + [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(TitleStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))] [SerieDataExtraField()] public class Ring : Serie { diff --git a/Runtime/Serie/Ring/RingHandler.cs b/Runtime/Serie/Ring/RingHandler.cs index 70c5f400..df5a27f1 100644 --- a/Runtime/Serie/Ring/RingHandler.cs +++ b/Runtime/Serie/Ring/RingHandler.cs @@ -86,6 +86,8 @@ namespace XCharts.Runtime var serieData = serie.GetSerieData(dataIndex); if (serieData == null) return; + Color32 color, toColor; + SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, dataIndex); var param = serie.context.param; param.serieName = serie.serieName; @@ -96,7 +98,7 @@ namespace XCharts.Runtime param.dataCount = serie.dataCount; param.value = serieData.GetData(0); param.total = serieData.GetData(1); - param.color = SerieHelper.GetItemColor(serie, serieData, chart.theme, dataIndex, false); + param.color = color; param.marker = SerieHelper.GetItemMarker(serie, serieData, marker); param.itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter); param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);; @@ -158,10 +160,10 @@ namespace XCharts.Runtime var degree = (float) (360 * value / max); var startDegree = GetStartAngle(serie); var toDegree = GetToAngle(serie, degree); - var itemStyle = SerieHelper.GetItemStyle(serie, serieData, serieData.context.highlight); + var itemStyle = SerieHelper.GetItemStyle(serie, serieData); var colorIndex = chart.GetLegendRealShowNameIndex(serieData.legendName); - var itemColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, serieData.context.highlight); - var itemToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, colorIndex, serieData.context.highlight); + Color32 itemColor, itemToColor; + SerieHelper.GetItemColor(out itemColor, out itemToColor, serie, serieData, chart.theme, colorIndex); var outsideRadius = serie.context.outsideRadius - j * (ringWidth + serie.gap); var insideRadius = outsideRadius - ringWidth; var borderWidth = itemStyle.borderWidth; @@ -214,8 +216,7 @@ namespace XCharts.Runtime chart.RefreshPainter(serie); } - public override void OnPointerDown(PointerEventData eventData) - { } + public override void OnPointerDown(PointerEventData eventData) { } private float GetStartAngle(Serie serie) { @@ -258,7 +259,12 @@ namespace XCharts.Runtime private void DrawBackground(VertexHelper vh, Serie serie, SerieData serieData, int index, float insideRadius, float outsideRadius) { var itemStyle = SerieHelper.GetItemStyle(serie, serieData); - var backgroundColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, index, false); + var backgroundColor = itemStyle.backgroundColor; + if (ChartHelper.IsClearColor(backgroundColor)) + { + backgroundColor = chart.theme.GetColor(index); + backgroundColor.a = 50; + } if (itemStyle.backgroundWidth != 0) { var centerRadius = (outsideRadius + insideRadius) / 2; diff --git a/Runtime/Serie/Scatter/BaseScatterHandler.cs b/Runtime/Serie/Scatter/BaseScatterHandler.cs index f8a3aa78..1958afc0 100644 --- a/Runtime/Serie/Scatter/BaseScatterHandler.cs +++ b/Runtime/Serie/Scatter/BaseScatterHandler.cs @@ -36,7 +36,7 @@ namespace XCharts.Runtime param.dimension = 1; param.dataCount = serie.dataCount; param.serieData = serieData; - param.color = SerieHelper.GetItemColor(serie, serieData, chart.theme, serie.context.colorIndex, false); + param.color = chart.GetItemColor(serie, serieData); param.marker = SerieHelper.GetItemMarker(serie, serieData, marker); param.itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter); param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter); @@ -151,12 +151,12 @@ namespace XCharts.Runtime continue; var highlight = serie.highlight || serieData.context.highlight; - var color = SerieHelper.GetItemColor(serie, serieData, theme, colorIndex, highlight); - var toColor = SerieHelper.GetItemToColor(serie, serieData, theme, colorIndex, highlight); - var emptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, colorIndex, highlight, false); - var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, highlight); - var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, theme, highlight); - var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight); + var state = SerieHelper.GetSerieState(serie, serieData); + Color32 color, toColor, emptyColor; + SerieHelper.GetItemColor(out color, out toColor, out emptyColor, serie, serieData, chart.theme, colorIndex, state); + var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, state); + var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, theme, state); + var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, state); double xValue = serieData.GetCurrData(0, dataChangeDuration, xAxis.inverse); double yValue = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse); @@ -255,13 +255,12 @@ namespace XCharts.Runtime if (!symbol.ShowSymbol(serieData.index, maxCount)) continue; - var highlight = serie.highlight || serieData.context.highlight; - var color = SerieHelper.GetItemColor(serie, serieData, theme, colorIndex, highlight); - var toColor = SerieHelper.GetItemToColor(serie, serieData, theme, colorIndex, highlight); - var emptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, colorIndex, highlight, false); - var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, highlight); - var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, theme, highlight); - var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight); + var state = SerieHelper.GetSerieState(serie, serieData); + Color32 color, toColor, emptyColor; + SerieHelper.GetItemColor(out color, out toColor, out emptyColor, serie, serieData, chart.theme, colorIndex, state); + var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, state); + var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, theme, state); + var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, state); var xValue = serieData.GetCurrData(0, dataChangeDuration, axis.inverse); if (serieData.IsDataChanged()) diff --git a/Runtime/Serie/Scatter/EffectScatter.cs b/Runtime/Serie/Scatter/EffectScatter.cs index f2219173..55696652 100644 --- a/Runtime/Serie/Scatter/EffectScatter.cs +++ b/Runtime/Serie/Scatter/EffectScatter.cs @@ -5,8 +5,8 @@ namespace XCharts.Runtime [System.Serializable] [SerieHandler(typeof(EffectScatterHandler), true)] [CoordOptions(typeof(GridCoord), typeof(SingleAxisCoord))] - [SerieExtraComponent(typeof(LabelStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))] - [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))] + [SerieExtraComponent(typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))] + [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))] [SerieDataExtraField("m_Radius")] public class EffectScatter : BaseScatter { diff --git a/Runtime/Serie/Scatter/Scatter.cs b/Runtime/Serie/Scatter/Scatter.cs index f633d74a..daf2ee56 100644 --- a/Runtime/Serie/Scatter/Scatter.cs +++ b/Runtime/Serie/Scatter/Scatter.cs @@ -5,8 +5,8 @@ namespace XCharts.Runtime [System.Serializable] [SerieHandler(typeof(ScatterHandler), true)] [CoordOptions(typeof(GridCoord), typeof(SingleAxisCoord))] - [SerieExtraComponent(typeof(LabelStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))] - [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))] + [SerieExtraComponent(typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))] + [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))] [SerieDataExtraField("m_Radius")] public class Scatter : BaseScatter { diff --git a/Runtime/Serie/Serie.ExtraComponent.cs b/Runtime/Serie/Serie.ExtraComponent.cs index 01f21b9d..06eb4726 100644 --- a/Runtime/Serie/Serie.ExtraComponent.cs +++ b/Runtime/Serie/Serie.ExtraComponent.cs @@ -14,9 +14,9 @@ namespace XCharts.Runtime { typeof(LineArrow), "m_LineArrows" }, { typeof(AreaStyle), "m_AreaStyles" }, { typeof(TitleStyle), "m_TitleStyles" }, - { typeof(EmphasisItemStyle), "m_EmphasisItemStyles" }, - { typeof(EmphasisLabelStyle), "m_EmphasisLabels" }, - { typeof(EmphasisLabelLine), "m_EmphasisLabelLines" }, + { typeof(EmphasisStyle), "m_EmphasisStyles" }, + { typeof(BlurStyle), "m_BlurStyles" }, + { typeof(SelectStyle), "m_SelectStyles" }, }; [SerializeField][IgnoreDoc] private List m_Labels = new List(); @@ -25,9 +25,9 @@ namespace XCharts.Runtime [SerializeField][IgnoreDoc] private List m_LineArrows = new List(); [SerializeField][IgnoreDoc] private List m_AreaStyles = new List(); [SerializeField][IgnoreDoc] private List m_TitleStyles = new List(); - [SerializeField][IgnoreDoc] private List m_EmphasisItemStyles = new List(); - [SerializeField][IgnoreDoc] private List m_EmphasisLabels = new List(); - [SerializeField][IgnoreDoc] private List m_EmphasisLabelLines = new List(); + [SerializeField][IgnoreDoc] private List m_EmphasisStyles = new List(); + [SerializeField][IgnoreDoc] private List m_BlurStyles = new List(); + [SerializeField][IgnoreDoc] private List m_SelectStyles = new List(); /// /// The style of area. @@ -51,22 +51,25 @@ namespace XCharts.Runtime /// public LineArrow lineArrow { get { return m_LineArrows.Count > 0 ? m_LineArrows[0] : null; } } /// - /// 高亮的图形样式 - /// - public EmphasisItemStyle emphasisItemStyle { get { return m_EmphasisItemStyles.Count > 0 ? m_EmphasisItemStyles[0] : null; } } - /// - /// 高亮时的标签样式 - /// - public EmphasisLabelStyle emphasisLabel { get { return m_EmphasisLabels.Count > 0 ? m_EmphasisLabels[0] : null; } } - /// - /// 高亮时的标签引导线样式 - /// - public EmphasisLabelLine emphasisLabelLine { get { return m_EmphasisLabelLines.Count > 0 ? m_EmphasisLabelLines[0] : null; } } - /// /// the icon of data. /// |数据项标题样式。 /// public TitleStyle titleStyle { get { return m_TitleStyles.Count > 0 ? m_TitleStyles[0] : null; } } + /// + /// style of emphasis state. + /// |高亮状态的样式。 + /// + public EmphasisStyle emphasisStyle { get { return m_EmphasisStyles.Count > 0 ? m_EmphasisStyles[0] : null; } } + /// + /// style of blur state. + /// |淡出状态的样式。 + /// + public BlurStyle blurStyle { get { return m_BlurStyles.Count > 0 ? m_BlurStyles[0] : null; } } + /// + /// style of select state. + /// |选中状态的样式。 + /// + public SelectStyle selectStyle { get { return m_SelectStyles.Count > 0 ? m_SelectStyles[0] : null; } } public void RemoveAllExtraComponent() { diff --git a/Runtime/Serie/Serie.cs b/Runtime/Serie/Serie.cs index 245b8dca..3673ee8b 100644 --- a/Runtime/Serie/Serie.cs +++ b/Runtime/Serie/Serie.cs @@ -161,6 +161,39 @@ namespace XCharts.Runtime Right } + /// + /// Serie state. Supports normal, emphasis, blur, and select states. + /// |Serie状态。支持正常、高亮、淡出、选中四种状态。 + /// + public enum SerieState + { + /// + /// Normal state. + /// |正常状态。 + /// + Normal, + /// + /// Emphasis state. + /// |高亮状态。 + /// + Emphasis, + /// + /// Blur state. + /// |淡出状态。 + /// + Blur, + /// + /// Select state. + /// |选中状态。 + /// + Select, + /// + /// Auto state. + /// |自动保持和父节点一致。一般用在SerieData。 + /// + Auto + } + /// /// 系列。 /// @@ -172,6 +205,7 @@ namespace XCharts.Runtime [SerializeField] private string m_CoordSystem = "GridCoord"; [SerializeField] private string m_SerieType = ""; [SerializeField] private string m_SerieName; + [SerializeField][Since("v3.2.0")] private SerieState m_State = SerieState.Normal; [SerializeField] private string m_Stack; [SerializeField] private int m_XAxisIndex = 0; [SerializeField] private int m_YAxisIndex = 0; @@ -296,6 +330,15 @@ namespace XCharts.Runtime /// public string legendName { get { return string.IsNullOrEmpty(serieName) ? ChartCached.IntToStr(index) : serieName; } } /// + /// The default state of a serie. + /// |系列的默认状态。 + /// + public SerieState state + { + get { return m_State; } + set { if (PropertyUtil.SetStruct(ref m_State, value)) { SetAllDirty(); } } + } + /// /// If stack the value. On the same category axis, the series with the same stack name would be put on top of each other. /// |数据堆叠,同个类目轴上系列配置相同的stack值后,后一个系列的值会在前一个系列的值上相加。 /// @@ -826,12 +869,14 @@ namespace XCharts.Runtime symbol.vertsDirty || lineStyle.vertsDirty || itemStyle.vertsDirty || - (lineArrow != null && lineArrow.vertsDirty) || - (areaStyle != null && areaStyle.vertsDirty) || - (label != null && label.vertsDirty) || - (labelLine != null && labelLine.vertsDirty) || - (emphasisItemStyle != null && emphasisItemStyle.vertsDirty) || - (titleStyle != null && titleStyle.vertsDirty) || + IsVertsDirty(lineArrow) || + IsVertsDirty(areaStyle) || + IsVertsDirty(label) || + IsVertsDirty(labelLine) || + IsVertsDirty(titleStyle) || + IsVertsDirty(emphasisStyle) || + IsVertsDirty(blurStyle) || + IsVertsDirty(selectStyle) || AnySerieDataVerticesDirty(); } } @@ -842,11 +887,12 @@ namespace XCharts.Runtime { return m_ComponentDirty || symbol.componentDirty || - (titleStyle != null && titleStyle.componentDirty) || - (label != null && label.componentDirty) || - (labelLine != null && labelLine.componentDirty) || - (emphasisLabel != null && emphasisLabel.componentDirty) || - (emphasisLabelLine != null && emphasisLabelLine.componentDirty); + IsComponentDirty(titleStyle) || + IsComponentDirty(label) || + IsComponentDirty(labelLine) || + IsComponentDirty(emphasisStyle) || + IsComponentDirty(blurStyle) || + IsComponentDirty(selectStyle); } } public override void ClearVerticesDirty() @@ -860,16 +906,13 @@ namespace XCharts.Runtime symbol.ClearVerticesDirty(); lineStyle.ClearVerticesDirty(); itemStyle.ClearVerticesDirty(); - if (areaStyle != null) - areaStyle.ClearVerticesDirty(); - if (label != null) - label.ClearVerticesDirty(); - if (emphasisItemStyle != null) - emphasisItemStyle.ClearVerticesDirty(); - if (lineArrow != null) - lineArrow.ClearVerticesDirty(); - if (titleStyle != null) - titleStyle.ClearVerticesDirty(); + ClearVerticesDirty(areaStyle); + ClearVerticesDirty(label); + ClearVerticesDirty(emphasisStyle); + ClearVerticesDirty(blurStyle); + ClearVerticesDirty(selectStyle); + ClearVerticesDirty(lineArrow); + ClearVerticesDirty(titleStyle); } public override void ClearComponentDirty() @@ -883,18 +926,13 @@ namespace XCharts.Runtime symbol.ClearComponentDirty(); lineStyle.ClearComponentDirty(); itemStyle.ClearComponentDirty(); - if (areaStyle != null) - areaStyle.ClearComponentDirty(); - if (label != null) - label.ClearComponentDirty(); - if (emphasisLabel != null) - emphasisLabel.ClearComponentDirty(); - if (emphasisLabelLine != null) - emphasisLabelLine.ClearComponentDirty(); - if (lineArrow != null) - lineArrow.ClearComponentDirty(); - if (titleStyle != null) - titleStyle.ClearComponentDirty(); + ClearComponentDirty(areaStyle); + ClearComponentDirty(label); + ClearComponentDirty(emphasisStyle); + ClearComponentDirty(blurStyle); + ClearComponentDirty(selectStyle); + ClearComponentDirty(lineArrow); + ClearComponentDirty(titleStyle); } public override void SetAllDirty() diff --git a/Runtime/Serie/SerieContext.cs b/Runtime/Serie/SerieContext.cs index a458a528..f996821d 100644 --- a/Runtime/Serie/SerieContext.cs +++ b/Runtime/Serie/SerieContext.cs @@ -84,6 +84,10 @@ namespace XCharts.Runtime /// public int vertCount; /// + /// theme的颜色索引 + /// + public int colorIndex; + /// /// 数据对应的位置坐标。 /// public List dataPoints = new List(); @@ -97,10 +101,6 @@ namespace XCharts.Runtime public List sortedData = new List(); public List rootData = new List(); /// - /// theme的颜色索引 - /// - public int colorIndex; - /// /// 绘制点 /// public List drawPoints = new List(); diff --git a/Runtime/Serie/SerieData.cs b/Runtime/Serie/SerieData.cs index bfa99c19..b61a2653 100644 --- a/Runtime/Serie/SerieData.cs +++ b/Runtime/Serie/SerieData.cs @@ -18,7 +18,7 @@ namespace XCharts.Runtime "m_ParentId", "m_Ignore", "m_Selected", - "m_Radius" + "m_Radius", }; public static Dictionary extraComponentMap = new Dictionary { { typeof(ItemStyle), "m_ItemStyles" }, @@ -28,9 +28,9 @@ namespace XCharts.Runtime { typeof(LineStyle), "m_LineStyles" }, { typeof(AreaStyle), "m_AreaStyles" }, { typeof(TitleStyle), "m_TitleStyles" }, - { typeof(EmphasisItemStyle), "m_EmphasisItemStyles" }, - { typeof(EmphasisLabelStyle), "m_EmphasisLabels" }, - { typeof(EmphasisLabelLine), "m_EmphasisLabelLines" }, + { typeof(EmphasisStyle), "m_EmphasisStyles" }, + { typeof(BlurStyle), "m_BlurStyles" }, + { typeof(SelectStyle), "m_SelectStyles" }, }; [SerializeField] private int m_Index; @@ -40,6 +40,7 @@ namespace XCharts.Runtime [SerializeField] private bool m_Ignore; [SerializeField] private bool m_Selected; [SerializeField] private float m_Radius; + [SerializeField][Since("v3.2.0")] private SerieState m_State = SerieState.Auto; [SerializeField][IgnoreDoc] private List m_ItemStyles = new List(); [SerializeField][IgnoreDoc] private List m_Labels = new List(); [SerializeField][IgnoreDoc] private List m_LabelLines = new List(); @@ -47,9 +48,9 @@ namespace XCharts.Runtime [SerializeField][IgnoreDoc] private List m_LineStyles = new List(); [SerializeField][IgnoreDoc] private List m_AreaStyles = new List(); [SerializeField][IgnoreDoc] private List m_TitleStyles = new List(); - [SerializeField][IgnoreDoc] private List m_EmphasisItemStyles = new List(); - [SerializeField][IgnoreDoc] private List m_EmphasisLabels = new List(); - [SerializeField][IgnoreDoc] private List m_EmphasisLabelLines = new List(); + [SerializeField][IgnoreDoc] private List m_EmphasisStyles = new List(); + [SerializeField][IgnoreDoc] private List m_BlurStyles = new List(); + [SerializeField][IgnoreDoc] private List m_SelectStyles = new List(); [SerializeField] private List m_Data = new List(); [NonSerialized] public SerieDataContext context = new SerieDataContext(); @@ -97,6 +98,11 @@ namespace XCharts.Runtime /// public bool selected { get { return m_Selected; } set { m_Selected = value; } } /// + /// the state of serie data. + /// |数据项的默认状态。 + /// + public SerieState state { get { return m_State; } set { m_State = value; } } + /// /// 数据项图例名称。当数据项名称不为空时,图例名称即为系列名称;反之则为索引index。 /// /// @@ -119,17 +125,17 @@ namespace XCharts.Runtime public AreaStyle areaStyle { get { return m_AreaStyles.Count > 0 ? m_AreaStyles[0] : null; } } public TitleStyle titleStyle { get { return m_TitleStyles.Count > 0 ? m_TitleStyles[0] : null; } } /// - /// 高亮的图形样式 + /// 高亮状态的样式 /// - public EmphasisItemStyle emphasisItemStyle { get { return m_EmphasisItemStyles.Count > 0 ? m_EmphasisItemStyles[0] : null; } } + public EmphasisStyle emphasisStyle { get { return m_EmphasisStyles.Count > 0 ? m_EmphasisStyles[0] : null; } } /// - /// 高亮时的标签样式 + /// 淡出状态的样式。 /// - public EmphasisLabelStyle emphasisLabel { get { return m_EmphasisLabels.Count > 0 ? m_EmphasisLabels[0] : null; } } + public BlurStyle blurStyle { get { return m_BlurStyles.Count > 0 ? m_BlurStyles[0] : null; } } /// - /// 高亮时的标签引导线样式 + /// 选中状态的样式。 /// - public EmphasisLabelLine emphasisLabelLine { get { return m_EmphasisLabelLines.Count > 0 ? m_EmphasisLabelLines[0] : null; } } + public SelectStyle selectStyle { get { return m_SelectStyles.Count > 0 ? m_SelectStyles[0] : null; } } /// /// An arbitrary dimension data list of data item. @@ -152,12 +158,14 @@ namespace XCharts.Runtime get { return m_VertsDirty || - (labelLine != null && labelLine.vertsDirty) || - (itemStyle != null && itemStyle.vertsDirty) || - (symbol != null && symbol.vertsDirty) || - (lineStyle != null && lineStyle.vertsDirty) || - (areaStyle != null && areaStyle.vertsDirty) || - (emphasisItemStyle != null && emphasisItemStyle.vertsDirty); + IsVertsDirty(labelLine) || + IsVertsDirty(itemStyle) || + IsVertsDirty(symbol) || + IsVertsDirty(lineStyle) || + IsVertsDirty(areaStyle) || + IsVertsDirty(emphasisStyle) || + IsVertsDirty(blurStyle) || + IsVertsDirty(selectStyle); } } public override bool componentDirty @@ -165,35 +173,38 @@ namespace XCharts.Runtime get { return m_ComponentDirty || - (labelStyle != null && labelStyle.componentDirty) || - (labelLine != null && labelLine.componentDirty) || - (titleStyle != null && titleStyle.componentDirty) || - (emphasisLabel != null && emphasisLabel.componentDirty) || - (emphasisLabelLine != null && emphasisLabelLine.componentDirty); + IsComponentDirty(labelStyle) || + IsComponentDirty(labelLine) || + IsComponentDirty(titleStyle) || + IsComponentDirty(emphasisStyle) || + IsComponentDirty(blurStyle) || + IsComponentDirty(selectStyle); } } public override void ClearVerticesDirty() { base.ClearVerticesDirty(); - if (labelLine != null) labelLine.ClearVerticesDirty(); - if (itemStyle != null) itemStyle.ClearVerticesDirty(); - if (lineStyle != null) lineStyle.ClearVerticesDirty(); - if (areaStyle != null) areaStyle.ClearVerticesDirty(); - if (symbol != null) symbol.ClearVerticesDirty(); - if (emphasisItemStyle != null) emphasisItemStyle.ClearVerticesDirty(); + ClearVerticesDirty(labelLine); + ClearVerticesDirty(itemStyle); + ClearVerticesDirty(lineStyle); + ClearVerticesDirty(areaStyle); + ClearVerticesDirty(emphasisStyle); + ClearVerticesDirty(blurStyle); + ClearVerticesDirty(selectStyle); } public override void ClearComponentDirty() { base.ClearComponentDirty(); - if (labelLine != null) labelLine.ClearComponentDirty(); - if (itemStyle != null) itemStyle.ClearComponentDirty(); - if (lineStyle != null) lineStyle.ClearComponentDirty(); - if (areaStyle != null) areaStyle.ClearComponentDirty(); - if (symbol != null) symbol.ClearComponentDirty(); - if (emphasisLabel != null) emphasisLabel.ClearComponentDirty(); - if (emphasisLabelLine != null) emphasisLabelLine.ClearComponentDirty(); + ClearComponentDirty(labelLine); + ClearComponentDirty(itemStyle); + ClearComponentDirty(lineStyle); + ClearComponentDirty(areaStyle); + ClearComponentDirty(symbol); + ClearComponentDirty(emphasisStyle); + ClearComponentDirty(blurStyle); + ClearComponentDirty(selectStyle); } public void Reset() @@ -217,9 +228,9 @@ namespace XCharts.Runtime m_LineStyles.Clear(); m_AreaStyles.Clear(); m_TitleStyles.Clear(); - m_EmphasisItemStyles.Clear(); - m_EmphasisLabels.Clear(); - m_EmphasisLabelLines.Clear(); + m_EmphasisStyles.Clear(); + m_BlurStyles.Clear(); + m_SelectStyles.Clear(); } public T GetOrAddComponent() where T : ChildComponent, ISerieDataComponent @@ -247,23 +258,23 @@ namespace XCharts.Runtime m_LabelLines.Add(new LabelLine() { show = true }); return m_LabelLines[0]; } - else if (type == typeof(EmphasisItemStyle)) + else if (type == typeof(EmphasisStyle)) { - if (m_EmphasisItemStyles.Count == 0) - m_EmphasisItemStyles.Add(new EmphasisItemStyle() { show = true }); - return m_EmphasisItemStyles[0]; + if (m_EmphasisStyles.Count == 0) + m_EmphasisStyles.Add(new EmphasisStyle() { show = true }); + return m_EmphasisStyles[0]; } - else if (type == typeof(EmphasisLabelStyle)) + else if (type == typeof(BlurStyle)) { - if (m_EmphasisLabels.Count == 0) - m_EmphasisLabels.Add(new EmphasisLabelStyle() { show = true }); - return m_EmphasisLabels[0]; + if (m_BlurStyles.Count == 0) + m_BlurStyles.Add(new BlurStyle() { show = true }); + return m_BlurStyles[0]; } - else if (type == typeof(EmphasisLabelLine)) + else if (type == typeof(SelectStyle)) { - if (m_EmphasisLabelLines.Count == 0) - m_EmphasisLabelLines.Add(new EmphasisLabelLine() { show = true }); - return m_EmphasisLabelLines[0]; + if (m_SelectStyles.Count == 0) + m_SelectStyles.Add(new SelectStyle() { show = true }); + return m_SelectStyles[0]; } else if (type == typeof(SerieSymbol)) { @@ -301,9 +312,9 @@ namespace XCharts.Runtime m_Labels.Clear(); m_LabelLines.Clear(); m_Symbols.Clear(); - m_EmphasisItemStyles.Clear(); - m_EmphasisLabels.Clear(); - m_EmphasisLabelLines.Clear(); + m_EmphasisStyles.Clear(); + m_BlurStyles.Clear(); + m_SelectStyles.Clear(); m_LineStyles.Clear(); m_AreaStyles.Clear(); m_TitleStyles.Clear(); @@ -322,12 +333,12 @@ namespace XCharts.Runtime m_Labels.Clear(); else if (type == typeof(LabelLine)) m_LabelLines.Clear(); - else if (type == typeof(EmphasisItemStyle)) - m_EmphasisItemStyles.Clear(); - else if (type == typeof(EmphasisLabelStyle)) - m_EmphasisLabels.Clear(); - else if (type == typeof(EmphasisLabelLine)) - m_EmphasisLabelLines.Clear(); + else if (type == typeof(EmphasisStyle)) + m_EmphasisStyles.Clear(); + else if (type == typeof(BlurStyle)) + m_BlurStyles.Clear(); + else if (type == typeof(SelectStyle)) + m_SelectStyles.Clear(); else if (type == typeof(SerieSymbol)) m_Symbols.Clear(); else if (type == typeof(LineStyle)) diff --git a/Runtime/Serie/SerieHandler.cs b/Runtime/Serie/SerieHandler.cs index 6f0f8ed9..2053240d 100644 --- a/Runtime/Serie/SerieHandler.cs +++ b/Runtime/Serie/SerieHandler.cs @@ -240,11 +240,9 @@ namespace XCharts.Runtime if (count == -1) count = serie.dataCount; var serieLabel = SerieHelper.GetSerieLabel(serie, serieData); - if (serieLabel == null) + if (serieLabel == null || !serieLabel.show) { - serieLabel = SerieHelper.GetSerieEmphasisLabel(serie, serieData); - if (serieLabel == null || !serieLabel.show) - return false; + return false; } var dataAutoColor = GetSerieDataAutoColor(serieData); @@ -375,14 +373,10 @@ namespace XCharts.Runtime { if (serieData.labelObject == null && serieData.context.dataLabels.Count <= 0) continue; - var serieLabel = SerieHelper.GetSerieLabel(serie, serieData); - var emphasisLabel = SerieHelper.GetSerieEmphasisLabel(serie, serieData); - var isHighlight = (serieData.context.highlight && emphasisLabel != null && emphasisLabel.show); + var currLabel = SerieHelper.GetSerieLabel(serie, serieData); var isIgnore = serie.IsIgnoreIndex(serieData.index, defaultDimension); - var currLabel = isHighlight && emphasisLabel != null ? emphasisLabel : serieLabel; if (serie.show && currLabel != null && - (currLabel.show || isHighlight) && serieData.context.canShowLabel && !isIgnore) { @@ -396,7 +390,7 @@ namespace XCharts.Runtime var labelObject = serieData.context.dataLabels[i]; var value = serieData.GetCurrData(i, dataChangeDuration); var content = string.IsNullOrEmpty(currLabel.formatter) ? - ChartCached.NumberToStr(value, serieLabel.numericFormatter) : + ChartCached.NumberToStr(value, currLabel.numericFormatter) : SerieLabelHelper.GetFormatterContent(serie, serieData, value, total, currLabel, color); var offset = GetSerieDataLabelOffset(serieData, currLabel); @@ -418,7 +412,7 @@ namespace XCharts.Runtime var total = serie.GetDataTotal(defaultDimension, serieData); var color = chart.GetItemColor(serie, serieData); var content = string.IsNullOrEmpty(currLabel.formatter) ? - ChartCached.NumberToStr(value, serieLabel.numericFormatter) : + ChartCached.NumberToStr(value, currLabel.numericFormatter) : SerieLabelHelper.GetFormatterContent(serie, serieData, value, total, currLabel, color); serieData.SetLabelActive(!isIgnore); @@ -492,7 +486,9 @@ namespace XCharts.Runtime public virtual Color GetSerieDataAutoColor(SerieData serieData) { var colorIndex = serie.useDataNameForColor ? serieData.index : serie.index; - return (Color) SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, false, false); + Color32 color, toColor; + SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, colorIndex, SerieState.Normal, false); + return (Color) color; } protected void UpdateCoordSerieParams(ref List paramList, ref string title, @@ -522,7 +518,7 @@ namespace XCharts.Runtime param.dataCount = serie.dataCount; param.value = serieData.GetData(1); param.total = serie.yTotal; - param.color = SerieHelper.GetItemColor(serie, serieData, chart.theme, serie.context.colorIndex, false); + param.color = chart.GetItemColor(serie, serieData); param.marker = SerieHelper.GetItemMarker(serie, serieData, marker); param.itemFormatter = itemFormatter; param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter); @@ -554,6 +550,8 @@ namespace XCharts.Runtime return; var colorIndex = chart.GetLegendRealShowNameIndex(serieData.name); + Color32 color, toColor; + SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, colorIndex, SerieState.Normal); var param = serie.context.param; param.serieName = serie.serieName; @@ -564,7 +562,7 @@ namespace XCharts.Runtime param.dataCount = serie.dataCount; param.value = serieData.GetData(param.dimension); param.total = SerieHelper.GetMaxData(serie, dimension); - param.color = SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, false); + param.color = color; param.marker = SerieHelper.GetItemMarker(serie, serieData, marker); param.itemFormatter = itemFormatter; param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter); diff --git a/Runtime/Serie/SerieHelper.cs b/Runtime/Serie/SerieHelper.cs index 073326ff..4afbba1a 100644 --- a/Runtime/Serie/SerieHelper.cs +++ b/Runtime/Serie/SerieHelper.cs @@ -242,105 +242,150 @@ namespace XCharts.Runtime } } + public static SerieState GetSerieState(Serie serie) + { + if (serie.highlight || serie.context.pointerEnter) return SerieState.Emphasis; + return serie.state; + } + + public static SerieState GetSerieState(Serie serie, SerieData serieData) + { + if (serieData == null || serieData.state == SerieState.Auto) return GetSerieState(serie); + if (serieData.context.highlight) return SerieState.Emphasis; + return serieData.state; + } + public static Color32 GetItemBackgroundColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, - bool highlight, bool useDefault = true) + SerieState state = SerieState.Auto, bool useDefault = false) { var color = ChartConst.clearColor32; - if (highlight) - { - var itemStyleEmphasis = GetItemStyleEmphasis(serie, serieData); - if (itemStyleEmphasis != null && !ChartHelper.IsClearColor(itemStyleEmphasis.backgroundColor)) - { - color = itemStyleEmphasis.backgroundColor; - ChartHelper.SetColorOpacity(ref color, itemStyleEmphasis.opacity); - return color; - } - } - var itemStyle = GetItemStyle(serie, serieData); - if (!ChartHelper.IsClearColor(itemStyle.backgroundColor)) - { - color = itemStyle.backgroundColor; - if (highlight) color = ChartHelper.GetHighlightColor(color); - ChartHelper.SetColorOpacity(ref color, itemStyle.opacity); - return color; - } - else if (useDefault) + var stateStyle = GetStateStyle(serie, serieData, state); + if (stateStyle == null) + color = GetItemStyle(serie, serieData, SerieState.Normal).backgroundColor; + else + color = stateStyle.itemStyle.backgroundColor; + if (useDefault && ChartHelper.IsClearColor(color)) { color = theme.GetColor(index); - if (highlight) color = ChartHelper.GetHighlightColor(color); color.a = 50; - return color; } return color; } - public static Color32 GetItemColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight, bool opacity = true) + public static void GetItemColor(out Color32 color, out Color32 toColor, + Serie serie, SerieData serieData, ThemeStyle theme, SerieState state = SerieState.Auto) { - if (serie == null) - return ChartConst.clearColor32; - - ItemStyle itemStyle = null; - if (highlight) - itemStyle = GetItemStyleEmphasis(serie, serieData); - if (itemStyle == null) - itemStyle = GetItemStyle(serie, serieData); - - var color = ChartHelper.IsClearColor(itemStyle.color) ? - theme.GetColor(index) : - itemStyle.color; - - if (highlight) - color = ChartHelper.GetHighlightColor(color); - if (opacity) - ChartHelper.SetColorOpacity(ref color, itemStyle.opacity); - return color; - } - public static Color32 GetItemColor0(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight, Color32 defaultColor) - { - if (serie == null) - return ChartConst.clearColor32; - - ItemStyle itemStyle = null; - if (highlight) - itemStyle = GetItemStyleEmphasis(serie, serieData); - if (itemStyle == null) - itemStyle = GetItemStyle(serie, serieData); - - var color = ChartHelper.IsClearColor(itemStyle.color0) ? - defaultColor : - itemStyle.color0; - - if (highlight) - color = ChartHelper.GetHighlightColor(color); - - ChartHelper.SetColorOpacity(ref color, itemStyle.opacity); - return color; + GetItemColor(out color, out toColor, serie, serieData, theme, serie.context.colorIndex, state, true); } - public static Color32 GetItemToColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight, bool opacity = true) + public static void GetItemColor(out Color32 color, out Color32 toColor, + Serie serie, SerieData serieData, ThemeStyle theme, int index, SerieState state = SerieState.Auto, bool opacity = true) { - if (serie == null) - return ChartConst.clearColor32; - - ItemStyle itemStyle = null; - if (highlight) - itemStyle = GetItemStyleEmphasis(serie, serieData); - if (itemStyle == null) - itemStyle = GetItemStyle(serie, serieData); - - var color = itemStyle.toColor; - if (ChartHelper.IsClearColor(color)) + color = ColorUtil.clearColor32; + toColor = ColorUtil.clearColor32; + if (serie == null) return; + if (state == SerieState.Auto) state = GetSerieState(serie, serieData); + var stateStyle = GetStateStyle(serie, serieData, state); + if (stateStyle == null) { - color = ChartHelper.IsClearColor(itemStyle.color) ? - theme.GetColor(index) : - itemStyle.color; + 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); + switch (state) + { + case SerieState.Emphasis: + color = ChartHelper.GetHighlightColor(color); + toColor = ChartHelper.GetHighlightColor(toColor); + break; + case SerieState.Blur: + color = ChartHelper.GetBlurColor(color); + toColor = ChartHelper.GetBlurColor(toColor); + break; + case SerieState.Select: + color = ChartHelper.GetSelectColor(color); + toColor = ChartHelper.GetSelectColor(toColor); + break; + default: + break; + } } + 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); + } + } - if (highlight) - color = ChartHelper.GetHighlightColor(color); + public static void GetItemColor(out Color32 color, out Color32 toColor, out Color32 backgroundColor, + Serie serie, SerieData serieData, ThemeStyle theme, int index, SerieState state = SerieState.Auto, bool opacity = true) + { + color = ColorUtil.clearColor32; + toColor = ColorUtil.clearColor32; + backgroundColor = ColorUtil.clearColor32; + if (serie == null) return; + if (state == SerieState.Auto) state = GetSerieState(serie, serieData); + var stateStyle = GetStateStyle(serie, serieData, state); + if (stateStyle == null) + { + 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); + backgroundColor = style.backgroundColor; + switch (state) + { + case SerieState.Emphasis: + color = ChartHelper.GetHighlightColor(color); + toColor = ChartHelper.GetHighlightColor(toColor); + break; + case SerieState.Blur: + color = ChartHelper.GetBlurColor(color); + toColor = ChartHelper.GetBlurColor(toColor); + break; + case SerieState.Select: + color = ChartHelper.GetSelectColor(color); + toColor = ChartHelper.GetSelectColor(toColor); + break; + default: + break; + } + } + else + { + 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); + } + } - if (opacity) - ChartHelper.SetColorOpacity(ref color, itemStyle.opacity); + public static Color32 GetItemColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, SerieState state = SerieState.Auto, bool opacity = true) + { + var color = ColorUtil.clearColor32; + if (serie == null) return color; + if (state == SerieState.Auto) state = GetSerieState(serie, serieData); + var stateStyle = GetStateStyle(serie, serieData, state); + if (stateStyle == null || !stateStyle.itemStyle.show) + { + var style = GetItemStyle(serie, serieData); + GetColor(ref color, style.color, style.color, style.opacity, theme, index, opacity); + switch (state) + { + case SerieState.Emphasis: + color = ChartHelper.GetHighlightColor(color); + break; + case SerieState.Blur: + color = ChartHelper.GetBlurColor(color); + break; + case SerieState.Select: + color = ChartHelper.GetSelectColor(color); + break; + default: + break; + } + } + else + { + GetColor(ref color, stateStyle.itemStyle.color, stateStyle.itemStyle.color, stateStyle.itemStyle.opacity, theme, index, opacity); + } return color; } @@ -370,66 +415,32 @@ namespace XCharts.Runtime } } - public static ItemStyle GetItemStyle(Serie serie, SerieData serieData, bool highlight = false) + public static ItemStyle GetItemStyle(Serie serie, SerieData serieData, SerieState state = SerieState.Auto) { - if (highlight) + if (state == SerieState.Auto) state = GetSerieState(serie, serieData); + if (state == SerieState.Normal) { - var style = GetItemStyleEmphasis(serie, serieData); - if (style == null) return GetItemStyle(serie, serieData, false); - else return style; - } - else if (serie.IsPerformanceMode()) return serie.itemStyle; - else if (serieData != null && serieData.itemStyle != null) return serieData.itemStyle; - else return serie.itemStyle; - } - - public static ItemStyle GetItemStyleEmphasis(Serie serie, SerieData serieData) - { - if (!serie.IsPerformanceMode() && serieData != null && serieData.emphasisItemStyle != null && serieData.emphasisItemStyle.show) - return serieData.emphasisItemStyle; - else if (serie.emphasisItemStyle != null && serie.emphasisItemStyle.show) return serie.emphasisItemStyle; - else return null; - } - - public static LabelStyle GetSerieLabel(Serie serie, SerieData serieData, bool highlight = false) - { - if (serieData == null) return serie.label; - if (highlight) - { - if (!serie.IsPerformanceMode() && serieData.emphasisLabel != null && serieData.emphasisLabel.show) - return serieData.emphasisLabel; - else if (serie.emphasisLabel != null && serie.emphasisLabel.show) return serie.emphasisLabel; - else return serie.label; + return serieData != null && serieData.itemStyle != null? serieData.itemStyle : serie.itemStyle; } else { - if (!serie.IsPerformanceMode() && serieData.labelStyle != null) return serieData.labelStyle; - else return serie.label; + var stateStyle = GetStateStyle(serie, serieData, state); + return stateStyle == null?serie.itemStyle : stateStyle.itemStyle; } } - public static LabelStyle GetSerieEmphasisLabel(Serie serie, SerieData serieData) + public static LabelStyle GetSerieLabel(Serie serie, SerieData serieData, SerieState state = SerieState.Auto) { - if (!serie.IsPerformanceMode() && serieData.emphasisLabel != null && serieData.emphasisLabel.show) - return serieData.emphasisLabel; - else if (serie.emphasisLabel != null && serie.emphasisLabel.show) return serie.emphasisLabel; - else return null; + if (state == SerieState.Auto) state = GetSerieState(serie, serieData); + var stateStyle = GetStateStyle(serie, serieData, state); + return stateStyle == null?serie.label : stateStyle.label; } - public static LabelLine GetSerieLabelLine(Serie serie, SerieData serieData, bool highlight = false) + public static LabelLine GetSerieLabelLine(Serie serie, SerieData serieData, SerieState state = SerieState.Auto) { - if (highlight) - { - if (!serie.IsPerformanceMode() && serieData.emphasisLabelLine != null && serieData.emphasisLabelLine.show) - return serieData.emphasisLabelLine; - else if (serie.emphasisLabelLine != null && serie.emphasisLabelLine.show) return serie.emphasisLabelLine; - else return serie.labelLine; - } - else - { - if (!serie.IsPerformanceMode() && serieData.labelLine != null) return serieData.labelLine; - else return serie.labelLine; - } + if (state == SerieState.Auto) state = GetSerieState(serie, serieData); + var stateStyle = GetStateStyle(serie, serieData, state); + return stateStyle == null?serie.labelLine : stateStyle.labelLine; } public static SerieSymbol GetSerieSymbol(Serie serie, SerieData serieData) @@ -456,92 +467,139 @@ namespace XCharts.Runtime else return serie.titleStyle; } - public static Color32 GetAreaColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight) + public static EmphasisStyle GetEmphasisStyle(Serie serie, SerieData serieData) { - Color32 color = ChartConst.clearColor32; - var areaStyle = GetAreaStyle(serie, serieData); - if (areaStyle == null || !areaStyle.show) - return color; - if (!ChartHelper.IsClearColor(areaStyle.color)) color = areaStyle.color; - else if (!ChartHelper.IsClearColor(serie.itemStyle.color)) color = serie.itemStyle.color; - else color = theme.GetColor(index); - ChartHelper.SetColorOpacity(ref color, areaStyle.opacity); - if (highlight) - { - if (!ChartHelper.IsClearColor(areaStyle.highlightColor)) - color = areaStyle.highlightColor; - else - color = ChartHelper.GetHighlightColor(color); - } - return color; + if (serieData != null && serieData.emphasisStyle != null) return serieData.emphasisStyle; + else return serie.emphasisStyle; } - public static Color32 GetAreaToColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight) + public static BlurStyle GetBlurStyle(Serie serie, SerieData serieData) { - Color32 color = ChartConst.clearColor32; - var areaStyle = GetAreaStyle(serie, serieData); - if (areaStyle == null || !areaStyle.show) - return color; - if (!ChartHelper.IsClearColor(areaStyle.toColor)) color = areaStyle.toColor; - else if (!ChartHelper.IsClearColor(serie.itemStyle.toColor)) color = serie.itemStyle.toColor; - else color = theme.GetColor(index); - ChartHelper.SetColorOpacity(ref color, areaStyle.opacity); - if (highlight) - { - if (!ChartHelper.IsClearColor(areaStyle.highlightToColor)) - color = areaStyle.highlightToColor; - else - color = ChartHelper.GetHighlightColor(color); - } - return color; + if (serieData != null && serieData.blurStyle != null) return serieData.blurStyle; + else return serie.blurStyle; + } + public static SelectStyle GetSelectStyle(Serie serie, SerieData serieData) + { + if (serieData != null && serieData.selectStyle != null) return serieData.selectStyle; + else return serie.selectStyle; } - public static Color32 GetLineColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight) + public static StateStyle GetStateStyle(Serie serie, SerieData serieData, SerieState state) { - Color32 color = ChartConst.clearColor32; - var lineStyle = GetLineStyle(serie, serieData); - if (highlight) + switch (state) { - var itemStyleEmphasis = GetItemStyleEmphasis(serie, null); - if (itemStyleEmphasis != null && !ChartHelper.IsClearColor(itemStyleEmphasis.color)) + case SerieState.Emphasis: + return GetEmphasisStyle(serie, serieData); + case SerieState.Blur: + return GetBlurStyle(serie, serieData); + case SerieState.Select: + return GetSelectStyle(serie, serieData); + default: + return null; + } + } + + public static bool GetAreaColor(out Color32 color, out Color32 toColor, + Serie serie, SerieData serieData, ThemeStyle theme, int index) + { + color = ChartConst.clearColor32; + toColor = ChartConst.clearColor32; + var state = GetSerieState(serie, serieData); + var stateStyle = GetStateStyle(serie, serieData, state); + if (stateStyle == null) + { + var areaStyle = GetAreaStyle(serie, serieData); + if (areaStyle == null || !areaStyle.show) return false; + GetColor(ref color, areaStyle.color, serie.itemStyle.color, areaStyle.opacity, theme, index); + GetColor(ref toColor, areaStyle.toColor, color, areaStyle.opacity, theme, index); + switch (state) { - color = itemStyleEmphasis.color; - ChartHelper.SetColorOpacity(ref color, itemStyleEmphasis.opacity); - return color; + case SerieState.Emphasis: + color = ChartHelper.GetHighlightColor(color); + toColor = ChartHelper.GetHighlightColor(toColor); + break; + case SerieState.Blur: + color = ChartHelper.GetBlurColor(color); + toColor = ChartHelper.GetBlurColor(toColor); + break; + case SerieState.Select: + color = ChartHelper.GetSelectColor(color); + toColor = ChartHelper.GetSelectColor(toColor); + break; + default: + break; } } - if (!ChartHelper.IsClearColor(lineStyle.color)) color = lineStyle.color; - else if (!ChartHelper.IsClearColor(serie.itemStyle.color)) color = serie.itemStyle.GetColor(); - if (ChartHelper.IsClearColor(color)) color = theme.GetColor(index); - ChartHelper.SetColorOpacity(ref color, lineStyle.opacity); - if (highlight) color = ChartHelper.GetHighlightColor(color); - return color; + else + { + if (stateStyle.areaStyle.show) + { + GetColor(ref color, stateStyle.areaStyle.color, stateStyle.itemStyle.color, stateStyle.areaStyle.opacity, theme, index); + GetColor(ref color, stateStyle.areaStyle.toColor, color, stateStyle.areaStyle.opacity, theme, index); + } + else + { + return false; + } + } + return true; } - public static float GetSymbolBorder(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight) + public static Color32 GetLineColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, SerieState state = SerieState.Auto) { - var itemStyle = GetItemStyle(serie, serieData, highlight); + Color32 color = ChartConst.clearColor32; + if (state == SerieState.Auto) + state = GetSerieState(serie, serieData); + var stateStyle = GetStateStyle(serie, serieData, state); + if (stateStyle == null) + { + var lineStyle = GetLineStyle(serie, serieData); + GetColor(ref color, lineStyle.color, serie.itemStyle.color, lineStyle.opacity, theme, index); + switch (state) + { + case SerieState.Emphasis: + return ChartHelper.GetHighlightColor(color); + case SerieState.Blur: + return ChartHelper.GetBlurColor(color); + case SerieState.Select: + return ChartHelper.GetSelectColor(color); + default: + return color; + } + } + else + { + GetColor(ref color, stateStyle.lineStyle.color, stateStyle.itemStyle.color, stateStyle.lineStyle.opacity, theme, index); + return color; + } + } + + private static void GetColor(ref Color32 color, Color32 checkColor, Color32 itemColor, + float opacity, ThemeStyle theme, int colorIndex, bool setOpacity = true) + { + if (!ChartHelper.IsClearColor(checkColor)) color = checkColor; + else if (!ChartHelper.IsClearColor(itemColor)) color = itemColor; + if (ChartHelper.IsClearColor(color)) color = theme.GetColor(colorIndex); + if (setOpacity) ChartHelper.SetColorOpacity(ref color, opacity); + } + + public static float GetSymbolBorder(Serie serie, SerieData serieData, ThemeStyle theme, SerieState state = SerieState.Auto) + { + var itemStyle = GetItemStyle(serie, serieData, state); if (itemStyle != null && itemStyle.borderWidth != 0) return itemStyle.borderWidth; else return serie.lineStyle.GetWidth(theme.serie.lineWidth) * 2; } - public static Color32 GetSymbolBorderColor(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight) + public static Color32 GetSymbolBorderColor(Serie serie, SerieData serieData, ThemeStyle theme, SerieState state = SerieState.Auto) { - var itemStyle = GetItemStyle(serie, serieData, highlight); + var itemStyle = GetItemStyle(serie, serieData, state); if (itemStyle != null && !ChartHelper.IsClearColor(itemStyle.borderColor)) return itemStyle.borderColor; else return serie.itemStyle.borderColor; } - public static float GetSymbolBorder(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight, float defaultWidth) + public static float[] GetSymbolCornerRadius(Serie serie, SerieData serieData, SerieState state = SerieState.Auto) { - var itemStyle = GetItemStyle(serie, serieData, highlight); - if (itemStyle != null && itemStyle.borderWidth != 0) return itemStyle.borderWidth; - else return defaultWidth; - } - - public static float[] GetSymbolCornerRadius(Serie serie, SerieData serieData, bool highlight) - { - var itemStyle = GetItemStyle(serie, serieData, highlight); + var itemStyle = GetItemStyle(serie, serieData, state); if (itemStyle != null) return itemStyle.cornerRadius; else return null; } diff --git a/Runtime/Serie/SeriesHelper.cs b/Runtime/Serie/SeriesHelper.cs index 71da5b81..5b191d44 100644 --- a/Runtime/Serie/SeriesHelper.cs +++ b/Runtime/Serie/SeriesHelper.cs @@ -106,7 +106,9 @@ namespace XCharts.Runtime break; } } - return SerieHelper.GetItemColor(destSerie, destSerieData, chart.theme, index, false); + Color32 color, toColor; + SerieHelper.GetItemColor(out color, out toColor, destSerie, destSerieData, chart.theme, index, SerieState.Normal); + return color; } ///