mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-25 18:30:14 +00:00
XCharts 2.0
This commit is contained in:
255
Runtime/Component/Theme/AxisTheme.cs
Normal file
255
Runtime/Component/Theme/AxisTheme.cs
Normal file
@@ -0,0 +1,255 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
#if dUI_TextMeshPro
|
||||
using TMPro;
|
||||
#endif
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
public class BaseAxisTheme : ComponentTheme
|
||||
{
|
||||
[SerializeField] protected LineStyle.Type m_LineType = LineStyle.Type.Solid;
|
||||
[SerializeField] protected float m_LineWidth = 1f;
|
||||
[SerializeField] protected float m_LineLength = 0f;
|
||||
[SerializeField] protected Color32 m_LineColor;
|
||||
[SerializeField] protected LineStyle.Type m_SplitLineType = LineStyle.Type.Dashed;
|
||||
[SerializeField] protected float m_SplitLineWidth = 1f;
|
||||
[SerializeField] protected float m_SplitLineLength = 0f;
|
||||
[SerializeField] protected Color32 m_SplitLineColor;
|
||||
[SerializeField] protected float m_TickWidth = 1f;
|
||||
[SerializeField] protected float m_TickLength = 5f;
|
||||
[SerializeField] protected Color32 m_TickColor;
|
||||
[SerializeField] protected List<Color32> m_SplitAreaColors = new List<Color32>();
|
||||
|
||||
/// <summary>
|
||||
/// the type of line.
|
||||
/// 坐标轴线类型。
|
||||
/// </summary>
|
||||
public LineStyle.Type lineType
|
||||
{
|
||||
get { return m_LineType; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineType, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the width of line.
|
||||
/// 坐标轴线宽。
|
||||
/// </summary>
|
||||
public float lineWidth
|
||||
{
|
||||
get { return m_LineWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the length of line.
|
||||
/// 坐标轴线长。
|
||||
/// </summary>
|
||||
public float lineLength
|
||||
{
|
||||
get { return m_LineLength; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineLength, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of line.
|
||||
/// 坐标轴线颜色。
|
||||
/// </summary>
|
||||
public Color32 lineColor
|
||||
{
|
||||
get { return m_LineColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_LineColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the type of split line.
|
||||
/// 分割线线类型。
|
||||
/// </summary>
|
||||
public LineStyle.Type splitLineType
|
||||
{
|
||||
get { return m_SplitLineType; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SplitLineType, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the width of split line.
|
||||
/// 分割线线宽。
|
||||
/// </summary>
|
||||
public float splitLineWidth
|
||||
{
|
||||
get { return m_SplitLineWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SplitLineWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the length of split line.
|
||||
/// 分割线线长。
|
||||
/// </summary>
|
||||
public float splitLineLength
|
||||
{
|
||||
get { return m_SplitLineLength; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SplitLineLength, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of line.
|
||||
/// 分割线线颜色。
|
||||
/// </summary>
|
||||
public Color32 splitLineColor
|
||||
{
|
||||
get { return m_SplitLineColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_SplitLineColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the length of tick.
|
||||
/// 刻度线线长。
|
||||
/// </summary>
|
||||
public float tickLength
|
||||
{
|
||||
get { return m_TickLength; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_TickLength, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the width of tick.
|
||||
/// 刻度线线宽。
|
||||
/// </summary>
|
||||
public float tickWidth
|
||||
{
|
||||
get { return m_TickWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_TickWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of tick.
|
||||
/// 坐标轴线颜色。
|
||||
/// </summary>
|
||||
public Color32 tickColor
|
||||
{
|
||||
get { return m_TickColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_TickColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public List<Color32> splitAreaColors
|
||||
{
|
||||
get { return m_SplitAreaColors; }
|
||||
set { if (value != null) { m_SplitAreaColors = value; SetVerticesDirty(); } }
|
||||
}
|
||||
|
||||
public BaseAxisTheme(Theme theme) : base(theme)
|
||||
{
|
||||
m_FontSize = XChartsSettings.fontSizeLv4;
|
||||
m_LineType = XChartsSettings.axisLineType;
|
||||
m_LineWidth = XChartsSettings.axisLineWidth;
|
||||
m_LineLength = 0;
|
||||
m_SplitLineType = XChartsSettings.axisSplitLineType;
|
||||
m_SplitLineWidth = XChartsSettings.axisSplitLineWidth;
|
||||
m_SplitLineLength = 0;
|
||||
m_TickWidth = XChartsSettings.axisTickWidth;
|
||||
m_TickLength = XChartsSettings.axisTickLength;
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.Default:
|
||||
m_LineColor = ColorUtil.GetColor("#514D4D");
|
||||
m_TickColor = ColorUtil.GetColor("#514D4D");
|
||||
m_SplitLineColor = ColorUtil.GetColor("#51515120");
|
||||
m_SplitAreaColors = new List<Color32>{
|
||||
new Color32(250,250,250,77),
|
||||
new Color32(200,200,200,77)
|
||||
};
|
||||
break;
|
||||
case Theme.Light:
|
||||
m_LineColor = ColorUtil.GetColor("#514D4D");
|
||||
m_TickColor = ColorUtil.GetColor("#514D4D");
|
||||
m_SplitLineColor = ColorUtil.GetColor("#51515120");
|
||||
m_SplitAreaColors = new List<Color32>{
|
||||
new Color32(250,250,250,77),
|
||||
new Color32(200,200,200,77)
|
||||
};
|
||||
break;
|
||||
case Theme.Dark:
|
||||
m_LineColor = ColorUtil.GetColor("#B9B8CE");
|
||||
m_TickColor = ColorUtil.GetColor("#B9B8CE");
|
||||
m_SplitLineColor = ColorUtil.GetColor("#484753");
|
||||
m_SplitAreaColors = new List<Color32>{
|
||||
new Color32(255,255,255,(byte)(0.02f * 255)),
|
||||
new Color32(255,255,255,(byte)(0.05f * 255))
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Copy(BaseAxisTheme theme)
|
||||
{
|
||||
base.Copy(theme);
|
||||
m_LineType = theme.lineType;
|
||||
m_LineWidth = theme.lineWidth;
|
||||
m_LineLength = theme.lineLength;
|
||||
m_LineColor = theme.lineColor;
|
||||
m_SplitLineType = theme.splitLineType;
|
||||
m_SplitLineWidth = theme.splitLineWidth;
|
||||
m_SplitLineLength = theme.splitLineLength;
|
||||
m_SplitLineColor = theme.splitLineColor;
|
||||
m_TickWidth = theme.tickWidth;
|
||||
m_TickLength = theme.tickLength;
|
||||
m_TickColor = theme.tickColor;
|
||||
ChartHelper.CopyList(m_SplitAreaColors, theme.splitAreaColors);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class AxisTheme : BaseAxisTheme
|
||||
{
|
||||
public AxisTheme(Theme theme) : base(theme)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class RadiusAxisTheme : BaseAxisTheme
|
||||
{
|
||||
public RadiusAxisTheme(Theme theme) : base(theme)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class AngleAxisTheme : BaseAxisTheme
|
||||
{
|
||||
public AngleAxisTheme(Theme theme) : base(theme)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class PolarAxisTheme : BaseAxisTheme
|
||||
{
|
||||
public PolarAxisTheme(Theme theme) : base(theme)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class RadarAxisTheme : BaseAxisTheme
|
||||
{
|
||||
public RadarAxisTheme(Theme theme) : base(theme)
|
||||
{
|
||||
m_SplitAreaColors.Clear();
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.Dark:
|
||||
m_SplitAreaColors.Add(ChartTheme.GetColor("#6f6f6f"));
|
||||
m_SplitAreaColors.Add(ChartTheme.GetColor("#606060"));
|
||||
break;
|
||||
case Theme.Default:
|
||||
m_SplitAreaColors.Add(ChartTheme.GetColor("#f6f6f6"));
|
||||
m_SplitAreaColors.Add(ChartTheme.GetColor("#e7e7e7"));
|
||||
break;
|
||||
case Theme.Light:
|
||||
m_SplitAreaColors.Add(ChartTheme.GetColor("#f6f6f6"));
|
||||
m_SplitAreaColors.Add(ChartTheme.GetColor("#e7e7e7"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Theme/AxisTheme.cs.meta
Normal file
11
Runtime/Component/Theme/AxisTheme.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aefd22e76a6f642c9985b1a29e389858
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
527
Runtime/Component/Theme/ChartTheme.cs
Normal file
527
Runtime/Component/Theme/ChartTheme.cs
Normal file
@@ -0,0 +1,527 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Text;
|
||||
#if dUI_TextMeshPro
|
||||
using TMPro;
|
||||
#endif
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// 主题
|
||||
/// </summary>
|
||||
public enum Theme
|
||||
{
|
||||
/// <summary>
|
||||
/// 默认主题。
|
||||
/// </summary>
|
||||
Default,
|
||||
/// <summary>
|
||||
/// 亮主题。
|
||||
/// </summary>
|
||||
Light,
|
||||
/// <summary>
|
||||
/// 暗主题。
|
||||
/// </summary>
|
||||
Dark,
|
||||
/// <summary>
|
||||
/// 自定义主题。
|
||||
/// </summary>
|
||||
Custom,
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
/// <summary>
|
||||
/// Theme.
|
||||
/// 主题相关配置。
|
||||
/// </summary>
|
||||
public class ChartTheme : ScriptableObject
|
||||
{
|
||||
[SerializeField] private Theme m_Theme = Theme.Default;
|
||||
[SerializeField] private string m_ThemeName = Theme.Default.ToString();
|
||||
[SerializeField] private Font m_Font;
|
||||
#if dUI_TextMeshPro
|
||||
[SerializeField] private TMP_FontAsset m_TMPFont;
|
||||
#endif
|
||||
|
||||
[SerializeField] private Color32 m_ContrastColor;
|
||||
[SerializeField] private Color32 m_BackgroundColor;
|
||||
|
||||
[SerializeField] private List<Color32> m_ColorPalette = new List<Color32>(13);
|
||||
|
||||
[SerializeField] private ComponentTheme m_Common;
|
||||
[SerializeField] private TitleTheme m_Title;
|
||||
[SerializeField] private SubTitleTheme m_SubTitle;
|
||||
[SerializeField] private LegendTheme m_Legend;
|
||||
[SerializeField] private AxisTheme m_Axis;
|
||||
[SerializeField] private RadiusAxisTheme m_RadiusAxis;
|
||||
[SerializeField] private AngleAxisTheme m_AngleAxis;
|
||||
[SerializeField] private PolarAxisTheme m_Polar;
|
||||
[SerializeField] private GaugeAxisTheme m_Gauge;
|
||||
[SerializeField] private RadarAxisTheme m_Radar;
|
||||
[SerializeField] private TooltipTheme m_Tooltip;
|
||||
[SerializeField] private DataZoomTheme m_DataZoom;
|
||||
[SerializeField] private VisualMapTheme m_VisualMap;
|
||||
[SerializeField] private SerieTheme m_Serie;
|
||||
|
||||
/// <summary>
|
||||
/// the theme of chart.
|
||||
/// 主题类型。
|
||||
/// </summary>
|
||||
public Theme theme
|
||||
{
|
||||
get { return m_Theme; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Theme, value)) SetComponentDirty(); }
|
||||
}
|
||||
public string themeName
|
||||
{
|
||||
get { return m_ThemeName; }
|
||||
set { if (PropertyUtil.SetClass(ref m_ThemeName, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// the contrast color of chart.
|
||||
/// 对比色。
|
||||
/// </summary>
|
||||
public Color32 contrastColor
|
||||
{
|
||||
get { return m_ContrastColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_ContrastColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the background color of chart.
|
||||
/// 背景颜色。
|
||||
/// </summary>
|
||||
public Color32 backgroundColor
|
||||
{
|
||||
get { return m_BackgroundColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The color list of palette. If no color is set in series, the colors would be adopted sequentially and circularly from this list as the colors of series.
|
||||
/// 调色盘颜色列表。如果系列没有设置颜色,则会依次循环从该列表中取颜色作为系列颜色。
|
||||
/// </summary>
|
||||
public List<Color32> colorPalette { get { return m_ColorPalette; } set { m_ColorPalette = value; SetVerticesDirty(); } }
|
||||
public ComponentTheme common { get { return m_Common; } set { m_Common = value; SetComponentDirty(); } }
|
||||
public TitleTheme title { get { return m_Title; } set { m_Title = value; SetComponentDirty(); } }
|
||||
public SubTitleTheme subTitle { get { return m_SubTitle; } set { m_SubTitle = value; SetComponentDirty(); } }
|
||||
public LegendTheme legend { get { return m_Legend; } set { m_Legend = value; SetComponentDirty(); } }
|
||||
public AxisTheme axis { get { return m_Axis; } set { m_Axis = value; SetAllDirty(); } }
|
||||
public RadiusAxisTheme radiusAxis { get { return m_RadiusAxis; } set { m_RadiusAxis = value; SetAllDirty(); } }
|
||||
public AngleAxisTheme angleAxis { get { return m_AngleAxis; } set { m_AngleAxis = value; SetAllDirty(); } }
|
||||
public PolarAxisTheme polar { get { return m_Polar; } set { m_Polar = value; SetAllDirty(); } }
|
||||
public GaugeAxisTheme gauge { get { return m_Gauge; } set { m_Gauge = value; SetAllDirty(); } }
|
||||
public RadarAxisTheme radar { get { return m_Radar; } set { m_Radar = value; SetAllDirty(); } }
|
||||
public TooltipTheme tooltip { get { return m_Tooltip; } set { m_Tooltip = value; SetAllDirty(); } }
|
||||
public DataZoomTheme dataZoom { get { return m_DataZoom; } set { m_DataZoom = value; SetAllDirty(); } }
|
||||
public VisualMapTheme visualMap { get { return m_VisualMap; } set { m_VisualMap = value; SetAllDirty(); } }
|
||||
public SerieTheme serie { get { return m_Serie; } set { m_Serie = value; SetVerticesDirty(); } }
|
||||
#if dUI_TextMeshPro
|
||||
/// <summary>
|
||||
/// the font of chart text。
|
||||
/// 字体。
|
||||
/// </summary>
|
||||
public TMP_FontAsset tmpFont
|
||||
{
|
||||
get { return m_TMPFont; }
|
||||
set
|
||||
{
|
||||
if (PropertyUtil.SetClass(ref m_TMPFont, value))
|
||||
{
|
||||
SetComponentDirty();
|
||||
SyncTMPFontToSubComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/// <summary>
|
||||
/// the font of chart text。
|
||||
/// 字体。
|
||||
/// </summary>
|
||||
public Font font
|
||||
{
|
||||
get { return m_Font; }
|
||||
set
|
||||
{
|
||||
if (PropertyUtil.SetClass(ref m_Font, value))
|
||||
{
|
||||
SetComponentDirty();
|
||||
SyncFontToSubComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[NonSerialized] protected bool m_VertsDirty;
|
||||
[NonSerialized] protected bool m_ComponentDirty;
|
||||
public virtual bool vertsDirty { get { return m_VertsDirty; } }
|
||||
public virtual bool componentDirty { get { return m_ComponentDirty; } }
|
||||
public bool anyDirty { get { return vertsDirty || componentDirty; } }
|
||||
|
||||
public void SetDefaultFont()
|
||||
{
|
||||
#if dUI_TextMeshPro
|
||||
tmpFont = XChartsSettings.tmpFont;
|
||||
SyncTMPFontToSubComponent();
|
||||
#else
|
||||
font = XChartsSettings.font;
|
||||
SyncFontToSubComponent();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the color of the specified index from the palette.
|
||||
/// 获得调色盘对应系列索引的颜色值。
|
||||
/// </summary>
|
||||
/// <param name="index">编号索引</param>
|
||||
/// <returns>the color,or Color.clear when failed.颜色值,失败时返回Color.clear</returns>
|
||||
public Color32 GetColor(int index)
|
||||
{
|
||||
if (index < 0) index = 0;
|
||||
var newIndex = index < m_ColorPalette.Count ? index : index % m_ColorPalette.Count;
|
||||
if (newIndex < m_ColorPalette.Count)
|
||||
return m_ColorPalette[newIndex];
|
||||
else return Color.clear;
|
||||
}
|
||||
|
||||
public void CheckWarning(StringBuilder sb)
|
||||
{
|
||||
#if dUI_TextMeshPro
|
||||
if (m_TMPFont == null)
|
||||
{
|
||||
sb.AppendFormat("warning:theme->tmpFont is null\n");
|
||||
}
|
||||
#else
|
||||
if (m_Font == null)
|
||||
{
|
||||
sb.AppendFormat("warning:theme->font is null\n");
|
||||
}
|
||||
#endif
|
||||
if (m_ColorPalette.Count == 0)
|
||||
{
|
||||
sb.AppendFormat("warning:theme->colorPalette is empty\n");
|
||||
}
|
||||
for (int i = 0; i < m_ColorPalette.Count; i++)
|
||||
{
|
||||
if (!ChartHelper.IsClearColor(m_ColorPalette[i]) && m_ColorPalette[i].a == 0)
|
||||
sb.AppendFormat("warning:theme->colorPalette[{0}] alpha = 0\n", i);
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary<int, string> _colorDic = new Dictionary<int, string>();
|
||||
/// <summary>
|
||||
/// Gets the hexadecimal color string of the specified index from the palette.
|
||||
/// 获得指定索引的十六进制颜色值字符串。
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public string GetColorStr(int index)
|
||||
{
|
||||
if (index < 0)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
index = index % m_ColorPalette.Count;
|
||||
if (_colorDic.ContainsKey(index)) return _colorDic[index];
|
||||
else
|
||||
{
|
||||
_colorDic[index] = ColorUtility.ToHtmlStringRGBA(GetColor(index));
|
||||
return _colorDic[index];
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyTheme(Theme theme)
|
||||
{
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.Dark:
|
||||
CopyTheme(ChartTheme.Dark);
|
||||
break;
|
||||
case Theme.Default:
|
||||
CopyTheme(ChartTheme.Default);
|
||||
break;
|
||||
case Theme.Light:
|
||||
CopyTheme(ChartTheme.Light);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// copy all configurations from theme.
|
||||
/// 复制主题的所有配置。
|
||||
/// </summary>
|
||||
/// <param name="theme"></param>
|
||||
public void CopyTheme(ChartTheme theme)
|
||||
{
|
||||
m_Theme = theme.theme;
|
||||
m_ThemeName = theme.themeName;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPFont = theme.tmpFont;
|
||||
#endif
|
||||
m_Font = theme.m_Font;
|
||||
m_ContrastColor = theme.contrastColor;
|
||||
m_BackgroundColor = theme.m_BackgroundColor;
|
||||
m_Common.Copy(theme.common);
|
||||
m_Legend.Copy(theme.m_Legend);
|
||||
m_Title.Copy(theme.m_Title);
|
||||
m_SubTitle.Copy(theme.m_SubTitle);
|
||||
m_Axis.Copy(theme.axis);
|
||||
m_RadiusAxis.Copy(theme.radiusAxis);
|
||||
m_AngleAxis.Copy(theme.angleAxis);
|
||||
m_Polar.Copy(theme.polar);
|
||||
m_Gauge.Copy(theme.gauge);
|
||||
m_Tooltip.Copy(theme.tooltip);
|
||||
m_DataZoom.Copy(theme.dataZoom);
|
||||
m_VisualMap.Copy(theme.visualMap);
|
||||
m_Serie.Copy(theme.serie);
|
||||
ChartHelper.CopyList(m_ColorPalette, theme.colorPalette);
|
||||
SetAllDirty();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear all custom configurations.
|
||||
/// 重置,清除所有自定义配置。
|
||||
/// </summary>
|
||||
public void ResetTheme()
|
||||
{
|
||||
switch (m_Theme)
|
||||
{
|
||||
case Theme.Default: CopyTheme(Default); break;
|
||||
case Theme.Light: CopyTheme(Light); break;
|
||||
case Theme.Dark: CopyTheme(Dark); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// default theme.
|
||||
/// 默认主题。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public static ChartTheme Default
|
||||
{
|
||||
get
|
||||
{
|
||||
var theme = ScriptableObject.CreateInstance<ChartTheme>();
|
||||
theme.theme = Theme.Default;
|
||||
theme.themeName = Theme.Default.ToString();
|
||||
theme.contrastColor = ColorUtil.GetColor("#514D4D");
|
||||
theme.backgroundColor = new Color32(255, 255, 255, 255);
|
||||
theme.colorPalette = new List<Color32>
|
||||
{
|
||||
new Color32(194, 53, 49, 255),
|
||||
new Color32(47, 69, 84, 255),
|
||||
new Color32(97, 160, 168, 255),
|
||||
new Color32(212, 130, 101, 255),
|
||||
new Color32(145, 199, 174, 255),
|
||||
new Color32(116, 159, 131, 255),
|
||||
new Color32(202, 134, 34, 255),
|
||||
new Color32(189, 162, 154, 255),
|
||||
new Color32(110, 112, 116, 255),
|
||||
new Color32(84, 101, 112, 255),
|
||||
new Color32(196, 204, 211, 255)
|
||||
};
|
||||
InitChartComponentTheme(theme);
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// light theme.
|
||||
/// 亮主题。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public static ChartTheme Light
|
||||
{
|
||||
get
|
||||
{
|
||||
var theme = ScriptableObject.CreateInstance<ChartTheme>();
|
||||
theme.theme = Theme.Light;
|
||||
theme.themeName = Theme.Light.ToString();
|
||||
theme.contrastColor = ColorUtil.GetColor("#514D4D");
|
||||
theme.backgroundColor = new Color32(255, 255, 255, 255);
|
||||
theme.colorPalette = new List<Color32>
|
||||
{
|
||||
ColorUtil.GetColor("#37A2DA"),
|
||||
ColorUtil.GetColor("#32C5E9"),
|
||||
ColorUtil.GetColor("#67E0E3"),
|
||||
ColorUtil.GetColor("#9FE6B8"),
|
||||
ColorUtil.GetColor("#FFDB5C"),
|
||||
ColorUtil.GetColor("#ff9f7f"),
|
||||
ColorUtil.GetColor("#fb7293"),
|
||||
ColorUtil.GetColor("#E062AE"),
|
||||
ColorUtil.GetColor("#E690D1"),
|
||||
ColorUtil.GetColor("#e7bcf3"),
|
||||
ColorUtil.GetColor("#9d96f5"),
|
||||
ColorUtil.GetColor("#8378EA"),
|
||||
ColorUtil.GetColor("#96BFFF"),
|
||||
};
|
||||
InitChartComponentTheme(theme);
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// dark theme.
|
||||
/// 暗主题。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public static ChartTheme Dark
|
||||
{
|
||||
get
|
||||
{
|
||||
var theme = ScriptableObject.CreateInstance<ChartTheme>();
|
||||
theme.name = Theme.Dark.ToString();
|
||||
theme.theme = Theme.Dark;
|
||||
theme.themeName = Theme.Dark.ToString();
|
||||
theme.contrastColor = ColorUtil.GetColor("#B9B8CE");
|
||||
theme.backgroundColor = ColorUtil.GetColor("#100C2A");
|
||||
theme.colorPalette = new List<Color32>
|
||||
{
|
||||
ColorUtil.GetColor("#4992ff"),
|
||||
ColorUtil.GetColor("#7cffb2"),
|
||||
ColorUtil.GetColor("#fddd60"),
|
||||
ColorUtil.GetColor("#ff6e76"),
|
||||
ColorUtil.GetColor("#58d9f9"),
|
||||
ColorUtil.GetColor("#05c091"),
|
||||
ColorUtil.GetColor("#ff8a45"),
|
||||
ColorUtil.GetColor("#8d48e3"),
|
||||
ColorUtil.GetColor("#dd79ff"),
|
||||
};
|
||||
InitChartComponentTheme(theme);
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
|
||||
public static ChartTheme EmptyTheme
|
||||
{
|
||||
get
|
||||
{
|
||||
var theme = ScriptableObject.CreateInstance<ChartTheme>();
|
||||
theme.name = Theme.Custom.ToString();
|
||||
theme.theme = Theme.Custom;
|
||||
theme.themeName = Theme.Custom.ToString();
|
||||
theme.contrastColor = Color.clear;
|
||||
theme.backgroundColor = Color.clear;
|
||||
theme.colorPalette = new List<Color32>();
|
||||
InitChartComponentTheme(theme);
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
|
||||
public void SyncFontToSubComponent()
|
||||
{
|
||||
common.font = font;
|
||||
title.font = font;
|
||||
subTitle.font = font;
|
||||
legend.font = font;
|
||||
axis.font = font;
|
||||
radiusAxis.font = font;
|
||||
angleAxis.font = font;
|
||||
polar.font = font;
|
||||
gauge.font = font;
|
||||
radar.font = font;
|
||||
tooltip.font = font;
|
||||
dataZoom.font = font;
|
||||
visualMap.font = font;
|
||||
}
|
||||
|
||||
#if dUI_TextMeshPro
|
||||
public void SyncTMPFontToSubComponent()
|
||||
{
|
||||
common.tmpFont = tmpFont;
|
||||
title.tmpFont = tmpFont;
|
||||
subTitle.tmpFont = tmpFont;
|
||||
legend.tmpFont = tmpFont;
|
||||
axis.tmpFont = tmpFont;
|
||||
radiusAxis.tmpFont = tmpFont;
|
||||
angleAxis.tmpFont = tmpFont;
|
||||
polar.tmpFont = tmpFont;
|
||||
gauge.tmpFont = tmpFont;
|
||||
radar.tmpFont = tmpFont;
|
||||
tooltip.tmpFont = tmpFont;
|
||||
dataZoom.tmpFont = tmpFont;
|
||||
visualMap.tmpFont = tmpFont;
|
||||
}
|
||||
#endif
|
||||
|
||||
private static void InitChartComponentTheme(ChartTheme theme)
|
||||
{
|
||||
theme.common = new ComponentTheme(theme.theme);
|
||||
theme.title = new TitleTheme(theme.theme);
|
||||
theme.subTitle = new SubTitleTheme(theme.theme);
|
||||
theme.legend = new LegendTheme(theme.theme);
|
||||
theme.axis = new AxisTheme(theme.theme);
|
||||
theme.radiusAxis = new RadiusAxisTheme(theme.theme);
|
||||
theme.angleAxis = new AngleAxisTheme(theme.theme);
|
||||
theme.polar = new PolarAxisTheme(theme.theme);
|
||||
theme.gauge = new GaugeAxisTheme(theme.theme);
|
||||
theme.radar = new RadarAxisTheme(theme.theme);
|
||||
theme.tooltip = new TooltipTheme(theme.theme);
|
||||
theme.dataZoom = new DataZoomTheme(theme.theme);
|
||||
theme.visualMap = new VisualMapTheme(theme.theme);
|
||||
theme.serie = new SerieTheme(theme.theme);
|
||||
theme.SetDefaultFont();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert the html string to color.
|
||||
/// 将字符串颜色值转成Color。
|
||||
/// </summary>
|
||||
/// <param name="hexColorStr"></param>
|
||||
/// <returns></returns>
|
||||
public static Color32 GetColor(string hexColorStr)
|
||||
{
|
||||
Color color;
|
||||
ColorUtility.TryParseHtmlString(hexColorStr, out color);
|
||||
return (Color32)color;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
internal virtual void SetVerticesDirty()
|
||||
{
|
||||
m_VertsDirty = true;
|
||||
}
|
||||
|
||||
internal virtual void ClearVerticesDirty()
|
||||
{
|
||||
m_VertsDirty = false;
|
||||
}
|
||||
|
||||
internal virtual void SetComponentDirty()
|
||||
{
|
||||
m_ComponentDirty = true;
|
||||
}
|
||||
|
||||
internal virtual void ClearComponentDirty()
|
||||
{
|
||||
m_ComponentDirty = false;
|
||||
}
|
||||
|
||||
public virtual void ClearDirty()
|
||||
{
|
||||
ClearVerticesDirty();
|
||||
ClearComponentDirty();
|
||||
}
|
||||
|
||||
public virtual void SetAllDirty()
|
||||
{
|
||||
SetVerticesDirty();
|
||||
SetComponentDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Theme/ChartTheme.cs.meta
Normal file
11
Runtime/Component/Theme/ChartTheme.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f28c6b3fb24d49afbe348cfadd0e1c7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
109
Runtime/Component/Theme/ComponentTheme.cs
Normal file
109
Runtime/Component/Theme/ComponentTheme.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
#if dUI_TextMeshPro
|
||||
using TMPro;
|
||||
#endif
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
public class ComponentTheme : MainComponent
|
||||
{
|
||||
[SerializeField] protected Font m_Font;
|
||||
[SerializeField] protected Color m_TextColor;
|
||||
[SerializeField] protected Color m_TextBackgroundColor;
|
||||
[SerializeField] protected int m_FontSize = 18;
|
||||
#if dUI_TextMeshPro
|
||||
[SerializeField] protected TMP_FontAsset m_TMPFont;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// the font of text。
|
||||
/// 字体。
|
||||
/// </summary>
|
||||
public Font font
|
||||
{
|
||||
get { return m_Font; }
|
||||
set { if (PropertyUtil.SetClass(ref m_Font, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of text.
|
||||
/// 文本颜色。
|
||||
/// </summary>
|
||||
public Color textColor
|
||||
{
|
||||
get { return m_TextColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_TextColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of text.
|
||||
/// 文本颜色。
|
||||
/// </summary>
|
||||
public Color textBackgroundColor
|
||||
{
|
||||
get { return m_TextBackgroundColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_TextBackgroundColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the font size of text.
|
||||
/// 文本字体大小。
|
||||
/// </summary>
|
||||
public int fontSize
|
||||
{
|
||||
get { return m_FontSize; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_FontSize, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
#if dUI_TextMeshPro
|
||||
/// <summary>
|
||||
/// the font of chart text。
|
||||
/// 字体。
|
||||
/// </summary>
|
||||
public TMP_FontAsset tmpFont
|
||||
{
|
||||
get { return m_TMPFont; }
|
||||
set { if (PropertyUtil.SetClass(ref m_TMPFont, value)) SetComponentDirty(); }
|
||||
}
|
||||
#endif
|
||||
|
||||
public ComponentTheme(Theme theme)
|
||||
{
|
||||
m_FontSize = XChartsSettings.fontSizeLv3;
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.Default:
|
||||
m_TextColor = ColorUtil.GetColor("#514D4D");
|
||||
break;
|
||||
case Theme.Light:
|
||||
m_TextColor = ColorUtil.GetColor("#514D4D");
|
||||
break;
|
||||
case Theme.Dark:
|
||||
m_TextColor = ColorUtil.GetColor("#B9B8CE");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Copy(ComponentTheme theme)
|
||||
{
|
||||
m_Font = theme.font;
|
||||
m_FontSize = theme.fontSize;
|
||||
m_TextColor = theme.textColor;
|
||||
m_TextBackgroundColor = theme.textBackgroundColor;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPFont = theme.tmpFont;
|
||||
#endif
|
||||
}
|
||||
|
||||
public virtual void Reset(ComponentTheme defaultTheme)
|
||||
{
|
||||
Copy(defaultTheme);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Theme/ComponentTheme.cs.meta
Normal file
11
Runtime/Component/Theme/ComponentTheme.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e78d1c80572324fc0b5cc5c935a2e34c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
132
Runtime/Component/Theme/DataZoomTheme.cs
Normal file
132
Runtime/Component/Theme/DataZoomTheme.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
public class DataZoomTheme : ComponentTheme
|
||||
{
|
||||
[SerializeField] protected float m_BorderWidth;
|
||||
[SerializeField] protected float m_DataLineWidth;
|
||||
[SerializeField] protected Color32 m_FillerColor;
|
||||
[SerializeField] protected Color32 m_BorderColor;
|
||||
[SerializeField] protected Color32 m_DataLineColor;
|
||||
[SerializeField] protected Color32 m_DataAreaColor;
|
||||
[SerializeField] protected Color32 m_BackgroundColor;
|
||||
|
||||
/// <summary>
|
||||
/// the width of border line.
|
||||
/// 边框线宽。
|
||||
/// </summary>
|
||||
public float borderWidth
|
||||
{
|
||||
get { return m_BorderWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the width of data line.
|
||||
/// 数据阴影线宽。
|
||||
/// </summary>
|
||||
public float dataLineWidth
|
||||
{
|
||||
get { return m_DataLineWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_DataLineWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of dataZoom data area.
|
||||
/// 数据区域颜色。
|
||||
/// </summary>
|
||||
public Color32 fillerColor
|
||||
{
|
||||
get { return m_FillerColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_FillerColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the color of dataZoom border.
|
||||
/// 边框颜色。
|
||||
/// </summary>
|
||||
public Color32 borderColor
|
||||
{
|
||||
get { return m_BorderColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BorderColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of data area line.
|
||||
/// 数据阴影的线条颜色。
|
||||
/// </summary>
|
||||
public Color32 dataLineColor
|
||||
{
|
||||
get { return m_DataLineColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_DataLineColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of data area line.
|
||||
/// 数据阴影的填充颜色。
|
||||
/// </summary>
|
||||
public Color32 dataAreaColor
|
||||
{
|
||||
get { return m_DataAreaColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_DataAreaColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the background color of datazoom.
|
||||
/// 背景颜色。
|
||||
/// </summary>
|
||||
public Color32 backgroundColor
|
||||
{
|
||||
get { return m_BackgroundColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
public DataZoomTheme(Theme theme) : base(theme)
|
||||
{
|
||||
m_BorderWidth = XChartsSettings.dataZoomBorderWidth;
|
||||
m_DataLineWidth = XChartsSettings.dataZoomDataLineWidth;
|
||||
m_BackgroundColor = Color.clear;
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.Default:
|
||||
m_TextColor = ColorUtil.GetColor("#333");
|
||||
m_FillerColor = new Color32(167, 183, 204, 110);
|
||||
m_BorderColor = ColorUtil.GetColor("#ddd");
|
||||
m_DataLineColor = ColorUtil.GetColor("#2f4554");
|
||||
m_DataAreaColor = new Color32(47, 69, 84, 85);
|
||||
break;
|
||||
case Theme.Light:
|
||||
m_TextColor = ColorUtil.GetColor("#333");
|
||||
m_FillerColor = new Color32(167, 183, 204, 110);
|
||||
m_BorderColor = ColorUtil.GetColor("#ddd");
|
||||
m_DataLineColor = ColorUtil.GetColor("#2f4554");
|
||||
m_DataAreaColor = new Color32(47, 69, 84, 85);
|
||||
break;
|
||||
case Theme.Dark:
|
||||
m_TextColor = ColorUtil.GetColor("#B9B8CE");
|
||||
m_FillerColor = new Color32(135, 163, 206, (byte)(0.2f * 255));
|
||||
m_BorderColor = ColorUtil.GetColor("#71708A");
|
||||
m_DataLineColor = ColorUtil.GetColor("#71708A");
|
||||
m_DataAreaColor = ColorUtil.GetColor("#71708A");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Copy(DataZoomTheme theme)
|
||||
{
|
||||
base.Copy(theme);
|
||||
m_BorderWidth = theme.borderWidth;
|
||||
m_DataLineWidth = theme.dataLineWidth;
|
||||
m_FillerColor = theme.fillerColor;
|
||||
m_BorderColor = theme.borderColor;
|
||||
m_DataLineColor = theme.dataLineColor;
|
||||
m_DataAreaColor = theme.dataAreaColor;
|
||||
m_BackgroundColor = theme.backgroundColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Theme/DataZoomTheme.cs.meta
Normal file
11
Runtime/Component/Theme/DataZoomTheme.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba535ef75742b4825b3cc2be4df6716f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
83
Runtime/Component/Theme/GaugeAxisTheme.cs
Normal file
83
Runtime/Component/Theme/GaugeAxisTheme.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
public class GaugeAxisTheme : BaseAxisTheme
|
||||
{
|
||||
[SerializeField] private Color32 m_BarBackgroundColor;
|
||||
[SerializeField]
|
||||
private List<StageColor> m_StageColor = new List<StageColor>()
|
||||
{
|
||||
new StageColor(0.2f,new Color32(145,199,174,255)),
|
||||
new StageColor(0.8f,new Color32(99,134,158,255)),
|
||||
new StageColor(1.0f,new Color32(194,53,49,255)),
|
||||
};
|
||||
/// <summary>
|
||||
/// 进度条背景颜色。
|
||||
/// </summary>
|
||||
public Color32 barBackgroundColor { get { return m_BarBackgroundColor; } set { m_BarBackgroundColor = value; } }
|
||||
/// <summary>
|
||||
/// 阶段颜色。
|
||||
/// </summary>
|
||||
public List<StageColor> stageColor { get { return m_StageColor; } set { m_StageColor = value; } }
|
||||
|
||||
public GaugeAxisTheme(Theme theme) : base(theme)
|
||||
{
|
||||
m_LineWidth = XChartsSettings.gaugeAxisLineWidth;
|
||||
m_LineLength = 0;
|
||||
m_SplitLineWidth = XChartsSettings.gaugeAxisSplitLineWidth;
|
||||
m_SplitLineLength = XChartsSettings.gaugeAxisSplitLineLength;
|
||||
m_TickWidth = XChartsSettings.gaugeAxisTickWidth;
|
||||
m_TickLength = XChartsSettings.gaugeAxisTickLength;
|
||||
m_SplitLineColor = Color.white;
|
||||
m_TickColor = Color.white;
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.Default:
|
||||
m_BarBackgroundColor = new Color32(200, 200, 200, 255);
|
||||
m_StageColor = new List<StageColor>()
|
||||
{
|
||||
new StageColor(0.2f,new Color32(145,199,174,255)),
|
||||
new StageColor(0.8f,new Color32(99,134,158,255)),
|
||||
new StageColor(1.0f,new Color32(194,53,49,255)),
|
||||
};
|
||||
break;
|
||||
case Theme.Light:
|
||||
m_BarBackgroundColor = new Color32(200, 200, 200, 255);
|
||||
m_StageColor = new List<StageColor>()
|
||||
{
|
||||
new StageColor(0.2f,new Color32(145,199,174,255)),
|
||||
new StageColor(0.8f,new Color32(99,134,158,255)),
|
||||
new StageColor(1.0f,new Color32(194,53,49,255)),
|
||||
};
|
||||
break;
|
||||
case Theme.Dark:
|
||||
m_BarBackgroundColor = new Color32(200, 200, 200, 255);
|
||||
m_StageColor = new List<StageColor>()
|
||||
{
|
||||
new StageColor(0.2f,new Color32(145,199,174,255)),
|
||||
new StageColor(0.8f,new Color32(99,134,158,255)),
|
||||
new StageColor(1.0f,new Color32(194,53,49,255)),
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Copy(GaugeAxisTheme theme)
|
||||
{
|
||||
base.Copy(theme);
|
||||
m_BarBackgroundColor = theme.barBackgroundColor;
|
||||
ChartHelper.CopyList(m_StageColor, theme.stageColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Theme/GaugeAxisTheme.cs.meta
Normal file
11
Runtime/Component/Theme/GaugeAxisTheme.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b38e4b45ec20b4c65a6dc82891c5c39a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
43
Runtime/Component/Theme/LegendTheme.cs
Normal file
43
Runtime/Component/Theme/LegendTheme.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
#if dUI_TextMeshPro
|
||||
using TMPro;
|
||||
#endif
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
public class LegendTheme : ComponentTheme
|
||||
{
|
||||
[SerializeField] protected Color m_UnableColor;
|
||||
|
||||
/// <summary>
|
||||
/// the color of text.
|
||||
/// 文本颜色。
|
||||
/// </summary>
|
||||
public Color unableColor
|
||||
{
|
||||
get { return m_UnableColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_UnableColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
public void Copy(LegendTheme theme)
|
||||
{
|
||||
base.Copy(theme);
|
||||
m_UnableColor = theme.unableColor;
|
||||
}
|
||||
|
||||
public LegendTheme(Theme theme) : base(theme)
|
||||
{
|
||||
m_UnableColor = ColorUtil.GetColor("#cccccc");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Theme/LegendTheme.cs.meta
Normal file
11
Runtime/Component/Theme/LegendTheme.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a86fb06a6b71c4735b87769ee0708293
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
93
Runtime/Component/Theme/SerieTheme.cs
Normal file
93
Runtime/Component/Theme/SerieTheme.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
public class SerieTheme : MainComponent
|
||||
{
|
||||
[SerializeField] protected float m_LineWidth;
|
||||
[SerializeField] protected float m_LineSymbolSize;
|
||||
[SerializeField] protected float m_LineSymbolSelectedSize;
|
||||
[SerializeField] protected float m_ScatterSymbolSize;
|
||||
[SerializeField] protected float m_ScatterSymbolSelectedSize;
|
||||
[SerializeField] protected float m_PieTooltipExtraRadius;
|
||||
[SerializeField] protected float m_PieSelectedOffset;
|
||||
|
||||
/// <summary>
|
||||
/// the color of text.
|
||||
/// 文本颜色。
|
||||
/// </summary>
|
||||
public float lineWidth
|
||||
{
|
||||
get { return m_LineWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
public float lineSymbolSize
|
||||
{
|
||||
get { return m_LineSymbolSize; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineSymbolSize, value)) SetVerticesDirty(); }
|
||||
}
|
||||
public float lineSymbolSelectedSize
|
||||
{
|
||||
get { return m_LineSymbolSelectedSize; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineSymbolSelectedSize, value)) SetVerticesDirty(); }
|
||||
}
|
||||
public float scatterSymbolSize
|
||||
{
|
||||
get { return m_ScatterSymbolSize; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ScatterSymbolSize, value)) SetVerticesDirty(); }
|
||||
}
|
||||
public float scatterSymbolSelectedSize
|
||||
{
|
||||
get { return m_ScatterSymbolSelectedSize; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ScatterSymbolSelectedSize, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 饼图鼠标移到高亮时的额外半径
|
||||
/// </summary>
|
||||
public float pieTooltipExtraRadius
|
||||
{
|
||||
get { return m_PieTooltipExtraRadius; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_PieTooltipExtraRadius, value < 0 ? 0f : value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 饼图选中时的中心点偏移
|
||||
/// </summary>
|
||||
public float pieSelectedOffset
|
||||
{
|
||||
get { return m_PieSelectedOffset; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_PieSelectedOffset, value < 0 ? 0f : value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public void Copy(SerieTheme theme)
|
||||
{
|
||||
m_LineWidth = theme.lineWidth;
|
||||
m_LineSymbolSize = theme.lineSymbolSize;
|
||||
m_LineSymbolSelectedSize = theme.lineSymbolSelectedSize;
|
||||
m_ScatterSymbolSize = theme.scatterSymbolSize;
|
||||
m_ScatterSymbolSelectedSize = theme.scatterSymbolSelectedSize;
|
||||
m_PieTooltipExtraRadius = theme.pieTooltipExtraRadius;
|
||||
m_PieSelectedOffset = theme.pieSelectedOffset;
|
||||
}
|
||||
|
||||
public SerieTheme(Theme theme)
|
||||
{
|
||||
m_LineWidth = XChartsSettings.serieLineWidth;
|
||||
m_LineSymbolSize = XChartsSettings.serieLineSymbolSize;
|
||||
m_LineSymbolSelectedSize = XChartsSettings.serieLineSymbolSelectedSize;
|
||||
m_ScatterSymbolSize = XChartsSettings.serieScatterSymbolSize;
|
||||
m_ScatterSymbolSelectedSize = XChartsSettings.serieScatterSymbolSelectedSize;
|
||||
m_PieTooltipExtraRadius = XChartsSettings.pieTooltipExtraRadius;
|
||||
m_PieSelectedOffset = XChartsSettings.pieSelectedOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Theme/SerieTheme.cs.meta
Normal file
11
Runtime/Component/Theme/SerieTheme.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9030b0e4afb164967b4991247947b195
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
32
Runtime/Component/Theme/SubTitleTheme.cs
Normal file
32
Runtime/Component/Theme/SubTitleTheme.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
public class SubTitleTheme : ComponentTheme
|
||||
{
|
||||
public SubTitleTheme(Theme theme) : base(theme)
|
||||
{
|
||||
m_FontSize = XChartsSettings.fontSizeLv2;
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.Default:
|
||||
m_TextColor = ColorUtil.GetColor("#969696");
|
||||
break;
|
||||
case Theme.Light:
|
||||
m_TextColor = ColorUtil.GetColor("#969696");
|
||||
break;
|
||||
case Theme.Dark:
|
||||
m_TextColor = ColorUtil.GetColor("#B9B8CE");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Theme/SubTitleTheme.cs.meta
Normal file
11
Runtime/Component/Theme/SubTitleTheme.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c642293f2d6674cbb85d1f081b9d89e8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
31
Runtime/Component/Theme/TitleTheme.cs
Normal file
31
Runtime/Component/Theme/TitleTheme.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
public class TitleTheme : ComponentTheme
|
||||
{
|
||||
public TitleTheme(Theme theme) : base(theme)
|
||||
{
|
||||
m_FontSize = XChartsSettings.fontSizeLv1;
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.Default:
|
||||
m_TextColor = ColorUtil.GetColor("#514D4D");
|
||||
break;
|
||||
case Theme.Light:
|
||||
break;
|
||||
case Theme.Dark:
|
||||
m_TextColor = ColorUtil.GetColor("#EEF1FA");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Theme/TitleTheme.cs.meta
Normal file
11
Runtime/Component/Theme/TitleTheme.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6649bc33964624c14a13ce34dd7eae77
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
123
Runtime/Component/Theme/TooltipTheme.cs
Normal file
123
Runtime/Component/Theme/TooltipTheme.cs
Normal file
@@ -0,0 +1,123 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
public class TooltipTheme : ComponentTheme
|
||||
{
|
||||
[SerializeField] protected LineStyle.Type m_LineType = LineStyle.Type.Solid;
|
||||
[SerializeField] protected float m_LineWidth = 1f;
|
||||
[SerializeField] protected Color32 m_LineColor;
|
||||
[SerializeField] protected Color32 m_AreaColor;
|
||||
[SerializeField] protected Color32 m_LabelTextColor;
|
||||
[SerializeField] protected Color32 m_LabelBackgroundColor;
|
||||
|
||||
/// <summary>
|
||||
/// the type of line.
|
||||
/// 坐标轴线类型。
|
||||
/// </summary>
|
||||
public LineStyle.Type lineType
|
||||
{
|
||||
get { return m_LineType; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineType, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the width of line.
|
||||
/// 指示线线宽。
|
||||
/// </summary>
|
||||
public float lineWidth
|
||||
{
|
||||
get { return m_LineWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of line.
|
||||
/// 指示线颜色。
|
||||
/// </summary>
|
||||
public Color32 lineColor
|
||||
{
|
||||
get { return m_LineColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_LineColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of line.
|
||||
/// 区域指示的颜色。
|
||||
/// </summary>
|
||||
public Color32 areaColor
|
||||
{
|
||||
get { return m_AreaColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_AreaColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the text color of tooltip cross indicator's axis label.
|
||||
/// 十字指示器坐标轴标签的文本颜色。
|
||||
/// </summary>
|
||||
public Color32 labelTextColor
|
||||
{
|
||||
get { return m_LabelTextColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_LabelTextColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the background color of tooltip cross indicator's axis label.
|
||||
/// 十字指示器坐标轴标签的背景颜色。
|
||||
/// </summary>
|
||||
public Color32 labelBackgroundColor
|
||||
{
|
||||
get { return m_LabelBackgroundColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_LabelBackgroundColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
public TooltipTheme(Theme theme) : base(theme)
|
||||
{
|
||||
m_LineType = LineStyle.Type.Solid;
|
||||
m_LineWidth = XChartsSettings.tootipLineWidth;
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.Default:
|
||||
m_TextBackgroundColor = ColorUtil.GetColor("#515151C8");
|
||||
m_TextColor = ColorUtil.GetColor("#FFFFFFFF");
|
||||
m_AreaColor = ColorUtil.GetColor("#51515120");
|
||||
m_LabelTextColor = ColorUtil.GetColor("#FFFFFFFF");
|
||||
m_LabelBackgroundColor = ColorUtil.GetColor("#292929FF");
|
||||
m_LineColor = ColorUtil.GetColor("#29292964");
|
||||
break;
|
||||
case Theme.Light:
|
||||
m_TextBackgroundColor = ColorUtil.GetColor("#515151C8");
|
||||
m_TextColor = ColorUtil.GetColor("#FFFFFFFF");
|
||||
m_AreaColor = ColorUtil.GetColor("#51515120");
|
||||
m_LabelTextColor = ColorUtil.GetColor("#FFFFFFFF");
|
||||
m_LabelBackgroundColor = ColorUtil.GetColor("#292929FF");
|
||||
m_LineColor = ColorUtil.GetColor("#29292964");
|
||||
break;
|
||||
case Theme.Dark:
|
||||
m_TextBackgroundColor = ColorUtil.GetColor("#515151C8");
|
||||
m_TextColor = ColorUtil.GetColor("#FFFFFFFF");
|
||||
m_AreaColor = ColorUtil.GetColor("#51515120");
|
||||
m_LabelTextColor = ColorUtil.GetColor("#FFFFFFFF");
|
||||
m_LabelBackgroundColor = ColorUtil.GetColor("#A7A7A7FF");
|
||||
m_LineColor = ColorUtil.GetColor("#eee");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Copy(TooltipTheme theme)
|
||||
{
|
||||
base.Copy(theme);
|
||||
m_LineType = theme.lineType;
|
||||
m_LineWidth = theme.lineWidth;
|
||||
m_LineColor = theme.lineColor;
|
||||
m_AreaColor = theme.areaColor;
|
||||
m_LabelTextColor = theme.labelTextColor;
|
||||
m_LabelBackgroundColor = theme.labelBackgroundColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Theme/TooltipTheme.cs.meta
Normal file
11
Runtime/Component/Theme/TooltipTheme.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f38f041e827e042a88338628b2b2c0db
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
93
Runtime/Component/Theme/VisualMapTheme.cs
Normal file
93
Runtime/Component/Theme/VisualMapTheme.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
public class VisualMapTheme : ComponentTheme
|
||||
{
|
||||
[SerializeField] protected float m_BorderWidth;
|
||||
[SerializeField] protected Color32 m_BorderColor;
|
||||
[SerializeField] protected Color32 m_BackgroundColor;
|
||||
[SerializeField] [Range(10, 50)] protected float m_TriangeLen = 20f;
|
||||
|
||||
/// <summary>
|
||||
/// the width of border.
|
||||
/// 边框线宽。
|
||||
/// </summary>
|
||||
public float borderWidth
|
||||
{
|
||||
get { return m_BorderWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of dataZoom border.
|
||||
/// 边框颜色。
|
||||
/// </summary>
|
||||
public Color32 borderColor
|
||||
{
|
||||
get { return m_BorderColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BorderColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the background color of visualmap.
|
||||
/// 背景颜色。
|
||||
/// </summary>
|
||||
public Color32 backgroundColor
|
||||
{
|
||||
get { return m_BackgroundColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 可视化组件的调节三角形边长。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public float triangeLen
|
||||
{
|
||||
get { return m_TriangeLen; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_TriangeLen, value < 0 ? 1f : value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public VisualMapTheme(Theme theme) : base(theme)
|
||||
{
|
||||
m_BorderWidth = XChartsSettings.visualMapBorderWidth;
|
||||
m_TriangeLen = XChartsSettings.visualMapTriangeLen;
|
||||
m_FontSize = XChartsSettings.fontSizeLv4;
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.Default:
|
||||
m_TextColor = ColorUtil.GetColor("#333");
|
||||
m_BorderColor = ColorUtil.GetColor("#ccc");
|
||||
m_BackgroundColor = ColorUtil.clearColor32;
|
||||
break;
|
||||
case Theme.Light:
|
||||
m_TextColor = ColorUtil.GetColor("#333");
|
||||
m_BorderColor = ColorUtil.GetColor("#ccc");
|
||||
m_BackgroundColor = ColorUtil.clearColor32;
|
||||
break;
|
||||
case Theme.Dark:
|
||||
m_TextColor = ColorUtil.GetColor("#B9B8CE");
|
||||
m_BorderColor = ColorUtil.GetColor("#ccc");
|
||||
m_BackgroundColor = ColorUtil.clearColor32;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Copy(VisualMapTheme theme)
|
||||
{
|
||||
base.Copy(theme);
|
||||
m_TriangeLen = theme.triangeLen;
|
||||
m_BorderWidth = theme.borderWidth;
|
||||
m_BorderColor = theme.borderColor;
|
||||
m_BackgroundColor = theme.backgroundColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Theme/VisualMapTheme.cs.meta
Normal file
11
Runtime/Component/Theme/VisualMapTheme.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35e5797039b994b23850aaa7ca827766
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user