3.0 - unitypackage

This commit is contained in:
monitor1394
2022-01-05 21:40:48 +08:00
parent c160867765
commit 228a4b2840
846 changed files with 105 additions and 467693 deletions

249
Runtime/Theme/AxisTheme.cs Normal file
View File

@@ -0,0 +1,249 @@
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(ThemeType theme) : base(theme)
{
m_FontSize = XCSettings.fontSizeLv4;
m_LineType = XCSettings.axisLineType;
m_LineWidth = XCSettings.axisLineWidth;
m_LineLength = 0;
m_SplitLineType = XCSettings.axisSplitLineType;
m_SplitLineWidth = XCSettings.axisSplitLineWidth;
m_SplitLineLength = 0;
m_TickWidth = XCSettings.axisTickWidth;
m_TickLength = XCSettings.axisTickLength;
switch (theme)
{
case ThemeType.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 ThemeType.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 ThemeType.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(ThemeType theme) : base(theme)
{
}
}
[Serializable]
public class RadiusAxisTheme : BaseAxisTheme
{
public RadiusAxisTheme(ThemeType theme) : base(theme)
{
}
}
[Serializable]
public class AngleAxisTheme : BaseAxisTheme
{
public AngleAxisTheme(ThemeType theme) : base(theme)
{
}
}
[Serializable]
public class PolarAxisTheme : BaseAxisTheme
{
public PolarAxisTheme(ThemeType theme) : base(theme)
{
}
}
[Serializable]
public class RadarAxisTheme : BaseAxisTheme
{
public RadarAxisTheme(ThemeType theme) : base(theme)
{
m_SplitAreaColors.Clear();
switch (theme)
{
case ThemeType.Dark:
m_SplitAreaColors.Add(ThemeStyle.GetColor("#6f6f6f"));
m_SplitAreaColors.Add(ThemeStyle.GetColor("#606060"));
break;
case ThemeType.Default:
m_SplitAreaColors.Add(ThemeStyle.GetColor("#f6f6f6"));
m_SplitAreaColors.Add(ThemeStyle.GetColor("#e7e7e7"));
break;
case ThemeType.Light:
m_SplitAreaColors.Add(ThemeStyle.GetColor("#f6f6f6"));
m_SplitAreaColors.Add(ThemeStyle.GetColor("#e7e7e7"));
break;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: aefd22e76a6f642c9985b1a29e389858
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,103 @@
using System;
using UnityEngine;
#if dUI_TextMeshPro
using TMPro;
#endif
namespace XCharts
{
[Serializable]
public class ComponentTheme : ChildComponent
{
[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 { 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 { m_TMPFont = value; SetComponentDirty(); }
}
#endif
public ComponentTheme(ThemeType theme)
{
m_FontSize = XCSettings.fontSizeLv3;
switch (theme)
{
case ThemeType.Default:
m_TextColor = ColorUtil.GetColor("#514D4D");
break;
case ThemeType.Light:
m_TextColor = ColorUtil.GetColor("#514D4D");
break;
case ThemeType.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);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e78d1c80572324fc0b5cc5c935a2e34c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,126 @@
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(ThemeType theme) : base(theme)
{
m_BorderWidth = XCSettings.dataZoomBorderWidth;
m_DataLineWidth = XCSettings.dataZoomDataLineWidth;
m_BackgroundColor = Color.clear;
switch (theme)
{
case ThemeType.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 ThemeType.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 ThemeType.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;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ba535ef75742b4825b3cc2be4df6716f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,77 @@
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(ThemeType theme) : base(theme)
{
m_LineWidth = XCSettings.gaugeAxisLineWidth;
m_LineLength = 0;
m_SplitLineWidth = XCSettings.gaugeAxisSplitLineWidth;
m_SplitLineLength = XCSettings.gaugeAxisSplitLineLength;
m_TickWidth = XCSettings.gaugeAxisTickWidth;
m_TickLength = XCSettings.gaugeAxisTickLength;
m_SplitLineColor = Color.white;
m_TickColor = Color.white;
switch (theme)
{
case ThemeType.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 ThemeType.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 ThemeType.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);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b38e4b45ec20b4c65a6dc82891c5c39a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,37 @@
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(ThemeType theme) : base(theme)
{
m_UnableColor = ColorUtil.GetColor("#cccccc");
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a86fb06a6b71c4735b87769ee0708293
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

153
Runtime/Theme/SerieTheme.cs Normal file
View File

@@ -0,0 +1,153 @@
using System;
using UnityEngine;
namespace XCharts
{
[Serializable]
public class SerieTheme : ChildComponent
{
[SerializeField] protected float m_LineWidth;
[SerializeField] protected float m_LineSymbolSize;
[SerializeField] protected float m_ScatterSymbolSize;
[SerializeField] protected float m_PieTooltipExtraRadius;
[SerializeField] protected float m_SelectedRate = 1.3f;
[SerializeField] protected float m_PieSelectedOffset;
[SerializeField] protected Color32 m_CandlestickColor = new Color32(194, 53, 49, 255);
[SerializeField] protected Color32 m_CandlestickColor0 = new Color32(49, 70, 86, 255);
[SerializeField] protected float m_CandlestickBorderWidth = 1;
[SerializeField] protected Color32 m_CandlestickBorderColor = new Color32(194, 53, 49, 255);
[SerializeField] protected Color32 m_CandlestickBorderColor0 = new Color32(49, 70, 86, 255);
/// <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 lineSymbolSize * selectedRate; } }
public float scatterSymbolSize
{
get { return m_ScatterSymbolSize; }
set { if (PropertyUtil.SetStruct(ref m_ScatterSymbolSize, value)) SetVerticesDirty(); }
}
public float scatterSymbolSelectedSize { get { return scatterSymbolSize * selectedRate; } }
public float selectedRate
{
get { return m_SelectedRate; }
set { if (PropertyUtil.SetStruct(ref m_SelectedRate, 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(); }
}
/// <summary>
/// K线图阳线填充色
/// </summary>
public Color32 candlestickColor
{
get { return m_CandlestickColor; }
set { if (PropertyUtil.SetColor(ref m_CandlestickColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// K线图阴线填充色
/// </summary>
public Color32 candlestickColor0
{
get { return m_CandlestickColor0; }
set { if (PropertyUtil.SetColor(ref m_CandlestickColor0, value)) SetVerticesDirty(); }
}
/// <summary>
/// K线图阳线边框色
/// </summary>
public Color32 candlestickBorderColor
{
get { return m_CandlestickBorderColor; }
set { if (PropertyUtil.SetColor(ref m_CandlestickBorderColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// K线图阴线边框色
/// </summary>
public Color32 candlestickBorderColor0
{
get { return m_CandlestickBorderColor0; }
set { if (PropertyUtil.SetColor(ref m_CandlestickBorderColor0, value)) SetVerticesDirty(); }
}
/// <summary>
/// K线图边框宽度
/// </summary>
public float candlestickBorderWidth
{
get { return m_CandlestickBorderWidth; }
set { if (PropertyUtil.SetStruct(ref m_CandlestickBorderWidth, value < 0 ? 0f : value)) SetVerticesDirty(); }
}
public void Copy(SerieTheme theme)
{
m_LineWidth = theme.lineWidth;
m_LineSymbolSize = theme.lineSymbolSize;
m_ScatterSymbolSize = theme.scatterSymbolSize;
selectedRate = theme.selectedRate;
m_PieTooltipExtraRadius = theme.pieTooltipExtraRadius;
m_PieSelectedOffset = theme.pieSelectedOffset;
m_CandlestickColor = theme.candlestickColor;
m_CandlestickColor0 = theme.candlestickColor0;
m_CandlestickBorderColor = theme.candlestickBorderColor;
m_CandlestickBorderColor0 = theme.candlestickBorderColor0;
m_CandlestickBorderWidth = theme.candlestickBorderWidth;
}
public SerieTheme(ThemeType theme)
{
m_LineWidth = XCSettings.serieLineWidth;
m_LineSymbolSize = XCSettings.serieLineSymbolSize;
m_ScatterSymbolSize = XCSettings.serieScatterSymbolSize;
m_PieTooltipExtraRadius = XCSettings.pieTooltipExtraRadius;
m_PieSelectedOffset = XCSettings.pieSelectedOffset;
m_CandlestickBorderWidth = XCSettings.serieCandlestickBorderWidth;
switch (theme)
{
case ThemeType.Default:
m_CandlestickColor = ColorUtil.GetColor("#c23531");
m_CandlestickColor0 = ColorUtil.GetColor("#314656");
m_CandlestickBorderColor = ColorUtil.GetColor("#c23531");
m_CandlestickBorderColor0 = ColorUtil.GetColor("#314656");
break;
case ThemeType.Light:
m_CandlestickColor = ColorUtil.GetColor("#c23531");
m_CandlestickColor0 = ColorUtil.GetColor("#314656");
m_CandlestickBorderColor = ColorUtil.GetColor("#c23531");
m_CandlestickBorderColor0 = ColorUtil.GetColor("#314656");
break;
case ThemeType.Dark:
m_CandlestickColor = ColorUtil.GetColor("#c23531");
m_CandlestickColor0 = ColorUtil.GetColor("#314656");
m_CandlestickBorderColor = ColorUtil.GetColor("#c23531");
m_CandlestickBorderColor0 = ColorUtil.GetColor("#314656");
break;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9030b0e4afb164967b4991247947b195
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
using System;
namespace XCharts
{
[Serializable]
public class SubTitleTheme : ComponentTheme
{
public SubTitleTheme(ThemeType theme) : base(theme)
{
m_FontSize = XCSettings.fontSizeLv2;
switch (theme)
{
case ThemeType.Default:
m_TextColor = ColorUtil.GetColor("#969696");
break;
case ThemeType.Light:
m_TextColor = ColorUtil.GetColor("#969696");
break;
case ThemeType.Dark:
m_TextColor = ColorUtil.GetColor("#B9B8CE");
break;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c642293f2d6674cbb85d1f081b9d89e8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

419
Runtime/Theme/Theme.cs Normal file
View File

@@ -0,0 +1,419 @@
using System.Collections.Generic;
using UnityEngine;
using System;
using System.Text;
#if dUI_TextMeshPro
using TMPro;
#endif
namespace XCharts
{
[Serializable]
/// <summary>
/// Theme.
/// 主题相关配置。
/// </summary>
public class Theme : ScriptableObject
{
[SerializeField] private ThemeType m_ThemeType = ThemeType.Default;
[SerializeField] private string m_ThemeName = ThemeType.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;
#if UNITY_2020_2
[NonReorderable]
#endif
[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 GaugeAxisTheme m_Gauge;
[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 ThemeType themeType
{
get { return m_ThemeType; }
set { PropertyUtil.SetStruct(ref m_ThemeType, value); }
}
public string themeName
{
get { return m_ThemeName; }
set { PropertyUtil.SetClass(ref m_ThemeName, value); }
}
/// <summary>
/// the contrast color of chart.
/// 对比色。
/// </summary>
public Color32 contrastColor
{
get { return m_ContrastColor; }
set { PropertyUtil.SetColor(ref m_ContrastColor, value); }
}
/// <summary>
/// the background color of chart.
/// 背景颜色。
/// </summary>
public Color32 backgroundColor
{
get { return m_BackgroundColor; }
set { PropertyUtil.SetColor(ref m_BackgroundColor, value); }
}
/// <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; } }
public ComponentTheme common { get { return m_Common; } set { m_Common = value; } }
public TitleTheme title { get { return m_Title; } set { m_Title = value; } }
public SubTitleTheme subTitle { get { return m_SubTitle; } set { m_SubTitle = value; } }
public LegendTheme legend { get { return m_Legend; } set { m_Legend = value; } }
public AxisTheme axis { get { return m_Axis; } set { m_Axis = value; } }
public GaugeAxisTheme gauge { get { return m_Gauge; } set { m_Gauge = value; } }
public TooltipTheme tooltip { get { return m_Tooltip; } set { m_Tooltip = value; } }
public DataZoomTheme dataZoom { get { return m_DataZoom; } set { m_DataZoom = value; } }
public VisualMapTheme visualMap { get { return m_VisualMap; } set { m_VisualMap = value; } }
public SerieTheme serie { get { return m_Serie; } set { m_Serie = value; } }
#if dUI_TextMeshPro
/// <summary>
/// the font of chart text。
/// 字体。
/// </summary>
public TMP_FontAsset tmpFont
{
get { return m_TMPFont; }
set
{
m_TMPFont = value;
if(value)
{
m_TMPFontName = value.name;
m_TMPFontInstanceId = value.GetInstanceID();
}
SetComponentDirty();
SyncTMPFontToSubComponent();
}
}
#endif
/// <summary>
/// the font of chart text。
/// 字体。
/// </summary>
public Font font
{
get { return m_Font; }
set
{
m_Font = value;
SyncFontToSubComponent();
}
}
// void OnEnable()
// {
// }
// void OnDisable()
// {
// }
public void SetDefaultFont()
{
#if dUI_TextMeshPro
tmpFont = XCSettings.tmpFont;
SyncTMPFontToSubComponent();
#else
font = XCSettings.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 bool CopyTheme(ThemeType theme)
{
switch (theme)
{
case ThemeType.Dark:
ResetToDarkTheme(this);
return true;
case ThemeType.Default:
ResetToDefaultTheme(this);
return true;
}
return false;
}
/// <summary>
/// copy all configurations from theme.
/// 复制主题的所有配置。
/// </summary>
/// <param name="theme"></param>
public void CopyTheme(Theme theme)
{
m_ThemeType = theme.themeType;
m_ThemeName = theme.themeName;
#if dUI_TextMeshPro
tmpFont = theme.tmpFont;
#endif
font = theme.font;
m_BackgroundColor = theme.backgroundColor;
m_Common.Copy(theme.common);
m_Legend.Copy(theme.legend);
m_Title.Copy(theme.title);
m_SubTitle.Copy(theme.subTitle);
m_Axis.Copy(theme.axis);
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);
}
/// <summary>
/// Clear all custom configurations.
/// 重置,清除所有自定义配置。
/// </summary>
public bool ResetTheme()
{
switch (m_ThemeType)
{
case ThemeType.Default: ResetToDefaultTheme(this); return true;
case ThemeType.Dark: ResetToDarkTheme(this); return true;
case ThemeType.Custom:
return false;
}
return false;
}
/// <summary>
/// 克隆主题。
/// </summary>
/// <returns></returns>
public Theme CloneTheme()
{
var theme = ScriptableObject.CreateInstance<Theme>();
InitChartComponentTheme(theme);
theme.CopyTheme(this);
return theme;
}
/// <summary>
/// default theme.
/// 默认主题。
/// </summary>
/// <value></value>
public static void ResetToDefaultTheme(Theme theme)
{
theme.themeType = ThemeType.Default;
theme.themeName = ThemeType.Default.ToString();
theme.backgroundColor = new Color32(255, 255, 255, 255);
theme.colorPalette = new List<Color32>
{
ColorUtil.GetColor("#5470c6"),
ColorUtil.GetColor("#91cc75"),
ColorUtil.GetColor("#fac858"),
ColorUtil.GetColor("#ee6666"),
ColorUtil.GetColor("#73c0de"),
ColorUtil.GetColor("#3ba272"),
ColorUtil.GetColor("#fc8452"),
ColorUtil.GetColor("#9a60b4"),
ColorUtil.GetColor("#ea7ccc"),
};
InitChartComponentTheme(theme);
}
/// <summary>
/// dark theme.
/// 暗主题。
/// </summary>
/// <value></value>
public static void ResetToDarkTheme(Theme theme)
{
theme.themeType = ThemeType.Dark;
theme.themeName = ThemeType.Dark.ToString();
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);
}
public static Theme EmptyTheme
{
get
{
var theme = ScriptableObject.CreateInstance<Theme>();
theme.themeType = ThemeType.Custom;
theme.themeName = ThemeType.Custom.ToString();
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;
gauge.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(Theme theme)
{
theme.common = new ComponentTheme(theme.themeType);
theme.title = new TitleTheme(theme.themeType);
theme.subTitle = new SubTitleTheme(theme.themeType);
theme.legend = new LegendTheme(theme.themeType);
theme.axis = new AxisTheme(theme.themeType);
theme.gauge = new GaugeAxisTheme(theme.themeType);
theme.tooltip = new TooltipTheme(theme.themeType);
theme.dataZoom = new DataZoomTheme(theme.themeType);
theme.visualMap = new VisualMapTheme(theme.themeType);
theme.serie = new SerieTheme(theme.themeType);
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 void SetColorPalette(List<string> hexColorStringList)
{
m_ColorPalette.Clear();
foreach (var hexColor in hexColorStringList)
m_ColorPalette.Add(ColorUtil.GetColor(hexColor));
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6c59330ca0f4443b69f06b890a44f32e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

216
Runtime/Theme/ThemeStyle.cs Normal file
View File

@@ -0,0 +1,216 @@
using System.Collections.Generic;
using UnityEngine;
using System;
using System.Text;
#if dUI_TextMeshPro
using TMPro;
#endif
namespace XCharts
{
/// <summary>
/// 主题
/// </summary>
public enum ThemeType
{
/// <summary>
/// 默认主题。
/// </summary>
Default,
/// <summary>
/// 亮主题。
/// </summary>
Light,
/// <summary>
/// 暗主题。
/// </summary>
Dark,
/// <summary>
/// 自定义主题。
/// </summary>
Custom,
}
[Serializable]
/// <summary>
/// Theme.
/// 主题相关配置。
/// </summary>
public class ThemeStyle : ChildComponent
{
[SerializeField] private Theme m_SharedTheme;
[SerializeField] private bool m_EnableCustomTheme;
[SerializeField] private Color32 m_CustomBackgroundColor;
#if UNITY_2020_2
[NonReorderable]
#endif
[SerializeField] private List<Color32> m_CustomColorPalette = new List<Color32>(13);
/// <summary>
/// the theme of chart.
/// 主题类型。
/// </summary>
public ThemeType themeType
{
get { return sharedTheme.themeType; }
}
public string themeName
{
get { return sharedTheme.themeName; }
}
public Theme sharedTheme
{
get { return m_SharedTheme; }
set { m_SharedTheme = value; SetAllDirty(); }
}
/// <summary>
/// the contrast color of chart.
/// 对比色。
/// </summary>
public Color32 contrastColor
{
get { return sharedTheme.contrastColor; }
}
/// <summary>
/// the background color of chart.
/// 背景颜色。
/// </summary>
public Color32 backgroundColor
{
get { return m_EnableCustomTheme ? m_CustomBackgroundColor : sharedTheme.backgroundColor; }
}
public bool enableCustomTheme
{
get { return m_EnableCustomTheme; }
set { m_EnableCustomTheme = value; _colorDic.Clear(); SetAllDirty(); }
}
/// <summary>
/// the custom background color of chart.
/// 自定义的背景颜色。
/// </summary>
public Color32 customBackgroundColor
{
get { return m_CustomBackgroundColor; }
set { m_CustomBackgroundColor = value; SetAllDirty(); }
}
/// <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_EnableCustomTheme ? m_CustomColorPalette : sharedTheme.colorPalette; }
}
public List<Color32> customColorPalette { get { return m_CustomColorPalette; } set { m_CustomColorPalette = value; SetVerticesDirty(); } }
public ComponentTheme common { get { return sharedTheme.common; } }
public TitleTheme title { get { return sharedTheme.title; } }
public SubTitleTheme subTitle { get { return sharedTheme.subTitle; } }
public LegendTheme legend { get { return sharedTheme.legend; } }
public AxisTheme axis { get { return sharedTheme.axis; } }
public GaugeAxisTheme gauge { get { return sharedTheme.gauge; } }
public TooltipTheme tooltip { get { return sharedTheme.tooltip; } }
public DataZoomTheme dataZoom { get { return sharedTheme.dataZoom; } }
public VisualMapTheme visualMap { get { return sharedTheme.visualMap; } }
public SerieTheme serie { get { return sharedTheme.serie; } }
/// <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 (colorPalette.Count <= 0) return Color.clear;
if (index < 0) index = 0;
var newIndex = index < colorPalette.Count ? index : index % colorPalette.Count;
if (newIndex < colorPalette.Count)
return colorPalette[newIndex];
else return Color.clear;
}
public Color32 GetBackgroundColor(Background background)
{
if (background != null && background.show && background.hideThemeBackgroundColor)
return ChartConst.clearColor32;
else
return backgroundColor;
}
public void SyncSharedThemeColorToCustom()
{
m_CustomBackgroundColor = sharedTheme.backgroundColor;
m_CustomColorPalette.Clear();
foreach (var color in sharedTheme.colorPalette)
{
m_CustomColorPalette.Add(color);
}
SetAllDirty();
}
public void CheckWarning(StringBuilder sb)
{
#if dUI_TextMeshPro
if (m_Profile.tmpFont == null)
{
sb.AppendFormat("warning:theme->tmpFont is null\n");
}
#else
if (sharedTheme.font == null)
{
sb.AppendFormat("warning:theme->font is null\n");
}
#endif
if (sharedTheme.colorPalette.Count == 0)
{
sb.AppendFormat("warning:theme->colorPalette is empty\n");
}
for (int i = 0; i < sharedTheme.colorPalette.Count; i++)
{
if (!ChartHelper.IsClearColor(sharedTheme.colorPalette[i]) && sharedTheme.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 % colorPalette.Count;
if (_colorDic.ContainsKey(index)) return _colorDic[index];
else
{
_colorDic[index] = ColorUtility.ToHtmlStringRGBA(GetColor(index));
return _colorDic[index];
}
}
/// <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;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bd363d1f78f9d47dab079b1376cf0680
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,25 @@
using System;
namespace XCharts
{
[Serializable]
public class TitleTheme : ComponentTheme
{
public TitleTheme(ThemeType theme) : base(theme)
{
m_FontSize = XCSettings.fontSizeLv1;
switch (theme)
{
case ThemeType.Default:
m_TextColor = ColorUtil.GetColor("#514D4D");
break;
case ThemeType.Light:
break;
case ThemeType.Dark:
m_TextColor = ColorUtil.GetColor("#EEF1FA");
break;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6649bc33964624c14a13ce34dd7eae77
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,119 @@
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(ThemeType theme) : base(theme)
{
m_LineType = LineStyle.Type.Solid;
m_LineWidth = XCSettings.tootipLineWidth;
switch (theme)
{
case ThemeType.Default:
m_TextBackgroundColor = ColorUtil.GetColor("#FFFFFFFF");
m_TextColor = ColorUtil.GetColor("#000000FF");
m_AreaColor = ColorUtil.GetColor("#51515120");
m_LabelTextColor = ColorUtil.GetColor("#FFFFFFFF");
m_LabelBackgroundColor = ColorUtil.GetColor("#292929FF");
m_LineColor = ColorUtil.GetColor("#29292964");
break;
case ThemeType.Light:
m_TextBackgroundColor = ColorUtil.GetColor("#FFFFFFFF");
m_TextColor = ColorUtil.GetColor("#000000FF");
m_AreaColor = ColorUtil.GetColor("#51515120");
m_LabelTextColor = ColorUtil.GetColor("#FFFFFFFF");
m_LabelBackgroundColor = ColorUtil.GetColor("#292929FF");
m_LineColor = ColorUtil.GetColor("#29292964");
break;
case ThemeType.Dark:
m_TextBackgroundColor = ColorUtil.GetColor("#FFFFFFFF");
m_TextColor = ColorUtil.GetColor("#000000FF");
m_AreaColor = ColorUtil.GetColor("#51515120");
m_LabelTextColor = ColorUtil.GetColor("#FFFFFFFF");
m_LabelBackgroundColor = ColorUtil.GetColor("#292929FF");
m_LineColor = ColorUtil.GetColor("#29292964");
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;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f38f041e827e042a88338628b2b2c0db
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,87 @@
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(ThemeType theme) : base(theme)
{
m_BorderWidth = XCSettings.visualMapBorderWidth;
m_TriangeLen = XCSettings.visualMapTriangeLen;
m_FontSize = XCSettings.fontSizeLv4;
switch (theme)
{
case ThemeType.Default:
m_TextColor = ColorUtil.GetColor("#333");
m_BorderColor = ColorUtil.GetColor("#ccc");
m_BackgroundColor = ColorUtil.clearColor32;
break;
case ThemeType.Light:
m_TextColor = ColorUtil.GetColor("#333");
m_BorderColor = ColorUtil.GetColor("#ccc");
m_BackgroundColor = ColorUtil.clearColor32;
break;
case ThemeType.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;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 35e5797039b994b23850aaa7ca827766
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: