[feature][serie] support EmphasisStle,BlurStyle and SelectStyle

This commit is contained in:
monitor1394
2022-07-25 07:46:03 +08:00
parent 8dde322c04
commit 4f93628667
61 changed files with 1052 additions and 758 deletions

View File

@@ -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;
/// <summary>
/// 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(); }
}
/// <summary>
/// the color of area,default use serie color.
/// |高亮时区域填充的颜色如果highlightToColor不是默认值则表示渐变色的起点颜色。
/// </summary>
public Color32 highlightColor
{
get { return m_HighlightColor; }
set { if (PropertyUtil.SetColor(ref m_HighlightColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// Gradient color, start highlightColor to highlightToColor.
/// |高亮时渐变色的终点颜色。
/// </summary>
public Color32 highlightToColor
{
get { return m_HighlightToColor; }
set { if (PropertyUtil.SetColor(ref m_HighlightToColor, value)) SetVerticesDirty(); }
}
public Color32 GetColor()
{

View File

@@ -1,11 +0,0 @@
using UnityEngine;
namespace XCharts.Runtime
{
/// <summary>
/// 高亮的图形样式
/// </summary>
[System.Serializable]
public class EmphasisItemStyle : ItemStyle, ISerieExtraComponent, ISerieDataComponent
{ }
}

View File

@@ -1,11 +0,0 @@
using UnityEngine;
namespace XCharts.Runtime
{
/// <summary>
/// 高亮的标签引导线样式
/// </summary>
[System.Serializable]
public class EmphasisLabelLine : LabelLine, ISerieExtraComponent, ISerieDataComponent
{ }
}

View File

@@ -1,11 +0,0 @@
using UnityEngine;
namespace XCharts.Runtime
{
/// <summary>
/// 高亮的标签样式
/// </summary>
[System.Serializable]
public class EmphasisLabelStyle : LabelStyle, ISerieExtraComponent, ISerieDataComponent
{ }
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 4cd4074bb11fc40059363dd78b9ee98d
guid: ca1088963feb54117bce8be6bceb64de
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@@ -0,0 +1,13 @@
using UnityEngine;
namespace XCharts.Runtime
{
/// <summary>
/// Configurations of blur state.
/// |淡出状态样式。
/// </summary>
[System.Serializable]
[Since("v3.2.0")]
public class BlurStyle : StateStyle, ISerieExtraComponent, ISerieDataComponent
{ }
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 3e025b0f4be6d4141aa08bdad0102aa7
guid: 4e3f901db80454f89800a84977289535
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,90 @@
using UnityEngine;
namespace XCharts.Runtime
{
/// <summary>
/// Configurations of emphasis state.
/// |高亮状态样式。
/// </summary>
[System.Serializable]
[Since("v3.2.0")]
public class EmphasisStyle : StateStyle, ISerieExtraComponent, ISerieDataComponent
{
/// <summary>
/// focus type.
/// |聚焦类型。
/// </summary>
public enum FocusType
{
/// <summary>
/// Do not fade out other data, it's by default.
/// |不淡出其它图形,默认使用该配置。
/// </summary>
None,
/// <summary>
/// Only focus (not fade out) the element of the currently highlighted data.
/// |只聚焦(不淡出)当前高亮的数据的图形。
/// </summary>
Self,
/// <summary>
/// Focus on all elements of the series which the currently highlighted data belongs to.
/// |聚焦当前高亮的数据所在的系列的所有图形。
/// </summary>
Series
}
/// <summary>
/// blur scope.
/// |淡出范围。
/// </summary>
public enum BlurScope
{
/// <summary>
/// coordinate system.
/// |淡出范围为坐标系,默认使用该配置。
/// </summary>
GridCoord,
/// <summary>
/// series.
/// |淡出范围为系列。
/// </summary>
Series,
/// <summary>
/// global.
/// |淡出范围为全局。
/// </summary>
Global
}
[SerializeField] private float m_Scale = 1.1f;
[SerializeField] private FocusType m_Focus = FocusType.None;
[SerializeField] private BlurScope m_BlurScope = BlurScope.GridCoord;
/// <summary>
/// Whether to scale to highlight the data in emphasis state.
/// |高亮时的缩放倍数。
/// </summary>
public float scale
{
get { return m_Scale; }
set { if (PropertyUtil.SetStruct(ref m_Scale, value)) SetVerticesDirty(); }
}
/// <summary>
/// When the data is highlighted, whether to fade out of other data to focus the highlighted.
/// |在高亮图形时,是否淡出其它数据的图形已达到聚焦的效果。
/// </summary>
public FocusType focus
{
get { return m_Focus; }
set { if (PropertyUtil.SetStruct(ref m_Focus, value)) SetVerticesDirty(); }
}
/// <summary>
/// The range of fade out when focus is enabled.
/// |在开启focus的时候可以通过blurScope配置淡出的范围。
/// </summary>
public BlurScope blurScope
{
get { return m_BlurScope; }
set { if (PropertyUtil.SetStruct(ref m_BlurScope, value)) SetVerticesDirty(); }
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 5d1095175540449f99bb9da27a5aaf04
guid: 91a31f424478042418811c32bb8aa2d5
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,13 @@
using UnityEngine;
namespace XCharts.Runtime
{
/// <summary>
/// Configurations of select state.
/// |选中状态样式。
/// </summary>
[System.Serializable]
[Since("v3.2.0")]
public class SelectStyle : StateStyle, ISerieExtraComponent, ISerieDataComponent
{ }
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 6e0b1690532674b24952a87e0aead6fa
guid: 986a9b6da6fdd48c49a9b665450dd605
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -3,15 +3,19 @@ using UnityEngine;
namespace XCharts.Runtime
{
/// <summary>
/// 高亮的图形样式和文本标签样式。
/// the state style of serie.
/// |Serie的状态样式。Serie的状态有正常高亮淡出选中四种状态。
/// </summary>
[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(); }
}
/// <summary>
/// 折线样式。
/// </summary>
public LineStyle lineStyle
{
get { return m_LineStyle; }
set { if (PropertyUtil.SetClass(ref m_LineStyle, value, true)) SetVerticesDirty(); }
}
/// <summary>
/// 区域样式。
/// </summary>
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();
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: a0d9ff3b8e09d464e9b5ea996b941314
guid: 921539f841914493a90f748c6c6662dc
MonoImporter:
externalObjects: {}
serializedVersion: 2