[feature][AreaStyle] support innerFill

This commit is contained in:
monitor1394
2022-08-09 08:29:06 +08:00
parent d1f9c77571
commit f1f2ea78be
9 changed files with 42 additions and 11 deletions

View File

@@ -57,9 +57,9 @@
## master ## master
* (2022.08.09) 修复`Serie`的数据项索引异常引起的其他问题 * (2022.08.09) 增加`AreaStyle``innerFill`参数支持填充凸多边形
* (2022.08.08) 优化`Serie`的数据项索引维护,增加检测和修复功能 * (2022.08.08) 优化`Serie`的数据项索引维护,增加检测和修复功能,修复相关问题
* (2022.07.29) 修复在某些`Unity`版本导入后图表创建异常的问题 * (2022.07.29) 修复`Unity`版本兼容:在某些版本导入后图表创建异常的问题
* (2022.07.29) 增加`Axis``Time`时间轴时,支持次刻度和次分割线 * (2022.07.29) 增加`Axis``Time`时间轴时,支持次刻度和次分割线
* (2022.07.28) 优化`Radar`雷达图效果 * (2022.07.28) 优化`Radar`雷达图效果
* (2022.07.28) 增加`Serie``colorBy`参数配置取色策略 * (2022.07.28) 增加`Serie``colorBy`参数配置取色策略
@@ -69,7 +69,7 @@
* (2022.07.22) 增加`Serie`的三种状态`EmphasisStyle`,`BlurStyle`,`SelectStyle` * (2022.07.22) 增加`Serie`的三种状态`EmphasisStyle`,`BlurStyle`,`SelectStyle`
* (2022.07.22) 去掉`AreaStyle``highlightColor``highlightToColor`参数 * (2022.07.22) 去掉`AreaStyle``highlightColor``highlightToColor`参数
* (2022.07.22) 去掉`Emphasis`,`EmphasisItemStyle`,`EmphasisLabelStyle`,`EmphasisLabelLine`组件 * (2022.07.22) 去掉`Emphasis`,`EmphasisItemStyle`,`EmphasisLabelStyle`,`EmphasisLabelLine`组件
* (2022.07.20) 文档支持用`Since`标识类从哪个版本开始支持 * (2022.07.20) 增加`Since`特性对类的支持
* (2022.07.20) 修复`Axis``Value`轴时,`AxisLabel``showStartLabel``showEndLabel`参数设置不生效的问题 * (2022.07.20) 修复`Axis``Value`轴时,`AxisLabel``showStartLabel``showEndLabel`参数设置不生效的问题
* (2022.07.19) 增加`Axis``MinorSplitLine`设置坐标轴次分割线 * (2022.07.19) 增加`Axis``MinorSplitLine`设置坐标轴次分割线
* (2022.07.19) 增加`Axis``MinorTick`设置坐标轴次刻度 * (2022.07.19) 增加`Axis``MinorTick`设置坐标轴次刻度
@@ -107,7 +107,7 @@
* (2022.06.25) 修复`DataZoom`开启时`Tooltip`显示数据不一致的问题 (#203) * (2022.06.25) 修复`DataZoom`开启时`Tooltip`显示数据不一致的问题 (#203)
* (2022.06.25) 修复`Toolip`在类目轴无数据时绘制异常的问题 (#204) * (2022.06.25) 修复`Toolip`在类目轴无数据时绘制异常的问题 (#204)
* (2022.06.25) 优化`Serie`设置`PlaceHolder`时的`Tooltip`表现 * (2022.06.25) 优化`Serie`设置`PlaceHolder`时的`Tooltip`表现
* (2022.06.25) 增加`Since`标识配置参数从哪个版本开始支持 * (2022.06.25) 增加`Since`特效用于标识配置参数从哪个版本开始支持
* (2022.06.24) 优化`Painter`绘制层,`Top`层细分为`Upper``Top` * (2022.06.24) 优化`Painter`绘制层,`Top`层细分为`Upper``Top`
* (2022.06.24) 增加`Legend``Background``Padding`的支持 * (2022.06.24) 增加`Legend``Background``Padding`的支持
* (2022.06.21) 增加`TextStyle``TextMeshPro``Sprite Asset`支持 (#201) * (2022.06.21) 增加`TextStyle``TextMeshPro``Sprite Asset`支持 (#201)

View File

@@ -255,6 +255,7 @@ Inherits or Implemented: [BaseGraph](#BaseGraph),[ISerializationCallbackReceiver
| `RemoveSerie()` |public void RemoveSerie(Serie serie)</br> | | `RemoveSerie()` |public void RemoveSerie(Serie serie)</br> |
| `RemoveSerie()` |public void RemoveSerie(string serieName)</br> | | `RemoveSerie()` |public void RemoveSerie(string serieName)</br> |
| `ReplaceSerie()` |public bool ReplaceSerie(Serie oldSerie, Serie newSerie)</br> | | `ReplaceSerie()` |public bool ReplaceSerie(Serie oldSerie, Serie newSerie)</br> |
| `ResetDataIndex()` |public bool ResetDataIndex(int serieIndex)</br>重置serie的数据项索引。避免数据项索引异常。 |
| `SetBasePainterMaterial()` |public void SetBasePainterMaterial(Material material)</br>设置Base Painter的材质球 | | `SetBasePainterMaterial()` |public void SetBasePainterMaterial(Material material)</br>设置Base Painter的材质球 |
| `SetMaxCache()` |public void SetMaxCache(int maxCache)</br>设置可缓存的最大数据量。当数据量超过该值时,会自动删除第一个值再加入最新值。 | | `SetMaxCache()` |public void SetMaxCache(int maxCache)</br>设置可缓存的最大数据量。当数据量超过该值时,会自动删除第一个值再加入最新值。 |
| `SetPainterActive()` |public void SetPainterActive(int index, bool flag)</br> | | `SetPainterActive()` |public void SetPainterActive(int index, bool flag)</br> |

View File

@@ -255,6 +255,7 @@ Inherits or Implemented: [BaseGraph](#BaseGraph),[ISerializationCallbackReceiver
| `RemoveSerie()` |public void RemoveSerie(Serie serie)</br> | | `RemoveSerie()` |public void RemoveSerie(Serie serie)</br> |
| `RemoveSerie()` |public void RemoveSerie(string serieName)</br> | | `RemoveSerie()` |public void RemoveSerie(string serieName)</br> |
| `ReplaceSerie()` |public bool ReplaceSerie(Serie oldSerie, Serie newSerie)</br> | | `ReplaceSerie()` |public bool ReplaceSerie(Serie oldSerie, Serie newSerie)</br> |
| `ResetDataIndex()` |public bool ResetDataIndex(int serieIndex)</br>重置serie的数据项索引。避免数据项索引异常。 |
| `SetBasePainterMaterial()` |public void SetBasePainterMaterial(Material material)</br>设置Base Painter的材质球 | | `SetBasePainterMaterial()` |public void SetBasePainterMaterial(Material material)</br>设置Base Painter的材质球 |
| `SetMaxCache()` |public void SetMaxCache(int maxCache)</br>设置可缓存的最大数据量。当数据量超过该值时,会自动删除第一个值再加入最新值。 | | `SetMaxCache()` |public void SetMaxCache(int maxCache)</br>设置可缓存的最大数据量。当数据量超过该值时,会自动删除第一个值再加入最新值。 |
| `SetPainterActive()` |public void SetPainterActive(int index, bool flag)</br> | | `SetPainterActive()` |public void SetPainterActive(int index, bool flag)</br> |

View File

@@ -215,6 +215,7 @@ The style of area.
|`color`|||the color of area,default use serie color. |`color`|||the color of area,default use serie color.
|`toColor`|||Gradient color, start color to toColor. |`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. |`opacity`|0.6f||Opacity of the component. Supports value from 0 to 1, and the component will not be drawn when set to 0.
|`fill`|true|v3.2.0|Whether to fill only polygonal areas. Currently, only convex polygons are supported.
## `ArrowStyle` ## `ArrowStyle`

View File

@@ -215,6 +215,7 @@ Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieExtraComponent
|`color`|||区域填充的颜色如果toColor不是默认值则表示渐变色的起点颜色。 |`color`|||区域填充的颜色如果toColor不是默认值则表示渐变色的起点颜色。
|`toColor`|||渐变色的终点颜色。 |`toColor`|||渐变色的终点颜色。
|`opacity`|0.6f||图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。 |`opacity`|0.6f||图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
|`fill`|true|v3.2.0|是否只填充多边形区域。目前只支持凸多边形。
## `ArrowStyle` ## `ArrowStyle`

View File

@@ -18,6 +18,7 @@ namespace XCharts.Editor
PropertyField(prop, "m_Color"); PropertyField(prop, "m_Color");
PropertyField(prop, "m_ToColor"); PropertyField(prop, "m_ToColor");
PropertyField(prop, "m_Opacity"); PropertyField(prop, "m_Opacity");
PropertyField(prop, "m_InnerFill");
--EditorGUI.indentLevel; --EditorGUI.indentLevel;
} }
} }

View File

@@ -37,6 +37,7 @@ namespace XCharts.Runtime
[SerializeField] private Color32 m_Color; [SerializeField] private Color32 m_Color;
[SerializeField] private Color32 m_ToColor; [SerializeField] private Color32 m_ToColor;
[SerializeField][Range(0, 1)] private float m_Opacity = 0.6f; [SerializeField][Range(0, 1)] private float m_Opacity = 0.6f;
[SerializeField][Since("v3.2.0")] private bool m_InnerFill;
/// <summary> /// <summary>
/// Set this to false to prevent the areafrom showing. /// Set this to false to prevent the areafrom showing.
@@ -83,6 +84,15 @@ namespace XCharts.Runtime
get { return m_Opacity; } get { return m_Opacity; }
set { if (PropertyUtil.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); } set { if (PropertyUtil.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
} }
/// <summary>
/// Whether to fill only polygonal areas. Currently, only convex polygons are supported.
/// |是否只填充多边形区域。目前只支持凸多边形。
/// </summary>
public bool innerFill
{
get { return m_InnerFill; }
set { if (PropertyUtil.SetStruct(ref m_InnerFill, value)) SetVerticesDirty(); }
}
public Color32 GetColor() public Color32 GetColor()
{ {

View File

@@ -24,11 +24,17 @@ namespace XCharts.Runtime
public static void DrawSerieLineArea(VertexHelper vh, Serie serie, Serie lastStackSerie, public static void DrawSerieLineArea(VertexHelper vh, Serie serie, Serie lastStackSerie,
ThemeStyle theme, VisualMap visualMap, bool isY, Axis axis, Axis relativedAxis, GridCoord grid) ThemeStyle theme, VisualMap visualMap, bool isY, Axis axis, Axis relativedAxis, GridCoord grid)
{ {
Color32 srcAreaColor, srcAreaToColor; Color32 areaColor, areaToColor;
if (!SerieHelper.GetAreaColor(out srcAreaColor, out srcAreaToColor, serie, null, theme, serie.context.colorIndex)) bool innerFill;
if (!SerieHelper.GetAreaColor(out areaColor, out areaToColor, out innerFill, serie, null, theme, serie.context.colorIndex))
{ {
return; return;
} }
if (innerFill)
{
UGL.DrawPolygon(vh, serie.context.dataPoints, areaColor);
return;
}
var gridXY = (isY ? grid.context.x : grid.context.y); var gridXY = (isY ? grid.context.x : grid.context.y);
if (lastStackSerie == null) if (lastStackSerie == null)
{ {
@@ -36,8 +42,8 @@ namespace XCharts.Runtime
gridXY + relativedAxis.context.offset, gridXY + relativedAxis.context.offset,
gridXY, gridXY,
gridXY + (isY ? grid.context.width : grid.context.height), gridXY + (isY ? grid.context.width : grid.context.height),
srcAreaColor, areaColor,
srcAreaToColor, areaToColor,
visualMap, visualMap,
axis, axis,
relativedAxis, relativedAxis,
@@ -49,8 +55,8 @@ namespace XCharts.Runtime
gridXY + relativedAxis.context.offset, gridXY + relativedAxis.context.offset,
gridXY, gridXY,
gridXY + (isY ? grid.context.width : grid.context.height), gridXY + (isY ? grid.context.width : grid.context.height),
srcAreaColor, areaColor,
srcAreaToColor, areaToColor,
visualMap); visualMap);
} }
} }

View File

@@ -531,15 +531,24 @@ namespace XCharts.Runtime
public static bool GetAreaColor(out Color32 color, out Color32 toColor, public static bool GetAreaColor(out Color32 color, out Color32 toColor,
Serie serie, SerieData serieData, ThemeStyle theme, int index) Serie serie, SerieData serieData, ThemeStyle theme, int index)
{
bool fill;
return GetAreaColor(out color, out toColor, out fill,serie, serieData, theme, index);
}
public static bool GetAreaColor(out Color32 color, out Color32 toColor, out bool innerFill,
Serie serie, SerieData serieData, ThemeStyle theme, int index)
{ {
color = ChartConst.clearColor32; color = ChartConst.clearColor32;
toColor = ChartConst.clearColor32; toColor = ChartConst.clearColor32;
innerFill = false;
var state = GetSerieState(serie, serieData); var state = GetSerieState(serie, serieData);
var stateStyle = GetStateStyle(serie, serieData, state); var stateStyle = GetStateStyle(serie, serieData, state);
if (stateStyle == null) if (stateStyle == null)
{ {
var areaStyle = GetAreaStyle(serie, serieData); var areaStyle = GetAreaStyle(serie, serieData);
if (areaStyle == null || !areaStyle.show) return false; if (areaStyle == null || !areaStyle.show) return false;
innerFill = areaStyle.innerFill;
GetColor(ref color, areaStyle.color, serie.itemStyle.color, areaStyle.opacity, theme, index); GetColor(ref color, areaStyle.color, serie.itemStyle.color, areaStyle.opacity, theme, index);
GetColor(ref toColor, areaStyle.toColor, color, areaStyle.opacity, theme, index); GetColor(ref toColor, areaStyle.toColor, color, areaStyle.opacity, theme, index);
switch (state) switch (state)
@@ -564,6 +573,7 @@ namespace XCharts.Runtime
{ {
if (stateStyle.areaStyle.show) if (stateStyle.areaStyle.show)
{ {
innerFill = stateStyle.areaStyle.innerFill;
GetColor(ref color, stateStyle.areaStyle.color, stateStyle.itemStyle.color, stateStyle.areaStyle.opacity, theme, index); 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); GetColor(ref color, stateStyle.areaStyle.toColor, color, stateStyle.areaStyle.opacity, theme, index);
} }