XCharts 2.0

This commit is contained in:
monitor1394
2021-01-11 08:54:28 +08:00
parent ed8d0687f7
commit 489095865d
304 changed files with 14799 additions and 12503 deletions

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System;
using UnityEngine;
@@ -12,17 +12,9 @@ namespace XCharts
{
public class ChartComponent
{
[SerializeField] protected string m_JsonData;
[SerializeField] protected bool m_DataFromJson;
[NonSerialized] protected bool m_VertsDirty;
[NonSerialized] protected bool m_ComponentDirty;
/// <summary>
/// json格式的字符串数据
/// </summary>
/// <returns></returns>
public string jsonData { get { return m_JsonData; } set { m_JsonData = value; ParseJsonData(value); } }
[NonSerialized] protected Painter m_Painter;
/// <summary>
/// 图表重绘标记。
/// </summary>
@@ -35,23 +27,9 @@ namespace XCharts
/// 需要重绘图表或重新初始化组件。
/// </summary>
public bool anyDirty { get { return vertsDirty || componentDirty; } }
internal void OnAfterDeserialize()
{
if (m_DataFromJson)
{
ParseJsonData(m_JsonData);
m_DataFromJson = false;
}
}
internal void OnBeforeSerialize()
{
}
public virtual void ParseJsonData(string json)
{
throw new Exception("no support yet");
}
public Painter painter { get { return m_Painter; } set { m_Painter = value; } }
public Action refreshComponent { get; set; }
public GameObject gameObject { get; set; }
internal virtual void SetVerticesDirty()
{
@@ -85,4 +63,12 @@ namespace XCharts
SetComponentDirty();
}
}
public class MainComponent : ChartComponent
{
}
public class SubComponent : ChartComponent
{
}
}

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System;
using System.Collections.Generic;
@@ -64,10 +64,25 @@ namespace XCharts
/// </summary>
Custom
}
/// <summary>
/// the position of axis in grid.
/// 坐标轴在Grid中的位置
/// </summary>
public enum AxisPosition
{
Left,
Right,
Bottom,
Top
}
[SerializeField] protected bool m_Show = true;
[SerializeField] protected AxisType m_Type;
[SerializeField] protected AxisMinMaxType m_MinMaxType;
[SerializeField] protected int m_GridIndex;
[SerializeField] protected int m_PolarIndex;
[SerializeField] protected AxisPosition m_Position;
[SerializeField] protected float m_Offset;
[SerializeField] protected float m_Min;
[SerializeField] protected float m_Max;
[SerializeField] protected int m_SplitNumber = 5;
@@ -97,7 +112,7 @@ namespace XCharts
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetAllDirty(); }
}
/// <summary>
/// the type of axis.
@@ -106,7 +121,7 @@ namespace XCharts
public AxisType type
{
get { return m_Type; }
set { if (PropertyUtility.SetStruct(ref m_Type, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Type, value)) SetAllDirty(); }
}
/// <summary>
/// the type of axis minmax.
@@ -115,7 +130,43 @@ namespace XCharts
public AxisMinMaxType minMaxType
{
get { return m_MinMaxType; }
set { if (PropertyUtility.SetStruct(ref m_MinMaxType, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_MinMaxType, value)) SetAllDirty(); }
}
/// <summary>
/// The index of the grid on which the axis are located, by default, is in the first grid.
/// 坐标轴所在的 grid 的索引,默认位于第一个 grid。
/// </summary>
public int gridIndex
{
get { return m_GridIndex; }
set { if (PropertyUtil.SetStruct(ref m_GridIndex, value)) SetAllDirty(); }
}
/// <summary>
/// The index of the polar on which the axis are located, by default, is in the first polar.
/// 坐标轴所在的 ploar 的索引,默认位于第一个 polar。
/// </summary>
public int polarIndex
{
get { return m_PolarIndex; }
set { if (PropertyUtil.SetStruct(ref m_PolarIndex, value)) SetAllDirty(); }
}
/// <summary>
/// the position of axis in grid.
/// 坐标轴在Grid中的位置。
/// </summary>
public AxisPosition position
{
get { return m_Position; }
set { if (PropertyUtil.SetStruct(ref m_Position, value)) SetAllDirty(); }
}
/// <summary>
/// the offset of axis from the default position. Useful when the same position has multiple axes.
/// 坐标轴相对默认位置的偏移。在相同position有多个坐标轴时有用。
/// </summary>
public float offset
{
get { return m_Offset; }
set { if (PropertyUtil.SetStruct(ref m_Offset, value)) SetAllDirty(); }
}
/// <summary>
/// The minimun value of axis.Valid when `minMaxType` is `Custom`
@@ -124,7 +175,7 @@ namespace XCharts
public float min
{
get { return m_Min; }
set { if (PropertyUtility.SetStruct(ref m_Min, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Min, value)) SetAllDirty(); }
}
/// <summary>
/// The maximum value of axis.Valid when `minMaxType` is `Custom`
@@ -133,7 +184,7 @@ namespace XCharts
public float max
{
get { return m_Max; }
set { if (PropertyUtility.SetStruct(ref m_Max, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Max, value)) SetAllDirty(); }
}
/// <summary>
/// Number of segments that the axis is split into.
@@ -142,7 +193,7 @@ namespace XCharts
public int splitNumber
{
get { return m_SplitNumber; }
set { if (PropertyUtility.SetStruct(ref m_SplitNumber, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_SplitNumber, value)) SetAllDirty(); }
}
/// <summary>
/// Compulsively set segmentation interval for axis.This is unavailable for category axis.
@@ -151,7 +202,7 @@ namespace XCharts
public float interval
{
get { return m_Interval; }
set { if (PropertyUtility.SetStruct(ref m_Interval, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Interval, value)) SetAllDirty(); }
}
/// <summary>
/// The boundary gap on both sides of a coordinate axis, which is valid only for category axis with type: 'Category'.
@@ -160,7 +211,7 @@ namespace XCharts
public bool boundaryGap
{
get { return IsCategory() ? m_BoundaryGap : false; }
set { if (PropertyUtility.SetStruct(ref m_BoundaryGap, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_BoundaryGap, value)) SetAllDirty(); }
}
/// <summary>
/// Base of logarithm, which is valid only for numeric axes with type: 'Log'.
@@ -172,7 +223,7 @@ namespace XCharts
set
{
if (value <= 0 || value == 1) value = 10;
if (PropertyUtility.SetStruct(ref m_LogBase, value)) SetAllDirty();
if (PropertyUtil.SetStruct(ref m_LogBase, value)) SetAllDirty();
}
}
/// <summary>
@@ -182,7 +233,7 @@ namespace XCharts
public bool logBaseE
{
get { return m_LogBaseE; }
set { if (PropertyUtility.SetStruct(ref m_LogBaseE, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_LogBaseE, value)) SetAllDirty(); }
}
/// <summary>
/// The max number of axis data cache.
@@ -192,7 +243,7 @@ namespace XCharts
public int maxCache
{
get { return m_MaxCache; }
set { if (PropertyUtility.SetStruct(ref m_MaxCache, value < 0 ? 0 : value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_MaxCache, value < 0 ? 0 : value)) SetAllDirty(); }
}
/// <summary>
/// The ratio of maximum and minimum values rounded upward. The default is 0, which is automatically calculated.
@@ -201,7 +252,7 @@ namespace XCharts
public int ceilRate
{
get { return m_CeilRate; }
set { if (PropertyUtility.SetStruct(ref m_CeilRate, value < 0 ? 0 : value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_CeilRate, value < 0 ? 0 : value)) SetAllDirty(); }
}
/// <summary>
/// Whether the axis are reversed or not. Invalid in `Category` axis.
@@ -210,7 +261,7 @@ namespace XCharts
public bool inverse
{
get { return m_Inverse; }
set { if (m_Type == AxisType.Value && PropertyUtility.SetStruct(ref m_Inverse, value)) SetAllDirty(); }
set { if (m_Type == AxisType.Value && PropertyUtil.SetStruct(ref m_Inverse, value)) SetAllDirty(); }
}
/// <summary>
/// Whether the positive position of axis is in clockwise. True for clockwise by default.
@@ -219,7 +270,7 @@ namespace XCharts
public bool clockwise
{
get { return m_Clockwise; }
set { if (PropertyUtility.SetStruct(ref m_Clockwise, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Clockwise, value)) SetAllDirty(); }
}
/// <summary>
/// Category data, available in type: 'Category' axis.
@@ -312,7 +363,7 @@ namespace XCharts
/// the axis label text list.
/// 坐标轴刻度标签的Text列表。
/// </summary>
public List<Text> axisLabelTextList { get { return m_AxisLabelTextList; } set { m_AxisLabelTextList = value; } }
public List<ChartText> axisLabelTextList { get { return m_AxisLabelTextList; } set { m_AxisLabelTextList = value; } }
/// <summary>
/// the current minimun value.
/// 当前最小值。
@@ -361,9 +412,9 @@ namespace XCharts
private int filterEnd;
private int filterMinShow;
private List<string> filterData;
private List<Text> m_AxisLabelTextList = new List<Text>();
private List<ChartText> m_AxisLabelTextList = new List<ChartText>();
private GameObject m_TooltipLabel;
private Text m_TooltipLabelText;
private ChartText m_TooltipLabelText;
private RectTransform m_TooltipLabelRect;
private float m_RuntimeMinValue;
private float m_RuntimeLastMinValue;
@@ -381,6 +432,7 @@ namespace XCharts
var axis = new Axis();
axis.show = show;
axis.type = type;
axis.gridIndex = 0;
axis.minMaxType = minMaxType;
axis.min = min;
axis.max = max;
@@ -407,6 +459,7 @@ namespace XCharts
show = axis.show;
type = axis.type;
minMaxType = axis.minMaxType;
gridIndex = axis.gridIndex;
min = axis.min;
max = axis.max;
splitNumber = axis.splitNumber;
@@ -514,7 +567,7 @@ namespace XCharts
/// <returns></returns>
internal List<string> GetDataList(DataZoom dataZoom)
{
if (dataZoom != null && dataZoom.enable)
if (dataZoom != null && dataZoom.enable && dataZoom.IsContainsAxisIndex(index))
{
UpdateFilterData(dataZoom);
return filterData;
@@ -532,7 +585,7 @@ namespace XCharts
/// <param name="dataZoom"></param>
internal void UpdateFilterData(DataZoom dataZoom)
{
if (dataZoom != null && dataZoom.enable)
if (dataZoom != null && dataZoom.enable && dataZoom.IsContainsAxisIndex(index))
{
var startIndex = (int)((data.Count - 1) * dataZoom.start / 100);
var endIndex = (int)((data.Count - 1) * dataZoom.end / 100);
@@ -593,7 +646,7 @@ namespace XCharts
if (axisLabelTextList[i] != null)
{
var text = AxisHelper.GetLabelName(this, coordinateWidth, i, minValue, maxValue, dataZoom, forcePercent);
axisLabelTextList[i].text = text;
axisLabelTextList[i].SetText(text);
}
}
}
@@ -602,31 +655,28 @@ namespace XCharts
{
m_TooltipLabel = label;
m_TooltipLabelRect = label.GetComponent<RectTransform>();
m_TooltipLabelText = label.GetComponentInChildren<Text>();
m_TooltipLabelText = new ChartText(label);
ChartHelper.SetActive(m_TooltipLabel, true);
}
internal void SetTooltipLabelColor(Color bgColor, Color textColor)
{
m_TooltipLabel.GetComponent<Image>().color = bgColor;
m_TooltipLabelText.color = textColor;
m_TooltipLabelText.SetColor(textColor);
}
internal void SetTooltipLabelActive(bool flag)
{
if (m_TooltipLabel && m_TooltipLabel.activeInHierarchy != flag)
{
ChartHelper.SetActive(m_TooltipLabel, flag);
}
ChartHelper.SetActive(m_TooltipLabel, flag);
}
internal void UpdateTooptipLabelText(string text)
{
if (m_TooltipLabelText)
if (m_TooltipLabelText != null)
{
m_TooltipLabelText.text = text;
m_TooltipLabelRect.sizeDelta = new Vector2(m_TooltipLabelText.preferredWidth + 8,
m_TooltipLabelText.preferredHeight + 8);
m_TooltipLabelText.SetText(text);
m_TooltipLabelRect.sizeDelta = new Vector2(m_TooltipLabelText.GetPreferredWidth() + 8,
m_TooltipLabelText.GetPreferredHeight() + 8);
}
}
@@ -753,10 +803,24 @@ namespace XCharts
return logBaseE ? Mathf.Log(value) : Mathf.Log(value, logBase);
}
public override void ParseJsonData(string jsonData)
public bool IsLeft()
{
if (string.IsNullOrEmpty(jsonData) || !m_DataFromJson) return;
m_Data = ChartHelper.ParseStringFromString(jsonData);
return position == AxisPosition.Left;
}
public bool IsRight()
{
return position == AxisPosition.Right;
}
public bool IsTop()
{
return position == AxisPosition.Top;
}
public bool IsBottom()
{
return position == AxisPosition.Bottom;
}
}
@@ -780,13 +844,15 @@ namespace XCharts
m_Max = 0,
m_SplitNumber = 5,
m_BoundaryGap = true,
m_Position = AxisPosition.Bottom,
m_Offset = 0,
m_Data = new List<string>()
{
"x1","x2","x3","x4","x5"
}
};
axis.splitLine.show = false;
axis.splitLine.lineStyle.type = LineStyle.Type.Dashed;
axis.splitLine.lineStyle.type = LineStyle.Type.None;
axis.axisLabel.textLimit.enable = true;
return axis;
}
@@ -813,10 +879,11 @@ namespace XCharts
m_Max = 0,
m_SplitNumber = 5,
m_BoundaryGap = false,
m_Position = AxisPosition.Left,
m_Data = new List<string>(5),
};
axis.splitLine.show = true;
axis.splitLine.lineStyle.type = LineStyle.Type.Dashed;
axis.splitLine.lineStyle.type = LineStyle.Type.None;
axis.axisLabel.textLimit.enable = false;
return axis;
}
@@ -868,7 +935,7 @@ namespace XCharts
public float startAngle
{
get { return m_StartAngle; }
set { if (PropertyUtility.SetStruct(ref m_StartAngle, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_StartAngle, value)) SetAllDirty(); }
}
public float runtimeStartAngle { get; set; }
@@ -881,9 +948,9 @@ namespace XCharts
{
m_Show = true,
m_Type = AxisType.Value,
m_SplitNumber = 13,
m_SplitNumber = 12,
m_BoundaryGap = false,
m_Data = new List<string>(13),
m_Data = new List<string>(12),
};
axis.splitLine.show = true;
axis.splitLine.lineStyle.type = LineStyle.Type.Solid;

View File

@@ -1,10 +1,10 @@
using System.Net.Mime;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System;
using UnityEngine;
@@ -41,7 +41,7 @@ namespace XCharts
public bool show
{
get { return m_Show; }
internal set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); }
internal set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); }
}
/// <summary>
/// the image of background.
@@ -50,7 +50,7 @@ namespace XCharts
public Sprite image
{
get { return m_Image; }
set { if (PropertyUtility.SetClass(ref m_Image, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetClass(ref m_Image, value)) SetComponentDirty(); }
}
/// <summary>
@@ -60,7 +60,7 @@ namespace XCharts
public Image.Type imageType
{
get { return m_ImageType; }
set { if (PropertyUtility.SetStruct(ref m_ImageType, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_ImageType, value)) SetComponentDirty(); }
}
/// <summary>
@@ -69,7 +69,7 @@ namespace XCharts
public Color imageColor
{
get { return m_ImageColor; }
set { if (PropertyUtility.SetColor(ref m_ImageColor, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetColor(ref m_ImageColor, value)) SetComponentDirty(); }
}
/// <summary>
@@ -79,14 +79,9 @@ namespace XCharts
public bool hideThemeBackgroundColor
{
get { return m_HideThemeBackgroundColor; }
set { if (PropertyUtility.SetStruct(ref m_HideThemeBackgroundColor, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_HideThemeBackgroundColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// 是否已激活
/// </summary>
public bool runtimeActive { get; internal set; }
public static Background defaultBackground
{
get

View File

@@ -1,10 +1,11 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@@ -68,8 +69,8 @@ namespace XCharts
}
[SerializeField] private bool m_Enable;
[SerializeField] private FilterMode m_FilterMode;
[SerializeField] private int m_XAxisIndex;
[SerializeField] private int m_YAxisIndex;
[SerializeField] private List<int> m_XAxisIndexs = new List<int>() { 0 };
[SerializeField] private List<int> m_YAxisIndexs = new List<int>() { };
[SerializeField] private bool m_SupportInside;
[SerializeField] private bool m_SupportSlider;
[SerializeField] private bool m_SupportSelect;
@@ -77,8 +78,13 @@ namespace XCharts
[SerializeField] private bool m_ShowDetail;
[SerializeField] private bool m_ZoomLock;
[SerializeField] private bool m_Realtime;
[SerializeField] private Color m_BackgroundColor;
[SerializeField] private float m_Height;
[SerializeField] protected Color32 m_FillerColor;
[SerializeField] protected Color32 m_BorderColor;
[SerializeField] protected float m_BorderWidth;
[SerializeField] protected Color32 m_BackgroundColor;
[SerializeField] private float m_Left;
[SerializeField] private float m_Right;
[SerializeField] private float m_Top;
[SerializeField] private float m_Bottom;
[SerializeField] private RangeMode m_RangeMode;
[SerializeField] private float m_Start;
@@ -88,8 +94,9 @@ namespace XCharts
[SerializeField] private int m_MinShowNum = 1;
[Range(1f, 20f)]
[SerializeField] private float m_ScrollSensitivity = 1.1f;
[SerializeField] private int m_FontSize = 18;
[SerializeField] private FontStyle m_FontStyle;
[SerializeField] private TextStyle m_TextStyle;
[SerializeField] private LineStyle m_LineStyle = new LineStyle(LineStyle.Type.Solid);
[SerializeField] private AreaStyle m_AreaStyle = new AreaStyle();
/// <summary>
/// Whether to show dataZoom.
@@ -98,7 +105,7 @@ namespace XCharts
public bool enable
{
get { return m_Enable; }
set { if (PropertyUtility.SetStruct(ref m_Enable, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Enable, value)) SetVerticesDirty(); }
}
/// <summary>
/// The mode of data filter.
@@ -107,25 +114,25 @@ namespace XCharts
public FilterMode filterMode
{
get { return m_FilterMode; }
set { if (PropertyUtility.SetStruct(ref m_FilterMode, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_FilterMode, value)) SetVerticesDirty(); }
}
/// <summary>
/// Specify which xAxis is controlled by the dataZoom.
/// 控制哪一个 x 轴。
/// 控制 x 轴索引列表
/// </summary>
public int xAxisIndex
public List<int> xAxisIndexs
{
get { return m_XAxisIndex; }
set { if (PropertyUtility.SetStruct(ref m_XAxisIndex, value)) SetVerticesDirty(); }
get { return m_XAxisIndexs; }
set { if (PropertyUtil.SetClass(ref m_XAxisIndexs, value)) SetVerticesDirty(); }
}
/// <summary>
/// Specify which yAxis is controlled by the dataZoom.
/// 控制哪一个 y 轴。
/// 控制 y 轴索引列表
/// </summary>
public int yAxisIndex
public List<int> yAxisIndexs
{
get { return m_YAxisIndex; }
set { if (PropertyUtility.SetStruct(ref m_YAxisIndex, value)) SetVerticesDirty(); }
get { return m_YAxisIndexs; }
set { if (PropertyUtil.SetClass(ref m_YAxisIndexs, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether built-in support is supported.
@@ -137,7 +144,7 @@ namespace XCharts
public bool supportInside
{
get { return m_SupportInside; }
set { if (PropertyUtility.SetStruct(ref m_SupportInside, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_SupportInside, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether a slider is supported. There are separate sliders on which the user zooms or roams.
@@ -146,7 +153,7 @@ namespace XCharts
public bool supportSlider
{
get { return m_SupportSlider; }
set { if (PropertyUtility.SetStruct(ref m_SupportSlider, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_SupportSlider, value)) SetVerticesDirty(); }
}
/// <summary>
/// 是否支持框选。提供一个选框进行数据区域缩放。
@@ -154,7 +161,7 @@ namespace XCharts
private bool supportSelect
{
get { return m_SupportSelect; }
set { if (PropertyUtility.SetStruct(ref m_SupportSelect, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_SupportSelect, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether to show data shadow, to indicate the data tendency in brief.
@@ -164,7 +171,7 @@ namespace XCharts
public bool showDataShadow
{
get { return m_ShowDataShadow; }
set { if (PropertyUtility.SetStruct(ref m_ShowDataShadow, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_ShowDataShadow, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether to show detail, that is, show the detailed data information when dragging.
@@ -174,7 +181,7 @@ namespace XCharts
public bool showDetail
{
get { return m_ShowDetail; }
set { if (PropertyUtility.SetStruct(ref m_ShowDetail, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_ShowDetail, value)) SetVerticesDirty(); }
}
/// <summary>
/// Specify whether to lock the size of window (selected area).
@@ -185,7 +192,7 @@ namespace XCharts
public bool zoomLock
{
get { return m_ZoomLock; }
set { if (PropertyUtility.SetStruct(ref m_ZoomLock, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_ZoomLock, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether to show data shadow in dataZoom-silder component, to indicate the data tendency in brief.
@@ -197,32 +204,81 @@ namespace XCharts
/// The background color of the component.
/// 组件的背景颜色。
/// </summary>
private Color backgroundColor
public Color backgroundColor
{
get { return m_BackgroundColor; }
set { if (PropertyUtility.SetStruct(ref m_BackgroundColor, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_BackgroundColor, 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>
/// 边框宽。
/// </summary>
public float borderWidth
{
get { return m_BorderWidth; }
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetComponentDirty(); }
}
/// <summary>
/// Distance between dataZoom component and the bottom side of the container.
/// bottom value is a instant pixel value like 10.
/// bottom value is a instant pixel value like 10 or float value [0-1].
/// default:10
/// 组件离容器下侧的距离。
/// </summary>
public float bottom
{
get { return m_Bottom; }
set { if (PropertyUtility.SetStruct(ref m_Bottom, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Bottom, value)) SetVerticesDirty(); }
}
/// <summary>
/// The height of dataZoom component.
/// height value is a instant pixel value like 10.
/// default:50
/// 组件高度
/// Distance between dataZoom component and the top side of the container.
/// top value is a instant pixel value like 10 or float value [0-1].
/// default:10
/// 组件离容器上侧的距离
/// </summary>
public float height
public float top
{
get { return m_Height; }
set { if (PropertyUtility.SetStruct(ref m_Height, value)) SetVerticesDirty(); }
get { return m_Top; }
set { if (PropertyUtil.SetStruct(ref m_Top, value)) SetVerticesDirty(); }
}
/// <summary>
/// Distance between dataZoom component and the left side of the container.
/// left value is a instant pixel value like 10 or float value [0-1].
/// default:10
/// 组件离容器左侧的距离。
/// </summary>
public float left
{
get { return m_Left; }
set { if (PropertyUtil.SetStruct(ref m_Left, value)) SetVerticesDirty(); }
}
/// <summary>
/// Distance between dataZoom component and the right side of the container.
/// right value is a instant pixel value like 10 or float value [0-1].
/// default:10
/// 组件离容器右侧的距离。
/// </summary>
public float right
{
get { return m_Right; }
set { if (PropertyUtil.SetStruct(ref m_Right, value)) SetVerticesDirty(); }
}
/// <summary>
/// Use absolute value or percent value in DataZoom.start and DataZoom.end.
@@ -232,7 +288,7 @@ namespace XCharts
public RangeMode rangeMode
{
get { return m_RangeMode; }
set { if (PropertyUtility.SetStruct(ref m_RangeMode, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_RangeMode, value)) SetVerticesDirty(); }
}
/// <summary>
/// The start percentage of the window out of the data extent, in the range of 0 ~ 100.
@@ -261,7 +317,7 @@ namespace XCharts
public int minShowNum
{
get { return m_MinShowNum; }
set { if (PropertyUtility.SetStruct(ref m_MinShowNum, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_MinShowNum, value)) SetVerticesDirty(); }
}
/// <summary>
/// The sensitivity of dataZoom scroll.
@@ -272,37 +328,49 @@ namespace XCharts
public float scrollSensitivity
{
get { return m_ScrollSensitivity; }
set { if (PropertyUtility.SetStruct(ref m_ScrollSensitivity, value)) SetVerticesDirty(); }
}
/// <summary>
/// font size.
/// 文字的字体大小。
/// </summary>
public int fontSize
{
get { return m_FontSize; }
set { if (PropertyUtility.SetStruct(ref m_FontSize, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_ScrollSensitivity, value)) SetVerticesDirty(); }
}
/// <summary>
/// font style.
/// 文字字体的风格。
/// 文字格
/// </summary>
public FontStyle fontStyle
public TextStyle textStyle
{
get { return m_FontStyle; }
set { if (PropertyUtility.SetStruct(ref m_FontStyle, value)) SetComponentDirty(); }
get { return m_TextStyle; }
set { if (PropertyUtil.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
}
/// <summary>
/// 阴影线条样式。
/// </summary>
public LineStyle lineStyle
{
get { return m_LineStyle; }
set { if (PropertyUtil.SetClass(ref m_LineStyle, value)) SetComponentDirty(); }
}
/// <summary>
/// 阴影填充样式。
/// </summary>
public AreaStyle areaStyle
{
get { return m_AreaStyle; }
set { if (PropertyUtil.SetClass(ref m_AreaStyle, value)) SetComponentDirty(); }
}
public int index { get; internal set; }
public float runtimeX { get; private set; }
public float runtimeY { get; private set; }
public float runtimeWidth { get; private set; }
public float runtimeHeight { get; private set; }
/// <summary>
/// The start label.
/// 组件的开始信息文本。
/// </summary>
private Text m_StartLabel { get; set; }
private ChartText m_StartLabel { get; set; }
/// <summary>
/// The end label.
/// 组件的结束信息文本。
/// </summary>
private Text m_EndLabel { get; set; }
private ChartText m_EndLabel { get; set; }
public static DataZoom defaultDataZoom
{
@@ -310,18 +378,31 @@ namespace XCharts
{
return new DataZoom()
{
supportInside = true,
supportSlider = true,
filterMode = FilterMode.None,
xAxisIndex = 0,
yAxisIndex = 0,
xAxisIndexs = new List<int>() { 0 },
yAxisIndexs = new List<int>() { },
showDataShadow = true,
showDetail = false,
zoomLock = false,
m_Height = 0,
m_Bottom = 10,
m_Left = 10,
m_Right = 10,
m_Top = 0.9f,
rangeMode = RangeMode.Percent,
start = 30,
end = 70,
m_ScrollSensitivity = 10,
m_TextStyle = new TextStyle(),
m_LineStyle = new LineStyle(LineStyle.Type.Solid){
opacity = 0.3f
},
m_AreaStyle = new AreaStyle()
{
show = true,
opacity = 0.3f,
},
};
}
}
@@ -333,10 +414,14 @@ namespace XCharts
/// <param name="startX"></param>
/// <param name="width"></param>
/// <returns></returns>
public bool IsInZoom(Vector2 pos, float startX, float startY, float width)
public bool IsInZoom(Vector2 pos)
{
Rect rect = Rect.MinMaxRect(startX, startY + m_Bottom, startX + width, startY + m_Bottom + m_Height);
return rect.Contains(pos);
if (pos.x < runtimeX - 1 || pos.x > runtimeX + runtimeWidth + 1 ||
pos.y < runtimeY - 1 || pos.y > runtimeY + runtimeHeight + 1)
{
return false;
}
return false;
}
/// <summary>
@@ -346,11 +431,11 @@ namespace XCharts
/// <param name="startX"></param>
/// <param name="width"></param>
/// <returns></returns>
public bool IsInSelectedZoom(Vector2 pos, float startX, float startY, float width)
public bool IsInSelectedZoom(Vector2 pos)
{
var start = startX + width * m_Start / 100;
var end = startX + width * m_End / 100;
Rect rect = Rect.MinMaxRect(start, startY + m_Bottom, end, startY + m_Bottom + m_Height);
var start = runtimeX + runtimeWidth * m_Start / 100;
var end = runtimeX + runtimeWidth * m_End / 100;
Rect rect = Rect.MinMaxRect(start, runtimeY, end, runtimeY + runtimeHeight);
return rect.Contains(pos);
}
@@ -361,10 +446,10 @@ namespace XCharts
/// <param name="startX"></param>
/// <param name="width"></param>
/// <returns></returns>
public bool IsInStartZoom(Vector2 pos, float startX, float startY, float width)
public bool IsInStartZoom(Vector2 pos)
{
var start = startX + width * m_Start / 100;
Rect rect = Rect.MinMaxRect(start - 10, startY + m_Bottom, start + 10, startY + m_Bottom + m_Height);
var start = runtimeX + runtimeWidth * m_Start / 100;
Rect rect = Rect.MinMaxRect(start - 10, runtimeY, start + 10, runtimeY + runtimeHeight);
return rect.Contains(pos);
}
@@ -375,24 +460,29 @@ namespace XCharts
/// <param name="startX"></param>
/// <param name="width"></param>
/// <returns></returns>
public bool IsInEndZoom(Vector2 pos, float startX, float startY, float width)
public bool IsInEndZoom(Vector2 pos)
{
var end = startX + width * m_End / 100;
Rect rect = Rect.MinMaxRect(end - 10, startY + m_Bottom, end + 10, startY + m_Bottom + m_Height);
var end = runtimeX + runtimeWidth * m_End / 100;
Rect rect = Rect.MinMaxRect(end - 10, runtimeY, end + 10, runtimeY + runtimeHeight);
return rect.Contains(pos);
}
public bool IsContainsAxisIndex(int index)
{
return xAxisIndexs.Contains(index);// || yAxisIndexs.Contains(index);
}
/// <summary>
/// 是否显示文本
/// </summary>
/// <param name="flag"></param>
internal void SetLabelActive(bool flag)
{
if (m_StartLabel && m_StartLabel.gameObject.activeInHierarchy != flag)
if (m_StartLabel != null && m_StartLabel.gameObject.activeInHierarchy != flag)
{
m_StartLabel.gameObject.SetActive(flag);
}
if (m_EndLabel && m_EndLabel.gameObject.activeInHierarchy != flag)
if (m_EndLabel != null && m_EndLabel.gameObject.activeInHierarchy != flag)
{
m_EndLabel.gameObject.SetActive(flag);
}
@@ -404,7 +494,7 @@ namespace XCharts
/// <param name="text"></param>
internal void SetStartLabelText(string text)
{
if (m_StartLabel) m_StartLabel.text = text;
if (m_StartLabel != null) m_StartLabel.SetText(text);
}
/// <summary>
@@ -413,43 +503,56 @@ namespace XCharts
/// <param name="text"></param>
internal void SetEndLabelText(string text)
{
if (m_EndLabel) m_EndLabel.text = text;
if (m_EndLabel != null) m_EndLabel.SetText(text);
}
/// <summary>
/// 获取DataZoom的高当height设置为0时自动计算合适的偏移。
/// </summary>
/// <param name="gridBottom"></param>
/// <returns></returns>
internal float GetHeight(float gridBottom)
{
if (height <= 0)
{
height = gridBottom - bottom - 30;
if (height < 10) height = 10;
return height;
}
else return height;
}
internal void SetStartLabel(Text startLabel)
internal void SetStartLabel(ChartText startLabel)
{
m_StartLabel = startLabel;
}
internal void SetEndLabel(Text endLabel)
internal void SetEndLabel(ChartText endLabel)
{
m_EndLabel = endLabel;
}
internal void UpdateStartLabelPosition(Vector3 pos)
{
m_StartLabel.transform.localPosition = pos;
m_StartLabel.SetLocalPosition(pos);
}
internal void UpdateEndLabelPosition(Vector3 pos)
{
m_EndLabel.transform.localPosition = pos;
m_EndLabel.SetLocalPosition(pos);
}
internal void UpdateRuntimeData(float chartX, float chartY, float chartWidth, float chartHeight)
{
var runtimeLeft = left <= 1 ? left * chartWidth : left;
var runtimeBottom = bottom <= 1 ? bottom * chartHeight : bottom;
var runtimeTop = top <= 1 ? top * chartHeight : top;
var runtimeRight = right <= 1 ? right * chartWidth : right;
runtimeX = chartX + runtimeLeft;
runtimeY = chartY + runtimeBottom;
runtimeWidth = chartWidth - runtimeLeft - runtimeRight;
runtimeHeight = chartHeight - runtimeTop - runtimeBottom;
}
public Color32 GetFillerColor(Color32 themeColor)
{
if (ChartHelper.IsClearColor(fillerColor)) return themeColor;
else return fillerColor;
}
public Color32 GetBackgroundColor(Color32 themeColor)
{
if (ChartHelper.IsClearColor(backgroundColor)) return themeColor;
else return backgroundColor;
}
public Color32 GetBorderColor(Color32 themeColor)
{
if (ChartHelper.IsClearColor(borderColor)) return themeColor;
else return borderColor;
}
}
}

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections.Generic;
using UnityEngine;
@@ -47,11 +47,12 @@ namespace XCharts
[SerializeField] private float m_ItemGap = 10f;
[SerializeField] private bool m_ItemAutoColor = true;
[SerializeField] private string m_Formatter;
[SerializeField] private TextStyle m_TextStyle = new TextStyle(18);
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
[SerializeField] private List<string> m_Data = new List<string>();
[SerializeField] private List<Sprite> m_Icons = new List<Sprite>();
private Dictionary<string, LegendItem> m_DataBtnList = new Dictionary<string, LegendItem>();
private Dictionary<int, float> m_RuntimeEachWidth = new Dictionary<int, float>();
/// <summary>
/// Whether to show legend component.
@@ -60,7 +61,7 @@ namespace XCharts
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); }
}
/// <summary>
/// Selected mode of legend, which controls whether series can be toggled displaying by clicking legends.
@@ -71,7 +72,7 @@ namespace XCharts
public SelectedMode selectedMode
{
get { return m_SelectedMode; }
set { if (PropertyUtility.SetStruct(ref m_SelectedMode, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_SelectedMode, value)) SetComponentDirty(); }
}
/// <summary>
/// Specify whether the layout of legend component is horizontal or vertical.
@@ -81,7 +82,7 @@ namespace XCharts
public Orient orient
{
get { return m_Orient; }
set { if (PropertyUtility.SetStruct(ref m_Orient, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Orient, value)) SetComponentDirty(); }
}
/// <summary>
/// The location of legend.
@@ -91,7 +92,7 @@ namespace XCharts
public Location location
{
get { return m_Location; }
set { if (PropertyUtility.SetClass(ref m_Location, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetClass(ref m_Location, value)) SetComponentDirty(); }
}
/// <summary>
/// Image width of legend symbol.
@@ -101,7 +102,7 @@ namespace XCharts
public float itemWidth
{
get { return m_ItemWidth; }
set { if (PropertyUtility.SetStruct(ref m_ItemWidth, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_ItemWidth, value)) SetComponentDirty(); }
}
/// <summary>
/// Image height of legend symbol.
@@ -111,7 +112,7 @@ namespace XCharts
public float itemHeight
{
get { return m_ItemHeight; }
set { if (PropertyUtility.SetStruct(ref m_ItemHeight, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_ItemHeight, value)) SetComponentDirty(); }
}
/// <summary>
/// The distance between each legend, horizontal distance in horizontal layout, and vertical distance in vertical layout.
@@ -121,7 +122,7 @@ namespace XCharts
public float itemGap
{
get { return m_ItemGap; }
set { if (PropertyUtility.SetStruct(ref m_ItemGap, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_ItemGap, value)) SetComponentDirty(); }
}
/// <summary>
/// Whether the legend symbol matches the color automatically.
@@ -131,7 +132,7 @@ namespace XCharts
public bool itemAutoColor
{
get { return m_ItemAutoColor; }
set { if (PropertyUtility.SetStruct(ref m_ItemAutoColor, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_ItemAutoColor, value)) SetComponentDirty(); }
}
/// <summary>
/// Legend content string template formatter. Support for wrapping lines with \n. Template:{name}.
@@ -142,7 +143,7 @@ namespace XCharts
public string formatter
{
get { return m_Formatter; }
set { if (PropertyUtility.SetClass(ref m_Formatter, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetClass(ref m_Formatter, value)) SetComponentDirty(); }
}
/// <summary>
/// the style of text.
@@ -151,7 +152,7 @@ namespace XCharts
public TextStyle textStyle
{
get { return m_TextStyle; }
set { if (PropertyUtility.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
}
/// <summary>
/// Data array of legend. An array item is usually a name representing string. (If it is a pie chart,
@@ -173,6 +174,7 @@ namespace XCharts
get { return m_Icons; }
set { if (value != null) { m_Icons = value; SetComponentDirty(); } }
}
public int index { get; internal set; }
/// <summary>
/// 图表是否需要刷新(图例组件不需要刷新图表)
/// </summary>
@@ -209,7 +211,7 @@ namespace XCharts
/// <summary>
/// 多列时每列的宽度
/// </summary>
public Dictionary<int, float> runtimeEachWidth { get; internal set; }
public Dictionary<int, float> runtimeEachWidth { get { return m_RuntimeEachWidth; }}
/// <summary>
/// 单列高度
/// </summary>
@@ -231,11 +233,10 @@ namespace XCharts
m_ItemWidth = 24.0f,
m_ItemHeight = 12.0f,
m_ItemGap = 10f,
runtimeEachWidth = new Dictionary<int, float>()
};
legend.location.top = 30;
legend.location.top = 35;
legend.textStyle.offset = new Vector2(2, 0);
legend.textStyle.fontSize = 18;
legend.textStyle.fontSize = 0;
return legend;
}
}
@@ -393,18 +394,6 @@ namespace XCharts
m_Location.OnChanged();
}
/// <summary>
/// Parsing the data from the JSON string.
/// 从json字符串解析数据json格式如['legend1','legend2','legend3','legend4','legend5']
/// </summary>
/// <param name="jsonData"></param>
public override void ParseJsonData(string jsonData)
{
if (string.IsNullOrEmpty(jsonData) || !m_DataFromJson) return;
m_Data = ChartHelper.ParseStringFromString(jsonData);
SetComponentDirty();
}
/// <summary>
/// 获得图例格式化后的显示内容。
/// </summary>

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System;
using UnityEngine;
@@ -33,7 +33,7 @@ namespace XCharts
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// [default:[0.5f,0.45f]]The center of ploar. The center[0] is the x-coordinate, and the center[1] is the y-coordinate.
@@ -53,7 +53,7 @@ namespace XCharts
public float radius
{
get { return m_Radius; }
set { if (PropertyUtility.SetStruct(ref m_Radius, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Radius, value)) SetAllDirty(); }
}
/// <summary>
/// [default:Color.clear]Background color of polar, which is transparent by default.
@@ -62,9 +62,9 @@ namespace XCharts
public Color backgroundColor
{
get { return m_BackgroundColor; }
set { if (PropertyUtility.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
}
public int index { get; internal set; }
/// <summary>
/// the center position of polar in container.
/// 极坐标在容器中的具体中心点。

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
using System.Collections.Generic;
@@ -84,10 +84,12 @@ namespace XCharts
/// </summary>
public Text text { get; set; }
}
[SerializeField] private bool m_Show;
[SerializeField] private Shape m_Shape;
[SerializeField] private float m_Radius = 100;
[SerializeField] private int m_SplitNumber = 5;
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.5f };
[SerializeField] private AxisLine m_AxisLine = AxisLine.defaultAxisLine;
[SerializeField] private AxisSplitLine m_SplitLine = AxisSplitLine.defaultSplitLine;
[SerializeField] private AxisSplitArea m_SplitArea = AxisSplitArea.defaultSplitArea;
[SerializeField] private bool m_Indicator = true;
@@ -97,6 +99,12 @@ namespace XCharts
[SerializeField] private bool m_IsAxisTooltip;
[SerializeField] private List<Indicator> m_IndicatorList = new List<Indicator>();
/// <summary>
/// [default:true]
/// Set this to false to prevent the radar from showing.
/// 是否显示雷达坐标系组件。
/// </summary>
public bool show { get { return m_Show; } set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); } }
/// <summary>
/// Radar render type, in which 'Polygon' and 'Circle' are supported.
/// 雷达图绘制类型,支持 'Polygon' 和 'Circle'。
/// </summary>
@@ -104,7 +112,7 @@ namespace XCharts
public Shape shape
{
get { return m_Shape; }
set { if (PropertyUtility.SetStruct(ref m_Shape, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Shape, value)) SetAllDirty(); }
}
/// <summary>
/// the radius of radar.
@@ -113,7 +121,7 @@ namespace XCharts
public float radius
{
get { return m_Radius; }
set { if (PropertyUtility.SetStruct(ref m_Radius, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Radius, value)) SetAllDirty(); }
}
/// <summary>
/// Segments of indicator axis.
@@ -122,7 +130,7 @@ namespace XCharts
public int splitNumber
{
get { return m_SplitNumber; }
set { if (PropertyUtility.SetStruct(ref m_SplitNumber, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_SplitNumber, value)) SetAllDirty(); }
}
/// <summary>
/// the center of radar chart.
@@ -135,13 +143,22 @@ namespace XCharts
set { if (value != null) { m_Center = value; SetAllDirty(); } }
}
/// <summary>
/// axis line.
/// 轴线。
/// </summary>
public AxisLine axisLine
{
get { return m_AxisLine; }
set { if (PropertyUtil.SetClass(ref m_AxisLine, value, true)) SetAllDirty(); }
}
/// <summary>
/// split line.
/// 分割线。
/// </summary>
public AxisSplitLine splitLine
{
get { return m_SplitLine; }
set { if (PropertyUtility.SetClass(ref m_SplitLine, value, true)) SetAllDirty(); }
set { if (PropertyUtil.SetClass(ref m_SplitLine, value, true)) SetAllDirty(); }
}
/// <summary>
/// Split area of axis in grid area.
@@ -150,7 +167,7 @@ namespace XCharts
public AxisSplitArea splitArea
{
get { return m_SplitArea; }
set { if (PropertyUtility.SetClass(ref m_SplitArea, value, true)) SetAllDirty(); }
set { if (PropertyUtil.SetClass(ref m_SplitArea, value, true)) SetAllDirty(); }
}
/// <summary>
/// Whether to show indicator.
@@ -159,7 +176,7 @@ namespace XCharts
public bool indicator
{
get { return m_Indicator; }
set { if (PropertyUtility.SetStruct(ref m_Indicator, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Indicator, value)) SetComponentDirty(); }
}
/// <summary>
/// The gap of indicator and radar.
@@ -168,7 +185,7 @@ namespace XCharts
public float indicatorGap
{
get { return m_IndicatorGap; }
set { if (PropertyUtility.SetStruct(ref m_IndicatorGap, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_IndicatorGap, value)) SetComponentDirty(); }
}
/// <summary>
/// The ratio of maximum and minimum values rounded upward. The default is 0, which is automatically calculated.
@@ -177,7 +194,7 @@ namespace XCharts
public int ceilRate
{
get { return m_CeilRate; }
set { if (PropertyUtility.SetStruct(ref m_CeilRate, value < 0 ? 0 : value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_CeilRate, value < 0 ? 0 : value)) SetAllDirty(); }
}
/// <summary>
/// 是否Tooltip显示轴线上的所有数据。
@@ -185,7 +202,7 @@ namespace XCharts
public bool isAxisTooltip
{
get { return m_IsAxisTooltip; }
set { if (PropertyUtility.SetStruct(ref m_IsAxisTooltip, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_IsAxisTooltip, value)) SetAllDirty(); }
}
/// <summary>
/// The position type of indicator.
@@ -194,7 +211,7 @@ namespace XCharts
public PositionType positionType
{
get { return m_PositionType; }
set { if (PropertyUtility.SetStruct(ref m_PositionType, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_PositionType, value)) SetAllDirty(); }
}
/// <summary>
/// the indicator list.
@@ -226,6 +243,7 @@ namespace XCharts
{
var radar = new Radar
{
m_Show = true,
m_Shape = Shape.Polygon,
m_Radius = 0.35f,
m_SplitNumber = 5,
@@ -242,7 +260,6 @@ namespace XCharts
radar.center[1] = 0.4f;
radar.splitLine.show = true;
radar.splitArea.show = true;
radar.splitLine.lineStyle.width = 0.6f;
return radar;
}
}
@@ -259,38 +276,6 @@ namespace XCharts
return true;
}
public override void ParseJsonData(string jsonData)
{
if (string.IsNullOrEmpty(jsonData) || !m_DataFromJson) return;
string pattern = "[\"|'](.*?)[\"|']";
if (Regex.IsMatch(jsonData, pattern))
{
m_IndicatorList.Clear();
MatchCollection m = Regex.Matches(jsonData, pattern);
foreach (Match match in m)
{
m_IndicatorList.Add(new Indicator()
{
name = match.Groups[1].Value
});
}
}
pattern = "(\\d+)";
if (Regex.IsMatch(jsonData, pattern))
{
MatchCollection m = Regex.Matches(jsonData, pattern);
int index = 0;
foreach (Match match in m)
{
if (m_IndicatorList[index] != null)
{
m_IndicatorList[index].max = int.Parse(match.Groups[1].Value);
}
index++;
}
}
}
public float GetIndicatorMin(int index)
{
if (index >= 0 && index < m_IndicatorList.Count)

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System;
using System.Collections.Generic;
@@ -226,9 +226,11 @@ namespace XCharts
[SerializeField] private SerieType m_Type;
[SerializeField] private string m_Name;
[SerializeField] private string m_Stack;
[SerializeField] [Range(0, 1)] private int m_AxisIndex = 0;
[SerializeField] private int m_XAxisIndex = 0;
[SerializeField] private int m_YAxisIndex = 0;
[SerializeField] private int m_RadarIndex = 0;
[SerializeField] private int m_VesselIndex = 0;
[SerializeField] private int m_PolarIndex = 0;
[SerializeField] protected int m_MinShow;
[SerializeField] protected int m_MaxShow;
[SerializeField] protected int m_MaxCache;
@@ -267,7 +269,7 @@ namespace XCharts
[SerializeField] private bool m_ClickOffset = true;
[SerializeField] private RoseType m_RoseType = RoseType.None;
[SerializeField] private float m_Space;
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.5f };
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.45f };
[SerializeField] private float[] m_Radius = new float[2] { 0, 80 };
[SerializeField] private SerieLabel m_Label = new SerieLabel();
[SerializeField] private SerieAnimation m_Animation = new SerieAnimation();
@@ -310,7 +312,7 @@ namespace XCharts
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) { SetVerticesDirty(); SetNameDirty(); } }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) { SetVerticesDirty(); SetNameDirty(); } }
}
/// <summary>
/// the chart type of serie.
@@ -319,7 +321,7 @@ namespace XCharts
public SerieType type
{
get { return m_Type; }
set { if (PropertyUtility.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
}
/// <summary>
/// Series name used for displaying in tooltip and filtering with legend.
@@ -328,7 +330,7 @@ namespace XCharts
public string name
{
get { return m_Name; }
set { if (PropertyUtility.SetClass(ref m_Name, value)) { SetVerticesDirty(); SetNameDirty(); } }
set { if (PropertyUtil.SetClass(ref m_Name, value)) { SetVerticesDirty(); SetNameDirty(); } }
}
/// <summary>
/// Legend name. When the serie name is not empty, the legend name is the series name; Otherwise, it is index.
@@ -342,16 +344,25 @@ namespace XCharts
public string stack
{
get { return m_Stack; }
set { if (PropertyUtility.SetClass(ref m_Stack, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetClass(ref m_Stack, value)) SetVerticesDirty(); }
}
/// <summary>
/// Index of axis to combine with, which is useful for multiple x axes in one chart.
/// 使用的坐标轴轴的 index,在单个图表实例中存在多个坐标轴轴的时候有用
/// the index of XAxis.
/// 使用X轴的index。
/// </summary>
public int axisIndex
public int xAxisIndex
{
get { return m_AxisIndex; }
set { if (PropertyUtility.SetStruct(ref m_AxisIndex, value)) SetVerticesDirty(); }
get { return m_XAxisIndex; }
set { if (PropertyUtil.SetStruct(ref m_XAxisIndex, value)) SetVerticesDirty(); }
}
/// <summary>
/// the index of YAxis.
/// 使用Y轴的index。
/// </summary>
public int yAxisIndex
{
get { return m_YAxisIndex; }
set { if (PropertyUtil.SetStruct(ref m_YAxisIndex, value)) SetVerticesDirty(); }
}
/// <summary>
/// Index of radar component that radar chart uses.
@@ -360,7 +371,7 @@ namespace XCharts
public int radarIndex
{
get { return m_RadarIndex; }
set { if (PropertyUtility.SetStruct(ref m_RadarIndex, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_RadarIndex, value)) SetVerticesDirty(); }
}
/// <summary>
/// Index of vesel component that liquid chart uses.
@@ -369,7 +380,16 @@ namespace XCharts
public int vesselIndex
{
get { return m_VesselIndex; }
set { if (PropertyUtility.SetStruct(ref m_VesselIndex, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_VesselIndex, value)) SetVerticesDirty(); }
}
/// <summary>
/// Index of polar component that serie uses.
/// 所使用的 polar 组件的 index。
/// </summary>
public int polarIndex
{
get { return m_PolarIndex; }
set { if (PropertyUtil.SetStruct(ref m_PolarIndex, value)) SetVerticesDirty(); }
}
/// <summary>
/// The min number of data to show in chart.
@@ -378,7 +398,7 @@ namespace XCharts
public int minShow
{
get { return m_MinShow; }
set { if (PropertyUtility.SetStruct(ref m_MinShow, value < 0 ? 0 : value)) { SetVerticesDirty(); } }
set { if (PropertyUtil.SetStruct(ref m_MinShow, value < 0 ? 0 : value)) { SetVerticesDirty(); } }
}
/// <summary>
/// The max number of data to show in chart.
@@ -387,7 +407,7 @@ namespace XCharts
public int maxShow
{
get { return m_MaxShow; }
set { if (PropertyUtility.SetStruct(ref m_MaxShow, value < 0 ? 0 : value)) { SetVerticesDirty(); } }
set { if (PropertyUtil.SetStruct(ref m_MaxShow, value < 0 ? 0 : value)) { SetVerticesDirty(); } }
}
/// <summary>
/// The max number of serie data cache.
@@ -398,7 +418,7 @@ namespace XCharts
public int maxCache
{
get { return m_MaxCache; }
set { if (PropertyUtility.SetStruct(ref m_MaxCache, value < 0 ? 0 : value)) { SetVerticesDirty(); } }
set { if (PropertyUtil.SetStruct(ref m_MaxCache, value < 0 ? 0 : value)) { SetVerticesDirty(); } }
}
/// <summary>
/// The style of area.
@@ -407,7 +427,7 @@ namespace XCharts
public AreaStyle areaStyle
{
get { return m_AreaStyle; }
set { if (PropertyUtility.SetClass(ref m_AreaStyle, value, true)) SetVerticesDirty(); }
set { if (PropertyUtil.SetClass(ref m_AreaStyle, value, true)) SetVerticesDirty(); }
}
/// <summary>
/// the symbol of serie data item.
@@ -416,7 +436,7 @@ namespace XCharts
public SerieSymbol symbol
{
get { return m_Symbol; }
set { if (PropertyUtility.SetClass(ref m_Symbol, value, true)) SetVerticesDirty(); }
set { if (PropertyUtil.SetClass(ref m_Symbol, value, true)) SetVerticesDirty(); }
}
/// <summary>
/// The type of line chart.
@@ -425,7 +445,7 @@ namespace XCharts
public LineType lineType
{
get { return m_LineType; }
set { if (PropertyUtility.SetStruct(ref m_LineType, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_LineType, value)) SetVerticesDirty(); }
}
/// <summary>
/// the min pixel dist of sample.
@@ -434,7 +454,7 @@ namespace XCharts
public float sampleDist
{
get { return m_SampleDist; }
set { if (PropertyUtility.SetStruct(ref m_SampleDist, value < 0 ? 0 : value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_SampleDist, value < 0 ? 0 : value)) SetVerticesDirty(); }
}
/// <summary>
/// the type of sample.
@@ -443,7 +463,7 @@ namespace XCharts
public SampleType sampleType
{
get { return m_SampleType; }
set { if (PropertyUtility.SetStruct(ref m_SampleType, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_SampleType, value)) SetVerticesDirty(); }
}
/// <summary>
/// 设定的采样平均值。当sampleType 为 Peak 时用于和过滤数据的平均值做对比是取最大值还是最小值。默认为0时会实时计算所有数据的平均值。
@@ -451,7 +471,7 @@ namespace XCharts
public float sampleAverage
{
get { return m_SampleAverage; }
set { if (PropertyUtility.SetStruct(ref m_SampleAverage, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_SampleAverage, value)) SetVerticesDirty(); }
}
/// <summary>
/// The style of line.
@@ -460,7 +480,7 @@ namespace XCharts
public LineStyle lineStyle
{
get { return m_LineStyle; }
set { if (PropertyUtility.SetClass(ref m_LineStyle, value, true)) SetVerticesDirty(); }
set { if (PropertyUtil.SetClass(ref m_LineStyle, value, true)) SetVerticesDirty(); }
}
/// <summary>
/// 柱形图类型。
@@ -468,7 +488,7 @@ namespace XCharts
public BarType barType
{
get { return m_BarType; }
set { if (PropertyUtility.SetStruct(ref m_BarType, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_BarType, value)) SetVerticesDirty(); }
}
/// <summary>
/// 柱形图是否为百分比堆积。相同stack的serie只要有一个barPercentStack为true则就显示成百分比堆叠柱状图。
@@ -476,7 +496,7 @@ namespace XCharts
public bool barPercentStack
{
get { return m_BarPercentStack; }
set { if (PropertyUtility.SetStruct(ref m_BarPercentStack, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_BarPercentStack, value)) SetVerticesDirty(); }
}
/// <summary>
/// The width of the bar. Adaptive when default 0.
@@ -485,7 +505,7 @@ namespace XCharts
public float barWidth
{
get { return m_BarWidth; }
set { if (PropertyUtility.SetStruct(ref m_BarWidth, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_BarWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// The gap between bars between different series, is a percent value like '0.3f' , which means 30% of the bar width, can be set as a fixed value.
@@ -500,7 +520,7 @@ namespace XCharts
public float barGap
{
get { return m_BarGap; }
set { if (PropertyUtility.SetStruct(ref m_BarGap, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_BarGap, value)) SetVerticesDirty(); }
}
/// <summary>
/// The bar gap of a single series, defaults to be 20% of the category gap, can be set as a fixed value.
@@ -513,7 +533,7 @@ namespace XCharts
public float barCategoryGap
{
get { return m_BarCategoryGap; }
set { if (PropertyUtility.SetStruct(ref m_BarCategoryGap, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_BarCategoryGap, value)) SetVerticesDirty(); }
}
/// <summary>
/// 斑马线的粗细。
@@ -521,7 +541,7 @@ namespace XCharts
public float barZebraWidth
{
get { return m_BarZebraWidth; }
set { if (PropertyUtility.SetStruct(ref m_BarZebraWidth, value < 0 ? 0 : value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_BarZebraWidth, value < 0 ? 0 : value)) SetVerticesDirty(); }
}
/// <summary>
/// 斑马线的间距。
@@ -529,7 +549,7 @@ namespace XCharts
public float barZebraGap
{
get { return m_BarZebraGap; }
set { if (PropertyUtility.SetStruct(ref m_BarZebraGap, value < 0 ? 0 : value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_BarZebraGap, value < 0 ? 0 : value)) SetVerticesDirty(); }
}
/// <summary>
@@ -539,7 +559,7 @@ namespace XCharts
public bool pieClickOffset
{
get { return m_ClickOffset; }
set { if (PropertyUtility.SetStruct(ref m_ClickOffset, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_ClickOffset, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether to show as Nightingale chart.
@@ -548,7 +568,7 @@ namespace XCharts
public RoseType pieRoseType
{
get { return m_RoseType; }
set { if (PropertyUtility.SetStruct(ref m_RoseType, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_RoseType, value)) SetVerticesDirty(); }
}
/// <summary>
/// the space of pie chart item.
@@ -557,7 +577,7 @@ namespace XCharts
public float pieSpace
{
get { return m_Space; }
set { if (PropertyUtility.SetStruct(ref m_Space, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Space, value)) SetVerticesDirty(); }
}
/// <summary>
/// the center of chart.
@@ -577,25 +597,13 @@ namespace XCharts
get { return m_Radius; }
set { if (value != null && value.Length == 2) { m_Radius = value; SetVerticesDirty(); } }
}
[Obsolete("Use Serie.center instead.", true)]
public float[] pieCenter
{
get { return center; }
set { center = value; }
}
[Obsolete("Use Serie.radius instead.", true)]
public float[] pieRadius
{
get { return radius; }
set { radius = value; }
}
/// <summary>
/// 最小值,映射到 startAngle。
/// </summary>
public float min
{
get { return m_Min; }
set { if (PropertyUtility.SetStruct(ref m_Min, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Min, value)) SetVerticesDirty(); }
}
/// <summary>
/// 最大值,映射到 endAngle。
@@ -603,7 +611,7 @@ namespace XCharts
public float max
{
get { return m_Max; }
set { if (PropertyUtility.SetStruct(ref m_Max, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Max, value)) SetVerticesDirty(); }
}
/// <summary>
/// 起始角度。和时钟一样12点钟位置是0度顺时针到360度。
@@ -611,7 +619,7 @@ namespace XCharts
public float startAngle
{
get { return m_StartAngle; }
set { if (PropertyUtility.SetStruct(ref m_StartAngle, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_StartAngle, value)) SetVerticesDirty(); }
}
/// <summary>
/// 结束角度。和时钟一样12点钟位置是0度顺时针到360度。
@@ -619,7 +627,7 @@ namespace XCharts
public float endAngle
{
get { return m_EndAngle; }
set { if (PropertyUtility.SetStruct(ref m_EndAngle, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_EndAngle, value)) SetVerticesDirty(); }
}
/// <summary>
/// 是否顺时针。
@@ -627,7 +635,7 @@ namespace XCharts
public bool clockwise
{
get { return m_Clockwise; }
set { if (PropertyUtility.SetStruct(ref m_Clockwise, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Clockwise, value)) SetVerticesDirty(); }
}
/// <summary>
@@ -636,7 +644,7 @@ namespace XCharts
public float ringGap
{
get { return m_RingGap; }
set { if (PropertyUtility.SetStruct(ref m_RingGap, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_RingGap, value)) SetVerticesDirty(); }
}
/// <summary>
/// 刻度分割段数。最大可设置36。
@@ -644,7 +652,7 @@ namespace XCharts
public int splitNumber
{
get { return m_SplitNumber; }
set { if (PropertyUtility.SetStruct(ref m_SplitNumber, value > 36 ? 36 : value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_SplitNumber, value > 36 ? 36 : value)) SetVerticesDirty(); }
}
/// <summary>
/// 是否开启圆弧效果。
@@ -652,7 +660,7 @@ namespace XCharts
public bool roundCap
{
get { return m_RoundCap; }
set { if (PropertyUtility.SetStruct(ref m_RoundCap, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_RoundCap, value)) SetVerticesDirty(); }
}
/// <summary>
/// 是否开启忽略数据。当为 true 时,数据值为 ignoreValue 时不进行绘制。
@@ -660,7 +668,7 @@ namespace XCharts
public bool ignore
{
get { return m_Ignore; }
set { if (PropertyUtility.SetStruct(ref m_Ignore, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Ignore, value)) SetVerticesDirty(); }
}
/// <summary>
/// 忽略数据的默认值。当ignore为true才有效。
@@ -668,7 +676,7 @@ namespace XCharts
public float ignoreValue
{
get { return m_IgnoreValue; }
set { if (PropertyUtility.SetStruct(ref m_IgnoreValue, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_IgnoreValue, value)) SetVerticesDirty(); }
}
/// <summary>
/// 雷达图类型。
@@ -676,7 +684,7 @@ namespace XCharts
public RadarType radarType
{
get { return m_RadarType; }
set { if (PropertyUtility.SetStruct(ref m_RadarType, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_RadarType, value)) SetVerticesDirty(); }
}
/// <summary>
/// 仪表盘轴线。
@@ -684,7 +692,7 @@ namespace XCharts
public GaugeAxis gaugeAxis
{
get { return m_GaugeAxis; }
set { if (PropertyUtility.SetClass(ref m_GaugeAxis, value, true)) SetVerticesDirty(); }
set { if (PropertyUtil.SetClass(ref m_GaugeAxis, value, true)) SetVerticesDirty(); }
}
/// <summary>
/// 仪表盘指针。
@@ -692,7 +700,7 @@ namespace XCharts
public GaugePointer gaugePointer
{
get { return m_GaugePointer; }
set { if (PropertyUtility.SetClass(ref m_GaugePointer, value, true)) SetVerticesDirty(); }
set { if (PropertyUtil.SetClass(ref m_GaugePointer, value, true)) SetVerticesDirty(); }
}
/// <summary>
/// 仪表盘类型。
@@ -700,7 +708,7 @@ namespace XCharts
public GaugeType gaugeType
{
get { return m_GaugeType; }
set { if (PropertyUtility.SetStruct(ref m_GaugeType, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_GaugeType, value)) SetVerticesDirty(); }
}
/// <summary>
/// Text label of graphic element,to explain some data information about graphic item like value, name and so on.
@@ -709,7 +717,7 @@ namespace XCharts
public SerieLabel label
{
get { return m_Label; }
set { if (PropertyUtility.SetClass(ref m_Label, value, true)) SetAllDirty(); }
set { if (PropertyUtil.SetClass(ref m_Label, value, true)) SetAllDirty(); }
}
/// <summary>
/// The start animation.
@@ -718,7 +726,7 @@ namespace XCharts
public SerieAnimation animation
{
get { return m_Animation; }
set { if (PropertyUtility.SetClass(ref m_Animation, value, true)) SetVerticesDirty(); }
set { if (PropertyUtil.SetClass(ref m_Animation, value, true)) SetVerticesDirty(); }
}
/// <summary>
/// The arrow of line.
@@ -727,7 +735,7 @@ namespace XCharts
public LineArrow lineArrow
{
get { return m_LineArrow; }
set { if (PropertyUtility.SetClass(ref m_LineArrow, value, true)) SetVerticesDirty(); }
set { if (PropertyUtil.SetClass(ref m_LineArrow, value, true)) SetVerticesDirty(); }
}
/// <summary>
/// The style of data item.
@@ -736,7 +744,7 @@ namespace XCharts
public ItemStyle itemStyle
{
get { return m_ItemStyle; }
set { if (PropertyUtility.SetClass(ref m_ItemStyle, value, true)) SetVerticesDirty(); }
set { if (PropertyUtil.SetClass(ref m_ItemStyle, value, true)) SetVerticesDirty(); }
}
/// <summary>
/// 高亮的图形样式和文本标签样式。
@@ -744,7 +752,7 @@ namespace XCharts
public Emphasis emphasis
{
get { return m_Emphasis; }
set { if (PropertyUtility.SetClass(ref m_Emphasis, value, true)) SetVerticesDirty(); }
set { if (PropertyUtil.SetClass(ref m_Emphasis, value, true)) SetVerticesDirty(); }
}
/// <summary>
/// 标题样式。
@@ -752,7 +760,7 @@ namespace XCharts
public TitleStyle titleStyle
{
get { return m_TitleStyle; }
set { if (PropertyUtility.SetClass(ref m_TitleStyle, value, true)) SetAllDirty(); }
set { if (PropertyUtil.SetClass(ref m_TitleStyle, value, true)) SetAllDirty(); }
}
/// <summary>
/// 数据项里的数据维数。
@@ -769,7 +777,7 @@ namespace XCharts
public bool clip
{
get { return m_Clip; }
set { if (PropertyUtility.SetStruct(ref m_Clip, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Clip, value)) SetVerticesDirty(); }
}
/// <summary>
/// Show negative number as positive number.
@@ -778,7 +786,7 @@ namespace XCharts
public bool showAsPositiveNumber
{
get { return m_ShowAsPositiveNumber; }
set { if (PropertyUtility.SetStruct(ref m_ShowAsPositiveNumber, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_ShowAsPositiveNumber, value)) SetComponentDirty(); }
}
/// <summary>
/// 是否开启大数据量优化,在数据图形特别多而出现卡顿时候可以开启。
@@ -790,7 +798,7 @@ namespace XCharts
get { return m_Large; }
set
{
if (PropertyUtility.SetStruct(ref m_Large, value))
if (PropertyUtil.SetStruct(ref m_Large, value))
{
SetAllDirty();
label.SetComponentDirty();
@@ -805,7 +813,7 @@ namespace XCharts
get { return m_LargeThreshold; }
set
{
if (PropertyUtility.SetStruct(ref m_LargeThreshold, value))
if (PropertyUtil.SetStruct(ref m_LargeThreshold, value))
{
SetAllDirty();
label.SetComponentDirty();
@@ -818,7 +826,7 @@ namespace XCharts
public bool avoidLabelOverlap
{
get { return m_AvoidLabelOverlap; }
set { if (PropertyUtility.SetStruct(ref m_AvoidLabelOverlap, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_AvoidLabelOverlap, value)) SetVerticesDirty(); }
}
/// <summary>
/// Wave length of the wave, which is relative to the diameter.
@@ -827,7 +835,7 @@ namespace XCharts
public float waveLength
{
get { return m_WaveLength; }
set { if (PropertyUtility.SetStruct(ref m_WaveLength, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_WaveLength, value)) SetVerticesDirty(); }
}
/// <summary>
/// 波高。
@@ -835,7 +843,7 @@ namespace XCharts
public float waveHeight
{
get { return m_WaveHeight; }
set { if (PropertyUtility.SetStruct(ref m_WaveHeight, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_WaveHeight, value)) SetVerticesDirty(); }
}
/// <summary>
/// 波偏移。
@@ -843,7 +851,7 @@ namespace XCharts
public float waveOffset
{
get { return m_WaveOffset; }
set { if (PropertyUtility.SetStruct(ref m_WaveOffset, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_WaveOffset, value)) SetVerticesDirty(); }
}
/// <summary>
/// 波速。正数时左移,负数时右移。
@@ -851,7 +859,7 @@ namespace XCharts
public float waveSpeed
{
get { return m_WaveSpeed; }
set { if (PropertyUtility.SetStruct(ref m_WaveSpeed, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_WaveSpeed, value)) SetVerticesDirty(); }
}
/// <summary>
/// 系列中的数据内容数组。SerieData可以设置1到n维数据。
@@ -950,7 +958,9 @@ namespace XCharts
/// </summary>
public float runtimePieDataTotal { get; internal set; }
public float runtimeWaveSpeed { get; internal set; }
public Painter runtimeCanvas { get; internal set; }
internal float runtimeCheckValue { get; set; }
public int runtimeGridIndex { get; internal set; }
public bool nameDirty { get { return m_NameDirty; } }
private void SetNameDirty()
@@ -1413,7 +1423,8 @@ namespace XCharts
/// <returns></returns>
public List<SerieData> GetDataList(DataZoom dataZoom = null)
{
if (dataZoom != null && dataZoom.enable)
if (dataZoom != null && dataZoom.enable
&& (dataZoom.xAxisIndexs.Contains(xAxisIndex) || dataZoom.yAxisIndexs.Contains(yAxisIndex)))
{
UpdateFilterData(dataZoom);
return m_FilterData;
@@ -1431,7 +1442,8 @@ namespace XCharts
/// <param name="dataZoom"></param>
internal void UpdateFilterData(DataZoom dataZoom)
{
if (dataZoom != null && dataZoom.enable)
if (dataZoom != null && dataZoom.enable
&& (dataZoom.xAxisIndexs.Contains(xAxisIndex) || dataZoom.yAxisIndexs.Contains(yAxisIndex)))
{
var startIndex = (int)((data.Count - 1) * dataZoom.start / 100);
var endIndex = (int)((data.Count - 1) * dataZoom.end / 100);
@@ -1674,6 +1686,14 @@ namespace XCharts
return false;
}
public bool IsCoordinateSerie()
{
return type == SerieType.Line
|| type == SerieType.Bar
|| type == SerieType.Scatter
|| type == SerieType.Heatmap;
}
/// <summary>
/// 设置指定index的数据图标的尺寸
/// </summary>
@@ -1708,9 +1728,9 @@ namespace XCharts
/// 从json中导入数据
/// </summary>
/// <param name="jsonData"></param>
public override void ParseJsonData(string jsonData)
public void ParseJsonData(string jsonData)
{
if (string.IsNullOrEmpty(jsonData) || !m_DataFromJson) return;
if (string.IsNullOrEmpty(jsonData)) return;
jsonData = jsonData.Replace("\r\n", "");
jsonData = jsonData.Replace(" ", "");
jsonData = jsonData.Replace("\n", "");

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
using System.Collections.Generic;
@@ -21,10 +21,6 @@ namespace XCharts
[SerializeField] protected List<Serie> m_Series;
[NonSerialized] private bool m_LabelDirty;
[Obsolete("Use Series.list instead.", true)]
public List<Serie> series { get { return m_Series; } }
/// <summary>
/// the list of serie
/// 系列列表。
@@ -261,15 +257,11 @@ namespace XCharts
{
serie.symbol.show = true;
serie.symbol.type = SerieSymbolType.Circle;
serie.symbol.size = 20f;
serie.symbol.selectedSize = 30f;
}
else if (type == SerieType.Line)
{
serie.symbol.show = true;
serie.symbol.type = SerieSymbolType.EmptyCircle;
serie.symbol.size = 2.5f;
serie.symbol.selectedSize = 5f;
}
else
{
@@ -698,14 +690,5 @@ namespace XCharts
if (serie.animation.enable) serie.animation.Reset();
}
}
/// <summary>
/// 从json中解析数据
/// </summary>
/// <param name="jsonData"></param>
public override void ParseJsonData(string jsonData)
{
//TODO:
}
}
}

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
using System;
@@ -17,14 +17,21 @@ namespace XCharts
[Serializable]
public class Settings : MainComponent
{
[SerializeField] [Range(1, 20)] protected int m_MaxPainter = 10;
[SerializeField] [Range(1, 10)] protected float m_LineSmoothStyle = 3f;
[SerializeField] [Range(1f, 20)] protected float m_LineSmoothness = 2f;
[SerializeField] [Range(1f, 20)] protected float m_LineSegmentDistance = 3f;
[SerializeField] [Range(1, 10)] protected float m_CicleSmoothness = 2f;
[SerializeField] [Range(10, 50)] protected float m_VisualMapTriangeLen = 20f;
[SerializeField] [Range(1, 20)] protected float m_PieTooltipExtraRadius = 8f;
[SerializeField] [Range(1, 20)] protected float m_PieSelectedOffset = 8f;
/// <summary>
/// max painter.
/// 设定的painter数量。
/// </summary>
public int maxPainter
{
get { return m_MaxPainter; }
set { if (PropertyUtil.SetStruct(ref m_MaxPainter, value < 0 ? 1 : value)) SetVerticesDirty(); }
}
/// <summary>
/// Curve smoothing factor. By adjusting the smoothing coefficient, the curvature of the curve can be changed,
/// and different curves with slightly different appearance can be obtained.
@@ -33,7 +40,7 @@ namespace XCharts
public float lineSmoothStyle
{
get { return m_LineSmoothStyle; }
set { if (PropertyUtility.SetStruct(ref m_LineSmoothStyle, value < 0 ? 1f : value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_LineSmoothStyle, value < 0 ? 1f : value)) SetVerticesDirty(); }
}
/// <summary>
/// Smoothness of curve. The smaller the value, the smoother the curve, but the number of vertices will increase.
@@ -44,7 +51,7 @@ namespace XCharts
public float lineSmoothness
{
get { return m_LineSmoothness; }
set { if (PropertyUtility.SetStruct(ref m_LineSmoothStyle, value < 0 ? 1f : value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_LineSmoothStyle, value < 0 ? 1f : value)) SetVerticesDirty(); }
}
/// <summary>
/// The partition distance of a line segment. A line in a normal line chart is made up of many segments,
@@ -56,7 +63,7 @@ namespace XCharts
public float lineSegmentDistance
{
get { return m_LineSegmentDistance; }
set { if (PropertyUtility.SetStruct(ref m_LineSegmentDistance, value < 0 ? 1f : value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_LineSegmentDistance, value < 0 ? 1f : value)) SetVerticesDirty(); }
}
/// <summary>
/// the smoothess of cricle.
@@ -65,32 +72,36 @@ namespace XCharts
public float cicleSmoothness
{
get { return m_CicleSmoothness; }
set { if (PropertyUtility.SetStruct(ref m_CicleSmoothness, value < 0 ? 1f : value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_CicleSmoothness, value < 0 ? 1f : value)) SetVerticesDirty(); }
}
/// <summary>
/// 可视化组件的调节三角形边长。
/// </summary>
/// <value></value>
public float visualMapTriangeLen
public void Copy(Settings settings)
{
get { return m_VisualMapTriangeLen; }
set { if (PropertyUtility.SetStruct(ref m_VisualMapTriangeLen, value < 0 ? 1f : value)) SetVerticesDirty(); }
m_MaxPainter = settings.maxPainter;
m_LineSmoothStyle = settings.lineSmoothStyle;
m_LineSmoothness = settings.lineSmoothness;
m_LineSegmentDistance = settings.lineSegmentDistance;
m_CicleSmoothness = settings.cicleSmoothness;
}
/// <summary>
/// 饼图鼠标移到高亮时的额外半径
/// </summary>
public float pieTooltipExtraRadius
public void Reset()
{
get { return m_PieTooltipExtraRadius; }
set { if (PropertyUtility.SetStruct(ref m_PieTooltipExtraRadius, value < 0 ? 0f : value)) SetVerticesDirty(); }
Copy(DefaultSettings);
}
/// <summary>
/// 饼图选中时的中心点偏移
/// </summary>
public float pieSelectedOffset
public static Settings DefaultSettings
{
get { return m_PieSelectedOffset; }
set { if (PropertyUtility.SetStruct(ref m_PieSelectedOffset, value < 0 ? 0f : value)) SetVerticesDirty(); }
get
{
return new Settings()
{
m_MaxPainter = XChartsSettings.maxPainter,
m_LineSmoothStyle = XChartsSettings.lineSmoothStyle,
m_LineSmoothness = XChartsSettings.lineSmoothness,
m_LineSegmentDistance = XChartsSettings.lineSegmentDistance,
m_CicleSmoothness = XChartsSettings.cicleSmoothness,
};
}
}
}
}

View File

@@ -1,629 +0,0 @@
using System.Text;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEngine;
using System;
using UnityEngine.Serialization;
namespace XCharts
{
/// <summary>
/// 主题
/// </summary>
public enum Theme
{
/// <summary>
/// 默认主题。
/// </summary>
Default,
/// <summary>
/// 亮主题。
/// </summary>
Light,
/// <summary>
/// 暗主题。
/// </summary>
Dark
}
[Serializable]
/// <summary>
/// Theme.
/// 主题相关配置。
/// </summary>
public class ThemeInfo : MainComponent
{
[SerializeField] private Theme m_Theme = Theme.Default;
[SerializeField] private Font m_Font;
[SerializeField] private Color32 m_BackgroundColor;
[FormerlySerializedAs("m_TextColor")]
[SerializeField] private Color32 m_TitleTextColor;
[SerializeField] private Color32 m_TitleSubTextColor;
[SerializeField] private Color32 m_LegendTextColor;
[SerializeField] private Color32 m_LegendUnableColor;
[SerializeField] private Color32 m_AxisTextColor;
[SerializeField] private Color32 m_AxisLineColor;
[SerializeField] private Color32 m_AxisSplitLineColor;
[SerializeField] private Color32 m_TooltipBackgroundColor;
[SerializeField] private Color32 m_TooltipFlagAreaColor;
[SerializeField] private Color32 m_TooltipTextColor;
[SerializeField] private Color32 m_TooltipLabelColor;
[SerializeField] private Color32 m_TooltipLineColor;
[SerializeField] private Color32 m_DataZoomTextColor;
[SerializeField] private Color32 m_DataZoomLineColor;
[SerializeField] private Color32 m_DataZoomSelectedColor;
[SerializeField] private Color32 m_VisualMapBackgroundColor;
[SerializeField] private Color32 m_VisualMapBorderColor;
[SerializeField] private Color32[] m_ColorPalette;
[SerializeField] private Font m_CustomFont;
[SerializeField] private Color32 m_CustomBackgroundColor;
[FormerlySerializedAs("m_CustomTextColor")]
[SerializeField] private Color32 m_CustomTitleTextColor;
[SerializeField] private Color32 m_CustomTitleSubTextColor;
[SerializeField] private Color32 m_CustomLegendTextColor;
[SerializeField] private Color32 m_CustomLegendUnableColor;
[SerializeField] private Color32 m_CustomAxisTextColor;
[SerializeField] private Color32 m_CustomAxisLineColor;
[SerializeField] private Color32 m_CustomAxisSplitLineColor;
[SerializeField] private Color32 m_CustomTooltipBackgroundColor;
[SerializeField] private Color32 m_CustomTooltipFlagAreaColor;
[SerializeField] private Color32 m_CustomTooltipTextColor;
[SerializeField] private Color32 m_CustomTooltipLabelColor;
[SerializeField] private Color32 m_CustomTooltipLineColor;
[SerializeField] private Color32 m_CustomDataZoomTextColor;
[SerializeField] private Color32 m_CustomDataZoomLineColor;
[SerializeField] private Color32 m_CustomDataZoomSelectedColor;
[SerializeField] private Color32 m_CustomVisualMapBackgroundColor;
[SerializeField] private Color32 m_CustomVisualMapBorderColor;
[SerializeField] private List<Color32> m_CustomColorPalette = new List<Color32>(13);
/// <summary>
/// the theme of chart.
/// 主题类型。
/// </summary>
public Theme theme
{
get { return m_Theme; }
set { if (PropertyUtility.SetStruct(ref m_Theme, value)) SetComponentDirty(); }
}
/// <summary>
/// the font of chart text。
/// 字体。
/// </summary>
public Font font
{
get { return m_CustomFont != null ? m_CustomFont : m_Font; }
set { if (PropertyUtility.SetClass(ref m_CustomFont, value)) SetComponentDirty(); }
}
/// <summary>
/// the background color of chart.
/// 背景颜色。
/// </summary>
public Color32 backgroundColor
{
get { return !ChartHelper.IsClearColor(m_CustomBackgroundColor) ? m_CustomBackgroundColor : m_BackgroundColor; }
set { if (PropertyUtility.SetColor(ref m_CustomBackgroundColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the main title text color.
/// 主标题颜色。
/// </summary>
public Color32 titleTextColor
{
get { return !ChartHelper.IsClearColor(m_CustomTitleTextColor) ? m_CustomTitleTextColor : m_TitleTextColor; }
set { if (PropertyUtility.SetColor(ref m_CustomTitleTextColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the subtitie text color.
/// 副标题颜色。
/// </summary>
public Color32 titleSubTextColor
{
get { return !ChartHelper.IsClearColor(m_CustomTitleSubTextColor) ? m_CustomTitleSubTextColor : m_TitleSubTextColor; }
set { if (PropertyUtility.SetColor(ref m_CustomTitleSubTextColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the legend text color.
/// 图例文字的颜色。
/// </summary>
public Color32 legendTextColor
{
get { return !ChartHelper.IsClearColor(m_CustomLegendTextColor) ? m_CustomLegendTextColor : m_LegendTextColor; }
set { if (PropertyUtility.SetColor(ref m_CustomLegendTextColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the legend unable text color.
/// 图例变为不可用时的按钮颜色。
/// </summary>
public Color32 legendUnableColor
{
get { return !ChartHelper.IsClearColor(m_CustomLegendUnableColor) ? m_CustomLegendUnableColor : m_LegendUnableColor; }
set { if (PropertyUtility.SetColor(ref m_CustomLegendUnableColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the axis text color.
/// 坐标轴上标签的颜色。
/// </summary>
public Color32 axisTextColor
{
get { return !ChartHelper.IsClearColor(m_CustomAxisTextColor) ? m_CustomAxisTextColor : m_AxisTextColor; }
set { if (PropertyUtility.SetColor(ref m_CustomAxisTextColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the color of axis line.
/// 坐标轴轴线的颜色。
/// </summary>
public Color32 axisLineColor
{
get { return !ChartHelper.IsClearColor(m_CustomAxisLineColor) ? m_CustomAxisLineColor : m_AxisLineColor; }
set { if (PropertyUtility.SetColor(ref m_CustomAxisLineColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color of axis split line.
/// 分割线的颜色,默认和坐标轴轴线颜色一致。
/// </summary>
public Color32 axisSplitLineColor
{
get { return !ChartHelper.IsClearColor(m_CustomAxisSplitLineColor) ? m_CustomAxisSplitLineColor : m_AxisSplitLineColor; }
set { if (PropertyUtility.SetColor(ref m_CustomAxisSplitLineColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the tooltip background color.
/// 提示框背景颜色。
/// </summary>
public Color32 tooltipBackgroundColor
{
get { return !ChartHelper.IsClearColor(m_CustomTooltipBackgroundColor) ? m_CustomTooltipBackgroundColor : m_TooltipBackgroundColor; }
set { if (PropertyUtility.SetColor(ref m_CustomTooltipBackgroundColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the color of tooltip shadow crosshair indicator.
/// 提示框阴影指示器的颜色。
/// </summary>
public Color32 tooltipFlagAreaColor
{
get { return !ChartHelper.IsClearColor(m_CustomTooltipFlagAreaColor) ? m_CustomTooltipFlagAreaColor : m_TooltipFlagAreaColor; }
set { if (PropertyUtility.SetColor(ref m_CustomTooltipFlagAreaColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color of tooltip text.
/// 提示框文字颜色。
/// </summary>
public Color32 tooltipTextColor
{
get { return !ChartHelper.IsClearColor(m_CustomTooltipTextColor) ? m_CustomTooltipTextColor : m_TooltipTextColor; }
set { if (PropertyUtility.SetColor(ref m_CustomTooltipTextColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the background color of tooltip cross indicator's axis label.
/// 提示框的十字指示器坐标轴标签的背景颜色。
/// </summary>
public Color32 tooltipLabelColor
{
get { return !ChartHelper.IsClearColor(m_CustomTooltipLabelColor) ? m_CustomTooltipLabelColor : m_TooltipLabelColor; }
set { if (PropertyUtility.SetColor(ref m_CustomTooltipLabelColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color tooltip indicator line.
/// 提示框的指示线的颜色。
/// </summary>
public Color32 tooltipLineColor
{
get { return !ChartHelper.IsClearColor(m_CustomTooltipLineColor) ? m_CustomTooltipLineColor : m_TooltipLineColor; }
set { if (PropertyUtility.SetColor(ref m_CustomTooltipLineColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color of datazoom text.
/// 区域缩放的文字颜色。
/// </summary>
public Color32 dataZoomTextColor
{
get { return !ChartHelper.IsClearColor(m_CustomDataZoomTextColor) ? m_CustomDataZoomTextColor : m_DataZoomTextColor; }
set { if (PropertyUtility.SetColor(ref m_CustomDataZoomTextColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the color of datazoom line.
/// 区域缩放的线条颜色。
/// </summary>
public Color32 dataZoomLineColor
{
get { return !ChartHelper.IsClearColor(m_CustomDataZoomLineColor) ? m_CustomDataZoomLineColor : m_DataZoomLineColor; }
set { if (PropertyUtility.SetColor(ref m_CustomDataZoomLineColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color of datazoom selected area.
/// 区域缩放的选中区域颜色。
/// </summary>
public Color32 dataZoomSelectedColor
{
get { return !ChartHelper.IsClearColor(m_CustomDataZoomSelectedColor) ? m_CustomDataZoomSelectedColor : m_DataZoomSelectedColor; }
set { if (PropertyUtility.SetColor(ref m_CustomDataZoomSelectedColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// 视觉映射组件的背景色。
/// </summary>
public Color32 visualMapBackgroundColor
{
get { return !ChartHelper.IsClearColor(m_CustomVisualMapBackgroundColor) ? m_CustomVisualMapBackgroundColor : m_VisualMapBackgroundColor; }
set { if (PropertyUtility.SetColor(ref m_CustomVisualMapBackgroundColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// 视觉映射的边框色。
/// </summary>
public Color32 visualMapBorderColor
{
get { return !ChartHelper.IsClearColor(m_CustomVisualMapBorderColor) ? m_CustomVisualMapBorderColor : m_VisualMapBorderColor; }
set { if (PropertyUtility.SetColor(ref m_CustomVisualMapBorderColor, 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 { set { m_CustomColorPalette = value; SetVerticesDirty(); } }
/// <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;
if (m_CustomColorPalette.Count > 0)
{
var customIndex = index < m_CustomColorPalette.Count ? index : index % m_CustomColorPalette.Count;
if (customIndex < m_CustomColorPalette.Count
&& !ChartHelper.IsClearColor(m_CustomColorPalette[customIndex]))
{
return m_CustomColorPalette[customIndex];
}
}
var newIndex = index < m_ColorPalette.Length ? index : index % m_ColorPalette.Length;
if (newIndex < m_ColorPalette.Length)
return m_ColorPalette[newIndex];
else return Color.clear;
}
public void CheckWarning(StringBuilder sb)
{
if (m_Font == null && m_CustomFont == null)
{
sb.AppendFormat("warning:theme->font is null\n");
}
if (m_ColorPalette.Length == 0 && m_CustomColorPalette.Count == 0)
{
sb.AppendFormat("warning:theme->colorPalette is empty\n");
}
for (int i = 0; i < m_ColorPalette.Length; i++)
{
if (!ChartHelper.IsClearColor(m_ColorPalette[i]) && m_ColorPalette[i].a == 0)
sb.AppendFormat("warning:theme->colorPalette[{0}] alpha = 0\n", i);
}
for (int i = 0; i < m_CustomColorPalette.Count; i++)
{
if (!ChartHelper.IsClearColor(m_CustomColorPalette[i]) && m_CustomColorPalette[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.Length;
if (_colorDic.ContainsKey(index)) return _colorDic[index];
else
{
_colorDic[index] = ColorUtility.ToHtmlStringRGBA(GetColor(index));
return _colorDic[index];
}
}
public void Copy(Theme theme)
{
switch (theme)
{
case Theme.Dark:
Copy(ThemeInfo.Dark);
break;
case Theme.Default:
Copy(ThemeInfo.Default);
break;
case Theme.Light:
Copy(ThemeInfo.Light);
break;
}
}
/// <summary>
/// copy all configurations from theme.
/// 复制主题的所有配置。
/// </summary>
/// <param name="theme"></param>
public void Copy(ThemeInfo theme)
{
m_Theme = theme.theme;
m_Font = theme.m_Font;
m_BackgroundColor = theme.m_BackgroundColor;
m_LegendUnableColor = theme.m_LegendUnableColor;
m_TitleTextColor = theme.m_TitleTextColor;
m_TitleSubTextColor = theme.m_TitleSubTextColor;
m_LegendTextColor = theme.m_LegendTextColor;
m_AxisTextColor = theme.m_AxisTextColor;
m_AxisLineColor = theme.m_AxisLineColor;
m_AxisSplitLineColor = theme.m_AxisSplitLineColor;
m_TooltipBackgroundColor = theme.m_TooltipBackgroundColor;
m_TooltipTextColor = theme.m_TooltipTextColor;
m_TooltipLabelColor = theme.m_TooltipLabelColor;
m_TooltipLineColor = theme.m_TooltipLineColor;
m_DataZoomLineColor = theme.m_DataZoomLineColor;
m_DataZoomSelectedColor = theme.m_DataZoomSelectedColor;
m_DataZoomTextColor = theme.m_DataZoomTextColor;
m_VisualMapBackgroundColor = theme.m_VisualMapBackgroundColor;
m_VisualMapBorderColor = theme.m_VisualMapBorderColor;
m_ColorPalette = new Color32[theme.m_ColorPalette.Length];
for (int i = 0; i < theme.m_ColorPalette.Length; i++)
{
m_ColorPalette[i] = theme.m_ColorPalette[i];
}
}
/// <summary>
/// Clear all custom configurations.
/// 重置,清除所有自定义配置。
/// </summary>
public void Reset()
{
m_Theme = Theme.Default;
m_Font = null;
m_BackgroundColor = Color.clear;
m_LegendUnableColor = Color.clear;
m_TitleTextColor = Color.clear;
m_TitleSubTextColor = Color.clear;
m_LegendTextColor = Color.clear;
m_AxisTextColor = Color.clear;
m_AxisLineColor = Color.clear;
m_AxisSplitLineColor = Color.clear;
m_TooltipBackgroundColor = Color.clear;
m_TooltipTextColor = Color.clear;
m_TooltipLabelColor = Color.clear;
m_TooltipLineColor = Color.clear;
m_DataZoomLineColor = Color.clear;
m_DataZoomSelectedColor = Color.clear;
m_DataZoomTextColor = Color.clear;
m_VisualMapBackgroundColor = Color.clear;
m_VisualMapBorderColor = Color.clear;
for (int i = 0; i < m_CustomColorPalette.Count; i++)
{
m_CustomColorPalette[i] = Color.clear;
}
}
/// <summary>
/// default theme.
/// 默认主题。
/// </summary>
/// <value></value>
public static ThemeInfo Default
{
get
{
return new ThemeInfo()
{
m_Theme = Theme.Default,
m_Font = Resources.GetBuiltinResource<Font>("Arial.ttf"),
m_BackgroundColor = new Color32(255, 255, 255, 255),
m_LegendUnableColor = GetColor("#cccccc"),
m_TitleTextColor = GetColor("#514D4D"),
m_TitleSubTextColor = GetColor("#514D4D"),
m_LegendTextColor = GetColor("#514D4D"),
m_AxisTextColor = GetColor("#514D4D"),
m_AxisLineColor = GetColor("#514D4D"),
m_AxisSplitLineColor = GetColor("#51515120"),
m_TooltipBackgroundColor = GetColor("#515151C8"),
m_TooltipTextColor = GetColor("#FFFFFFFF"),
m_TooltipFlagAreaColor = GetColor("#51515120"),
m_TooltipLabelColor = GetColor("#292929FF"),
m_TooltipLineColor = GetColor("#29292964"),
m_DataZoomLineColor = GetColor("#51515120"),
m_DataZoomSelectedColor = GetColor("#51515120"),
m_DataZoomTextColor = GetColor("#514D4D"),
m_VisualMapBackgroundColor = GetColor("#51515120"),
m_VisualMapBorderColor = GetColor("#cccccc"),
m_ColorPalette = new 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)
},
m_CustomColorPalette = new List<Color32>{
Color.clear,
Color.clear,
Color.clear,
Color.clear,
Color.clear,
Color.clear,
Color.clear,
Color.clear,
Color.clear,
Color.clear,
Color.clear
}
};
}
}
/// <summary>
/// light theme.
/// 亮主题。
/// </summary>
/// <value></value>
public static ThemeInfo Light
{
get
{
return new ThemeInfo()
{
m_Theme = Theme.Light,
m_Font = Resources.GetBuiltinResource<Font>("Arial.ttf"),
m_BackgroundColor = new Color32(255, 255, 255, 255),
m_LegendUnableColor = GetColor("#cccccc"),
m_TitleTextColor = GetColor("#514D4D"),
m_TitleSubTextColor = GetColor("#514D4D"),
m_LegendTextColor = GetColor("#514D4D"),
m_AxisTextColor = GetColor("#514D4D"),
m_AxisLineColor = GetColor("#514D4D"),
m_AxisSplitLineColor = GetColor("#51515120"),
m_TooltipBackgroundColor = GetColor("#515151C8"),
m_TooltipTextColor = GetColor("#FFFFFFFF"),
m_TooltipFlagAreaColor = GetColor("#51515120"),
m_TooltipLabelColor = GetColor("#292929FF"),
m_TooltipLineColor = GetColor("#29292964"),
m_DataZoomLineColor = GetColor("#51515120"),
m_DataZoomSelectedColor = GetColor("#51515120"),
m_DataZoomTextColor = GetColor("#514D4D"),
m_VisualMapBackgroundColor = GetColor("#51515120"),
m_VisualMapBorderColor = GetColor("#cccccc"),
m_ColorPalette = new Color32[]
{
new Color32(55, 162, 218, 255),
new Color32(255, 159, 127, 255),
new Color32(50, 197, 233, 255),
new Color32(251, 114, 147, 255),
new Color32(103, 224, 227, 255),
new Color32(224, 98, 174, 255),
new Color32(159, 230, 184, 255),
new Color32(230, 144, 209, 255),
new Color32(255, 219, 92, 255),
new Color32(230, 188, 243, 255),
new Color32(157, 150, 245, 255),
new Color32(131, 120, 234, 255),
new Color32(150, 191, 255, 255)
},
m_CustomColorPalette = new List<Color32>{
Color.clear,
Color.clear,
Color.clear,
Color.clear,
Color.clear,
Color.clear,
Color.clear,
Color.clear,
Color.clear,
Color.clear,
Color.clear,
Color.clear,
Color.clear
}
};
}
}
/// <summary>
/// dark theme.
/// 暗主题。
/// </summary>
/// <value></value>
public static ThemeInfo Dark
{
get
{
return new ThemeInfo()
{
m_Theme = Theme.Dark,
m_Font = Resources.GetBuiltinResource<Font>("Arial.ttf"),
m_LegendUnableColor = GetColor("#cccccc"),
m_BackgroundColor = new Color32(34, 34, 34, 255),
m_TitleTextColor = GetColor("#eee"),
m_TitleSubTextColor = GetColor("#eee"),
m_LegendTextColor = GetColor("#eee"),
m_AxisTextColor = GetColor("#eee"),
m_AxisLineColor = GetColor("#eee"),
m_AxisSplitLineColor = GetColor("#aaa"),
m_TooltipBackgroundColor = GetColor("#515151C8"),
m_TooltipTextColor = GetColor("#FFFFFFFF"),
m_TooltipFlagAreaColor = GetColor("#51515120"),
m_TooltipLabelColor = GetColor("#A7A7A7FF"),
m_TooltipLineColor = GetColor("#eee"),
m_DataZoomLineColor = GetColor("#FFFFFF45"),
m_DataZoomSelectedColor = GetColor("#D0D0D03D"),
m_DataZoomTextColor = GetColor("#FFFFFFFF"),
m_VisualMapBackgroundColor = GetColor("#aaa"),
m_VisualMapBorderColor = GetColor("#cccccc"),
m_ColorPalette = new Color32[]
{
new Color32(221, 107, 102, 255),
new Color32(117, 154, 160, 255),
new Color32(230, 157, 135, 255),
new Color32(141, 193, 169, 255),
new Color32(234, 126, 83, 255),
new Color32(238, 221, 120, 255),
new Color32(115, 163, 115, 255),
new Color32(115, 185, 188, 255),
new Color32(114, 137, 171, 255),
new Color32(145, 202, 140, 255),
new Color32(244, 159, 66, 255)
},
m_CustomColorPalette = new List<Color32>{
Color.clear,
Color.clear,
Color.clear,
Color.clear,
Color.clear,
Color.clear,
Color.clear,
Color.clear,
Color.clear,
Color.clear,
Color.clear
}
};
}
}
/// <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();
}
}
}

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
using System;
@@ -19,9 +19,9 @@ namespace XCharts
{
[SerializeField] private bool m_Show = true;
[SerializeField] private string m_Text;
[SerializeField] private TextStyle m_TextStyle = new TextStyle(16);
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
[SerializeField] private string m_SubText;
[SerializeField] private TextStyle m_SubTextStyle = new TextStyle(14);
[SerializeField] private TextStyle m_SubTextStyle = new TextStyle();
[SerializeField] private float m_ItemGap = 8;
[SerializeField] private Location m_Location = Location.defaultTop;
@@ -30,19 +30,12 @@ namespace XCharts
/// Set this to false to prevent the title from showing.
/// 是否显示标题组件。
/// </summary>
public bool show { get { return m_Show; } set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); } }
public bool show { get { return m_Show; } set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); } }
/// <summary>
/// The main title text, supporting \n for newlines.
/// 主标题文本,支持使用 \n 换行。
/// </summary>
public string text { get { return m_Text; } set { if (PropertyUtility.SetClass(ref m_Text, value)) SetComponentDirty(); } }
/// <summary>
/// [default:16]
/// main title font size.
/// 主标题文字的字体大小。
/// </summary>
[Obsolete("use textStyle instead.", true)]
public int textFontSize { get { return m_TextStyle.fontSize; } set { m_TextStyle.fontSize = value; } }
public string text { get { return m_Text; } set { if (PropertyUtil.SetClass(ref m_Text, value)) SetComponentDirty(); } }
/// <summary>
/// The text style of main title.
/// 主标题文本样式。
@@ -50,7 +43,7 @@ namespace XCharts
public TextStyle textStyle
{
get { return m_TextStyle; }
set { if (PropertyUtility.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
}
/// <summary>
/// Subtitle text, supporting for \n for newlines.
@@ -59,7 +52,7 @@ namespace XCharts
public string subText
{
get { return m_SubText; }
set { if (PropertyUtility.SetClass(ref m_SubText, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetClass(ref m_SubText, value)) SetComponentDirty(); }
}
/// <summary>
/// The text style of sub title.
@@ -68,18 +61,7 @@ namespace XCharts
public TextStyle subTextStyle
{
get { return m_SubTextStyle; }
set { if (PropertyUtility.SetClass(ref m_SubTextStyle, value)) SetComponentDirty(); }
}
/// <summary>
/// [default:14]
/// subtitle font size.
/// 副标题文字的字体大小。
/// </summary>
[Obsolete("use subTextStyle instead.", true)]
public int subTextFontSize
{
get { return m_SubTextStyle.fontSize; }
set { m_SubTextStyle.fontSize = value; }
set { if (PropertyUtil.SetClass(ref m_SubTextStyle, value)) SetComponentDirty(); }
}
/// <summary>
/// [default:8]
@@ -89,7 +71,7 @@ namespace XCharts
public float itemGap
{
get { return m_ItemGap; }
set { if (PropertyUtility.SetStruct(ref m_ItemGap, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_ItemGap, value)) SetComponentDirty(); }
}
/// <summary>
/// The location of title component.
@@ -98,9 +80,11 @@ namespace XCharts
public Location location
{
get { return m_Location; }
set { if (PropertyUtility.SetClass(ref m_Location, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetClass(ref m_Location, value)) SetComponentDirty(); }
}
public int index { get; internal set; }
public override bool vertsDirty { get { return false; } }
public override bool componentDirty
{
@@ -123,10 +107,10 @@ namespace XCharts
{
m_Show = true,
m_Text = "Chart Title",
m_TextStyle = new TextStyle(16),
m_TextStyle = new TextStyle(),
m_SubText = "",
m_SubTextStyle = new TextStyle(14),
m_ItemGap = 8,
m_SubTextStyle = new TextStyle(),
m_ItemGap = 0,
m_Location = Location.defaultTop
};
return title;

View File

@@ -1,17 +1,15 @@
using System.Linq;
using System.Collections.ObjectModel;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
using UnityEngine.EventSystems;
namespace XCharts
{
@@ -66,12 +64,12 @@ namespace XCharts
[SerializeField] private bool m_AlwayShow = false;
[SerializeField] private Vector2 m_Offset = new Vector2(18f, -25f);
[SerializeField] private Sprite m_BackgroundImage;
[SerializeField] private TextStyle m_TextStyle = new TextStyle(18, FontStyle.Normal);
[SerializeField] private LineStyle m_LineStyle = new LineStyle(LineStyle.Type.Solid, 0.7f);
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
[SerializeField] private LineStyle m_LineStyle = new LineStyle(LineStyle.Type.None);
private GameObject m_GameObject;
private GameObject m_Content;
private Text m_ContentText;
private ChartText m_ContentText;
private Image m_ContentImage;
private RectTransform m_ContentRect;
private RectTransform m_ContentTextRect;
@@ -84,7 +82,7 @@ namespace XCharts
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) { SetAllDirty(); SetActive(value); } }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) { SetAllDirty(); SetActive(value); } }
}
/// <summary>
/// Indicator type.
@@ -93,7 +91,7 @@ namespace XCharts
public Type type
{
get { return m_Type; }
set { if (PropertyUtility.SetStruct(ref m_Type, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Type, value)) SetAllDirty(); }
}
/// <summary>
/// A string template formatter for the total content of the prompt box. Support for wrapping lines with \n.
@@ -161,10 +159,6 @@ namespace XCharts
/// 最小高度。如若 fixedHeight 设有值,优先取 fixedHeight。
/// </summary>
public float minHeight { get { return m_MinHeight; } set { m_MinHeight = value; } }
[Obsolete("Use Tooltip.textStyle.fontSize instead.", true)]
public int fontSize { get; set; }
[Obsolete("Use Tooltip.textStyle.fontStyle instead.", true)]
public FontStyle fontStyle { get; set; }
/// <summary>
/// Standard numeric format string. Used to format numeric values to display as strings.
/// Using 'Axx' form: 'A' is the single character of the format specifier, supporting 'C' currency,
@@ -178,7 +172,7 @@ namespace XCharts
public string numericFormatter
{
get { return m_NumericFormatter; }
set { if (PropertyUtility.SetClass(ref m_NumericFormatter, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetClass(ref m_NumericFormatter, value)) SetComponentDirty(); }
}
/// <summary>
/// the text padding of left and right. defaut:5.
@@ -291,6 +285,11 @@ namespace XCharts
/// 当前指示的角度。
/// </summary>
public float runtimeAngle { get; internal set; }
/// <summary>
/// 当前指示的Grid索引。
/// </summary>
public int runtimeGridIndex { get; internal set; }
public int runtimePolarIndex { get; internal set; }
public static Tooltip defaultTooltip
{
@@ -329,7 +328,7 @@ namespace XCharts
m_ContentRect = m_Content.GetComponent<RectTransform>();
m_ContentImage = m_Content.GetComponent<Image>();
m_ContentImage.raycastTarget = false;
m_ContentText = m_Content.GetComponentInChildren<Text>();
m_ContentText = new ChartText(m_Content);
if (m_ContentText != null)
{
m_ContentTextRect = m_ContentText.gameObject.GetComponentInChildren<RectTransform>();
@@ -343,6 +342,7 @@ namespace XCharts
/// </summary>
public void UpdateToTop()
{
if (m_GameObject == null) return;
int count = m_GameObject.transform.parent.childCount;
m_GameObject.GetComponent<RectTransform>().SetSiblingIndex(count - 1);
}
@@ -376,9 +376,9 @@ namespace XCharts
/// <param name="color"></param>
public void SetContentTextColor(Color color)
{
if (m_ContentText)
if (m_ContentText != null)
{
m_ContentText.color = color;
m_ContentText.SetColor(color);
}
}
@@ -388,16 +388,16 @@ namespace XCharts
/// <param name="txt"></param>
public void UpdateContentText(string txt)
{
if (m_ContentText)
if (m_ContentText != null)
{
m_ContentText.text = txt;
m_ContentText.SetText(txt);
float wid, hig;
if (m_FixedWidth > 0) wid = m_FixedWidth;
else if (m_MinWidth > 0 && m_ContentText.preferredWidth < m_MinWidth) wid = m_MinWidth;
else wid = m_ContentText.preferredWidth + m_PaddingLeftRight * 2;
else if (m_MinWidth > 0 && m_ContentText.GetPreferredWidth() < m_MinWidth) wid = m_MinWidth;
else wid = m_ContentText.GetPreferredWidth() + m_PaddingLeftRight * 2;
if (m_FixedHeight > 0) hig = m_FixedHeight;
else if (m_MinHeight > 0 && m_ContentText.preferredHeight < m_MinHeight) hig = m_MinHeight;
else hig = m_ContentText.preferredHeight + m_PaddingTopBottom * 2;
else if (m_MinHeight > 0 && m_ContentText.GetPreferredHeight() < m_MinHeight) hig = m_MinHeight;
else hig = m_ContentText.GetPreferredHeight() + m_PaddingTopBottom * 2;
if (m_ContentRect != null) m_ContentRect.sizeDelta = new Vector2(wid, hig);
if (m_ContentTextRect != null)
{
@@ -476,7 +476,8 @@ namespace XCharts
internal void UpdateLastDataIndex()
{
lastDataIndex[0] = runtimeDataIndex[0];
lastDataIndex[1] = runtimeDataIndex[1];
if (runtimeDataIndex.Count > 1)
lastDataIndex[1] = runtimeDataIndex[1];
}
/// <summary>
@@ -485,7 +486,9 @@ namespace XCharts
/// <returns></returns>
public bool IsSelected()
{
return runtimeDataIndex[0] >= 0 || runtimeDataIndex[1] >= 0;
foreach (var index in runtimeDataIndex)
if (index >= 0) return true;
return false;
}
/// <summary>
@@ -495,7 +498,9 @@ namespace XCharts
/// <returns></returns>
public bool IsSelected(int index)
{
return runtimeDataIndex[0] == index || runtimeDataIndex[1] == index;
foreach (var temp in runtimeDataIndex)
if (temp == index) return true;
return false;
}
public void ClearSerieDataIndex()

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System;
using UnityEngine;
@@ -62,7 +62,7 @@ namespace XCharts
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// The shape of vessel.
@@ -72,7 +72,7 @@ namespace XCharts
public Shape shape
{
get { return m_Shape; }
set { if (PropertyUtility.SetStruct(ref m_Shape, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Shape, value)) SetVerticesDirty(); }
}
/// <summary>
/// Thickness of vessel.
@@ -82,7 +82,7 @@ namespace XCharts
public float shapeWidth
{
get { return m_ShapeWidth; }
set { if (PropertyUtility.SetStruct(ref m_ShapeWidth, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_ShapeWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// The gap between the vessel and the liquid.
@@ -92,7 +92,7 @@ namespace XCharts
public float gap
{
get { return m_Gap; }
set { if (PropertyUtility.SetStruct(ref m_Gap, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Gap, value)) SetVerticesDirty(); }
}
/// <summary>
/// The center of vesselß. The center[0] is the x-coordinate, and the center[1] is the y-coordinate.
@@ -115,7 +115,7 @@ namespace XCharts
public float radius
{
get { return m_Radius; }
set { if (PropertyUtility.SetStruct(ref m_Radius, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Radius, value)) SetAllDirty(); }
}
/// <summary>
/// The smoothness of wave.
@@ -125,7 +125,7 @@ namespace XCharts
public float smoothness
{
get { return m_Smoothness; }
set { if (PropertyUtility.SetStruct(ref m_Smoothness, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Smoothness, value)) SetAllDirty(); }
}
/// <summary>
/// Background color of polar, which is transparent by default.
@@ -135,7 +135,7 @@ namespace XCharts
public Color32 backgroundColor
{
get { return m_BackgroundColor; }
set { if (PropertyUtility.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// Vessel color. The default is consistent with Serie.
@@ -144,7 +144,7 @@ namespace XCharts
public Color32 color
{
get { return m_Color; }
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether automatic color. If true, the color matches serie.
@@ -154,7 +154,7 @@ namespace XCharts
public bool autoColor
{
get { return m_AutoColor; }
set { if (PropertyUtility.SetStruct(ref m_AutoColor, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_AutoColor, value)) SetVerticesDirty(); }
}
public int index { get; internal set; }
/// <summary>

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections.Generic;
using UnityEngine;
@@ -101,7 +101,7 @@ namespace XCharts
public bool enable
{
get { return m_Enable; }
set { if (PropertyUtility.SetStruct(ref m_Enable, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Enable, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether to display components. If set to false, it will not show up, but the data mapping function still exists.
@@ -113,7 +113,7 @@ namespace XCharts
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// the type of visualmap component.
@@ -122,7 +122,7 @@ namespace XCharts
public Type type
{
get { return m_Type; }
set { if (PropertyUtility.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
}
/// <summary>
/// 映射方向。
@@ -130,7 +130,7 @@ namespace XCharts
public Direction direction
{
get { return m_Direction; }
set { if (PropertyUtility.SetStruct(ref m_Direction, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Direction, value)) SetVerticesDirty(); }
}
/// <summary>
/// the selected mode for Piecewise visualMap.
@@ -139,7 +139,7 @@ namespace XCharts
public SelectedMode selectedMode
{
get { return m_SelectedMode; }
set { if (PropertyUtility.SetStruct(ref m_SelectedMode, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_SelectedMode, value)) SetVerticesDirty(); }
}
/// <summary>
/// The minimum allowed. 'min' must be user specified. [visualmap.min, visualmap.max] forms the "domain" of the visualMap.
@@ -149,7 +149,7 @@ namespace XCharts
public float min
{
get { return m_Min; }
set { if (PropertyUtility.SetStruct(ref m_Min, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Min, value)) SetVerticesDirty(); }
}
/// <summary>
/// The maximum allowed. 'max' must be user specified. [visualmap.min, visualmap.max] forms the "domain" of the visualMap.
@@ -187,7 +187,7 @@ namespace XCharts
public int splitNumber
{
get { return m_SplitNumber; }
set { if (PropertyUtility.SetStruct(ref m_SplitNumber, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_SplitNumber, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether the handle used for dragging is displayed (the handle can be dragged to adjust the selected range).
@@ -197,7 +197,7 @@ namespace XCharts
public bool calculable
{
get { return m_Calculable; }
set { if (PropertyUtility.SetStruct(ref m_Calculable, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Calculable, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether to update in real time while dragging.
@@ -207,7 +207,7 @@ namespace XCharts
public bool realtime
{
get { return m_Realtime; }
set { if (PropertyUtility.SetStruct(ref m_Realtime, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Realtime, value)) SetVerticesDirty(); }
}
/// <summary>
/// The width of the figure, that is, the width of the color bar.
@@ -217,7 +217,7 @@ namespace XCharts
public float itemWidth
{
get { return m_ItemWidth; }
set { if (PropertyUtility.SetStruct(ref m_ItemWidth, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_ItemWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// The height of the figure, that is, the height of the color bar.
@@ -227,7 +227,7 @@ namespace XCharts
public float itemHeight
{
get { return m_ItemHeight; }
set { if (PropertyUtility.SetStruct(ref m_ItemHeight, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_ItemHeight, value)) SetVerticesDirty(); }
}
/// <summary>
/// Border line width.
@@ -237,7 +237,7 @@ namespace XCharts
public float borderWidth
{
get { return m_BorderWidth; }
set { if (PropertyUtility.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// Specifies "which dimension" of the data to map to the visual element. "Data" is series.data.
@@ -248,7 +248,7 @@ namespace XCharts
public int dimension
{
get { return m_Dimension; }
set { if (PropertyUtility.SetStruct(ref m_Dimension, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Dimension, value)) SetVerticesDirty(); }
}
/// <summary>
/// When the hoverLink function is turned on, when the mouse hovers over the visualMap component,
@@ -263,7 +263,7 @@ namespace XCharts
public bool hoverLink
{
get { return m_HoverLink; }
set { if (PropertyUtility.SetStruct(ref m_HoverLink, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_HoverLink, value)) SetVerticesDirty(); }
}
/// <summary>
/// Automatically set min, Max value
@@ -272,7 +272,7 @@ namespace XCharts
public bool autoMinMax
{
get { return m_AutoMinMax; }
set { if (PropertyUtility.SetStruct(ref m_AutoMinMax, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_AutoMinMax, value)) SetVerticesDirty(); }
}
/// <summary>
/// Specify whether the layout of component is horizontal or vertical.
@@ -282,7 +282,7 @@ namespace XCharts
public Orient orient
{
get { return m_Orient; }
set { if (PropertyUtility.SetStruct(ref m_Orient, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Orient, value)) SetVerticesDirty(); }
}
/// <summary>
/// The location of component.
@@ -291,7 +291,7 @@ namespace XCharts
public Location location
{
get { return m_Location; }
set { if (PropertyUtility.SetClass(ref m_Location, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetClass(ref m_Location, value)) SetVerticesDirty(); }
}
/// <summary>
/// Defines the visual color in the selected range.

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System;
using UnityEngine;
@@ -38,7 +38,7 @@ namespace XCharts
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// Distance between grid component and the left side of the container.
@@ -47,7 +47,7 @@ namespace XCharts
public float left
{
get { return m_Left; }
set { if (PropertyUtility.SetStruct(ref m_Left, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Left, value)) SetAllDirty(); }
}
/// <summary>
/// Distance between grid component and the right side of the container.
@@ -56,7 +56,7 @@ namespace XCharts
public float right
{
get { return m_Right; }
set { if (PropertyUtility.SetStruct(ref m_Right, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Right, value)) SetAllDirty(); }
}
/// <summary>
/// Distance between grid component and the top side of the container.
@@ -65,7 +65,7 @@ namespace XCharts
public float top
{
get { return m_Top; }
set { if (PropertyUtility.SetStruct(ref m_Top, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Top, value)) SetAllDirty(); }
}
/// <summary>
/// Distance between grid component and the bottom side of the container.
@@ -74,7 +74,7 @@ namespace XCharts
public float bottom
{
get { return m_Bottom; }
set { if (PropertyUtility.SetStruct(ref m_Bottom, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Bottom, value)) SetAllDirty(); }
}
/// <summary>
/// Background color of grid, which is transparent by default.
@@ -83,7 +83,24 @@ namespace XCharts
public Color backgroundColor
{
get { return m_BackgroundColor; }
set { if (PropertyUtility.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
}
public int index { get; internal set; }
public float runtimeX { get; private set; }
public float runtimeY { get; private set; }
public float runtimeWidth { get; private set; }
public float runtimeHeight { get; private set; }
internal void UpdateRuntimeData(float chartX, float chartY, float chartWidth, float chartHeight)
{
var runtimeLeft = left <= 1 ? left * chartWidth : left;
var runtimeBottom = bottom <= 1 ? bottom * chartHeight : bottom;
var runtimeTop = top <= 1 ? top * chartHeight : top;
var runtimeRight = right <= 1 ? right * chartWidth : right;
runtimeX = chartX + runtimeLeft;
runtimeY = chartY + runtimeBottom;
runtimeWidth = chartWidth - runtimeLeft - runtimeRight;
runtimeHeight = chartHeight - runtimeTop - runtimeBottom;
}
public static Grid defaultGrid

View File

@@ -1,13 +0,0 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
namespace XCharts
{
public class MainComponent : ChartComponent
{
}
}

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
@@ -55,7 +55,7 @@ namespace XCharts
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// the origin of area.
@@ -64,7 +64,7 @@ namespace XCharts
public AreaOrigin origin
{
get { return m_Origin; }
set { if (PropertyUtility.SetStruct(ref m_Origin, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Origin, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color of area,default use serie color.
@@ -73,7 +73,7 @@ namespace XCharts
public Color32 color
{
get { return m_Color; }
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetVerticesDirty(); }
}
/// <summary>
/// Gradient color, start color to toColor.
@@ -82,7 +82,7 @@ namespace XCharts
public Color32 toColor
{
get { return m_ToColor; }
set { if (PropertyUtility.SetColor(ref m_ToColor, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetColor(ref m_ToColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// Opacity of the component. Supports value from 0 to 1, and the component will not be drawn when set to 0.
@@ -91,7 +91,7 @@ namespace XCharts
public float opacity
{
get { return m_Opacity; }
set { if (PropertyUtility.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
}
/// <summary>
/// 鼠标悬浮时是否高亮之前的区域
@@ -99,7 +99,7 @@ namespace XCharts
public bool tooltipHighlight
{
get { return m_TooltipHighlight; }
set { if (PropertyUtility.SetStruct(ref m_TooltipHighlight, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_TooltipHighlight, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color of area,default use serie color.
@@ -108,7 +108,7 @@ namespace XCharts
public Color32 highlightColor
{
get { return m_HighlightColor; }
set { if (PropertyUtility.SetColor(ref m_HighlightColor, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetColor(ref m_HighlightColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// Gradient color, start highlightColor to highlightToColor.
@@ -117,7 +117,7 @@ namespace XCharts
public Color32 highlightToColor
{
get { return m_HighlightToColor; }
set { if (PropertyUtility.SetColor(ref m_HighlightToColor, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetColor(ref m_HighlightToColor, value)) SetVerticesDirty(); }
}
public static AreaStyle defaultAreaStyle
@@ -129,10 +129,32 @@ namespace XCharts
m_Show = false,
m_Color = Color.clear,
m_ToColor = Color.clear,
m_Opacity = 1
m_Opacity = 0.6f
};
return area;
}
}
public Color32 GetColor()
{
if (m_Opacity == 1) return m_Color;
var color = m_Color;
color.a = (byte)(color.a * m_Opacity);
return color;
}
public Color32 GetColor(Color32 themeColor)
{
if (!ChartHelper.IsClearColor(color))
{
return GetColor();
}
else
{
var color = themeColor;
color.a = (byte)(color.a * opacity);
return color;
}
}
}
}

View File

@@ -0,0 +1,97 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System;
using UnityEngine;
namespace XCharts
{
/// <summary>
/// </summary>
[Serializable]
public class Arrow : SubComponent
{
[SerializeField] private float m_Width = 10;
[SerializeField] private float m_Height = 15;
[SerializeField] private float m_Offset = 0;
[SerializeField] private float m_Dent = 3;
[SerializeField] private Color32 m_Color = Color.clear;
/// <summary>
/// The widht of arrow.
/// 箭头宽。
/// </summary>
public float width
{
get { return m_Width; }
set { if (PropertyUtil.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
}
/// <summary>
/// The height of arrow.
/// 箭头高。
/// </summary>
public float height
{
get { return m_Height; }
set { if (PropertyUtil.SetStruct(ref m_Height, value)) SetVerticesDirty(); }
}
/// <summary>
/// The offset of arrow.
/// 箭头偏移。
/// </summary>
public float offset
{
get { return m_Offset; }
set { if (PropertyUtil.SetStruct(ref m_Offset, value)) SetVerticesDirty(); }
}
/// <summary>
/// The dent of arrow.
/// 箭头的凹度。
/// </summary>
public float dent
{
get { return m_Dent; }
set { if (PropertyUtil.SetStruct(ref m_Dent, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color of arrow.
/// 箭头颜色。
/// </summary>
public Color32 color
{
get { return m_Color; }
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetVerticesDirty(); }
}
public Arrow Clone()
{
var arrow = new Arrow();
arrow.width = width;
arrow.height = height;
arrow.offset = offset;
arrow.dent = dent;
arrow.color = color;
return arrow;
}
public void Copy(Arrow arrow)
{
width = arrow.width;
height = arrow.height;
offset = arrow.offset;
dent = arrow.dent;
color = arrow.color;
}
public Color32 GetColor(Color32 defaultColor)
{
if (ChartHelper.IsClearColor(color)) return defaultColor;
else return color;
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 94e905091d07140de987a531a6ff90d9
guid: bf0a2263a511d4348a256df8e732bb1b
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System;
using UnityEngine;
@@ -22,15 +22,12 @@ namespace XCharts
[SerializeField] private string m_Formatter;
[SerializeField] private int m_Interval = 0;
[SerializeField] private bool m_Inside = false;
[SerializeField] private float m_Rotate;
[SerializeField] private float m_Margin;
[SerializeField] private Color m_Color;
[SerializeField] private int m_FontSize;
[SerializeField] private FontStyle m_FontStyle;
[SerializeField] private string m_NumericFormatter = "";
[SerializeField] private bool m_ShowAsPositiveNumber = false;
[SerializeField] private bool m_OnZero = false;
[SerializeField] private TextLimit m_TextLimit = new TextLimit();
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
/// <summary>
/// Set this to false to prevent the axis label from appearing.
@@ -39,7 +36,7 @@ namespace XCharts
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); }
}
/// <summary>
/// The display interval of the axis label.
@@ -48,7 +45,7 @@ namespace XCharts
public int interval
{
get { return m_Interval; }
set { if (PropertyUtility.SetStruct(ref m_Interval, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Interval, value)) SetComponentDirty(); }
}
/// <summary>
/// Set this to true so the axis labels face the inside direction.
@@ -57,16 +54,7 @@ namespace XCharts
public bool inside
{
get { return m_Inside; }
set { if (PropertyUtility.SetStruct(ref m_Inside, value)) SetComponentDirty(); }
}
/// <summary>
/// Rotation degree of axis label, which is especially useful when there is no enough space for category axis.
/// 刻度标签旋转的角度,在类目轴的类目标签显示不下的时候可以通过旋转防止标签之间重叠。
/// </summary>
public float rotate
{
get { return m_Rotate; }
set { if (PropertyUtility.SetStruct(ref m_Rotate, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Inside, value)) SetComponentDirty(); }
}
/// <summary>
/// The margin between the axis label and the axis line.
@@ -75,34 +63,7 @@ namespace XCharts
public float margin
{
get { return m_Margin; }
set { if (PropertyUtility.SetStruct(ref m_Margin, value)) SetComponentDirty(); }
}
/// <summary>
/// the color of axis label text.
/// 刻度标签文字的颜色默认取Theme的axisTextColor。
/// </summary>
public Color color
{
get { return m_Color; }
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetComponentDirty(); }
}
/// <summary>
/// font size.
/// 文字的字体大小。
/// </summary>
public int fontSize
{
get { return m_FontSize; }
set { if (PropertyUtility.SetStruct(ref m_FontSize, value)) SetComponentDirty(); }
}
/// <summary>
/// font style.
/// 文字字体的风格。
/// </summary>
public FontStyle fontStyle
{
get { return m_FontStyle; }
set { if (PropertyUtility.SetStruct(ref m_FontStyle, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Margin, value)) SetComponentDirty(); }
}
/// <summary>
/// 图例内容字符串模版格式器。支持用 \n 换行。
@@ -111,7 +72,7 @@ namespace XCharts
public string formatter
{
get { return m_Formatter; }
set { if (PropertyUtility.SetClass(ref m_Formatter, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetClass(ref m_Formatter, value)) SetComponentDirty(); }
}
/// <summary>
@@ -124,7 +85,7 @@ namespace XCharts
public string numericFormatter
{
get { return m_NumericFormatter; }
set { if (PropertyUtility.SetClass(ref m_NumericFormatter, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetClass(ref m_NumericFormatter, value)) SetComponentDirty(); }
}
/// <summary>
@@ -134,7 +95,7 @@ namespace XCharts
public bool showAsPositiveNumber
{
get { return m_ShowAsPositiveNumber; }
set { if (PropertyUtility.SetStruct(ref m_ShowAsPositiveNumber, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_ShowAsPositiveNumber, value)) SetComponentDirty(); }
}
/// <summary>
@@ -143,7 +104,7 @@ namespace XCharts
public bool onZero
{
get { return m_OnZero; }
set { if (PropertyUtility.SetStruct(ref m_OnZero, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_OnZero, value)) SetComponentDirty(); }
}
/// <summary>
@@ -155,6 +116,16 @@ namespace XCharts
set { if (value != null) { m_TextLimit = value; SetComponentDirty(); } }
}
/// <summary>
/// The text style of axis name.
/// 文本样式。
/// </summary>
public TextStyle textStyle
{
get { return m_TextStyle; }
set { if (PropertyUtil.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
}
public override bool componentDirty { get { return m_ComponentDirty || m_TextLimit.componentDirty; } }
internal override void ClearComponentDirty()
{
@@ -171,11 +142,8 @@ namespace XCharts
m_Show = true,
m_Interval = 0,
m_Inside = false,
m_Rotate = 0,
m_Margin = 8,
m_Color = Color.clear,
m_FontSize = 18,
m_FontStyle = FontStyle.Normal
m_TextStyle = new TextStyle(),
};
}
}
@@ -187,12 +155,10 @@ namespace XCharts
axisLable.formatter = formatter;
axisLable.interval = interval;
axisLable.inside = inside;
axisLable.rotate = rotate;
axisLable.margin = margin;
axisLable.color = color;
axisLable.fontSize = fontSize;
axisLable.numericFormatter = numericFormatter;
axisLable.textLimit = textLimit.Clone();
axisLable.textStyle.Copy(textStyle);
return axisLable;
}
@@ -202,15 +168,13 @@ namespace XCharts
formatter = axisLable.formatter;
interval = axisLable.interval;
inside = axisLable.inside;
rotate = axisLable.rotate;
margin = axisLable.margin;
color = axisLable.color;
fontSize = axisLable.fontSize;
numericFormatter = axisLable.numericFormatter;
textLimit.Copy(axisLable.textLimit);
textStyle.Copy(axisLable.textStyle);
}
public void SetRelatedText(Text txt, float labelWidth)
public void SetRelatedText(ChartText txt, float labelWidth)
{
m_TextLimit.SetRelatedText(txt, labelWidth);
}

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
@@ -11,29 +11,15 @@ namespace XCharts
{
/// <summary>
/// Settings related to axis line.
/// 坐标轴的分隔线。
/// 坐标轴线。
/// </summary>
[System.Serializable]
public class AxisLine : SubComponent
public class AxisLine : BaseLine
{
[SerializeField] private bool m_Show;
[SerializeField] private bool m_OnZero;
[SerializeField] private float m_Width = 0.6f;
[SerializeField] private bool m_Symbol;
[SerializeField] private float m_SymbolWidth;
[SerializeField] private float m_SymbolHeight;
[SerializeField] private float m_SymbolOffset;
[SerializeField] private float m_SymbolDent;
[SerializeField] private bool m_ShowArrow;
[SerializeField] private Arrow m_Arrow = new Arrow();
/// <summary>
/// Set this to false to prevent the axis line from showing.
/// 是否显示坐标轴轴线。
/// </summary>
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// When mutiple axes exists, this option can be used to specify which axis can be "onZero" to.
/// X 轴或者 Y 轴的轴线是否在另一个轴的 0 刻度上,只有在另一个轴为数值轴且包含 0 刻度时有效。
@@ -41,63 +27,26 @@ namespace XCharts
public bool onZero
{
get { return m_OnZero; }
set { if (PropertyUtility.SetStruct(ref m_OnZero, value)) SetVerticesDirty(); }
}
/// <summary>
/// line style line width.
/// 坐标轴线线宽。
/// </summary>
public float width
{
get { return m_Width; }
set { if (PropertyUtility.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_OnZero, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether to show the arrow symbol of axis.
/// 是否显示箭头。
/// </summary>
public bool symbol
public bool showArrow
{
get { return m_Symbol; }
set { if (PropertyUtility.SetStruct(ref m_Symbol, value)) SetVerticesDirty(); }
get { return m_ShowArrow; }
set { if (PropertyUtil.SetStruct(ref m_ShowArrow, value)) SetVerticesDirty(); }
}
/// <summary>
/// the width of arrow symbol.
/// 箭头
/// the arrow of line.
/// 轴线箭头。
/// </summary>
public float symbolWidth
public Arrow arrow
{
get { return m_SymbolWidth; }
set { if (PropertyUtility.SetStruct(ref m_SymbolWidth, value)) SetVerticesDirty(); }
get { return m_Arrow; }
set { if (PropertyUtil.SetClass(ref m_Arrow, value)) SetVerticesDirty(); }
}
/// <summary>
/// the height of arrow symbol.
/// 箭头高。
/// </summary>
public float symbolHeight
{
get { return m_SymbolHeight; }
set { if (PropertyUtility.SetStruct(ref m_SymbolHeight, value)) SetVerticesDirty(); }
}
/// <summary>
/// the offset of arrow symbol.
/// 箭头偏移。
/// </summary>
public float symbolOffset
{
get { return m_SymbolOffset; }
set { if (PropertyUtility.SetStruct(ref m_SymbolOffset, value)) SetVerticesDirty(); }
}
/// <summary>
/// the dent of arrow symbol.
/// 箭头的凹陷程度。
/// </summary>
public float symbolDent
{
get { return m_SymbolDent; }
set { if (PropertyUtility.SetStruct(ref m_SymbolDent, value)) SetVerticesDirty(); }
}
public static AxisLine defaultAxisLine
{
get
@@ -106,12 +55,9 @@ namespace XCharts
{
m_Show = true,
m_OnZero = true,
m_Width = 0.7f,
m_Symbol = false,
m_SymbolWidth = 10,
m_SymbolHeight = 15,
m_SymbolOffset = -5f,
m_SymbolDent = 3,
m_ShowArrow = false,
m_Arrow = new Arrow(),
m_LineStyle = new LineStyle(LineStyle.Type.None),
};
return axisLine;
}
@@ -122,25 +68,17 @@ namespace XCharts
var axisLine = new AxisLine();
axisLine.show = show;
axisLine.onZero = onZero;
axisLine.width = width;
axisLine.symbol = symbol;
axisLine.symbolWidth = symbolWidth;
axisLine.symbolHeight = symbolHeight;
axisLine.symbolOffset = symbolOffset;
axisLine.symbolDent = symbolDent;
axisLine.showArrow = showArrow;
axisLine.arrow = arrow.Clone();
return axisLine;
}
public void Copy(AxisLine axisLine)
{
show = axisLine.show;
base.Copy(axisLine);
onZero = axisLine.onZero;
width = axisLine.width;
symbol = axisLine.symbol;
symbolWidth = axisLine.symbolWidth;
symbolHeight = axisLine.symbolHeight;
symbolOffset = axisLine.symbolOffset;
symbolDent = axisLine.symbolDent;
showArrow = axisLine.showArrow;
arrow.Copy(axisLine.arrow);
}
}
}

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System;
using UnityEngine;
@@ -30,11 +30,7 @@ namespace XCharts
[SerializeField] private bool m_Show;
[SerializeField] private string m_Name;
[SerializeField] private Location m_Location;
[SerializeField] private Vector2 m_Offset;
[SerializeField] private float m_Rotate;
[SerializeField] private Color m_Color;
[SerializeField] private int m_FontSize;
[SerializeField] private FontStyle m_FontStyle;
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
/// <summary>
/// Whether to show axis name.
@@ -43,7 +39,7 @@ namespace XCharts
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); }
}
/// <summary>
/// the name of axis.
@@ -52,7 +48,7 @@ namespace XCharts
public string name
{
get { return m_Name; }
set { if (PropertyUtility.SetClass(ref m_Name, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetClass(ref m_Name, value)) SetComponentDirty(); }
}
/// <summary>
/// Location of axis name.
@@ -61,52 +57,17 @@ namespace XCharts
public Location location
{
get { return m_Location; }
set { if (PropertyUtility.SetStruct(ref m_Location, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Location, value)) SetComponentDirty(); }
}
/// <summary>
/// the offset of axis name and axis line.
/// 坐标轴名称与轴线之间的偏移
/// The text style of axis name.
/// 文本样式
/// </summary>
public Vector2 offset
public TextStyle textStyle
{
get { return m_Offset; }
set { if (PropertyUtility.SetStruct(ref m_Offset, value)) SetComponentDirty(); }
}
/// <summary>
/// Rotation of axis name.
/// 坐标轴名字旋转,角度值。
/// </summary>
public float rotate
{
get { return m_Rotate; }
set { if (PropertyUtility.SetStruct(ref m_Rotate, value)) SetComponentDirty(); }
}
/// <summary>
/// Color of axis name.
/// 坐标轴名称的文字颜色。
/// </summary>
public Color color
{
get { return m_Color; }
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetComponentDirty(); }
}
/// <summary>
/// axis name font size.
/// 坐标轴名称的文字大小。
/// </summary>
public int fontSize
{
get { return m_FontSize; }
set { if (PropertyUtility.SetStruct(ref m_FontSize, value)) SetComponentDirty(); }
}
/// <summary>
/// axis name font style.
/// 坐标轴名称的文字风格。
/// </summary>
public FontStyle fontStyle
{
get { return m_FontStyle; }
set { if (PropertyUtility.SetStruct(ref m_FontStyle, value)) SetComponentDirty(); }
get { return m_TextStyle; }
set { if (PropertyUtil.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
}
public static AxisName defaultAxisName
@@ -118,10 +79,7 @@ namespace XCharts
m_Show = false,
m_Name = "axisName",
m_Location = Location.End,
m_Rotate = 0,
m_Color = Color.clear,
m_FontSize = 18,
m_FontStyle = FontStyle.Normal
m_TextStyle = new TextStyle(),
};
}
}
@@ -132,11 +90,7 @@ namespace XCharts
axisName.show = show;
axisName.name = name;
axisName.location = location;
axisName.offset = offset;
axisName.rotate = rotate;
axisName.color = color;
axisName.fontSize = fontSize;
axisName.fontStyle = fontStyle;
axisName.textStyle.Copy(textStyle);
return axisName;
}
@@ -145,11 +99,7 @@ namespace XCharts
show = axisName.show;
name = axisName.name;
location = axisName.location;
offset = axisName.offset;
rotate = axisName.rotate;
color = axisName.color;
fontSize = axisName.fontSize;
fontStyle = axisName.fontStyle;
textStyle.Copy(axisName.textStyle);
}
}
}

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System;
using System.Collections.Generic;
@@ -28,7 +28,7 @@ namespace XCharts
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// Color of split area. SplitArea color could also be set in color array,
@@ -49,10 +49,7 @@ namespace XCharts
return new AxisSplitArea()
{
m_Show = false,
m_Color = new List<Color32>(){
new Color32(250,250,250,77),
new Color32(200,200,200,77)
}
m_Color = new List<Color32>() { }
};
}
}
@@ -73,10 +70,18 @@ namespace XCharts
ChartHelper.CopyList(color, splitArea.color);
}
public Color32 getColor(int index)
public Color32 GetColor(int index, BaseAxisTheme theme)
{
var i = index % color.Count;
return color[i];
if (color.Count > 0)
{
var i = index % color.Count;
return color[i];
}
else
{
var i = index % theme.splitAreaColors.Count;
return theme.splitAreaColors[i];
}
}
}
}

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System;
using UnityEngine;
@@ -15,33 +15,14 @@ namespace XCharts
/// 坐标轴在 grid 区域中的分隔线。
/// </summary>
[Serializable]
public class AxisSplitLine : SubComponent
public class AxisSplitLine : BaseLine
{
[SerializeField] private bool m_Show;
[SerializeField] private int m_Interval;
[SerializeField] private LineStyle m_LineStyle = new LineStyle(0.7f);
/// <summary>
/// Set this to true to show the split line.
/// 是否显示分隔线。
/// </summary>
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
public int interval
{
get { return m_Interval; }
set { if (PropertyUtility.SetStruct(ref m_Interval, value)) SetVerticesDirty(); }
}
/// <summary>
/// 线条样式
/// </summary>
public LineStyle lineStyle
{
get { return m_LineStyle; }
set { if (value != null) { m_LineStyle = value; SetVerticesDirty(); } }
set { if (PropertyUtil.SetStruct(ref m_Interval, value)) SetVerticesDirty(); }
}
public override bool vertsDirty { get { return m_VertsDirty || m_LineStyle.anyDirty; } }
@@ -72,23 +53,8 @@ namespace XCharts
public void Copy(AxisSplitLine splitLine)
{
show = splitLine.show;
base.Copy(splitLine);
interval = splitLine.interval;
lineStyle.Copy(splitLine.lineStyle);
}
internal Color32 GetColor(ThemeInfo theme)
{
if (!ChartHelper.IsClearColor(lineStyle.color))
{
return lineStyle.GetColor();
}
else
{
var color = theme.axisSplitLineColor;
color.a = (byte)(color.a * lineStyle.opacity);
return color;
}
}
internal bool NeedShow(int index)

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
@@ -15,23 +15,11 @@ namespace XCharts
/// 坐标轴刻度相关设置。
/// </summary>
[System.Serializable]
public class AxisTick : SubComponent
public class AxisTick : BaseLine
{
[SerializeField] private bool m_Show;
[SerializeField] private bool m_AlignWithLabel;
[SerializeField] private bool m_Inside;
[SerializeField] private float m_Length;
[SerializeField] private float m_Width;
/// <summary>
/// Set this to false to prevent the axis tick from showing.
/// 是否显示坐标轴刻度。
/// </summary>
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// Align axis tick with label, which is available only when boundaryGap is set to be true in category axis.
/// 类目轴中在 boundaryGap 为 true 的时候有效,可以保证刻度线和标签对齐。
@@ -39,7 +27,7 @@ namespace XCharts
public bool alignWithLabel
{
get { return m_AlignWithLabel; }
set { if (PropertyUtility.SetStruct(ref m_AlignWithLabel, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_AlignWithLabel, value)) SetVerticesDirty(); }
}
/// <summary>
/// Set this to true so the axis labels face the inside direction.
@@ -48,25 +36,7 @@ namespace XCharts
public bool inside
{
get { return m_Inside; }
set { if (PropertyUtility.SetStruct(ref m_Inside, value)) SetVerticesDirty(); }
}
/// <summary>
/// The length of the axis tick.
/// 坐标轴刻度的长度。
/// </summary>
public float length
{
get { return m_Length; }
set { if (PropertyUtility.SetStruct(ref m_Length, value)) SetVerticesDirty(); }
}
/// <summary>
/// The width of the axis tick.Keep the same width with axis line when default 0.
/// 坐标轴刻度的宽度。默认为0时宽度和坐标轴一致。
/// </summary>
public float width
{
get { return m_Width; }
set { if (PropertyUtility.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Inside, value)) SetVerticesDirty(); }
}
public static AxisTick defaultTick
@@ -78,8 +48,6 @@ namespace XCharts
m_Show = true,
m_AlignWithLabel = false,
m_Inside = false,
m_Width = 0f,
m_Length = 5f
};
return tick;
}
@@ -91,8 +59,7 @@ namespace XCharts
axisTick.show = show;
axisTick.alignWithLabel = alignWithLabel;
axisTick.inside = inside;
axisTick.length = length;
axisTick.width = width;
axisTick.lineStyle = lineStyle.Clone();
return axisTick;
}
@@ -101,8 +68,6 @@ namespace XCharts
show = axisTick.show;
alignWithLabel = axisTick.alignWithLabel;
inside = axisTick.inside;
length = axisTick.length;
width = axisTick.width;
}
}
}

View File

@@ -0,0 +1,89 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
namespace XCharts
{
/// <summary>
/// Settings related to base line.
/// 线条基础配置。
/// </summary>
[System.Serializable]
public class BaseLine : SubComponent
{
[SerializeField] protected bool m_Show;
[SerializeField] protected LineStyle m_LineStyle = new LineStyle();
/// <summary>
/// Set this to false to prevent the axis line from showing.
/// 是否显示坐标轴轴线。
/// </summary>
public bool show
{
get { return m_Show; }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// 线条样式
/// </summary>
public LineStyle lineStyle
{
get { return m_LineStyle; }
set { if (value != null) { m_LineStyle = value; SetVerticesDirty(); } }
}
public static BaseLine defaultBaseLine
{
get
{
var axisLine = new BaseLine
{
m_Show = true,
m_LineStyle = new LineStyle()
};
return axisLine;
}
}
public BaseLine()
{
lineStyle = new LineStyle();
}
public BaseLine(bool show) : base()
{
m_Show = show;
}
public void Copy(BaseLine axisLine)
{
show = axisLine.show;
lineStyle.Copy(axisLine.lineStyle);
}
public LineStyle.Type GetType(LineStyle.Type themeType)
{
return lineStyle.GetType(themeType);
}
public float GetWidth(float themeWidth)
{
return lineStyle.GetWidth(themeWidth);
}
public float GetLength(float themeLength)
{
return lineStyle.GetLength(themeLength);
}
public Color32 GetColor(Color32 themeColor)
{
return lineStyle.GetColor(themeColor);
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 7fa63cd119419441789620060693a7cb
guid: 4c431b00ccffe4db4b61179b6df06eb2
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
@@ -41,7 +41,7 @@ namespace XCharts
public SerieLabel label
{
get { return m_Label; }
set { if (PropertyUtility.SetClass(ref m_Label, value, true)) SetAllDirty(); }
set { if (PropertyUtil.SetClass(ref m_Label, value, true)) SetAllDirty(); }
}
/// <summary>
/// 图形样式。
@@ -49,7 +49,7 @@ namespace XCharts
public ItemStyle itemStyle
{
get { return m_ItemStyle; }
set { if (PropertyUtility.SetClass(ref m_ItemStyle, value, true)) SetVerticesDirty(); }
set { if (PropertyUtil.SetClass(ref m_ItemStyle, value, true)) SetVerticesDirty(); }
}
public override bool vertsDirty { get { return m_VertsDirty || label.vertsDirty || itemStyle.vertsDirty; } }

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections.Generic;
using UnityEngine;
@@ -17,135 +17,10 @@ namespace XCharts
[System.Serializable]
public class GaugeAxis : SubComponent
{
[System.Serializable]
public class AxisLine
{
[System.Serializable]
public class StageColor
{
[SerializeField] private float m_Percent;
[SerializeField] private Color32 m_Color;
/// <summary>
/// 结束位置百分比。
/// </summary>
public float percent { get { return m_Percent; } set { m_Percent = value; } }
/// <summary>
/// 颜色。
/// </summary>
public Color32 color { get { return m_Color; } set { m_Color = value; } }
public StageColor(float percent, Color32 color)
{
m_Percent = percent;
m_Color = color;
}
}
[SerializeField] private bool m_Show = true;
[SerializeField] private float m_Width = 15f;
[SerializeField] private float m_Opacity = 1f;
[SerializeField] private Color32 m_BarColor;
[SerializeField] private Color32 m_BarBackgroundColor = new Color32(200, 200, 200, 255);
[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>
/// Set this to false to prevent the axis line from showing.
/// 是否显示坐标轴轴线。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
/// <summary>
/// line style line width.
/// 坐标轴线线宽。
/// </summary>
public float width { get { return m_Width; } set { m_Width = value; } }
/// <summary>
/// The opacity of axis line.
/// 透明度。
/// </summary>
public float opacity { get { return m_Opacity; } set { m_Opacity = value; } }
/// <summary>
/// 进度条颜色。
/// </summary>
public Color32 barColor { get { return m_BarColor; } set { m_BarColor = value; } }
/// <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; } }
}
/// <summary>
/// 分割线
/// </summary>
[System.Serializable]
public class SplitLine
{
[SerializeField] private bool m_Show = true;
[SerializeField] private float m_Length = 15;
[SerializeField]
private LineStyle m_LineStyle = new LineStyle()
{
width = 1.5f,
type = LineStyle.Type.Solid,
color = new Color32(238, 238, 238, 255)
};
/// <summary>
/// 是否显示分割线。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
/// <summary>
/// 分割线长度。
/// </summary>
public float length { get { return m_Length; } set { m_Length = value; } }
/// <summary>
/// 分割线样式。
/// </summary>
public LineStyle lineStyle { get { return m_LineStyle; } set { m_LineStyle = value; } }
}
/// <summary>
/// 刻度
/// </summary>
[System.Serializable]
public class AxisTick
{
[SerializeField] private bool m_Show = true;
[SerializeField] private float m_Length = 5;
[SerializeField] private float m_SplitNumber = 5;
[SerializeField]
private LineStyle m_LineStyle = new LineStyle()
{
width = 1f,
type = LineStyle.Type.Solid,
color = new Color32(238, 238, 238, 255)
};
/// <summary>
/// 是否显示刻度。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
/// <summary>
/// 刻度长度。当为0-1的浮点数时表示半径的百分比。
/// </summary>
public float length { get { return m_Length; } set { m_Length = value; } }
/// <summary>
/// 分割线之间的分割段数。
/// </summary>
public float splitNumber { get { return m_SplitNumber; } set { m_SplitNumber = value; } }
/// <summary>
/// 刻度线样式。
/// </summary>
public LineStyle lineStyle { get { return m_LineStyle; } set { m_LineStyle = value; } }
}
[SerializeField] private bool m_Show = true;
[SerializeField] private AxisLine m_AxisLine = new AxisLine();
[SerializeField] private SplitLine m_SplitLine = new SplitLine();
[SerializeField] private AxisTick m_AxisTick = new AxisTick();
[SerializeField] private GaugeAxisLine m_AxisLine = new GaugeAxisLine(true);
[SerializeField] private GaugeAxisSplitLine m_SplitLine = new GaugeAxisSplitLine(true);
[SerializeField] private GaugeAxisTick m_AxisTick = new GaugeAxisTick(true);
[SerializeField] private SerieLabel m_AxisLabel = new SerieLabel();
[SerializeField] private List<string> m_AxisLabelText = new List<string>();
@@ -154,17 +29,17 @@ namespace XCharts
/// axis line style.
/// 仪表盘轴线样式。
/// </summary>
public AxisLine axisLine { get { return m_AxisLine; } set { m_AxisLine = value; } }
public GaugeAxisLine axisLine { get { return m_AxisLine; } set { m_AxisLine = value; } }
/// <summary>
/// slit line style.
/// 分割线。
/// </summary>
public SplitLine splitLine { get { return m_SplitLine; } set { m_SplitLine = value; } }
public GaugeAxisSplitLine splitLine { get { return m_SplitLine; } set { m_SplitLine = value; } }
/// <summary>
/// axis tick style.
/// 刻度。
/// </summary>
public AxisTick axisTick { get { return m_AxisTick; } set { m_AxisTick = value; } }
public GaugeAxisTick axisTick { get { return m_AxisTick; } set { m_AxisTick = value; } }
/// <summary>
/// axis label style.
/// 文本标签。
@@ -181,23 +56,24 @@ namespace XCharts
public List<float> runtimeStageAngle = new List<float>();
public List<Vector3> runtimeLabelPosition = new List<Vector3>();
private List<LabelObject> m_RuntimeLabelList = new List<LabelObject>();
private List<ChartLabel> m_RuntimeLabelList = new List<ChartLabel>();
internal Color32 GetAxisLineColor(ThemeInfo theme, int index)
internal Color32 GetAxisLineColor(ChartTheme theme, int index)
{
var color = !ChartHelper.IsClearColor(axisLine.barColor) ? axisLine.barColor : theme.GetColor(index);
ChartHelper.SetColorOpacity(ref color, axisLine.opacity);
ChartHelper.SetColorOpacity(ref color, axisLine.lineStyle.opacity);
return color;
}
internal Color32 GetAxisLineBackgroundColor(ThemeInfo theme, int index)
internal Color32 GetAxisLineBackgroundColor(ChartTheme theme, int index)
{
var color = !ChartHelper.IsClearColor(axisLine.barBackgroundColor) ? axisLine.barBackgroundColor : ChartConst.greyColor32;
ChartHelper.SetColorOpacity(ref color, axisLine.opacity);
var color = !ChartHelper.IsClearColor(axisLine.barBackgroundColor)
? axisLine.barBackgroundColor : ChartConst.greyColor32;
ChartHelper.SetColorOpacity(ref color, axisLine.lineStyle.opacity);
return color;
}
internal Color32 GetSplitLineColor(ThemeInfo theme, int serieIndex, float angle)
internal Color32 GetSplitLineColor(Color32 themeColor, int serieIndex, float angle)
{
Color32 color;
if (!ChartHelper.IsClearColor(splitLine.lineStyle.color))
@@ -206,21 +82,12 @@ namespace XCharts
ChartHelper.SetColorOpacity(ref color, splitLine.lineStyle.opacity);
return color;
}
for (int i = 0; i < runtimeStageAngle.Count; i++)
{
if (angle < runtimeStageAngle[i])
{
color = axisLine.stageColor[i].color;
ChartHelper.SetColorOpacity(ref color, splitLine.lineStyle.opacity);
return color;
}
}
color = theme.GetColor(serieIndex);
color = themeColor;
ChartHelper.SetColorOpacity(ref color, splitLine.lineStyle.opacity);
return color;
}
internal Color32 GetAxisTickColor(ThemeInfo theme, int serieIndex, float angle)
internal Color32 GetAxisTickColor(Color32 themeColor, int serieIndex, float angle)
{
Color32 color;
if (!ChartHelper.IsClearColor(axisTick.lineStyle.color))
@@ -229,21 +96,12 @@ namespace XCharts
ChartHelper.SetColorOpacity(ref color, axisTick.lineStyle.opacity);
return color;
}
for (int i = 0; i < runtimeStageAngle.Count; i++)
{
if (angle < runtimeStageAngle[i])
{
color = axisLine.stageColor[i].color;
ChartHelper.SetColorOpacity(ref color, axisTick.lineStyle.opacity);
return color;
}
}
color = theme.GetColor(serieIndex);
color = themeColor;
ChartHelper.SetColorOpacity(ref color, axisTick.lineStyle.opacity);
return color;
}
internal Color32 GetPointerColor(ThemeInfo theme, int serieIndex, float angle, ItemStyle itemStyle)
internal Color32 GetPointerColor(ChartTheme theme, int serieIndex, float angle, ItemStyle itemStyle)
{
Color32 color;
if (!ChartHelper.IsClearColor(itemStyle.color))
@@ -269,12 +127,12 @@ namespace XCharts
m_RuntimeLabelList.Clear();
}
public void AddLabelObject(LabelObject label)
public void AddLabelObject(ChartLabel label)
{
m_RuntimeLabelList.Add(label);
}
public LabelObject GetLabelObject(int index)
public ChartLabel GetLabelObject(int index)
{
if (index >= 0 && index < m_RuntimeLabelList.Count)
{

View File

@@ -0,0 +1,63 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections.Generic;
using UnityEngine;
namespace XCharts
{
[System.Serializable]
public class StageColor
{
[SerializeField] private float m_Percent;
[SerializeField] private Color32 m_Color;
/// <summary>
/// 结束位置百分比。
/// </summary>
public float percent { get { return m_Percent; } set { m_Percent = value; } }
/// <summary>
/// 颜色。
/// </summary>
public Color32 color { get { return m_Color; } set { m_Color = value; } }
public StageColor(float percent, Color32 color)
{
m_Percent = percent;
m_Color = color;
}
}
[System.Serializable]
public class GaugeAxisLine : BaseLine
{
[SerializeField] private Color32 m_BarColor;
[SerializeField] private Color32 m_BarBackgroundColor = new Color32(200, 200, 200, 255);
[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 barColor { get { return m_BarColor; } set { m_BarColor = value; } }
/// <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 GaugeAxisLine(bool show) : base(show)
{
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: a0b05891df2284bc588cf6b668bfeb7b
guid: 2c35880091e5a4382876c47bd843a99f
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,20 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
namespace XCharts
{
/// <summary>
/// 分割线
/// </summary>
[System.Serializable]
public class GaugeAxisSplitLine : BaseLine
{
public GaugeAxisSplitLine(bool show) : base(show)
{
}
}
}

View File

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

View File

@@ -0,0 +1,27 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
namespace XCharts
{
/// <summary>
/// 刻度
/// </summary>
[System.Serializable]
public class GaugeAxisTick : BaseLine
{
[SerializeField] private float m_SplitNumber = 5;
/// <summary>
/// 分割线之间的分割段数。
/// </summary>
public float splitNumber { get { return m_SplitNumber; } set { m_SplitNumber = value; } }
public GaugeAxisTick(bool show) : base(show)
{
}
}
}

View File

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

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections.Generic;
using UnityEngine;
@@ -29,7 +29,7 @@ namespace XCharts
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// Pointer length. It can be an absolute value, or it can be a percentage relative to the radius (0-1).
@@ -38,7 +38,7 @@ namespace XCharts
public float length
{
get { return m_Length; }
set { if (PropertyUtility.SetStruct(ref m_Length, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Length, value)) SetVerticesDirty(); }
}
/// <summary>
/// Pointer width.
@@ -47,7 +47,7 @@ namespace XCharts
public float width
{
get { return m_Width; }
set { if (PropertyUtility.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
}
}
}

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
using UnityEngine.UI;

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System;
using System.Collections.Generic;
@@ -84,7 +84,7 @@ namespace XCharts
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// 数据项颜色。
@@ -92,7 +92,7 @@ namespace XCharts
public Color32 color
{
get { return m_Color; }
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetVerticesDirty(); }
}
/// <summary>
/// Gradient color1.
@@ -101,7 +101,7 @@ namespace XCharts
public Color32 toColor
{
get { return m_ToColor; }
set { if (PropertyUtility.SetColor(ref m_ToColor, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetColor(ref m_ToColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// Gradient color2.Only valid in line diagrams.
@@ -110,7 +110,7 @@ namespace XCharts
public Color32 toColor2
{
get { return m_ToColor2; }
set { if (PropertyUtility.SetColor(ref m_ToColor2, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetColor(ref m_ToColor2, value)) SetVerticesDirty(); }
}
/// <summary>
/// 数据项背景颜色。
@@ -118,7 +118,7 @@ namespace XCharts
public Color32 backgroundColor
{
get { return m_BackgroundColor; }
set { if (PropertyUtility.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// 中心区域颜色。
@@ -126,7 +126,7 @@ namespace XCharts
public Color32 centerColor
{
get { return m_CenterColor; }
set { if (PropertyUtility.SetColor(ref m_CenterColor, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetColor(ref m_CenterColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// 中心区域间隙。
@@ -134,7 +134,7 @@ namespace XCharts
public float centerGap
{
get { return m_CenterGap; }
set { if (PropertyUtility.SetStruct(ref m_CenterGap, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_CenterGap, value)) SetVerticesDirty(); }
}
/// <summary>
/// 数据项背景宽度。
@@ -142,7 +142,7 @@ namespace XCharts
public float backgroundWidth
{
get { return m_BackgroundWidth; }
set { if (PropertyUtility.SetStruct(ref m_BackgroundWidth, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_BackgroundWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// 边框的类型。
@@ -150,7 +150,7 @@ namespace XCharts
public Type borderType
{
get { return m_BorderType; }
set { if (PropertyUtility.SetStruct(ref m_BorderType, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_BorderType, value)) SetVerticesDirty(); }
}
/// <summary>
/// 边框的颜色。
@@ -158,7 +158,7 @@ namespace XCharts
public Color32 borderColor
{
get { return m_BorderColor; }
set { if (PropertyUtility.SetColor(ref m_BorderColor, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetColor(ref m_BorderColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// 边框宽。
@@ -166,7 +166,7 @@ namespace XCharts
public float borderWidth
{
get { return m_BorderWidth; }
set { if (PropertyUtility.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// 透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
@@ -174,7 +174,7 @@ namespace XCharts
public float opacity
{
get { return m_Opacity; }
set { if (PropertyUtility.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
}
/// <summary>
/// 提示框单项的字符串模版格式器。具体配置参考`Tooltip`的`formatter`
@@ -182,7 +182,7 @@ namespace XCharts
public string tooltipFormatter
{
get { return m_TooltipFormatter; }
set { if (PropertyUtility.SetClass(ref m_TooltipFormatter, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetClass(ref m_TooltipFormatter, value)) SetVerticesDirty(); }
}
/// <summary>
/// Standard numeric format strings.
@@ -194,7 +194,7 @@ namespace XCharts
public string numericFormatter
{
get { return m_NumericFormatter; }
set { if (PropertyUtility.SetClass(ref m_NumericFormatter, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetClass(ref m_NumericFormatter, value)) SetComponentDirty(); }
}
/// <summary>
/// The radius of rounded corner. Its unit is px. Use array to respectively specify the 4 corner radiuses((clockwise upper left, upper right, bottom right and bottom left)).
@@ -203,7 +203,7 @@ namespace XCharts
public float[] cornerRadius
{
get { return m_CornerRadius; }
set { if (PropertyUtility.SetClass(ref m_CornerRadius, value, true)) SetVerticesDirty(); }
set { if (PropertyUtil.SetClass(ref m_CornerRadius, value, true)) SetVerticesDirty(); }
}
/// <summary>
/// 实际边框宽。边框不显示时为0。

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System;
using UnityEngine;
@@ -28,10 +28,14 @@ namespace XCharts
}
[SerializeField] private bool m_Show;
[SerializeField] Position m_Position;
[SerializeField] private float m_Width = 10;
[SerializeField] private float m_Height = 15;
[SerializeField] private float m_Offset = 0;
[SerializeField] private float m_Dent = 3;
[SerializeField]
private Arrow m_Arrow = new Arrow()
{
width = 10,
height = 15,
offset = 0,
dent = 3
};
/// <summary>
/// Whether to show the arrow.
@@ -40,7 +44,7 @@ namespace XCharts
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// The position of arrow.
@@ -49,43 +53,17 @@ namespace XCharts
public Position position
{
get { return m_Position; }
set { if (PropertyUtility.SetStruct(ref m_Position, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Position, value)) SetVerticesDirty(); }
}
/// <summary>
/// The widht of arrow.
/// 箭头
/// the arrow of line.
/// 箭头。
/// </summary>
public float width
public Arrow arrow
{
get { return m_Width; }
set { if (PropertyUtility.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
}
/// <summary>
/// The height of arrow.
/// 箭头高。
/// </summary>
public float height
{
get { return m_Height; }
set { if (PropertyUtility.SetStruct(ref m_Height, value)) SetVerticesDirty(); }
}
/// <summary>
/// The offset of arrow.
/// 箭头偏移。
/// </summary>
public float offset
{
get { return m_Offset; }
set { if (PropertyUtility.SetStruct(ref m_Offset, value)) SetVerticesDirty(); }
}
/// <summary>
/// The dent of arrow.
/// 箭头的凹度。
/// </summary>
public float dent
{
get { return m_Dent; }
set { if (PropertyUtility.SetStruct(ref m_Dent, value)) SetVerticesDirty(); }
get { return m_Arrow; }
set { if (PropertyUtil.SetClass(ref m_Arrow, value)) SetVerticesDirty(); }
}
}
}

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
@@ -44,13 +44,15 @@ namespace XCharts
/// 双点划线
/// </summary>
DashDotDot,
None,
}
[SerializeField] private bool m_Show = true;
[SerializeField] private Type m_Type = Type.Solid;
[SerializeField] private Color32 m_Color;
[SerializeField] private Color32 m_ToColor;
[SerializeField] private Color32 m_ToColor2;
[SerializeField] private float m_Width = 0.8f;
[SerializeField] private float m_Width = 0;
[SerializeField] private float m_Length = 0;
[SerializeField] [Range(0, 1)] private float m_Opacity = 1;
/// <summary>
@@ -60,7 +62,7 @@ namespace XCharts
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// the type of line.
@@ -69,7 +71,7 @@ namespace XCharts
public Type type
{
get { return m_Type; }
set { if (PropertyUtility.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color of line, default use serie color.
@@ -78,7 +80,7 @@ namespace XCharts
public Color32 color
{
get { return m_Color; }
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetVerticesDirty(); }
}
/// <summary>
/// the middle color of line, default use serie color.
@@ -87,7 +89,7 @@ namespace XCharts
public Color32 toColor
{
get { return m_ToColor; }
set { if (PropertyUtility.SetColor(ref m_ToColor, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetColor(ref m_ToColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the end color of line, default use serie color.
@@ -96,7 +98,7 @@ namespace XCharts
public Color32 toColor2
{
get { return m_ToColor2; }
set { if (PropertyUtility.SetColor(ref m_ToColor2, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetColor(ref m_ToColor2, value)) SetVerticesDirty(); }
}
/// <summary>
/// the width of line.
@@ -105,7 +107,16 @@ namespace XCharts
public float width
{
get { return m_Width; }
set { if (PropertyUtility.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
}
/// <summary>
/// the length of line.
/// 线长。
/// /// </summary>
public float length
{
get { return m_Length; }
set { if (PropertyUtil.SetStruct(ref m_Length, value)) SetVerticesDirty(); }
}
/// <summary>
/// Opacity of the line. Supports value from 0 to 1, and the line will not be drawn when set to 0.
@@ -114,7 +125,7 @@ namespace XCharts
public float opacity
{
get { return m_Opacity; }
set { if (PropertyUtility.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
}
public LineStyle()
@@ -126,6 +137,11 @@ namespace XCharts
this.width = width;
}
public LineStyle(LineStyle.Type type)
{
this.type = type;
}
public LineStyle(LineStyle.Type type, float width)
{
this.type = type;
@@ -190,5 +206,34 @@ namespace XCharts
}
return color;
}
public Type GetType(Type themeType)
{
return type == Type.None ? themeType : type;
}
public float GetWidth(float themeWidth)
{
return width == 0 ? themeWidth : width;
}
public float GetLength(float themeLength)
{
return length == 0 ? themeLength : length;
}
public Color32 GetColor(Color32 themeColor)
{
if (!ChartHelper.IsClearColor(color))
{
return GetColor();
}
else
{
var color = themeColor;
color.a = (byte)(color.a * opacity);
return color;
}
}
}
}

View File

@@ -1,12 +1,15 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System;
using UnityEngine;
#if dUI_TextMeshPro
using TMPro;
#endif
namespace XCharts
{
@@ -39,7 +42,10 @@ namespace XCharts
[SerializeField] private float m_Top;
[SerializeField] private float m_Bottom;
private TextAnchor m_TextAnchor;
private TextAnchor m_TextAlignment;
#if dUI_TextMeshPro
private TextAlignmentOptions m_TMPTextAlignment;
#endif
private Vector2 m_AnchorMin;
private Vector2 m_AnchorMax;
private Vector2 m_Pivot;
@@ -50,7 +56,7 @@ namespace XCharts
public Align align
{
get { return m_Align; }
set { if (PropertyUtility.SetStruct(ref m_Align, value)) { SetComponentDirty(); UpdateAlign(); } }
set { if (PropertyUtil.SetStruct(ref m_Align, value)) { SetComponentDirty(); UpdateAlign(); } }
}
/// <summary>
/// Distance between component and the left side of the container.
@@ -59,7 +65,7 @@ namespace XCharts
public float left
{
get { return m_Left; }
set { if (PropertyUtility.SetStruct(ref m_Left, value)) { SetComponentDirty(); UpdateAlign(); } }
set { if (PropertyUtil.SetStruct(ref m_Left, value)) { SetComponentDirty(); UpdateAlign(); } }
}
/// <summary>
/// Distance between component and the left side of the container.
@@ -68,7 +74,7 @@ namespace XCharts
public float right
{
get { return m_Right; }
set { if (PropertyUtility.SetStruct(ref m_Right, value)) { SetComponentDirty(); UpdateAlign(); } }
set { if (PropertyUtil.SetStruct(ref m_Right, value)) { SetComponentDirty(); UpdateAlign(); } }
}
/// <summary>
/// Distance between component and the left side of the container.
@@ -77,7 +83,7 @@ namespace XCharts
public float top
{
get { return m_Top; }
set { if (PropertyUtility.SetStruct(ref m_Top, value)) { SetComponentDirty(); UpdateAlign(); } }
set { if (PropertyUtil.SetStruct(ref m_Top, value)) { SetComponentDirty(); UpdateAlign(); } }
}
/// <summary>
/// Distance between component and the left side of the container.
@@ -86,7 +92,7 @@ namespace XCharts
public float bottom
{
get { return m_Bottom; }
set { if (PropertyUtility.SetStruct(ref m_Bottom, value)) { SetComponentDirty(); UpdateAlign(); } }
set { if (PropertyUtil.SetStruct(ref m_Bottom, value)) { SetComponentDirty(); UpdateAlign(); } }
}
/// <summary>
@@ -94,7 +100,11 @@ namespace XCharts
/// Location对应的Anchor锚点
/// </summary>
/// <value></value>
public TextAnchor runtimeTextAnchor { get { return m_TextAnchor; } }
public TextAnchor runtimeTextAlignment { get { return m_TextAlignment; } }
#if dUI_TextMeshPro
public TextAlignmentOptions runtimeTMPTextAlignment { get { return m_TMPTextAlignment; } }
#endif
/// <summary>
/// the minimum achor.
/// Location对应的anchorMin。
@@ -179,55 +189,82 @@ namespace XCharts
switch (m_Align)
{
case Align.BottomCenter:
m_TextAnchor = TextAnchor.LowerCenter;
m_TextAlignment = TextAnchor.LowerCenter;
#if dUI_TextMeshPro
m_TMPTextAlignment = TextAlignmentOptions.Bottom;
#endif
m_AnchorMin = new Vector2(0.5f, 0);
m_AnchorMax = new Vector2(0.5f, 0);
m_Pivot = new Vector2(0.5f, 0);
break;
case Align.BottomLeft:
m_TextAnchor = TextAnchor.LowerLeft;
m_TextAlignment = TextAnchor.LowerLeft;
#if dUI_TextMeshPro
m_TMPTextAlignment = TextAlignmentOptions.BottomLeft;
#endif
m_AnchorMin = new Vector2(0, 0);
m_AnchorMax = new Vector2(0, 0);
m_Pivot = new Vector2(0, 0);
break;
case Align.BottomRight:
m_TextAnchor = TextAnchor.LowerRight;
m_TextAlignment = TextAnchor.LowerRight;
#if dUI_TextMeshPro
m_TMPTextAlignment = TextAlignmentOptions.BottomRight;
#endif
m_AnchorMin = new Vector2(1, 0);
m_AnchorMax = new Vector2(1, 0);
m_Pivot = new Vector2(1, 0);
break;
case Align.Center:
m_TextAnchor = TextAnchor.MiddleCenter;
m_TextAlignment = TextAnchor.MiddleCenter;
#if dUI_TextMeshPro
m_TMPTextAlignment = TextAlignmentOptions.Center;
#endif
m_AnchorMin = new Vector2(0.5f, 0.5f);
m_AnchorMax = new Vector2(0.5f, 0.5f);
m_Pivot = new Vector2(0.5f, 0.5f);
break;
case Align.CenterLeft:
m_TextAnchor = TextAnchor.MiddleLeft;
m_TextAlignment = TextAnchor.MiddleLeft;
#if dUI_TextMeshPro
m_TMPTextAlignment = TextAlignmentOptions.Left;
#endif
m_AnchorMin = new Vector2(0, 0.5f);
m_AnchorMax = new Vector2(0, 0.5f);
m_Pivot = new Vector2(0, 0.5f);
break;
case Align.CenterRight:
m_TextAnchor = TextAnchor.MiddleRight;
m_TextAlignment = TextAnchor.MiddleRight;
#if dUI_TextMeshPro
m_TMPTextAlignment = TextAlignmentOptions.Right;
#endif
m_AnchorMin = new Vector2(1, 0.5f);
m_AnchorMax = new Vector2(1, 0.5f);
m_Pivot = new Vector2(1, 0.5f);
break;
case Align.TopCenter:
m_TextAnchor = TextAnchor.UpperCenter;
m_TextAlignment = TextAnchor.UpperCenter;
#if dUI_TextMeshPro
m_TMPTextAlignment = TextAlignmentOptions.Top;
#endif
m_AnchorMin = new Vector2(0.5f, 1);
m_AnchorMax = new Vector2(0.5f, 1);
m_Pivot = new Vector2(0.5f, 1);
break;
case Align.TopLeft:
m_TextAnchor = TextAnchor.UpperLeft;
m_TextAlignment = TextAnchor.UpperLeft;
#if dUI_TextMeshPro
m_TMPTextAlignment = TextAlignmentOptions.TopLeft;
#endif
m_AnchorMin = new Vector2(0, 1);
m_AnchorMax = new Vector2(0, 1);
m_Pivot = new Vector2(0, 1);
break;
case Align.TopRight:
m_TextAnchor = TextAnchor.UpperRight;
m_TextAlignment = TextAnchor.UpperRight;
#if dUI_TextMeshPro
m_TMPTextAlignment = TextAlignmentOptions.TopRight;
#endif
m_AnchorMin = new Vector2(1, 1);
m_AnchorMax = new Vector2(1, 1);
m_Pivot = new Vector2(1, 1);

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections.Generic;
using UnityEngine;

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Linq;
using System.Collections.Generic;
@@ -34,7 +34,7 @@ namespace XCharts
[SerializeField] private SerieSymbol m_Symbol = new SerieSymbol();
[SerializeField] private List<float> m_Data = new List<float>();
public LabelObject labelObject { get; set; }
public ChartLabel labelObject { get; set; }
private bool m_Show = true;
private float m_RtPieOutsideRadius;
@@ -169,6 +169,7 @@ namespace XCharts
public Vector3 runtimePosition { get; internal set; }
public float runtimeAngle { get; internal set; }
public Vector3 runtiemPieOffsetCenter { get; internal set; }
public float runtimeStackHig { get; internal set; }
private List<float> m_PreviousData = new List<float>();
private List<float> m_DataUpdateTime = new List<float>();
private List<bool> m_DataUpdateFlag = new List<bool>();

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System;
using UnityEngine;
@@ -83,15 +83,10 @@ namespace XCharts
[SerializeField] private Vector3 m_Offset;
[SerializeField] private float m_Margin;
[SerializeField] private string m_Formatter;
[SerializeField] private float m_Rotate = 0;
[SerializeField] private float m_PaddingLeftRight = 2f;
[SerializeField] private float m_PaddingTopBottom = 2f;
[SerializeField] private Color m_Color;
[SerializeField] private Color32 m_BackgroundColor;
[SerializeField] private float m_BackgroundWidth = 0;
[SerializeField] private float m_BackgroundHeight = 0;
[SerializeField] private int m_FontSize = 18;
[SerializeField] private FontStyle m_FontStyle = FontStyle.Normal;
[SerializeField] private bool m_Line = true;
[SerializeField] private LineType m_LineType = LineType.BrokenLine;
[SerializeField] private Color32 m_LineColor = ChartConst.clearColor32;
@@ -103,6 +98,7 @@ namespace XCharts
[SerializeField] private Color32 m_BorderColor = ChartConst.greyColor32;
[SerializeField] private string m_NumericFormatter = "";
[SerializeField] private bool m_AutoOffset = false;
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
public void Reset()
{
@@ -112,12 +108,8 @@ namespace XCharts
m_Margin = 0;
m_PaddingLeftRight = 2f;
m_PaddingTopBottom = 2f;
m_Color = Color.clear;
m_BackgroundColor = Color.clear;
m_BackgroundWidth = 0;
m_BackgroundHeight = 0;
m_FontSize = 18;
m_FontStyle = FontStyle.Normal;
m_Line = true;
m_LineType = LineType.BrokenLine;
m_LineColor = Color.clear;
@@ -138,7 +130,7 @@ namespace XCharts
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetAllDirty(); }
}
/// <summary>
/// The position of label.
@@ -147,7 +139,7 @@ namespace XCharts
public Position position
{
get { return m_Position; }
set { if (PropertyUtility.SetStruct(ref m_Position, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Position, value)) SetVerticesDirty(); }
}
/// <summary>
/// 标签内容字符串模版格式器。支持用 \n 换行。
@@ -165,7 +157,7 @@ namespace XCharts
public string formatter
{
get { return m_Formatter; }
set { if (PropertyUtility.SetClass(ref m_Formatter, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetClass(ref m_Formatter, value)) SetVerticesDirty(); }
}
/// <summary>
/// offset to the host graphic element.
@@ -174,7 +166,7 @@ namespace XCharts
public Vector3 offset
{
get { return m_Offset; }
set { if (PropertyUtility.SetStruct(ref m_Offset, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Offset, value)) SetVerticesDirty(); }
}
/// <summary>
/// 距离轴线的距离。
@@ -182,25 +174,7 @@ namespace XCharts
public float margin
{
get { return m_Margin; }
set { if (PropertyUtility.SetStruct(ref m_Margin, value)) SetVerticesDirty(); }
}
/// <summary>
/// Text color,If set as default ,the color will assigned as series color.
/// 自定义文字颜色,默认和系列的颜色一致。
/// </summary>
public Color color
{
get { return m_Color; }
set { if (PropertyUtility.SetStruct(ref m_Color, value)) SetComponentDirty(); }
}
/// <summary>
/// the background color. If set as default, it means than don't show background.
/// 标签的背景色,默认无颜色。
/// </summary>
public Color32 backgroundColor
{
get { return m_BackgroundColor; }
set { if (PropertyUtility.SetStruct(ref m_BackgroundColor, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Margin, value)) SetVerticesDirty(); }
}
/// <summary>
/// the width of background. If set as default value 0, it means than the background width auto set as the text width.
@@ -210,7 +184,7 @@ namespace XCharts
public float backgroundWidth
{
get { return m_BackgroundWidth; }
set { if (PropertyUtility.SetStruct(ref m_BackgroundWidth, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_BackgroundWidth, value)) SetComponentDirty(); }
}
/// <summary>
/// the height of background. If set as default value 0, it means than the background height auto set as the text height.
@@ -220,16 +194,7 @@ namespace XCharts
public float backgroundHeight
{
get { return m_BackgroundHeight; }
set { if (PropertyUtility.SetStruct(ref m_BackgroundHeight, value)) SetComponentDirty(); }
}
/// <summary>
/// Rotate label.
/// 标签旋转。
/// </summary>
public float rotate
{
get { return m_Rotate; }
set { if (PropertyUtility.SetStruct(ref m_Rotate, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_BackgroundHeight, value)) SetComponentDirty(); }
}
/// <summary>
/// the text padding of left and right. defaut:2.
@@ -238,7 +203,7 @@ namespace XCharts
public float paddingLeftRight
{
get { return m_PaddingLeftRight; }
set { if (PropertyUtility.SetStruct(ref m_PaddingLeftRight, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_PaddingLeftRight, value)) SetComponentDirty(); }
}
/// <summary>
/// the text padding of top and bottom. defaut:2.
@@ -247,25 +212,7 @@ namespace XCharts
public float paddingTopBottom
{
get { return m_PaddingTopBottom; }
set { if (PropertyUtility.SetStruct(ref m_PaddingTopBottom, value)) SetComponentDirty(); }
}
/// <summary>
/// font size.
/// 文字的字体大小。
/// </summary>
public int fontSize
{
get { return m_FontSize; }
set { if (PropertyUtility.SetStruct(ref m_FontSize, value)) SetAllDirty(); }
}
/// <summary>
/// font style.
/// 文字的字体风格。
/// </summary>
public FontStyle fontStyle
{
get { return m_FontStyle; }
set { if (PropertyUtility.SetStruct(ref m_FontStyle, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_PaddingTopBottom, value)) SetComponentDirty(); }
}
/// <summary>
/// Whether to show visual guide line.Will show when label position is set as 'outside'.
@@ -274,7 +221,7 @@ namespace XCharts
public bool line
{
get { return m_Line; }
set { if (PropertyUtility.SetStruct(ref m_Line, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Line, value)) SetComponentDirty(); }
}
/// <summary>
/// the type of visual guide line.
@@ -283,7 +230,7 @@ namespace XCharts
public LineType lineType
{
get { return m_LineType; }
set { if (PropertyUtility.SetStruct(ref m_LineType, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_LineType, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color of visual guild line.
@@ -292,7 +239,7 @@ namespace XCharts
public Color32 lineColor
{
get { return m_LineColor; }
set { if (PropertyUtility.SetStruct(ref m_LineColor, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_LineColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the width of visual guild line.
@@ -301,7 +248,7 @@ namespace XCharts
public float lineWidth
{
get { return m_LineWidth; }
set { if (PropertyUtility.SetStruct(ref m_LineWidth, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_LineWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// The length of the first segment of visual guide line.
@@ -310,7 +257,7 @@ namespace XCharts
public float lineLength1
{
get { return m_LineLength1; }
set { if (PropertyUtility.SetStruct(ref m_LineLength1, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_LineLength1, value)) SetVerticesDirty(); }
}
/// <summary>
/// The length of the second segment of visual guide line.
@@ -319,7 +266,7 @@ namespace XCharts
public float lineLength2
{
get { return m_LineLength2; }
set { if (PropertyUtility.SetStruct(ref m_LineLength2, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_LineLength2, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether to show border.
@@ -328,7 +275,7 @@ namespace XCharts
public bool border
{
get { return m_Border; }
set { if (PropertyUtility.SetStruct(ref m_Border, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Border, value)) SetVerticesDirty(); }
}
/// <summary>
/// the width of border.
@@ -337,7 +284,7 @@ namespace XCharts
public float borderWidth
{
get { return m_BorderWidth; }
set { if (PropertyUtility.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color of border.
@@ -346,7 +293,7 @@ namespace XCharts
public Color32 borderColor
{
get { return m_BorderColor; }
set { if (PropertyUtility.SetStruct(ref m_BorderColor, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_BorderColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// Standard numeric format strings.
@@ -358,7 +305,7 @@ namespace XCharts
public string numericFormatter
{
get { return m_NumericFormatter; }
set { if (PropertyUtility.SetClass(ref m_NumericFormatter, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetClass(ref m_NumericFormatter, value)) SetComponentDirty(); }
}
/// <summary>
/// 是否开启自动偏移。当开启时Y的偏移会自动判断曲线的开口来决定向上还是向下偏移。
@@ -366,7 +313,17 @@ namespace XCharts
public bool autoOffset
{
get { return m_AutoOffset; }
set { if (PropertyUtility.SetStruct(ref m_AutoOffset, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_AutoOffset, value)) SetAllDirty(); }
}
/// <summary>
/// the sytle of text.
/// 文本样式。
/// </summary>
public TextStyle textStyle
{
get { return m_TextStyle; }
set { if (PropertyUtil.SetClass(ref m_TextStyle, value)) SetAllDirty(); }
}
}
}

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections.Generic;
using UnityEngine;
@@ -81,8 +81,8 @@ namespace XCharts
[SerializeField] private bool m_Show = true;
[SerializeField] private SerieSymbolType m_Type = SerieSymbolType.EmptyCircle;
[SerializeField] private SerieSymbolSizeType m_SizeType = SerieSymbolSizeType.Custom;
[SerializeField] private float m_Size = 6f;
[SerializeField] private float m_SelectedSize = 10f;
[SerializeField] private float m_Size = 0f;
[SerializeField] private float m_SelectedSize = 0f;
[SerializeField] private int m_DataIndex = 1;
[SerializeField] private float m_DataScale = 1;
[SerializeField] private float m_SelectedDataScale = 1.5f;
@@ -98,8 +98,8 @@ namespace XCharts
m_Show = false;
m_Type = SerieSymbolType.EmptyCircle;
m_SizeType = SerieSymbolSizeType.Custom;
m_Size = 6f;
m_SelectedDataScale = 10f;
m_Size = 0f;
m_SelectedSize = 0f;
m_DataIndex = 1;
m_DataScale = 1;
m_SelectedDataScale = 1.5f;
@@ -118,7 +118,7 @@ namespace XCharts
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetAllDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetAllDirty(); }
}
/// <summary>
/// the type of symbol.
@@ -127,7 +127,7 @@ namespace XCharts
public SerieSymbolType type
{
get { return m_Type; }
set { if (PropertyUtility.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
}
/// <summary>
/// the type of symbol size.
@@ -136,7 +136,7 @@ namespace XCharts
public SerieSymbolSizeType sizeType
{
get { return m_SizeType; }
set { if (PropertyUtility.SetStruct(ref m_SizeType, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_SizeType, value)) SetVerticesDirty(); }
}
/// <summary>
/// the size of symbol.
@@ -145,7 +145,7 @@ namespace XCharts
public float size
{
get { return m_Size; }
set { if (PropertyUtility.SetStruct(ref m_Size, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Size, value)) SetVerticesDirty(); }
}
/// <summary>
/// the size of selected symbol.
@@ -154,7 +154,7 @@ namespace XCharts
public float selectedSize
{
get { return m_SelectedSize; }
set { if (PropertyUtility.SetStruct(ref m_SelectedSize, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_SelectedSize, value)) SetVerticesDirty(); }
}
/// <summary>
/// whitch data index is when the sizeType assined as FromData.
@@ -163,7 +163,7 @@ namespace XCharts
public int dataIndex
{
get { return m_DataIndex; }
set { if (PropertyUtility.SetStruct(ref m_DataIndex, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_DataIndex, value)) SetVerticesDirty(); }
}
/// <summary>
/// the scale of data when sizeType assined as FromData.
@@ -172,7 +172,7 @@ namespace XCharts
public float dataScale
{
get { return m_DataScale; }
set { if (PropertyUtility.SetStruct(ref m_DataScale, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_DataScale, value)) SetVerticesDirty(); }
}
/// <summary>
/// the scale of selected data when sizeType assined as FromData.
@@ -181,7 +181,7 @@ namespace XCharts
public float selectedDataScale
{
get { return m_SelectedDataScale; }
set { if (PropertyUtility.SetStruct(ref m_SelectedDataScale, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_SelectedDataScale, value)) SetVerticesDirty(); }
}
/// <summary>
/// the callback of size when sizeType assined as Callback.
@@ -190,7 +190,7 @@ namespace XCharts
public SymbolSizeCallback sizeCallback
{
get { return m_SizeCallback; }
set { if (PropertyUtility.SetClass(ref m_SizeCallback, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetClass(ref m_SizeCallback, value)) SetVerticesDirty(); }
}
/// <summary>
/// the callback of size when sizeType assined as Callback.
@@ -199,7 +199,7 @@ namespace XCharts
public SymbolSizeCallback selectedSizeCallback
{
get { return m_SelectedSizeCallback; }
set { if (PropertyUtility.SetClass(ref m_SelectedSizeCallback, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetClass(ref m_SelectedSizeCallback, value)) SetVerticesDirty(); }
}
/// <summary>
/// the index start to show symbol.
@@ -208,7 +208,7 @@ namespace XCharts
public int startIndex
{
get { return m_StartIndex; }
set { if (PropertyUtility.SetStruct(ref m_StartIndex, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_StartIndex, value)) SetVerticesDirty(); }
}
/// <summary>
/// the interval of show symbol.
@@ -217,7 +217,7 @@ namespace XCharts
public int interval
{
get { return m_Interval; }
set { if (PropertyUtility.SetStruct(ref m_Interval, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Interval, value)) SetVerticesDirty(); }
}
/// <summary>
/// whether to show the last symbol.
@@ -226,7 +226,7 @@ namespace XCharts
public bool forceShowLast
{
get { return m_ForceShowLast; }
set { if (PropertyUtility.SetStruct(ref m_ForceShowLast, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_ForceShowLast, value)) SetVerticesDirty(); }
}
/// <summary>
/// the gap of symbol and line segment.
@@ -235,7 +235,7 @@ namespace XCharts
public float gap
{
get { return m_Gap; }
set { if (PropertyUtility.SetStruct(ref m_Gap, value)) SetVerticesDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Gap, value)) SetVerticesDirty(); }
}
private List<float> m_AnimationSize = new List<float>() { 0, 5, 10 };
/// <summary>
@@ -249,26 +249,25 @@ namespace XCharts
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public float GetSize(List<float> data)
public float GetSize(List<float> data, float themeSize)
{
if (data == null) return size;
switch (m_SizeType)
{
case SerieSymbolSizeType.Custom:
return size;
return size == 0 ? themeSize : size;
case SerieSymbolSizeType.FromData:
if (dataIndex >= 0 && dataIndex < data.Count)
if (data != null && dataIndex >= 0 && dataIndex < data.Count)
{
return data[dataIndex] * m_DataScale;
}
else
{
return size;
return size == 0 ? themeSize : size;
}
case SerieSymbolSizeType.Callback:
if (sizeCallback != null) return sizeCallback(data);
else return size;
default: return size;
if (data != null && sizeCallback != null) return sizeCallback(data);
else return size == 0 ? themeSize : size;
default: return size == 0 ? themeSize : size;
}
}
@@ -277,26 +276,25 @@ namespace XCharts
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public float GetSelectedSize(List<float> data)
public float GetSelectedSize(List<float> data, float themeSelectedSize)
{
if (data == null) return selectedSize;
switch (m_SizeType)
{
case SerieSymbolSizeType.Custom:
return selectedSize;
return selectedSize == 0 ? themeSelectedSize : selectedSize;
case SerieSymbolSizeType.FromData:
if (dataIndex >= 0 && dataIndex < data.Count)
if (data != null && dataIndex >= 0 && dataIndex < data.Count)
{
return data[dataIndex] * m_SelectedDataScale;
}
else
{
return selectedSize;
return selectedSize == 0 ? themeSelectedSize : selectedSize;
}
case SerieSymbolSizeType.Callback:
if (selectedSizeCallback != null) return selectedSizeCallback(data);
else return selectedSize;
default: return selectedSize;
if (data != null && selectedSizeCallback != null) return selectedSizeCallback(data);
else return selectedSize == 0 ? themeSelectedSize : selectedSize;
default: return selectedSize == 0 ? themeSelectedSize : selectedSize;
}
}

View File

@@ -1,9 +1,9 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System;
using UnityEngine;
@@ -33,7 +33,7 @@ namespace XCharts
public bool enable
{
get { return m_Enable; }
set { if (PropertyUtility.SetStruct(ref m_Enable, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Enable, value)) SetComponentDirty(); }
}
/// <summary>
/// Set the maximum width. A default of 0 indicates automatic fetch; otherwise, custom.
@@ -43,7 +43,7 @@ namespace XCharts
public float maxWidth
{
get { return m_MaxWidth; }
set { if (PropertyUtility.SetStruct(ref m_MaxWidth, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_MaxWidth, value)) SetComponentDirty(); }
}
/// <summary>
/// White pixel distance at both ends.
@@ -53,7 +53,7 @@ namespace XCharts
public float gap
{
get { return m_Gap; }
set { if (PropertyUtility.SetStruct(ref m_Gap, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Gap, value)) SetComponentDirty(); }
}
/// <summary>
/// Suffixes when the length exceeds.
@@ -63,11 +63,10 @@ namespace XCharts
public string suffix
{
get { return m_Suffix; }
set { if (PropertyUtility.SetClass(ref m_Suffix, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetClass(ref m_Suffix, value)) SetComponentDirty(); }
}
private Text m_RelatedText;
private TextGenerationSettings m_RelatedTextSettings;
private ChartText m_RelatedText;
private float m_RelatedTextWidth = 0;
public TextLimit Clone()
@@ -88,10 +87,9 @@ namespace XCharts
suffix = textLimit.suffix;
}
public void SetRelatedText(Text txt, float labelWidth)
public void SetRelatedText(ChartText txt, float labelWidth)
{
m_RelatedText = txt;
m_RelatedTextSettings = txt.GetGenerationSettings(Vector2.zero);
m_RelatedTextWidth = labelWidth;
}
@@ -104,8 +102,8 @@ namespace XCharts
{
if (m_Enable)
{
float len = m_RelatedText.cachedTextGenerator.GetPreferredWidth(content, m_RelatedTextSettings);
float suffixLen = m_RelatedText.cachedTextGenerator.GetPreferredWidth(suffix, m_RelatedTextSettings);
float len = m_RelatedText.GetPreferredWidth(content);
float suffixLen = m_RelatedText.GetPreferredWidth(suffix);
if (len >= checkWidth - m_Gap * 2)
{
return content.Substring(0, GetAdaptLength(content, suffixLen)) + suffix;
@@ -133,7 +131,7 @@ namespace XCharts
float len = 0;
while (len != limit && middle != start)
{
len = m_RelatedText.cachedTextGenerator.GetPreferredWidth(content.Substring(0, middle), m_RelatedTextSettings);
len = m_RelatedText.GetPreferredWidth(content.Substring(0, middle));
if (len < limit)
{
start = middle;

View File

@@ -1,12 +1,15 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System;
using UnityEngine;
#if dUI_TextMeshPro
using TMPro;
#endif
namespace XCharts
{
@@ -18,18 +21,20 @@ namespace XCharts
public class TextStyle : SubComponent
{
[SerializeField] private Font m_Font;
[SerializeField] private float m_Rotate = 0;
[SerializeField] private Vector2 m_Offset = Vector2.zero;
[SerializeField] private Color m_Color = Color.clear;
[SerializeField] private Color m_BackgroundColor = Color.clear;
[SerializeField] private int m_FontSize = 18;
[SerializeField] private int m_FontSize = 0;
[SerializeField] private FontStyle m_FontStyle = FontStyle.Normal;
[SerializeField] private float m_LineSpacing = 1f;
// [SerializeField] private float m_PaddingLeft = 0f;
// [SerializeField] private float m_PaddingRight = 0f;
// [SerializeField] private float m_PaddingTop = 0f;
// [SerializeField] private float m_PaddingBottom = 0f;
[SerializeField] private TextAnchor m_Alignment = TextAnchor.MiddleCenter;
#if dUI_TextMeshPro
[SerializeField] private TMP_FontAsset m_TMPFont;
[SerializeField] private FontStyles m_TMPFontStyle = FontStyles.Normal;
[SerializeField] private TextAlignmentOptions m_TMPAlignment = TextAlignmentOptions.Left;
#endif
/// <summary>
/// Rotation of text.
/// 文本的旋转。
@@ -38,7 +43,7 @@ namespace XCharts
public float rotate
{
get { return m_Rotate; }
set { if (PropertyUtility.SetStruct(ref m_Rotate, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Rotate, value)) SetComponentDirty(); }
}
/// <summary>
/// the offset of position.
@@ -48,7 +53,7 @@ namespace XCharts
public Vector2 offset
{
get { return m_Offset; }
set { if (PropertyUtility.SetStruct(ref m_Offset, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Offset, value)) SetComponentDirty(); }
}
public Vector3 offsetv3 { get { return new Vector3(m_Offset.x, m_Offset.y, 0); } }
@@ -61,7 +66,7 @@ namespace XCharts
public Color color
{
get { return m_Color; }
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetComponentDirty(); }
}
/// <summary>
/// the color of text.
@@ -71,7 +76,7 @@ namespace XCharts
public Color backgroundColor
{
get { return m_BackgroundColor; }
set { if (PropertyUtility.SetColor(ref m_BackgroundColor, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the font of text. When `null`, the theme's font is used by default.
@@ -81,7 +86,7 @@ namespace XCharts
public Font font
{
get { return m_Font; }
set { if (PropertyUtility.SetClass(ref m_Font, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetClass(ref m_Font, value)) SetComponentDirty(); }
}
/// <summary>
/// font size.
@@ -91,7 +96,7 @@ namespace XCharts
public int fontSize
{
get { return m_FontSize; }
set { if (PropertyUtility.SetStruct(ref m_FontSize, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_FontSize, value)) SetComponentDirty(); }
}
/// <summary>
/// font style.
@@ -101,7 +106,7 @@ namespace XCharts
public FontStyle fontStyle
{
get { return m_FontStyle; }
set { if (PropertyUtility.SetStruct(ref m_FontStyle, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_FontStyle, value)) SetComponentDirty(); }
}
/// <summary>
/// text line spacing.
@@ -111,8 +116,34 @@ namespace XCharts
public float lineSpacing
{
get { return m_LineSpacing; }
set { if (PropertyUtility.SetStruct(ref m_LineSpacing, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_LineSpacing, value)) SetComponentDirty(); }
}
/// <summary>
/// 对齐方式。
/// </summary>
public TextAnchor alignment
{
get { return m_Alignment; }
set { if (PropertyUtil.SetStruct(ref m_Alignment, value)) SetComponentDirty(); }
}
#if dUI_TextMeshPro
public TMP_FontAsset tmpFont
{
get { return m_TMPFont; }
set { if (PropertyUtil.SetClass(ref m_TMPFont, value)) SetComponentDirty(); }
}
public FontStyles tmpFontStyle
{
get { return m_TMPFontStyle; }
set { if (PropertyUtil.SetStruct(ref m_TMPFontStyle, value)) SetComponentDirty(); }
}
public TextAlignmentOptions tmpAlignment
{
get { return m_TMPAlignment; }
set { if (PropertyUtil.SetStruct(ref m_TMPAlignment, value)) SetComponentDirty(); }
}
#endif
public TextStyle()
{
@@ -143,5 +174,44 @@ namespace XCharts
this.color = color;
this.rotate = rotate;
}
public void Copy(TextStyle textStyle)
{
font = textStyle.font;
rotate = textStyle.rotate;
offset = textStyle.offset;
color = textStyle.color;
backgroundColor = textStyle.backgroundColor;
fontSize = textStyle.fontSize;
fontStyle = textStyle.fontStyle;
lineSpacing = textStyle.lineSpacing;
alignment = textStyle.alignment;
#if dUI_TextMeshPro
m_TMPFont = textStyle.tmpFont;
m_TMPAlignment = textStyle.tmpAlignment;
m_TMPFontStyle = textStyle.tmpFontStyle;
#endif
}
public void UpdateAlignmentByLocation(Location location)
{
#if dUI_TextMeshPro
m_TMPAlignment = location.runtimeTMPTextAlignment;
#else
m_Alignment = location.runtimeTextAlignment;
#endif
}
public Color GetColor(Color defaultColor)
{
if (ChartHelper.IsClearColor(color)) return defaultColor;
else return color;
}
public int GetFontSize(ComponentTheme defaultTheme)
{
if(fontSize == 0) return defaultTheme.fontSize;
else return fontSize;
}
}
}

View File

@@ -1,10 +1,10 @@
/*
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System;
using UnityEngine;
@@ -22,7 +22,7 @@ namespace XCharts
{
[SerializeField] private bool m_Show;
[FormerlySerializedAs("m_textStyle")]
[SerializeField] private TextStyle m_TextStyle = new TextStyle(18);
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
/// <summary>
/// Whether to show title.
@@ -31,7 +31,7 @@ namespace XCharts
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); }
}
/// <summary>
@@ -41,7 +41,7 @@ namespace XCharts
public TextStyle textStyle
{
get { return m_TextStyle; }
set { if (PropertyUtility.SetClass(ref m_TextStyle, value, true)) SetComponentDirty(); }
set { if (PropertyUtil.SetClass(ref m_TextStyle, value, true)) SetComponentDirty(); }
}
public override bool componentDirty { get { return m_ComponentDirty || textStyle.componentDirty; } }
@@ -52,7 +52,7 @@ namespace XCharts
textStyle.ClearComponentDirty();
}
public Text runtimeText { get; set; }
public ChartText runtimeText { get; set; }
public bool IsInited()
{
@@ -61,26 +61,28 @@ namespace XCharts
public void SetActive(bool active)
{
if (runtimeText)
if (runtimeText != null)
{
ChartHelper.SetActive(runtimeText, active);
runtimeText.SetActive(active);
}
}
public void UpdatePosition(Vector3 pos)
{
if (runtimeText)
if (runtimeText != null)
{
runtimeText.transform.localPosition = pos + new Vector3(m_TextStyle.offset.x, m_TextStyle.offset.y);
runtimeText.SetLocalPosition(pos + new Vector3(m_TextStyle.offset.x, m_TextStyle.offset.y));
}
}
public void SetText(string text)
{
if (runtimeText && !runtimeText.text.Equals(text))
if (runtimeText == null) return;
var oldText = runtimeText.GetText();
if (oldText != null && !oldText.Equals(text))
{
if (!ChartHelper.IsClearColor(textStyle.color)) runtimeText.color = textStyle.color;
runtimeText.text = text;
if (!ChartHelper.IsClearColor(textStyle.color)) runtimeText.SetColor(textStyle.color);
runtimeText.SetText(text);
}
}
}

View File

@@ -1,13 +0,0 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
namespace XCharts
{
public class SubComponent : ChartComponent
{
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cf2fdcbe222404d7b869946ef6fee032
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View 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;
}
}
}
}

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,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();
}
}
}

View File

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

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

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,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;
}
}
}

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

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,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");
}
}
}

View File

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

View 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;
}
}
}

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,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;
}
}
}
}

View File

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

View 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;
}
}
}
}

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,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;
}
}
}

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,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;
}
}
}

View File

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