2021-01-11 08:54:28 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
2022-02-19 22:37:57 +08:00
|
|
|
|
namespace XCharts.Runtime
|
2021-01-11 08:54:28 +08:00
|
|
|
|
{
|
|
|
|
|
|
[Serializable]
|
2021-11-23 13:20:07 +08:00
|
|
|
|
public class SerieTheme : ChildComponent
|
2021-01-11 08:54:28 +08:00
|
|
|
|
{
|
|
|
|
|
|
[SerializeField] protected float m_LineWidth;
|
|
|
|
|
|
[SerializeField] protected float m_LineSymbolSize;
|
|
|
|
|
|
[SerializeField] protected float m_ScatterSymbolSize;
|
|
|
|
|
|
[SerializeField] protected float m_PieTooltipExtraRadius;
|
2021-12-23 13:23:18 +08:00
|
|
|
|
[SerializeField] protected float m_SelectedRate = 1.3f;
|
2021-01-11 08:54:28 +08:00
|
|
|
|
[SerializeField] protected float m_PieSelectedOffset;
|
2022-01-16 22:16:33 +08:00
|
|
|
|
[SerializeField] protected Color32 m_CandlestickColor = new Color32(235, 84, 84, 255);
|
|
|
|
|
|
[SerializeField] protected Color32 m_CandlestickColor0 = new Color32(71, 178, 98, 255);
|
2021-03-10 13:03:36 +08:00
|
|
|
|
[SerializeField] protected float m_CandlestickBorderWidth = 1;
|
2022-01-16 22:16:33 +08:00
|
|
|
|
[SerializeField] protected Color32 m_CandlestickBorderColor = new Color32(235, 84, 84, 255);
|
|
|
|
|
|
[SerializeField] protected Color32 m_CandlestickBorderColor0 = new Color32(71, 178, 98, 255);
|
2021-01-11 08:54:28 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the color of text.
|
2022-03-24 08:37:06 +08:00
|
|
|
|
/// |文本颜色。
|
2021-01-11 08:54:28 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public float lineWidth
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_LineWidth; }
|
|
|
|
|
|
set { if (PropertyUtil.SetStruct(ref m_LineWidth, value)) SetVerticesDirty(); }
|
|
|
|
|
|
}
|
2022-07-04 08:30:43 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the symbol size of line serie.
|
|
|
|
|
|
/// |折线图的Symbol大小。
|
|
|
|
|
|
/// </summary>
|
2021-01-11 08:54:28 +08:00
|
|
|
|
public float lineSymbolSize
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_LineSymbolSize; }
|
|
|
|
|
|
set { if (PropertyUtil.SetStruct(ref m_LineSymbolSize, value)) SetVerticesDirty(); }
|
|
|
|
|
|
}
|
2022-07-04 08:30:43 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the selected symbol size of line serie.
|
|
|
|
|
|
/// |折线图Symbol在被选中状态时的大小。
|
|
|
|
|
|
/// </summary>
|
2021-12-23 13:23:18 +08:00
|
|
|
|
public float lineSymbolSelectedSize { get { return lineSymbolSize * selectedRate; } }
|
2022-07-04 08:30:43 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the symbol size of scatter serie.
|
|
|
|
|
|
/// |散点图的Symbol大小。
|
|
|
|
|
|
/// </summary>
|
2021-01-11 08:54:28 +08:00
|
|
|
|
public float scatterSymbolSize
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_ScatterSymbolSize; }
|
|
|
|
|
|
set { if (PropertyUtil.SetStruct(ref m_ScatterSymbolSize, value)) SetVerticesDirty(); }
|
|
|
|
|
|
}
|
2022-07-04 08:30:43 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the selected symbol size of scatter serie.
|
|
|
|
|
|
/// |散点图的Symbol在被选中状态时的大小。
|
|
|
|
|
|
/// </summary>
|
2021-12-23 13:23:18 +08:00
|
|
|
|
public float scatterSymbolSelectedSize { get { return scatterSymbolSize * selectedRate; } }
|
2022-07-04 08:30:43 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the rate of symbol size of line or scatter serie.
|
|
|
|
|
|
/// |折线图或散点图在被选中时的放大倍数。
|
|
|
|
|
|
/// </summary>
|
2021-12-23 13:23:18 +08:00
|
|
|
|
public float selectedRate
|
2021-01-11 08:54:28 +08:00
|
|
|
|
{
|
2021-12-23 13:23:18 +08:00
|
|
|
|
get { return m_SelectedRate; }
|
|
|
|
|
|
set { if (PropertyUtil.SetStruct(ref m_SelectedRate, value)) SetVerticesDirty(); }
|
2021-01-11 08:54:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2022-07-04 08:30:43 +08:00
|
|
|
|
/// the extra radius of pie when actived by tooltip.
|
|
|
|
|
|
/// |饼图鼠标移到高亮时的额外半径
|
2021-01-11 08:54:28 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public float pieTooltipExtraRadius
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_PieTooltipExtraRadius; }
|
|
|
|
|
|
set { if (PropertyUtil.SetStruct(ref m_PieTooltipExtraRadius, value < 0 ? 0f : value)) SetVerticesDirty(); }
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
2022-07-04 08:30:43 +08:00
|
|
|
|
/// the center offset of pie if selected.
|
|
|
|
|
|
/// |饼图选中时的中心点偏移。
|
2021-01-11 08:54:28 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public float pieSelectedOffset
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_PieSelectedOffset; }
|
|
|
|
|
|
set { if (PropertyUtil.SetStruct(ref m_PieSelectedOffset, value < 0 ? 0f : value)) SetVerticesDirty(); }
|
|
|
|
|
|
}
|
2021-03-10 13:03:36 +08:00
|
|
|
|
/// <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(); }
|
|
|
|
|
|
}
|
2021-01-11 08:54:28 +08:00
|
|
|
|
|
|
|
|
|
|
public void Copy(SerieTheme theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_LineWidth = theme.lineWidth;
|
|
|
|
|
|
m_LineSymbolSize = theme.lineSymbolSize;
|
|
|
|
|
|
m_ScatterSymbolSize = theme.scatterSymbolSize;
|
2021-12-23 13:23:18 +08:00
|
|
|
|
selectedRate = theme.selectedRate;
|
2021-01-11 08:54:28 +08:00
|
|
|
|
m_PieTooltipExtraRadius = theme.pieTooltipExtraRadius;
|
|
|
|
|
|
m_PieSelectedOffset = theme.pieSelectedOffset;
|
2021-03-10 13:03:36 +08:00
|
|
|
|
m_CandlestickColor = theme.candlestickColor;
|
|
|
|
|
|
m_CandlestickColor0 = theme.candlestickColor0;
|
|
|
|
|
|
m_CandlestickBorderColor = theme.candlestickBorderColor;
|
|
|
|
|
|
m_CandlestickBorderColor0 = theme.candlestickBorderColor0;
|
|
|
|
|
|
m_CandlestickBorderWidth = theme.candlestickBorderWidth;
|
2021-01-11 08:54:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-23 13:20:07 +08:00
|
|
|
|
public SerieTheme(ThemeType theme)
|
2021-01-11 08:54:28 +08:00
|
|
|
|
{
|
2021-11-23 13:20:07 +08:00
|
|
|
|
m_LineWidth = XCSettings.serieLineWidth;
|
|
|
|
|
|
m_LineSymbolSize = XCSettings.serieLineSymbolSize;
|
|
|
|
|
|
m_ScatterSymbolSize = XCSettings.serieScatterSymbolSize;
|
|
|
|
|
|
m_PieTooltipExtraRadius = XCSettings.pieTooltipExtraRadius;
|
|
|
|
|
|
m_PieSelectedOffset = XCSettings.pieSelectedOffset;
|
|
|
|
|
|
m_CandlestickBorderWidth = XCSettings.serieCandlestickBorderWidth;
|
2021-03-10 13:03:36 +08:00
|
|
|
|
switch (theme)
|
|
|
|
|
|
{
|
2021-11-23 13:20:07 +08:00
|
|
|
|
case ThemeType.Default:
|
2022-01-16 22:16:33 +08:00
|
|
|
|
m_CandlestickColor = ColorUtil.GetColor("#eb5454");
|
|
|
|
|
|
m_CandlestickColor0 = ColorUtil.GetColor("#47b262");
|
|
|
|
|
|
m_CandlestickBorderColor = ColorUtil.GetColor("#eb5454");
|
|
|
|
|
|
m_CandlestickBorderColor0 = ColorUtil.GetColor("#47b262");
|
2021-03-10 13:03:36 +08:00
|
|
|
|
break;
|
2021-11-23 13:20:07 +08:00
|
|
|
|
case ThemeType.Light:
|
2022-01-16 22:16:33 +08:00
|
|
|
|
m_CandlestickColor = ColorUtil.GetColor("#eb5454");
|
|
|
|
|
|
m_CandlestickColor0 = ColorUtil.GetColor("#47b262");
|
|
|
|
|
|
m_CandlestickBorderColor = ColorUtil.GetColor("#eb5454");
|
|
|
|
|
|
m_CandlestickBorderColor0 = ColorUtil.GetColor("#47b262");
|
2021-03-10 13:03:36 +08:00
|
|
|
|
break;
|
2021-11-23 13:20:07 +08:00
|
|
|
|
case ThemeType.Dark:
|
2022-01-16 22:16:33 +08:00
|
|
|
|
m_CandlestickColor = ColorUtil.GetColor("#f64e56");
|
|
|
|
|
|
m_CandlestickColor0 = ColorUtil.GetColor("#54ea92");
|
|
|
|
|
|
m_CandlestickBorderColor = ColorUtil.GetColor("#f64e56");
|
|
|
|
|
|
m_CandlestickBorderColor0 = ColorUtil.GetColor("#54ea92");
|
2021-03-10 13:03:36 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2021-01-11 08:54:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|