mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-22 08:50:10 +00:00
[feature][AreaStyle] support innerFill
This commit is contained in:
@@ -37,6 +37,7 @@ namespace XCharts.Runtime
|
||||
[SerializeField] private Color32 m_Color;
|
||||
[SerializeField] private Color32 m_ToColor;
|
||||
[SerializeField][Range(0, 1)] private float m_Opacity = 0.6f;
|
||||
[SerializeField][Since("v3.2.0")] private bool m_InnerFill;
|
||||
|
||||
/// <summary>
|
||||
/// Set this to false to prevent the areafrom showing.
|
||||
@@ -83,6 +84,15 @@ namespace XCharts.Runtime
|
||||
get { return m_Opacity; }
|
||||
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()
|
||||
{
|
||||
|
||||
@@ -24,11 +24,17 @@ 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)
|
||||
{
|
||||
Color32 srcAreaColor, srcAreaToColor;
|
||||
if (!SerieHelper.GetAreaColor(out srcAreaColor, out srcAreaToColor, serie, null, theme, serie.context.colorIndex))
|
||||
Color32 areaColor, areaToColor;
|
||||
bool innerFill;
|
||||
if (!SerieHelper.GetAreaColor(out areaColor, out areaToColor, out innerFill, serie, null, theme, serie.context.colorIndex))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (innerFill)
|
||||
{
|
||||
UGL.DrawPolygon(vh, serie.context.dataPoints, areaColor);
|
||||
return;
|
||||
}
|
||||
var gridXY = (isY ? grid.context.x : grid.context.y);
|
||||
if (lastStackSerie == null)
|
||||
{
|
||||
@@ -36,8 +42,8 @@ namespace XCharts.Runtime
|
||||
gridXY + relativedAxis.context.offset,
|
||||
gridXY,
|
||||
gridXY + (isY ? grid.context.width : grid.context.height),
|
||||
srcAreaColor,
|
||||
srcAreaToColor,
|
||||
areaColor,
|
||||
areaToColor,
|
||||
visualMap,
|
||||
axis,
|
||||
relativedAxis,
|
||||
@@ -49,8 +55,8 @@ namespace XCharts.Runtime
|
||||
gridXY + relativedAxis.context.offset,
|
||||
gridXY,
|
||||
gridXY + (isY ? grid.context.width : grid.context.height),
|
||||
srcAreaColor,
|
||||
srcAreaToColor,
|
||||
areaColor,
|
||||
areaToColor,
|
||||
visualMap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -531,15 +531,24 @@ namespace XCharts.Runtime
|
||||
|
||||
public static bool GetAreaColor(out Color32 color, out Color32 toColor,
|
||||
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;
|
||||
toColor = ChartConst.clearColor32;
|
||||
innerFill = false;
|
||||
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;
|
||||
innerFill = areaStyle.innerFill;
|
||||
GetColor(ref color, areaStyle.color, serie.itemStyle.color, areaStyle.opacity, theme, index);
|
||||
GetColor(ref toColor, areaStyle.toColor, color, areaStyle.opacity, theme, index);
|
||||
switch (state)
|
||||
@@ -564,6 +573,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
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.toColor, color, stateStyle.areaStyle.opacity, theme, index);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user