增加运行时和非运行时参数变更自动刷新图表

This commit is contained in:
monitor1394
2020-03-05 20:25:19 +08:00
parent 11ee36de58
commit 7465bb760d
44 changed files with 1989 additions and 1209 deletions

View File

@@ -17,7 +17,7 @@ namespace XCharts
/// 直角坐标系的坐标轴组件。
/// </summary>
[System.Serializable]
public class Axis : MainComponent, IEquatable<Axis>
public class Axis : MainComponent
{
/// <summary>
/// the type of axis.
@@ -91,92 +91,187 @@ namespace XCharts
/// Set this to false to prevent the axis from showing.
/// 是否显示坐标轴。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetAllDirty(); }
}
/// <summary>
/// the type of axis.
/// 坐标轴类型。
/// </summary>
public AxisType type { get { return m_Type; } set { m_Type = value; } }
public AxisType type
{
get { return m_Type; }
set { if (PropertyUtility.SetStruct(ref m_Type, value)) SetAllDirty(); }
}
/// <summary>
/// the type of axis minmax.
/// 坐标轴刻度最大最小值显示类型。
/// </summary>
public AxisMinMaxType minMaxType { get { return m_MinMaxType; } set { m_MinMaxType = value; } }
public AxisMinMaxType minMaxType
{
get { return m_MinMaxType; }
set { if (PropertyUtility.SetStruct(ref m_MinMaxType, value)) SetAllDirty(); }
}
/// <summary>
/// The minimun value of axis.
/// 设定的坐标轴刻度最小值当minMaxType为Custom时有效。
/// </summary>
public float min { get { return m_Min; } set { m_Min = value; } }
public float min
{
get { return m_Min; }
set { if (PropertyUtility.SetStruct(ref m_Min, value)) SetAllDirty(); }
}
/// <summary>
/// The maximum value of axis.
/// 设定的坐标轴刻度最大值当minMaxType为Custom时有效。
/// </summary>
public float max { get { return m_Max; } set { m_Max = value; } }
public float max
{
get { return m_Max; }
set { if (PropertyUtility.SetStruct(ref m_Max, value)) SetAllDirty(); }
}
/// <summary>
/// Number of segments that the axis is split into.
/// 坐标轴的分割段数。
/// </summary>
public int splitNumber { get { return m_SplitNumber; } set { m_SplitNumber = value; } }
public int splitNumber
{
get { return m_SplitNumber; }
set { if (PropertyUtility.SetStruct(ref m_SplitNumber, value)) SetAllDirty(); }
}
/// <summary>
/// 强制设置坐标轴分割间隔。无法在类目轴中使用。
/// Compulsively set segmentation interval for axis.This is unavailable for category axis.
/// </summary>
public float interval { get { return m_Interval; } set { m_Interval = value; } }
public float interval
{
get { return m_Interval; }
set { if (PropertyUtility.SetStruct(ref m_Interval, value)) SetAllDirty(); }
}
/// <summary>
/// The boundary gap on both sides of a coordinate axis.
/// 坐标轴两边是否留白。
/// </summary>
public bool boundaryGap { get { return m_BoundaryGap; } set { m_BoundaryGap = value; } }
public bool boundaryGap
{
get { return m_BoundaryGap; }
set { if (PropertyUtility.SetStruct(ref m_BoundaryGap, value)) SetAllDirty(); }
}
/// <summary>
/// Base of logarithm, which is valid only for numeric axes with type: 'Log'.
/// 对数轴的底数只在对数轴type:'Log')中有效。
/// </summary>
public float logBase { get { return m_LogBase; } set { m_LogBase = value; } }
public float logBase
{
get { return m_LogBase; }
set { if (PropertyUtility.SetStruct(ref m_LogBase, value)) SetAllDirty(); }
}
/// <summary>
/// 对数轴是否以自然数 e 为底数,为 true 时 logBase 失效。
/// </summary>
public bool logBaseE { get { return m_LogBaseE; } set { m_LogBaseE = value; } }
public bool logBaseE
{
get { return m_LogBaseE; }
set { if (PropertyUtility.SetStruct(ref m_LogBaseE, value)) SetAllDirty(); }
}
/// <summary>
/// The max number of axis data cache.
/// The first data will be remove when the size of axis data is larger then maxCache.
/// 可缓存的最大数据量。默认为0没有限制大于0时超过指定值会移除旧数据再插入新数据。
/// </summary>
public int maxCache { get { return m_MaxCache; } set { m_MaxCache = value < 0 ? 0 : value; } }
public int maxCache
{
get { return m_MaxCache; }
set { if (PropertyUtility.SetStruct(ref m_MaxCache, value < 0 ? 0 : value)) SetAllDirty(); }
}
/// <summary>
/// Category data, available in type: 'Category' axis.
/// 类目数据在类目轴type: 'category')中有效。
/// </summary>
public List<string> data { get { return m_Data; } set { if (value != null) m_Data = value; } }
public List<string> data
{
get { return m_Data; }
set { if (value != null) { m_Data = value; SetAllDirty(); } }
}
/// <summary>
/// axis Line.
/// 坐标轴轴线。
/// </summary>
public AxisLine axisLine { get { return m_AxisLine; } set { m_AxisLine = value; } }
/// /// </summary>
public AxisLine axisLine
{
get { return m_AxisLine; }
set { if (value != null) { m_AxisLine = value; SetVerticesDirty(); } }
}
/// <summary>
/// axis name.
/// 坐标轴名称。
/// </summary>
public AxisName axisName { get { return m_AxisName; } set { m_AxisName = value; } }
public AxisName axisName
{
get { return m_AxisName; }
set { if (value != null) { m_AxisName = value; SetComponentDirty(); } }
}
/// <summary>
/// axis tick.
/// 坐标轴刻度。
/// </summary>
public AxisTick axisTick { get { return m_AxisTick; } set { m_AxisTick = value; } }
public AxisTick axisTick
{
get { return m_AxisTick; }
set { if (value != null) { m_AxisTick = value; SetVerticesDirty(); } }
}
/// <summary>
/// axis label.
/// 坐标轴刻度标签。
/// </summary>
public AxisLabel axisLabel { get { return m_AxisLabel; } set { m_AxisLabel = value; } }
public AxisLabel axisLabel
{
get { return m_AxisLabel; }
set { if (value != null) { m_AxisLabel = value; SetComponentDirty(); } }
}
/// <summary>
/// axis split line.
/// 坐标轴分割线。
/// </summary>
public AxisSplitLine splitLine { get { return m_SplitLine; } set { m_SplitLine = value; } }
public AxisSplitLine splitLine
{
get { return m_SplitLine; }
set { if (value != null) { m_SplitLine = value; SetVerticesDirty(); } }
}
/// <summary>
/// axis split area.
/// 坐标轴分割区域。
/// </summary>
public AxisSplitArea splitArea { get { return m_SplitArea; } set { m_SplitArea = value; } }
public AxisSplitArea splitArea
{
get { return m_SplitArea; }
set { if (value != null) { m_SplitArea = value; SetVerticesDirty(); } }
}
public override bool vertsDirty
{
get { return m_VertsDirty || axisLine.anyDirty || axisTick.anyDirty || splitLine.anyDirty || splitArea.anyDirty; }
}
public override bool componentDirty
{
get { return m_ComponentDirty || axisName.anyDirty || axisLabel.anyDirty; }
}
internal override void ClearComponentDirty()
{
base.ClearComponentDirty();
axisName.ClearComponentDirty();
axisLabel.ClearComponentDirty();
}
internal override void ClearVerticesDirty()
{
base.ClearVerticesDirty();
axisLine.ClearVerticesDirty();
axisTick.ClearVerticesDirty();
splitLine.ClearVerticesDirty();
splitArea.ClearVerticesDirty();
}
/// <summary>
/// the axis label text list.
/// 坐标轴刻度标签的Text列表。
@@ -244,29 +339,13 @@ namespace XCharts
private bool m_RuntimeMinValueFirstChanged = true;
private bool m_RuntimeMaxValueFirstChanged = true;
public void Copy(Axis other)
{
m_Show = other.show;
m_Type = other.type;
m_Min = other.min;
m_Max = other.max;
m_SplitNumber = other.splitNumber;
m_Interval = other.interval;
m_BoundaryGap = other.boundaryGap;
m_AxisName.Copy(other.axisName);
m_AxisLabel.Copy(other.axisLabel);
m_Data.Clear();
m_Data.Capacity = m_Data.Count;
foreach (var d in other.data) m_Data.Add(d);
}
/// <summary>
/// 清空类目数据
/// </summary>
public void ClearData()
{
m_Data.Clear();
SetAllDirty();
}
/// <summary>
@@ -311,6 +390,7 @@ namespace XCharts
}
}
m_Data.Add(category);
SetAllDirty();
}
/// <summary>
@@ -692,7 +772,7 @@ namespace XCharts
{
if (value != m_RuntimeMaxValue)
{
if (check)
if (check && Application.isPlaying)
{
if (m_RuntimeMinValueFirstChanged)
{
@@ -720,7 +800,7 @@ namespace XCharts
{
if (value != m_RuntimeMaxValue)
{
if (check)
if (check && Application.isPlaying)
{
if (m_RuntimeMaxValueFirstChanged)
{
@@ -746,6 +826,7 @@ namespace XCharts
internal float GetCurrMinValue(float duration)
{
if (!Application.isPlaying) return m_RuntimeMinValue;
if (m_RuntimeMinValue == 0 && m_RuntimeMaxValue == 0) return 0;
if (!m_RuntimeMinValueChanged) return m_RuntimeMinValue;
var time = Time.time - m_RuntimeMinValueUpdateTime;
@@ -764,6 +845,7 @@ namespace XCharts
internal float GetCurrMaxValue(float duration)
{
if (!Application.isPlaying) return m_RuntimeMaxValue;
if (m_RuntimeMinValue == 0 && m_RuntimeMaxValue == 0) return 0;
if (!m_RuntimeMaxValueChanged) return m_RuntimeMaxValue;
var time = Time.time - m_RuntimeMaxValueUpdateTime;
@@ -782,6 +864,7 @@ namespace XCharts
public bool IsValueChanging(float duration)
{
if (!Application.isPlaying) return false;
if (GetCurrMinValue(duration) != m_RuntimeMinValue || GetCurrMaxValue(duration) != m_RuntimeMaxValue)
{
return true;
@@ -798,65 +881,6 @@ namespace XCharts
return logBaseE ? Mathf.Log(value) : Mathf.Log(value, logBase);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
else if (obj is Axis)
{
return Equals((Axis)obj);
}
else
{
return false;
}
}
public bool Equals(Axis other)
{
if (ReferenceEquals(null, other))
{
return false;
}
return show == other.show &&
type == other.type &&
min == other.min &&
max == other.max &&
splitNumber == other.splitNumber &&
interval == other.interval &&
m_AxisLabel.Equals(other.axisLabel) &&
boundaryGap == other.boundaryGap &&
runtimeMinValue == other.runtimeMinValue &&
runtimeMaxValue == other.runtimeMaxValue &&
axisName.Equals(other.axisName) &&
ChartHelper.IsValueEqualsList<string>(m_Data, other.data);
}
public static bool operator ==(Axis left, Axis right)
{
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
{
return true;
}
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
{
return false;
}
return Equals(left, right);
}
public static bool operator !=(Axis left, Axis right)
{
return !(left == right);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public override void ParseJsonData(string jsonData)
{
if (string.IsNullOrEmpty(jsonData) || !m_DataFromJson) return;
@@ -872,26 +896,6 @@ namespace XCharts
[System.Serializable]
public class XAxis : Axis
{
public XAxis Clone()
{
var axis = XAxisPool.Get();
axis.show = show;
axis.type = type;
axis.min = min;
axis.max = max;
axis.splitNumber = splitNumber;
axis.interval = interval;
axis.boundaryGap = boundaryGap;
axis.splitLine.Copy(axis.splitLine);
axis.axisName.Copy(axisName);
axis.axisLabel.Copy(axisLabel);
axis.data.Clear();
if (axis.data.Capacity < data.Count) axis.data.Capacity = data.Count;
foreach (var d in data) axis.data.Add(d);
return axis;
}
public static XAxis defaultXAxis
{
get
@@ -925,26 +929,6 @@ namespace XCharts
[System.Serializable]
public class YAxis : Axis
{
public YAxis Clone()
{
var axis = YAxisPool.Get();
axis.show = show;
axis.type = type;
axis.min = min;
axis.max = max;
axis.splitNumber = splitNumber;
axis.interval = interval;
axis.boundaryGap = boundaryGap;
axis.axisName.Copy(axisName);
axis.axisLabel.Copy(axisLabel);
axis.splitLine.Copy(splitLine);
axis.data.Clear();
if (axis.data.Capacity < data.Count) axis.data.Capacity = data.Count;
foreach (var d in data) axis.data.Add(d);
return axis;
}
public static YAxis defaultYAxis
{
get

View File

@@ -90,52 +90,92 @@ namespace XCharts
/// Whether to show dataZoom.
/// 是否显示缩放区域。
/// </summary>
public bool enable { get { return m_Enable; } set { m_Enable = value; } }
public bool enable
{
get { return m_Enable; }
set { if (PropertyUtility.SetStruct(ref m_Enable, value)) SetVerticesDirty(); }
}
/// <summary>
/// The mode of data filter.
/// 数据过滤类型。
/// </summary>
public FilterMode filterMode { get { return m_FilterMode; } set { m_FilterMode = value; } }
public FilterMode filterMode
{
get { return m_FilterMode; }
set { if (PropertyUtility.SetStruct(ref m_FilterMode, value)) SetVerticesDirty(); }
}
/// <summary>
/// Specify which xAxis is controlled by the dataZoom.
/// 控制哪一个 x 轴。
/// </summary>
public int xAxisIndex { get { return m_XAxisIndex; } set { m_XAxisIndex = value; } }
public int xAxisIndex
{
get { return m_XAxisIndex; }
set { if (PropertyUtility.SetStruct(ref m_XAxisIndex, value)) SetVerticesDirty(); }
}
/// <summary>
/// Specify which yAxis is controlled by the dataZoom.
/// 控制哪一个 y 轴。
/// </summary>
public int yAxisIndex { get { return m_YAxisIndex; } set { m_YAxisIndex = value; } }
public int yAxisIndex
{
get { return m_YAxisIndex; }
set { if (PropertyUtility.SetStruct(ref m_YAxisIndex, value)) SetVerticesDirty(); }
}
/// <summary>
/// 是否支持内置。内置于坐标系中,使用户可以在坐标系上通过鼠标拖拽、鼠标滚轮、手指滑动(触屏上)来缩放或漫游坐标系。
/// </summary>
public bool supportInside { get { return m_SupportInside; } set { m_SupportInside = value; } }
public bool supportInside
{
get { return m_SupportInside; }
set { if (PropertyUtility.SetStruct(ref m_SupportInside, value)) SetVerticesDirty(); }
}
/// <summary>
/// 是否支持滑动条。有单独的滑动条,用户在滑动条上进行缩放或漫游。
/// </summary>
public bool supportSlider { get { return m_SupportSlider; } set { m_SupportSlider = value; } }
public bool supportSlider
{
get { return m_SupportSlider; }
set { if (PropertyUtility.SetStruct(ref m_SupportSlider, value)) SetVerticesDirty(); }
}
/// <summary>
/// 是否支持框选。提供一个选框进行数据区域缩放。
/// </summary>
private bool supportSelect { get { return m_SupportSelect; } set { m_SupportSelect = value; } }
private bool supportSelect
{
get { return m_SupportSelect; }
set { if (PropertyUtility.SetStruct(ref m_SupportSelect, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether to show data shadow, to indicate the data tendency in brief.
/// default:true
/// 是否显示数据阴影。数据阴影可以简单地反应数据走势。
/// </summary>
public bool showDataShadow { get { return m_ShowDataShadow; } set { m_ShowDataShadow = value; } }
public bool showDataShadow
{
get { return m_ShowDataShadow; }
set { if (PropertyUtility.SetStruct(ref m_ShowDataShadow, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether to show detail, that is, show the detailed data information when dragging.
/// 是否显示detail即拖拽时候显示详细数值信息。
/// </summary>
public bool showDetail { get { return m_ShowDetail; } set { m_ShowDetail = value; } }
public bool showDetail
{
get { return m_ShowDetail; }
set { if (PropertyUtility.SetStruct(ref m_ShowDetail, value)) SetVerticesDirty(); }
}
/// <summary>
/// Specify whether to lock the size of window (selected area).
/// default:false
/// 是否锁定选择区域(或叫做数据窗口)的大小。
/// 如果设置为 true 则锁定选择区域的大小,也就是说,只能平移,不能缩放。
/// </summary>
public bool zoomLock { get { return m_ZoomLock; } set { m_ZoomLock = value; } }
public bool zoomLock
{
get { return m_ZoomLock; }
set { if (PropertyUtility.SetStruct(ref m_ZoomLock, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether to show data shadow in dataZoom-silder component, to indicate the data tendency in brief.
/// default:true
@@ -146,27 +186,43 @@ namespace XCharts
/// The background color of the component.
/// 组件的背景颜色。
/// </summary>
private Color backgroundColor { get { return m_BackgroundColor; } set { m_BackgroundColor = value; } }
private Color backgroundColor
{
get { return m_BackgroundColor; }
set { if (PropertyUtility.SetStruct(ref m_BackgroundColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// Distance between dataZoom component and the bottom side of the container.
/// bottom value is a instant pixel value like 10.
/// default:10
/// 组件离容器下侧的距离。
/// </summary>
public float bottom { get { return m_Bottom; } set { m_Bottom = value; } }
public float bottom
{
get { return m_Bottom; }
set { if (PropertyUtility.SetStruct(ref m_Bottom, value)) SetVerticesDirty(); }
}
/// <summary>
/// The height of dataZoom component.
/// height value is a instant pixel value like 10.
/// default:50
/// 组件高度。
/// </summary>
public float height { get { return m_Height; } set { m_Height = value; } }
public float height
{
get { return m_Height; }
set { if (PropertyUtility.SetStruct(ref m_Height, value)) SetVerticesDirty(); }
}
/// <summary>
/// Use absolute value or percent value in DataZoom.start and DataZoom.end.
/// default:RangeMode.Percent.
/// 取绝对值还是百分比。
/// </summary>
public RangeMode rangeMode { get { return m_RangeMode; } set { m_RangeMode = value; } }
public RangeMode rangeMode
{
get { return m_RangeMode; }
set { if (PropertyUtility.SetStruct(ref m_RangeMode, value)) SetVerticesDirty(); }
}
/// <summary>
/// The start percentage of the window out of the data extent, in the range of 0 ~ 100.
/// default:30
@@ -175,7 +231,7 @@ namespace XCharts
public float start
{
get { return m_Start; }
set { m_Start = value; if (m_Start < 0) m_Start = 0; if (m_Start > 100) m_Start = 100; }
set { m_Start = value; if (m_Start < 0) m_Start = 0; if (m_Start > 100) m_Start = 100; SetVerticesDirty(); }
}
/// <summary>
/// The end percentage of the window out of the data extent, in the range of 0 ~ 100.
@@ -185,29 +241,45 @@ namespace XCharts
public float end
{
get { return m_End; }
set { m_End = value; if (m_End < 0) m_End = 0; if (m_End > 100) m_End = 100; }
set { m_End = value; if (m_End < 0) m_End = 0; if (m_End > 100) m_End = 100; SetVerticesDirty(); }
}
/// <summary>
/// 最小显示数据个数。当DataZoom放大到最大时最小显示的数据个数。
/// </summary>
public int minShowNum { get { return m_MinShowNum; } set { m_MinShowNum = value; } }
public int minShowNum
{
get { return m_MinShowNum; }
set { if (PropertyUtility.SetStruct(ref m_MinShowNum, value)) SetVerticesDirty(); }
}
/// <summary>
/// The sensitivity of dataZoom scroll.
/// The larger the number, the more sensitive it is.
/// default:10
/// 缩放区域组件的敏感度。值越高每次缩放所代表的数据越多。
/// </summary>
public float scrollSensitivity { get { return m_ScrollSensitivity; } set { m_ScrollSensitivity = value; } }
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 { m_FontSize = value; } }
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 { m_FontStyle = value; } }
public FontStyle fontStyle
{
get { return m_FontStyle; }
set { if (PropertyUtility.SetStruct(ref m_FontStyle, value)) SetComponentDirty(); }
}
/// <summary>
/// The start label.

View File

@@ -5,10 +5,8 @@
/* */
/******************************************/
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace XCharts
{
@@ -17,7 +15,7 @@ namespace XCharts
/// 图例组件展现了不同系列的标记,颜色和名字。可以通过点击图例控制哪些系列不显示。
/// </summary>
[System.Serializable]
public class Legend : MainComponent, IPropertyChanged, IEquatable<Legend>
public class Legend : MainComponent, IPropertyChanged
{
/// <summary>
/// Selected mode of legend, which controls whether series can be toggled displaying by clicking legends.
@@ -58,53 +56,93 @@ namespace XCharts
/// Whether to show legend component.
/// 是否显示图例组件。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); }
}
/// <summary>
/// Selected mode of legend, which controls whether series can be toggled displaying by clicking legends.
/// 选择模式。控制是否可以通过点击图例改变系列的显示状态。默认开启图例选择,可以设成 None 关闭。
/// </summary>
/// <value></value>
public SelectedMode selectedMode { get { return m_SelectedMode; } set { m_SelectedMode = value; } }
public SelectedMode selectedMode
{
get { return m_SelectedMode; }
set { if (PropertyUtility.SetStruct(ref m_SelectedMode, value)) SetComponentDirty(); }
}
/// <summary>
/// Specify whether the layout of legend component is horizontal or vertical.
/// 布局方式是横还是竖。
/// </summary>
public Orient orient { get { return m_Orient; } set { m_Orient = value; } }
public Orient orient
{
get { return m_Orient; }
set { if (PropertyUtility.SetStruct(ref m_Orient, value)) SetComponentDirty(); }
}
/// <summary>
/// The location of legend.
/// 图例显示的位置。
/// </summary>
public Location location { get { return m_Location; } set { m_Location = value; } }
public Location location
{
get { return m_Location; }
set { if (PropertyUtility.SetClass(ref m_Location, value)) SetComponentDirty(); }
}
/// <summary>
/// Image width of legend symbol.
/// 图例标记的图形宽度。
/// </summary>
public float itemWidth { get { return m_ItemWidth; } set { m_ItemWidth = value; } }
public float itemWidth
{
get { return m_ItemWidth; }
set { if (PropertyUtility.SetStruct(ref m_ItemWidth, value)) SetComponentDirty(); }
}
/// <summary>
/// Image height of legend symbol.
/// 图例标记的图形高度。
/// </summary>
public float itemHeight { get { return m_ItemHeight; } set { m_ItemHeight = value; } }
public float itemHeight
{
get { return m_ItemHeight; }
set { if (PropertyUtility.SetStruct(ref m_ItemHeight, value)) SetComponentDirty(); }
}
/// <summary>
/// The distance between each legend, horizontal distance in horizontal layout, and vertical distance in vertical layout.
/// 图例每项之间的间隔。横向布局时为水平间隔,纵向布局时为纵向间隔。
/// </summary>
public float itemGap { get { return m_ItemGap; } set { m_ItemGap = value; } }
public float itemGap
{
get { return m_ItemGap; }
set { if (PropertyUtility.SetStruct(ref m_ItemGap, value)) SetComponentDirty(); }
}
/// <summary>
/// Whether the legend symbol matches the color automatically.
/// 图例标记的图形是否自动匹配颜色。
/// </summary>
public bool itemAutoColor { get { return m_ItemAutoColor; } set { m_ItemAutoColor = value; } }
public bool itemAutoColor
{
get { return m_ItemAutoColor; }
set { if (PropertyUtility.SetStruct(ref m_ItemAutoColor, value)) SetComponentDirty(); }
}
/// <summary>
/// 图例内容字符串模版格式器。支持用 \n 换行。
/// 模板变量为图例名称 {name}
/// </summary>
public string formatter { get { return m_Formatter; } set { m_Formatter = value; } }
public string formatter
{
get { return m_Formatter; }
set { if (PropertyUtility.SetClass(ref m_Formatter, value)) SetComponentDirty(); }
}
/// <summary>
/// the style of text.
/// 文本样式。
/// </summary>
public TextStyle textStyle { get { return m_TextStyle; } set { m_TextStyle = value; } }
public TextStyle textStyle
{
get { return m_TextStyle; }
set { if (PropertyUtility.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,
/// it could also be the name of a single data in the pie chart) of a series.
@@ -112,11 +150,38 @@ namespace XCharts
/// 图例的数据数组。数组项通常为一个字符串,每一项代表一个系列的 name如果是饼图也可以是饼图单个数据的 name
/// 如果 data 没有被指定会自动从当前系列中获取。指定data时里面的数据项和serie匹配时才会生效。
/// </summary>
public List<string> data { get { return m_Data; } }
public List<string> data
{
get { return m_Data; }
set { if (value != null) { m_Data = value; SetComponentDirty(); } }
}
/// <summary>
/// 自定义的图例标记图形。
/// </summary>
public List<Sprite> icons { get { return m_Icons; } }
public List<Sprite> icons
{
get { return m_Icons; }
set { if (value != null) { m_Icons = value; SetComponentDirty(); } }
}
/// <summary>
/// 图表是否需要刷新(图例组件不需要刷新图表)
/// </summary>
public override bool vertsDirty { get { return false; } }
/// <summary>
/// 组件是否需要刷新
/// </summary>
public override bool componentDirty
{
get { return m_ComponentDirty || location.componentDirty || textStyle.componentDirty; }
}
internal override void ClearComponentDirty()
{
base.ClearComponentDirty();
location.ClearComponentDirty();
textStyle.ClearComponentDirty();
}
/// <summary>
/// the button list of legend.
/// 图例按钮列表。
@@ -179,78 +244,6 @@ namespace XCharts
return legend;
}
}
public void Copy(Legend legend)
{
m_Show = legend.show;
m_SelectedMode = legend.selectedMode;
m_Orient = legend.orient;
m_Location.Copy(legend.location);
m_ItemWidth = legend.itemWidth;
m_ItemHeight = legend.itemHeight;
m_ItemGap = legend.itemGap;
itemAutoColor = legend.itemAutoColor;
m_TextStyle.Copy(legend.textStyle);
ChartHelper.CopyList<string>(m_Data, legend.data);
ChartHelper.CopyList<Sprite>(m_Icons, legend.icons);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
else if (obj is Legend)
{
return Equals((Legend)obj);
}
else
{
return false;
}
}
public bool Equals(Legend other)
{
if (ReferenceEquals(null, other))
{
return false;
}
return show == other.show &&
selectedMode == other.selectedMode &&
orient == other.orient &&
location == other.location &&
itemWidth == other.itemWidth &&
itemHeight == other.itemHeight &&
itemGap == other.itemGap &&
itemAutoColor == other.itemAutoColor &&
textStyle.Equals(other.textStyle) &&
ChartHelper.IsValueEqualsList<string>(m_Data, other.data) &&
ChartHelper.IsValueEqualsList<Sprite>(m_Icons, other.icons);
}
public static bool operator ==(Legend left, Legend right)
{
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
{
return true;
}
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
{
return false;
}
return Equals(left, right);
}
public static bool operator !=(Legend left, Legend right)
{
return !(left == right);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
/// <summary>
/// 清空
@@ -258,6 +251,7 @@ namespace XCharts
public void ClearData()
{
m_Data.Clear();
SetComponentDirty();
}
/// <summary>
@@ -279,6 +273,7 @@ namespace XCharts
if (m_Data.Contains(name))
{
m_Data.Remove(name);
SetComponentDirty();
}
}
@@ -291,6 +286,7 @@ namespace XCharts
if (!m_Data.Contains(name) && !string.IsNullOrEmpty(name))
{
m_Data.Add(name);
SetComponentDirty();
}
}
@@ -379,7 +375,7 @@ namespace XCharts
{
m_Location.OnChanged();
}
/// <summary>
/// 从json字符串解析数据json格式如['邮件营销','联盟广告','视频广告','直接访问','搜索引擎']
/// </summary>
@@ -388,6 +384,7 @@ namespace XCharts
{
if (string.IsNullOrEmpty(jsonData) || !m_DataFromJson) return;
m_Data = ChartHelper.ParseStringFromString(jsonData);
SetComponentDirty();
}
public string GetFormatterContent(string category)

View File

@@ -18,7 +18,7 @@ namespace XCharts
/// 雷达图坐标系组件,只适用于雷达图。
/// </summary>
[System.Serializable]
public class Radar : MainComponent, IEquatable<Radar>
public class Radar : MainComponent
{
/// <summary>
/// Radar render type, in which 'Polygon' and 'Circle' are supported.
@@ -48,7 +48,7 @@ namespace XCharts
/// 雷达图的指示器,用来指定雷达图中的多个变量(维度)。
/// </summary>
[System.Serializable]
public class Indicator : IEquatable<Indicator>
public class Indicator
{
[SerializeField] private string m_Name;
[SerializeField] private float m_Max;
@@ -79,48 +79,6 @@ namespace XCharts
/// 指示器的文本组件。
/// </summary>
public Text text { get; set; }
public Indicator Clone()
{
return new Indicator()
{
m_Name = name,
m_Max = max,
m_Min = min,
m_TextStyle = textStyle.Clone()
};
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
else if (obj is Indicator)
{
return Equals((Indicator)obj);
}
else
{
return false;
}
}
public bool Equals(Indicator other)
{
if (ReferenceEquals(null, other))
{
return false;
}
return m_Name.Equals(other.name) &&
m_TextStyle.Equals(other.textStyle);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
[SerializeField] private Shape m_Shape;
[SerializeField] private float m_Radius = 100;
@@ -137,46 +95,82 @@ namespace XCharts
/// 雷达图绘制类型,支持 'Polygon' 和 'Circle'。
/// </summary>
/// <value></value>
public Shape shape { get { return m_Shape; } set { m_Shape = value; } }
public Shape shape
{
get { return m_Shape; }
set { if (PropertyUtility.SetStruct(ref m_Shape, value)) SetAllDirty(); }
}
/// <summary>
/// the radius of radar.
/// 雷达图的半径。
/// </summary>
public float radius { get { return m_Radius; } set { m_Radius = value; } }
public float radius
{
get { return m_Radius; }
set { if (PropertyUtility.SetStruct(ref m_Radius, value)) SetAllDirty(); }
}
/// <summary>
/// Segments of indicator axis.
/// 指示器轴的分割段数。
/// </summary>
public int splitNumber { get { return m_SplitNumber; } set { m_SplitNumber = value; } }
public int splitNumber
{
get { return m_SplitNumber; }
set { if (PropertyUtility.SetStruct(ref m_SplitNumber, value)) SetAllDirty(); }
}
/// <summary>
/// the center of radar chart.
/// 雷达图的中心点。数组的第一项是横坐标,第二项是纵坐标。
/// 当值为0-1之间时表示百分比设置成百分比时第一项是相对于容器宽度第二项是相对于容器高度。
/// </summary>
public float[] center { get { return m_Center; } set { m_Center = value; } }
public float[] center
{
get { return m_Center; }
set { if (value != null) { m_Center = value; SetAllDirty(); } }
}
/// <summary>
/// split line.
/// 分割线。
/// </summary>
public AxisSplitLine splitLine { get { return m_SplitLine; } set { m_SplitLine = value; } }
public AxisSplitLine splitLine
{
get { return m_SplitLine; }
set { if (PropertyUtility.SetClass(ref m_SplitLine, value, true)) SetAllDirty(); }
}
/// <summary>
/// Split area of axis in grid area.
/// 分割区域。
/// </summary>
public AxisSplitArea splitArea { get { return m_SplitArea; } set { m_SplitArea = value; } }
public AxisSplitArea splitArea
{
get { return m_SplitArea; }
set { if (PropertyUtility.SetClass(ref m_SplitArea, value, true)) SetAllDirty(); }
}
/// <summary>
/// Whether to show indicator.
/// 是否显示指示器。
/// </summary>
public bool indicator { get { return m_Indicator; } set { m_Indicator = value; } }
public bool indicator
{
get { return m_Indicator; }
set { if (PropertyUtility.SetStruct(ref m_Indicator, value)) SetComponentDirty(); }
}
/// <summary>
/// 指示器和雷达的间距。
/// </summary>
public float indicatorGap { get { return m_IndicatorGap; } set { m_IndicatorGap = value; } }
public float indicatorGap
{
get { return m_IndicatorGap; }
set { if (PropertyUtility.SetStruct(ref m_IndicatorGap, value)) SetComponentDirty(); }
}
/// <summary>
/// 显示位置类型。
/// /// 显示位置类型。
/// </summary>
public PositionType positionType { get { return m_PositionType; } set { m_PositionType = value; } }
public PositionType positionType
{
get { return m_PositionType; }
set { if (PropertyUtility.SetStruct(ref m_PositionType, value)) SetAllDirty(); }
}
/// <summary>
/// the indicator list.
/// 指示器列表。
@@ -227,69 +221,6 @@ namespace XCharts
}
}
public void Copy(Radar other)
{
m_Shape = other.shape;
m_Radius = other.radius;
m_SplitNumber = other.splitNumber;
m_Center[0] = other.center[0];
m_Center[1] = other.center[1];
m_Indicator = other.indicator;
//m_SplitLine.Copy(other.splitLine);
//m_SplitArea.Copy(other.splitArea);
indicatorList.Clear();
foreach (var d in other.indicatorList) indicatorList.Add(d.Clone());
}
public Radar Clone()
{
var radar = new Radar();
radar.shape = shape;
radar.positionType = positionType;
radar.radius = radius;
radar.splitNumber = splitNumber;
radar.center[0] = center[0];
radar.center[1] = center[1];
radar.indicatorList.Clear();
radar.indicator = indicator;
radar.indicatorGap = indicatorGap;
foreach (var d in indicatorList) radar.indicatorList.Add(d.Clone());
return radar;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
else if (obj is Radar)
{
return Equals((Radar)obj);
}
else
{
return false;
}
}
public bool Equals(Radar other)
{
if (ReferenceEquals(null, other))
{
return false;
}
return radius == other.radius &&
shape == other.shape &&
positionType == other.positionType &&
splitNumber == other.splitNumber &&
center[0] == other.center[0] &&
center[1] == other.center[1] &&
indicator == other.indicator &&
indicatorGap == other.indicatorGap &&
IsEqualsIndicatorList(indicatorList, other.indicatorList);
}
private bool IsEqualsIndicatorList(List<Indicator> indicators1, List<Indicator> indicators2)
{
if (indicators1.Count != indicators2.Count) return false;
@@ -302,29 +233,6 @@ namespace XCharts
return true;
}
public static bool operator ==(Radar left, Radar right)
{
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
{
return true;
}
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
{
return false;
}
return Equals(left, right);
}
public static bool operator !=(Radar left, Radar right)
{
return !(left == right);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public override void ParseJsonData(string jsonData)
{
if (string.IsNullOrEmpty(jsonData) || !m_DataFromJson) return;
@@ -428,6 +336,7 @@ namespace XCharts
indicator.min = min;
indicator.max = max;
indicatorList.Add(indicator);
SetAllDirty();
return indicator;
}
@@ -438,6 +347,7 @@ namespace XCharts
indicator.name = name;
indicator.min = min;
indicator.max = max;
SetAllDirty();
return true;
}

View File

@@ -7,7 +7,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using UnityEngine;
namespace XCharts
@@ -258,22 +257,35 @@ namespace XCharts
[NonSerialized] private Dictionary<int, List<Vector3>> m_DownSmoothPoints = new Dictionary<int, List<Vector3>>();
[NonSerialized] private List<Vector3> m_DataPoints = new List<Vector3>();
[NonSerialized] private bool m_NeedUpdateFilterData;
[NonSerialized] private bool m_NameDirty;
/// <summary>
/// Whether to show serie in chart.
/// 系列是否显示在图表上。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) { SetVerticesDirty(); SetNameDirty(); } }
}
/// <summary>
/// the chart type of serie.
/// 系列的图表类型。
/// </summary>
public SerieType type { get { return m_Type; } set { m_Type = value; } }
public SerieType type
{
get { return m_Type; }
set { if (PropertyUtility.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
}
/// <summary>
/// Series name used for displaying in tooltip and filtering with legend.
/// 系列名称,用于 tooltip 的显示legend 的图例筛选。
/// </summary>
public string name { get { return m_Name; } set { m_Name = value; } }
public string name
{
get { return m_Name; }
set { if (PropertyUtility.SetClass(ref m_Name, value)) { SetVerticesDirty(); SetNameDirty(); } }
}
/// <summary>
/// 图例名称。当系列名称不为空时图例名称即为系列名称反之则为索引index。
/// </summary>
@@ -282,17 +294,29 @@ namespace XCharts
/// If stack the value. On the same category axis, the series with the same stack name would be put on top of each other.
/// 数据堆叠同个类目轴上系列配置相同的stack值后后一个系列的值会在前一个系列的值上相加。
/// </summary>
public string stack { get { return m_Stack; } set { m_Stack = value; } }
public string stack
{
get { return m_Stack; }
set { if (PropertyUtility.SetClass(ref m_Stack, value)) SetVerticesDirty(); }
}
/// <summary>
/// Index of axis to combine with, which is useful for multiple x axes in one chart.
/// 使用的坐标轴轴的 index在单个图表实例中存在多个坐标轴轴的时候有用。
/// </summary>
public int axisIndex { get { return m_AxisIndex; } set { m_AxisIndex = value; } }
public int axisIndex
{
get { return m_AxisIndex; }
set { if (PropertyUtility.SetStruct(ref m_AxisIndex, value)) SetVerticesDirty(); }
}
/// <summary>
/// Index of radar component that radar chart uses.
/// 雷达图所使用的 radar 组件的 index。
/// </summary>
public int radarIndex { get { return m_RadarIndex; } set { m_RadarIndex = value; } }
public int radarIndex
{
get { return m_RadarIndex; }
set { if (PropertyUtility.SetStruct(ref m_RadarIndex, value)) SetVerticesDirty(); }
}
/// <summary>
/// The min number of data to show in chart.
/// 系列所显示数据的最小索引
@@ -300,7 +324,7 @@ namespace XCharts
public int minShow
{
get { return m_MinShow; }
set { m_MinShow = value; if (m_MinShow < 0) m_MinShow = 0; }
set { if (PropertyUtility.SetStruct(ref m_MinShow, value < 0 ? 0 : value)) { SetVerticesDirty(); } }
}
/// <summary>
/// The max number of data to show in chart.
@@ -309,7 +333,7 @@ namespace XCharts
public int maxShow
{
get { return m_MaxShow; }
set { m_MaxShow = value; if (m_MaxShow < 0) m_MaxShow = 0; }
set { if (PropertyUtility.SetStruct(ref m_MaxShow, value < 0 ? 0 : value)) { SetVerticesDirty(); } }
}
/// <summary>
/// The max number of serie data cache.
@@ -320,55 +344,95 @@ namespace XCharts
public int maxCache
{
get { return m_MaxCache; }
set { m_MaxCache = value; if (m_MaxCache < 0) m_MaxCache = 0; }
set { if (PropertyUtility.SetStruct(ref m_MaxCache, value < 0 ? 0 : value)) { SetVerticesDirty(); } }
}
/// <summary>
/// The style of area.
/// 区域填充样式。
/// </summary>
public AreaStyle areaStyle { get { return m_AreaStyle; } set { m_AreaStyle = value; } }
public AreaStyle areaStyle
{
get { return m_AreaStyle; }
set { if (PropertyUtility.SetClass(ref m_AreaStyle, value, true)) SetVerticesDirty(); }
}
/// <summary>
/// the symbol of serie data item.
/// 标记的图形。
/// </summary>
public SerieSymbol symbol { get { return m_Symbol; } set { m_Symbol = value; } }
public SerieSymbol symbol
{
get { return m_Symbol; }
set { if (PropertyUtility.SetClass(ref m_Symbol, value, true)) SetVerticesDirty(); }
}
/// <summary>
/// The type of line chart.
/// 折线图样式类型。
/// </summary>
public LineType lineType { get { return m_LineType; } set { m_LineType = value; } }
public LineType lineType
{
get { return m_LineType; }
set { if (PropertyUtility.SetStruct(ref m_LineType, value)) SetVerticesDirty(); }
}
/// <summary>
/// the min pixel dist of sample.
/// 采样的最小像素距离默认为0时不采样。当两个数据点间的水平距离小于改值时开启采样保证两点间的水平距离不小于改值。
/// </summary>
public float sampleDist { get { return m_SampleDist; } set { m_SampleDist = value < 0 ? 0 : value; } }
public float sampleDist
{
get { return m_SampleDist; }
set { if (PropertyUtility.SetStruct(ref m_SampleDist, value < 0 ? 0 : value)) SetVerticesDirty(); }
}
/// <summary>
/// the type of sample.
/// 采样类型。当sampleDist大于0时有效。
/// </summary>
public SampleType sampleType { get { return m_SampleType; } set { m_SampleType = value; } }
public SampleType sampleType
{
get { return m_SampleType; }
set { if (PropertyUtility.SetStruct(ref m_SampleType, value)) SetVerticesDirty(); }
}
/// <summary>
/// 设定的采样平均值。当sampleType 为 Peak 时用于和过滤数据的平均值做对比是取最大值还是最小值。默认为0时会实时计算所有数据的平均值。
/// </summary>
public float sampleAverage { get { return m_SampleAverage; } set { m_SampleAverage = value; } }
public float sampleAverage
{
get { return m_SampleAverage; }
set { if (PropertyUtility.SetStruct(ref m_SampleAverage, value)) SetVerticesDirty(); }
}
/// <summary>
/// The style of line.
/// 线条样式。
/// </summary>
public LineStyle lineStyle { get { return m_LineStyle; } set { m_LineStyle = value; } }
public LineStyle lineStyle
{
get { return m_LineStyle; }
set { if (PropertyUtility.SetClass(ref m_LineStyle, value, true)) SetVerticesDirty(); }
}
/// <summary>
/// 柱形图类型。
/// </summary>
public BarType barType { get { return m_BarType; } set { m_BarType = value; } }
public BarType barType
{
get { return m_BarType; }
set { if (PropertyUtility.SetStruct(ref m_BarType, value)) SetVerticesDirty(); }
}
/// <summary>
/// 柱形图是否为百分比堆积。相同stack的serie只要有一个barPercentStack为true则就显示成百分比堆叠柱状图。
/// </summary>
public bool barPercentStack { get { return m_BarPercentStack; } set { m_BarPercentStack = value; } }
public bool barPercentStack
{
get { return m_BarPercentStack; }
set { if (PropertyUtility.SetStruct(ref m_BarPercentStack, value)) SetVerticesDirty(); }
}
/// <summary>
/// The width of the bar. Adaptive when default 0.
/// 柱条的宽度,不设时自适应。支持设置成相对于类目宽度的百分比。
/// </summary>
public float barWidth { get { return m_BarWidth; } set { m_BarWidth = value; } }
public float barWidth
{
get { return m_BarWidth; }
set { if (PropertyUtility.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.
/// <para>Set barGap as '-1' can overlap bars that belong to different series, which is useful when making a series of bar be background.
@@ -379,8 +443,11 @@ namespace XCharts
/// 如果想要两个系列的柱子重叠,可以设置 barGap 为 '-1f'。这在用柱子做背景的时候有用。
/// 在同一坐标系上,此属性会被多个 'bar' 系列共享。此属性应设置于此坐标系中最后一个 'bar' 系列上才会生效,并且是对此坐标系中所有 'bar' 系列生效。
/// </summary>
/// <value></value>
public float barGap { get { return m_BarGap; } set { m_BarGap = value; } }
public float barGap
{
get { return m_BarGap; }
set { if (PropertyUtility.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.
/// In a single coodinate system, this attribute is shared by multiple 'bar' series.
@@ -389,113 +456,217 @@ namespace XCharts
/// 同一系列的柱间距离默认为类目间距的20%,可设固定值。
/// 在同一坐标系上,此属性会被多个 'bar' 系列共享。此属性应设置于此坐标系中最后一个 'bar' 系列上才会生效,并且是对此坐标系中所有 'bar' 系列生效。
/// </summary>
public float barCategoryGap { get { return m_BarCategoryGap; } set { m_BarCategoryGap = value; } }
public float barCategoryGap
{
get { return m_BarCategoryGap; }
set { if (PropertyUtility.SetStruct(ref m_BarCategoryGap, value)) SetVerticesDirty(); }
}
/// <summary>
/// 斑马线的粗细。
/// </summary>
public float barZebraWidth { get { return m_BarZebraWidth; } set { m_BarZebraWidth = value > 0 ? value : 0; } }
public float barZebraWidth
{
get { return m_BarZebraWidth; }
set { if (PropertyUtility.SetStruct(ref m_BarZebraWidth, value < 0 ? 0 : value)) SetVerticesDirty(); }
}
/// <summary>
/// 斑马线的间距。
/// </summary>
public float barZebraGap { get { return m_BarZebraGap; } set { m_BarZebraGap = value > 0 ? value : 0; } }
public float barZebraGap
{
get { return m_BarZebraGap; }
set { if (PropertyUtility.SetStruct(ref m_BarZebraGap, value < 0 ? 0 : value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether offset when mouse click pie chart item.
/// 鼠标点击时是否开启偏移一般用在PieChart图表中。
/// </summary>
public bool pieClickOffset { get { return m_ClickOffset; } set { m_ClickOffset = value; } }
public bool pieClickOffset
{
get { return m_ClickOffset; }
set { if (PropertyUtility.SetStruct(ref m_ClickOffset, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether to show as Nightingale chart.
/// 是否展示成南丁格尔图,通过半径区分数据大小。
/// </summary>
public RoseType pieRoseType { get { return m_RoseType; } set { m_RoseType = value; } }
public RoseType pieRoseType
{
get { return m_RoseType; }
set { if (PropertyUtility.SetStruct(ref m_RoseType, value)) SetVerticesDirty(); }
}
/// <summary>
/// the space of pie chart item.
/// 饼图项间的空隙留白。
/// </summary>
public float pieSpace { get { return m_Space; } set { m_Space = value; } }
public float pieSpace
{
get { return m_Space; }
set { if (PropertyUtility.SetStruct(ref m_Space, value)) SetVerticesDirty(); }
}
/// <summary>
/// the center of chart.
/// 中心点。
/// </summary>
public float[] center { get { return m_Center; } set { m_Center = value; } }
public float[] center
{
get { return m_Center; }
set { if (value != null && value.Length == 2) { m_Center = value; SetVerticesDirty(); } }
}
/// <summary>
/// the radius of chart.
/// 半径。radius[0]表示内径radius[1]表示外径。
/// </summary>
public float[] radius { get { return m_Radius; } set { m_Radius = value; } }
public float[] radius
{
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; } }
public float[] pieCenter
{
get { return center; }
set { center = value; }
}
[Obsolete("Use Serie.radius instead.", true)]
public float[] pieRadius { get { return radius; } set { radius = value; } }
public float[] pieRadius
{
get { return radius; }
set { radius = value; }
}
/// <summary>
/// 最小值,映射到 startAngle。
/// </summary>
public float min { get { return m_Min; } set { m_Min = value; } }
public float min
{
get { return m_Min; }
set { if (PropertyUtility.SetStruct(ref m_Min, value)) SetVerticesDirty(); }
}
/// <summary>
/// 最大值,映射到 endAngle。
/// </summary>
public float max { get { return m_Max; } set { m_Max = value; } }
public float max
{
get { return m_Max; }
set { if (PropertyUtility.SetStruct(ref m_Max, value)) SetVerticesDirty(); }
}
/// <summary>
/// 起始角度。和时钟一样12点钟位置是0度顺时针到360度。
/// </summary>
public float startAngle { get { return m_StartAngle; } set { m_StartAngle = value; } }
public float startAngle
{
get { return m_StartAngle; }
set { if (PropertyUtility.SetStruct(ref m_StartAngle, value)) SetVerticesDirty(); }
}
/// <summary>
/// 结束角度。和时钟一样12点钟位置是0度顺时针到360度。
/// </summary>
public float endAngle { get { return m_EndAngle; } set { m_EndAngle = value; } }
public float endAngle
{
get { return m_EndAngle; }
set { if (PropertyUtility.SetStruct(ref m_EndAngle, value)) SetVerticesDirty(); }
}
/// <summary>
/// 是否顺时针。
/// </summary>
public bool clockwise { get { return m_Clockwise; } set { m_Clockwise = value; } }
public bool clockwise
{
get { return m_Clockwise; }
set { if (PropertyUtility.SetStruct(ref m_Clockwise, value)) SetVerticesDirty(); }
}
/// <summary>
/// 刻度分割段数。
/// 刻度分割段数。最大可设置36。
/// </summary>
public int splitNumber { get { return m_SplitNumber; } set { m_SplitNumber = value > 36 ? 36 : value; } }
public int splitNumber
{
get { return m_SplitNumber; }
set { if (PropertyUtility.SetStruct(ref m_SplitNumber, value > 36 ? 36 : value)) SetVerticesDirty(); }
}
/// <summary>
/// 是否开启圆弧形边角。
/// </summary>
public bool arcShaped { get { return m_ArcShaped; } set { m_ArcShaped = value; } }
public bool arcShaped
{
get { return m_ArcShaped; }
set { if (PropertyUtility.SetStruct(ref m_ArcShaped, value)) SetVerticesDirty(); }
}
/// <summary>
/// 仪表盘轴线。
/// </summary>
public GaugeAxis gaugeAxis { get { return m_GaugeAxis; } set { m_GaugeAxis = value; } }
public GaugeAxis gaugeAxis
{
get { return m_GaugeAxis; }
set { if (PropertyUtility.SetClass(ref m_GaugeAxis, value, true)) SetVerticesDirty(); }
}
/// <summary>
/// 仪表盘指针。
/// </summary>
public GaugePointer gaugePointer { get { return m_GaugePointer; } set { m_GaugePointer = value; } }
public GaugePointer gaugePointer
{
get { return m_GaugePointer; }
set { if (PropertyUtility.SetClass(ref m_GaugePointer, value, true)) SetVerticesDirty(); }
}
/// <summary>
/// 仪表盘类型。
/// </summary>
public GaugeType gaugeType { get { return m_GaugeType; } set { m_GaugeType = value; } }
public GaugeType gaugeType
{
get { return m_GaugeType; }
set { if (PropertyUtility.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.
/// 图形上的文本标签,可用于说明图形的一些数据信息,比如值,名称等。
/// </summary>
public SerieLabel label { get { return m_Label; } set { m_Label = value; } }
public SerieLabel label
{
get { return m_Label; }
set { if (PropertyUtility.SetClass(ref m_Label, value, true)) SetAllDirty(); }
}
/// <summary>
/// The start animation.
/// 起始动画。
/// </summary>
public SerieAnimation animation { get { return m_Animation; } set { m_Animation = value; } }
public SerieAnimation animation
{
get { return m_Animation; }
set { if (PropertyUtility.SetClass(ref m_Animation, value, true)) SetVerticesDirty(); }
}
/// <summary>
/// The arrow of line.
/// 折线图的箭头。
/// </summary>
public LineArrow lineArrow { get { return m_LineArrow; } set { m_LineArrow = value; } }
public LineArrow lineArrow
{
get { return m_LineArrow; }
set { if (PropertyUtility.SetClass(ref m_LineArrow, value, true)) SetVerticesDirty(); }
}
/// <summary>
/// The style of data item.
/// 图形样式。
/// </summary>
public ItemStyle itemStyle { get { return m_ItemStyle; } set { m_ItemStyle = value; } }
public ItemStyle itemStyle
{
get { return m_ItemStyle; }
set { if (PropertyUtility.SetClass(ref m_ItemStyle, value, true)) SetVerticesDirty(); }
}
/// <summary>
/// 高亮的图形样式和文本标签样式。
/// </summary>
public Emphasis emphasis { get { return m_Emphasis; } set { m_Emphasis = value; } }
public Emphasis emphasis
{
get { return m_Emphasis; }
set { if (PropertyUtility.SetClass(ref m_Emphasis, value, true)) SetVerticesDirty(); }
}
/// <summary>
/// 标题样式。
/// </summary>
public TitleStyle titleStyle { get { return m_TitleStyle; } set { m_TitleStyle = value; } }
public TitleStyle titleStyle
{
get { return m_TitleStyle; }
set { if (PropertyUtility.SetClass(ref m_TitleStyle, value, true)) SetAllDirty(); }
}
/// <summary>
/// 数据项里的数据维数。
/// </summary>
@@ -508,12 +679,63 @@ namespace XCharts
/// If clip the overflow on the coordinate system.
/// 是否裁剪超出坐标系部分的图形。
/// </summary>
public bool clip { get { return m_Clip; } set { m_Clip = value; } }
public bool clip
{
get { return m_Clip; }
set { if (PropertyUtility.SetStruct(ref m_Clip, value)) SetVerticesDirty(); }
}
/// <summary>
/// 系列中的数据内容数组。SerieData可以设置1到n维数据。
/// </summary>
public List<SerieData> data { get { return m_Data; } }
public override bool vertsDirty
{
get
{
return m_VertsDirty ||
symbol.vertsDirty ||
lineStyle.vertsDirty ||
lineArrow.vertsDirty ||
itemStyle.vertsDirty ||
areaStyle.vertsDirty ||
label.vertsDirty ||
emphasis.vertsDirty ||
gaugeAxis.vertsDirty ||
gaugePointer.vertsDirty ||
titleStyle.vertsDirty;
}
}
internal override void ClearVerticesDirty()
{
base.ClearVerticesDirty();
symbol.ClearVerticesDirty();
lineStyle.ClearVerticesDirty();
lineArrow.ClearVerticesDirty();
itemStyle.ClearVerticesDirty();
areaStyle.ClearVerticesDirty();
label.ClearVerticesDirty();
emphasis.ClearVerticesDirty();
gaugeAxis.ClearVerticesDirty();
gaugePointer.ClearVerticesDirty();
titleStyle.ClearVerticesDirty();
}
internal override void ClearComponentDirty()
{
base.ClearComponentDirty();
symbol.ClearComponentDirty();
lineStyle.ClearComponentDirty();
lineArrow.ClearComponentDirty();
itemStyle.ClearComponentDirty();
areaStyle.ClearComponentDirty();
label.ClearComponentDirty();
emphasis.ClearComponentDirty();
gaugeAxis.ClearComponentDirty();
gaugePointer.ClearComponentDirty();
titleStyle.ClearComponentDirty();
}
/// <summary>
/// The index of serie,start at 0.
/// 系列的索引从0开始。
@@ -554,7 +776,22 @@ namespace XCharts
/// </summary>
public float runtimePieDataTotal { get; internal set; }
internal int runtimeLastCheckDataCount { get; set; }
public bool nameDirty { get { return m_NameDirty; } }
private void SetNameDirty()
{
m_NameDirty = true;
}
public void ClearNameDirty()
{
m_NameDirty = false;
}
public override void ClearDirty()
{
base.ClearDirty();
}
internal List<Vector3> GetUpSmoothList(int dataIndex, int size = 100)
{
if (m_UpSmoothPoints.ContainsKey(dataIndex))
@@ -711,6 +948,7 @@ namespace XCharts
public void ClearData()
{
m_Data.Clear();
SetVerticesDirty();
}
/// <summary>
@@ -719,7 +957,15 @@ namespace XCharts
/// <param name="index"></param>
public void RemoveData(int index)
{
m_Data.RemoveAt(index);
if (index >= 0 && index < m_Data.Count)
{
if (!string.IsNullOrEmpty(m_Data[index].name))
{
SetNameDirty();
}
SetVerticesDirty();
m_Data.RemoveAt(index);
}
}
/// <summary>
@@ -746,6 +992,11 @@ namespace XCharts
serieData.index = xValue;
m_Data.Add(serieData);
m_ShowDataDimension = 1;
SetVerticesDirty();
if (string.IsNullOrEmpty(dataName))
{
SetNameDirty();
}
return serieData;
}
@@ -774,6 +1025,11 @@ namespace XCharts
serieData.index = m_Data.Count;
m_Data.Add(serieData);
m_ShowDataDimension = 2;
SetVerticesDirty();
if (string.IsNullOrEmpty(dataName))
{
SetNameDirty();
}
return serieData;
}
@@ -814,6 +1070,11 @@ namespace XCharts
serieData.data.Add(valueList[i]);
}
m_Data.Add(serieData);
SetVerticesDirty();
if (string.IsNullOrEmpty(dataName))
{
SetNameDirty();
}
return serieData;
}
}
@@ -1044,7 +1305,9 @@ namespace XCharts
{
if (index >= 0 && index < m_Data.Count)
{
return m_Data[index].UpdateData(dimension, value);
var flag = m_Data[index].UpdateData(dimension, value);
if (flag) SetVerticesDirty();
return flag;
}
else
{
@@ -1064,6 +1327,7 @@ namespace XCharts
var serieData = m_Data[index];
for (int i = 0; i < values.Count; i++)
serieData.UpdateData(i, values[i]);
SetVerticesDirty();
return true;
}
return false;
@@ -1075,6 +1339,7 @@ namespace XCharts
{
var serieData = m_Data[index];
serieData.name = name;
SetNameDirty();
if (serieData.labelText != null)
{
serieData.labelText.text = name == null ? "" : name;
@@ -1381,6 +1646,7 @@ namespace XCharts
}
}
}
SetAllDirty();
}
}
}

View File

@@ -18,12 +18,13 @@ namespace XCharts
[System.Serializable]
public class Series : MainComponent
{
[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
/// 系列列表。
@@ -51,6 +52,74 @@ namespace XCharts
}
}
public override bool vertsDirty
{
get
{
if (m_VertsDirty) return true;
foreach (var serie in m_Series)
{
if (serie.vertsDirty) return true;
}
return false;
}
}
public bool labelDirty
{
get
{
if (m_LabelDirty) return true;
foreach (var serie in m_Series)
{
if (serie.label.componentDirty) return true;
}
return false;
}
}
public bool labelUpdate
{
get
{
foreach (var serie in m_Series)
{
if (serie.label.vertsDirty) return true;
}
return false;
}
}
public void SetLabelDirty()
{
m_LabelDirty = true;
}
internal override void ClearVerticesDirty()
{
base.ClearVerticesDirty();
foreach (var serie in m_Series)
{
serie.ClearVerticesDirty();
}
}
internal void ClearLabelDirty()
{
m_LabelDirty = false;
foreach (var serie in m_Series)
{
serie.label.ClearVerticesDirty();
}
}
public override void SetAllDirty()
{
base.SetAllDirty();
SetLabelDirty();
}
/// <summary>
/// 清空所有系列的数据
/// </summary>
@@ -294,6 +363,7 @@ namespace XCharts
}
serie.animation.Restart();
m_Series.Add(serie);
SetVerticesDirty();
return serie;
}

View File

@@ -30,14 +30,22 @@ namespace XCharts
/// and different curves with slightly different appearance can be obtained.
/// 曲线平滑系数。通过调整平滑系数可以改变曲线的曲率,得到外观稍微有变化的不同曲线。
/// </summary>
public float lineSmoothStyle { get { return m_LineSmoothStyle; } set { m_LineSmoothStyle = value <= 0 ? 1f : value; } }
public float lineSmoothStyle
{
get { return m_LineSmoothStyle; }
set { if (PropertyUtility.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.
/// When the area with gradient is filled, the larger the value, the worse the transition effect.
/// 曲线平滑度。值越小曲线越平滑,但顶点数也会随之增加。当开启有渐变的区域填充时,数值越大渐变过渡效果越差。
/// </summary>
/// <value></value>
public float lineSmoothness { get { return m_LineSmoothness; } set { m_LineSmoothness = value <= 0 ? 1f : value; } }
public float lineSmoothness
{
get { return m_LineSmoothness; }
set { if (PropertyUtility.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,
/// the number of which is determined by the change in value. The smaller the number of segments,
@@ -45,25 +53,44 @@ namespace XCharts
/// 线段的分割距离。普通折线图的线是由很多线段组成,段数由该数值决定。值越小段数越多,但顶点数也会随之增加。当开启有渐变的区域填充时,数值越大渐变过渡效果越差。
/// </summary>
/// <value></value>
public float lineSegmentDistance { get { return m_LineSegmentDistance; } set { m_LineSegmentDistance = value <= 0 ? 1f : value; } }
public float lineSegmentDistance
{
get { return m_LineSegmentDistance; }
set { if (PropertyUtility.SetStruct(ref m_LineSegmentDistance, value < 0 ? 1f : value)) SetVerticesDirty(); }
}
/// <summary>
/// the smoothess of cricle.
/// 圆形的平滑度。数越小圆越平滑,但顶点数也会随之增加。
/// </summary>
public float cicleSmoothness { get { return m_CicleSmoothness; } set { m_CicleSmoothness = value <= 0 ? 1f : value; } }
public float cicleSmoothness
{
get { return m_CicleSmoothness; }
set { if (PropertyUtility.SetStruct(ref m_CicleSmoothness, value < 0 ? 1f : value)) SetVerticesDirty(); }
}
/// <summary>
/// 可视化组件的调节三角形长。
/// 可视化组件的调节三角形长。
/// </summary>
/// <value></value>
public float visualMapTriangeLen { get { return m_VisualMapTriangeLen; } set { m_VisualMapTriangeLen = value <= 0 ? 1f : value; } }
public float visualMapTriangeLen
{
get { return m_VisualMapTriangeLen; }
set { if (PropertyUtility.SetStruct(ref m_VisualMapTriangeLen, value < 0 ? 1f : value)) SetVerticesDirty(); }
}
/// <summary>
/// 饼图鼠标移到高亮时的额外半径
/// </summary>
public float pieTooltipExtraRadius { get { return m_PieTooltipExtraRadius; } set { m_PieTooltipExtraRadius = value <= 0 ? 0 : value; } }
public float pieTooltipExtraRadius
{
get { return m_PieTooltipExtraRadius; }
set { if (PropertyUtility.SetStruct(ref m_PieTooltipExtraRadius, value < 0 ? 0f : value)) SetVerticesDirty(); }
}
/// <summary>
/// 饼图选中时的中心点偏移
/// </summary>
public float pieSelectedOffset { get { return m_PieSelectedOffset; } set { m_PieSelectedOffset = value <= 0 ? 0 : value; } }
public float pieSelectedOffset
{
get { return m_PieSelectedOffset; }
set { if (PropertyUtility.SetStruct(ref m_PieSelectedOffset, value < 0 ? 0f : value)) SetVerticesDirty(); }
}
}
}

View File

@@ -36,7 +36,7 @@ namespace XCharts
/// Theme.
/// 主题相关配置。
/// </summary>
public class ThemeInfo : MainComponent, IEquatable<ThemeInfo>
public class ThemeInfo : MainComponent
{
[SerializeField] private Theme m_Theme = Theme.Default;
[SerializeField] private Font m_Font;
@@ -86,7 +86,11 @@ namespace XCharts
/// the theme of chart.
/// 主题类型。
/// </summary>
public Theme theme { get { return m_Theme; } set { m_Theme = value; } }
public Theme theme
{
get { return m_Theme; }
set { if (PropertyUtility.SetStruct(ref m_Theme, value)) SetComponentDirty(); }
}
/// <summary>
/// the font of chart text。
/// 字体。
@@ -94,7 +98,7 @@ namespace XCharts
public Font font
{
get { return m_CustomFont != null ? m_CustomFont : m_Font; }
set { m_CustomFont = value; }
set { if (PropertyUtility.SetClass(ref m_CustomFont, value)) SetComponentDirty(); }
}
/// <summary>
/// the background color of chart.
@@ -103,7 +107,7 @@ namespace XCharts
public Color32 backgroundColor
{
get { return m_CustomBackgroundColor != Color.clear ? m_CustomBackgroundColor : m_BackgroundColor; }
set { m_CustomBackgroundColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomBackgroundColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the main title text color.
@@ -112,7 +116,7 @@ namespace XCharts
public Color32 titleTextColor
{
get { return m_CustomTitleTextColor != Color.clear ? m_CustomTitleTextColor : m_TitleTextColor; }
set { m_CustomTitleTextColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomTitleTextColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the subtitie text color.
@@ -121,7 +125,7 @@ namespace XCharts
public Color32 titleSubTextColor
{
get { return m_CustomTitleSubTextColor != Color.clear ? m_CustomTitleSubTextColor : m_TitleSubTextColor; }
set { m_CustomTitleSubTextColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomTitleSubTextColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the legend text color.
@@ -130,10 +134,8 @@ namespace XCharts
public Color32 legendTextColor
{
get { return m_CustomLegendTextColor != Color.clear ? m_CustomLegendTextColor : m_LegendTextColor; }
set { m_CustomLegendTextColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomLegendTextColor, value)) SetComponentDirty(); }
}
public Color32 defaultLegendTextColor{get{return m_LegendTextColor;}set{m_LegendTextColor=value;}}
/// <summary>
/// the legend unable text color.
/// 图例变为不可用时的按钮颜色。
@@ -141,7 +143,7 @@ namespace XCharts
public Color32 legendUnableColor
{
get { return m_CustomLegendUnableColor != Color.clear ? m_CustomLegendUnableColor : m_LegendUnableColor; }
set { m_CustomLegendUnableColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomLegendUnableColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the axis text color.
@@ -150,7 +152,7 @@ namespace XCharts
public Color32 axisTextColor
{
get { return m_CustomAxisTextColor != Color.clear ? m_CustomAxisTextColor : m_AxisTextColor; }
set { m_CustomAxisTextColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomAxisTextColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the color of axis line.
@@ -159,7 +161,7 @@ namespace XCharts
public Color32 axisLineColor
{
get { return m_CustomAxisLineColor != Color.clear ? m_CustomAxisLineColor : m_AxisLineColor; }
set { m_CustomAxisLineColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomAxisLineColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color of axis split line.
@@ -168,7 +170,7 @@ namespace XCharts
public Color32 axisSplitLineColor
{
get { return m_CustomAxisSplitLineColor != Color.clear ? m_CustomAxisSplitLineColor : m_AxisSplitLineColor; }
set { m_CustomAxisSplitLineColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomAxisSplitLineColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the tooltip background color.
@@ -177,7 +179,7 @@ namespace XCharts
public Color32 tooltipBackgroundColor
{
get { return m_CustomTooltipBackgroundColor != Color.clear ? m_CustomTooltipBackgroundColor : m_TooltipBackgroundColor; }
set { m_CustomTooltipBackgroundColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomTooltipBackgroundColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the color of tooltip shadow crosshair indicator.
@@ -186,7 +188,7 @@ namespace XCharts
public Color32 tooltipFlagAreaColor
{
get { return m_CustomTooltipFlagAreaColor != Color.clear ? m_CustomTooltipFlagAreaColor : m_TooltipFlagAreaColor; }
set { m_CustomTooltipFlagAreaColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomTooltipFlagAreaColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color of tooltip text.
@@ -195,7 +197,7 @@ namespace XCharts
public Color32 tooltipTextColor
{
get { return m_CustomTooltipTextColor != Color.clear ? m_CustomTooltipTextColor : m_TooltipTextColor; }
set { m_CustomTooltipTextColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomTooltipTextColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the background color of tooltip cross indicator's axis label.
@@ -204,7 +206,7 @@ namespace XCharts
public Color32 tooltipLabelColor
{
get { return m_CustomTooltipLabelColor != Color.clear ? m_CustomTooltipLabelColor : m_TooltipLabelColor; }
set { m_CustomTooltipLabelColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomTooltipLabelColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color tooltip indicator line.
@@ -213,7 +215,7 @@ namespace XCharts
public Color32 tooltipLineColor
{
get { return m_CustomTooltipLineColor != Color.clear ? m_CustomTooltipLineColor : m_TooltipLineColor; }
set { m_CustomTooltipLineColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomTooltipLineColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color of datazoom text.
@@ -222,7 +224,7 @@ namespace XCharts
public Color32 dataZoomTextColor
{
get { return m_CustomDataZoomTextColor != Color.clear ? m_CustomDataZoomTextColor : m_DataZoomTextColor; }
set { m_CustomDataZoomTextColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomDataZoomTextColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the color of datazoom line.
@@ -231,7 +233,7 @@ namespace XCharts
public Color32 dataZoomLineColor
{
get { return m_CustomDataZoomLineColor != Color.clear ? m_CustomDataZoomLineColor : m_DataZoomLineColor; }
set { m_CustomDataZoomLineColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomDataZoomLineColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color of datazoom selected area.
@@ -240,7 +242,7 @@ namespace XCharts
public Color32 dataZoomSelectedColor
{
get { return m_CustomDataZoomSelectedColor != Color.clear ? m_CustomDataZoomSelectedColor : m_DataZoomSelectedColor; }
set { m_CustomDataZoomSelectedColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomDataZoomSelectedColor, value)) SetVerticesDirty(); }
}
/// <summary>
@@ -249,7 +251,7 @@ namespace XCharts
public Color32 visualMapBackgroundColor
{
get { return m_CustomVisualMapBackgroundColor != Color.clear ? m_CustomVisualMapBackgroundColor : m_VisualMapBackgroundColor; }
set { m_CustomVisualMapBackgroundColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomVisualMapBackgroundColor, value)) SetVerticesDirty(); }
}
/// <summary>
@@ -258,14 +260,14 @@ namespace XCharts
public Color32 visualMapBorderColor
{
get { return m_CustomVisualMapBorderColor != Color.clear ? m_CustomVisualMapBorderColor : m_VisualMapBorderColor; }
set { m_CustomVisualMapBorderColor = value; }
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; } }
public List<Color32> colorPalette { set { m_CustomColorPalette = value; SetVerticesDirty(); } }
/// <summary>
/// Gets the color of the specified index from the palette.
@@ -312,6 +314,22 @@ namespace XCharts
}
}
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.
/// 复制主题的所有配置。
@@ -579,64 +597,6 @@ namespace XCharts
return (Color32)color;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
else if (obj is ThemeInfo)
{
return Equals((ThemeInfo)obj);
}
else
{
return false;
}
}
public bool Equals(ThemeInfo other)
{
if (ReferenceEquals(null, other))
{
return false;
}
return m_Font == other.m_Font &&
ChartHelper.IsValueEqualsColor(m_LegendUnableColor, other.m_LegendUnableColor) &&
ChartHelper.IsValueEqualsColor(m_BackgroundColor, other.m_BackgroundColor) &&
ChartHelper.IsValueEqualsColor(m_TitleTextColor, other.m_TitleTextColor) &&
ChartHelper.IsValueEqualsColor(m_TitleSubTextColor, other.m_TitleSubTextColor) &&
ChartHelper.IsValueEqualsColor(m_AxisTextColor, other.m_AxisTextColor) &&
ChartHelper.IsValueEqualsColor(m_AxisLineColor, other.m_AxisLineColor) &&
ChartHelper.IsValueEqualsColor(m_AxisSplitLineColor, other.m_AxisSplitLineColor) &&
ChartHelper.IsValueEqualsColor(m_TooltipBackgroundColor, other.m_TooltipBackgroundColor) &&
ChartHelper.IsValueEqualsColor(m_AxisSplitLineColor, other.m_AxisSplitLineColor) &&
ChartHelper.IsValueEqualsColor(m_TooltipTextColor, other.m_TooltipTextColor) &&
ChartHelper.IsValueEqualsColor(m_TooltipFlagAreaColor, other.m_TooltipFlagAreaColor) &&
ChartHelper.IsValueEqualsColor(m_DataZoomLineColor, other.m_DataZoomLineColor) &&
ChartHelper.IsValueEqualsColor(m_DataZoomSelectedColor, other.m_DataZoomSelectedColor) &&
ChartHelper.IsValueEqualsColor(m_DataZoomTextColor, other.m_DataZoomTextColor) &&
m_ColorPalette.Length == other.m_ColorPalette.Length;
}
public static bool operator ==(ThemeInfo left, ThemeInfo right)
{
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
{
return true;
}
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
{
return false;
}
return Equals(left, right);
}
public static bool operator !=(ThemeInfo left, ThemeInfo right)
{
return !(left == right);
}
public override int GetHashCode()
{
return base.GetHashCode();

View File

@@ -15,7 +15,7 @@ namespace XCharts
/// 标题组件,包含主标题和副标题。
/// </summary>
[Serializable]
public class Title : MainComponent, IPropertyChanged, IEquatable<Title>
public class Title : MainComponent, IPropertyChanged
{
[SerializeField] private bool m_Show = true;
[SerializeField] private string m_Text;
@@ -30,50 +30,61 @@ namespace XCharts
/// Set this to false to prevent the title from showing.
/// 是否显示标题组件。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
public bool show { get { return m_Show; } set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); } }
/// <summary>
/// The main title text, supporting for \n for newlines.
/// 主标题文本,支持使用 \n 换行。
/// </summary>
public string text { get { return m_Text; } set { m_Text = value; } }
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.", false)]
[Obsolete("use textStyle instead.", true)]
public int textFontSize { get { return m_TextStyle.fontSize; } set { m_TextStyle.fontSize = value; } }
/// <summary>
/// 主标题文本样式。
/// </summary>
public TextStyle textStyle { get { return m_TextStyle; } set { m_TextStyle = value; } }
public TextStyle textStyle { get { return m_TextStyle; } set { if (PropertyUtility.SetClass(ref m_TextStyle, value)) SetComponentDirty(); } }
/// <summary>
/// Subtitle text, supporting for \n for newlines.
/// 副标题文本,支持使用 \n 换行。
/// </summary>
public string subText { get { return m_SubText; } set { m_SubText = value; } }
public string subText { get { return m_SubText; } set { if (PropertyUtility.SetClass(ref m_SubText, value)) SetComponentDirty(); } }
/// <summary>
/// 副标题文本样式。
/// </summary>
public TextStyle subTextStyle { get { return m_SubTextStyle; } set { m_SubTextStyle = value; } }
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.", false)]
[Obsolete("use subTextStyle instead.", true)]
public int subTextFontSize { get { return m_SubTextStyle.fontSize; } set { m_SubTextStyle.fontSize = value; } }
/// <summary>
/// [default:8]
/// The gap between the main title and subtitle.
/// 主副标题之间的间距。
/// </summary>
public float itemGap { get { return m_ItemGap; } set { m_ItemGap = value; } }
public float itemGap { get { return m_ItemGap; } set { if (PropertyUtility.SetStruct(ref m_ItemGap, value)) SetComponentDirty(); } }
/// <summary>
/// The location of title component.
/// 标题显示位置。
/// </summary>
public Location location { get { return m_Location; } set { m_Location = value; } }
public Location location { get { return m_Location; } set { if (PropertyUtility.SetClass(ref m_Location, value)) SetComponentDirty(); } }
public override bool vertsDirty { get { return false; } }
public override bool componentDirty { get { return m_ComponentDirty || location.componentDirty || textStyle.componentDirty || subTextStyle.componentDirty; } }
internal override void ClearComponentDirty()
{
base.ClearComponentDirty();
location.ClearComponentDirty();
textStyle.ClearComponentDirty();
subTextStyle.ClearComponentDirty();
}
public static Title defaultTitle
{
@@ -92,70 +103,6 @@ namespace XCharts
return title;
}
}
public void Copy(Title title)
{
m_Show = title.show;
m_Text = title.text;
m_TextStyle.Copy(title.textStyle);
m_SubTextStyle.Copy(title.subTextStyle);
m_SubText = title.subText;
m_ItemGap = title.itemGap;
m_Location.Copy(title.location);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
else if (obj is Title)
{
return Equals((Title)obj);
}
else
{
return false;
}
}
public bool Equals(Title other)
{
if (ReferenceEquals(null, other))
{
return false;
}
return m_Show == other.show &&
m_Text.Equals(other.text) &&
m_TextStyle.Equals(other.textStyle) &&
m_SubText.Equals(other.subText) &&
m_SubTextStyle.Equals(other.subTextStyle) &&
m_ItemGap == other.itemGap &&
m_Location.Equals(other.location);
}
public static bool operator ==(Title left, Title right)
{
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
{
return true;
}
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
{
return false;
}
return Equals(left, right);
}
public static bool operator !=(Title left, Title right)
{
return !(left == right);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public void OnChanged()
{

View File

@@ -77,13 +77,20 @@ namespace XCharts
/// Whether to show the tooltip component.
/// 是否显示提示框组件。
/// </summary>
/// <returns></returns>
public bool show { get { return m_Show; } set { m_Show = value; SetActive(value); } }
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) { SetAllDirty(); SetActive(value); } }
}
/// <summary>
/// Indicator type.
/// 提示框指示器类型。
/// </summary>
public Type type { get { return m_Type; } set { m_Type = value; } }
public Type type
{
get { return m_Type; }
set { if (PropertyUtility.SetStruct(ref m_Type, value)) SetAllDirty(); }
}
/// <summary>
/// 提示框总内容的字符串模版格式器。支持用 \n 或 "<br/>" 换行。当formatter不为空时优先使用formatter否则使用itemFormatter。
/// 模板变量有 {a}, {b}{c}{d}{e},分别表示系列名,数据名,数据值等。{a0},{b1},c{1}等可指定serie。
@@ -166,11 +173,34 @@ namespace XCharts
/// <summary>
/// 提示框内容文本样式。
/// </summary>
public TextStyle textStyle { get { return m_TextStyle; } set { if (value != null) m_TextStyle = value; } }
public TextStyle textStyle
{
get { return m_TextStyle; }
set { if (value != null) { m_TextStyle = value; SetComponentDirty(); } }
}
/// <summary>
/// 指示线样式。
/// </summary>
public LineStyle lineStyle { get { return m_LineStyle; } set { if (value != null) m_LineStyle = value; } }
public LineStyle lineStyle
{
get { return m_LineStyle; }
set { if (value != null) m_LineStyle = value; SetComponentDirty(); }
}
/// <summary>
/// 组件是否需要刷新
/// </summary>
public override bool componentDirty
{
get { return m_ComponentDirty || lineStyle.componentDirty || textStyle.componentDirty; }
}
internal override void ClearComponentDirty()
{
base.ClearComponentDirty();
lineStyle.ClearComponentDirty();
textStyle.ClearComponentDirty();
}
/// <summary>
/// The data index currently indicated by Tooltip.

View File

@@ -73,27 +73,51 @@ namespace XCharts
/// <summary>
/// 是否开启组件功能。
/// </summary>
public bool enable { get { return m_Enable; } set { m_Enable = value; } }
public bool enable
{
get { return m_Enable; }
set { if (PropertyUtility.SetStruct(ref m_Enable, value)) SetVerticesDirty(); }
}
/// <summary>
/// 是否显示组件。如果设置为 false不会显示但是数据映射的功能还存在。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Enable, value)) SetVerticesDirty(); }
}
/// <summary>
/// 组件类型。
/// </summary>
public Type type { get { return m_Type; } set { m_Type = value; } }
public Type type
{
get { return m_Type; }
set { if (PropertyUtility.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
}
/// <summary>
/// 选择模式。
/// </summary>
public SelectedMode selectedMode { get { return m_SelectedMode; } set { m_SelectedMode = value; } }
public SelectedMode selectedMode
{
get { return m_SelectedMode; }
set { if (PropertyUtility.SetStruct(ref m_SelectedMode, value)) SetVerticesDirty(); }
}
/// <summary>
/// 允许的最小值。'min' 必须用户指定。[visualMap.min, visualMap.max] 形成了视觉映射的『定义域』。
/// </summary>
public float min { get { return m_Min; } set { m_Min = value; } }
public float min
{
get { return m_Min; }
set { if (PropertyUtility.SetStruct(ref m_Min, value)) SetVerticesDirty(); }
}
/// <summary>
/// 允许的最大值。'max' 必须用户指定。[visualMap.min, visualMax.max] 形成了视觉映射的『定义域』。
/// </summary>
public float max { get { return m_Max; } set { m_Max = value < min ? min + 1 : value; } }
public float max
{
get { return m_Max; }
set { m_Max = value < min ? min + 1 : value; SetVerticesDirty(); }
}
/// <summary>
/// 指定手柄对应数值的位置。range 应在 min max 范围内。
/// </summary>
@@ -110,55 +134,116 @@ namespace XCharts
/// 对于连续型数据自动平均切分成几段默认为0时自动匹配inRange颜色列表大小。
/// </summary>
/// <value></value>
public int splitNumber { get { return m_SplitNumber; } set { m_SplitNumber = value; } }
public int splitNumber
{
get { return m_SplitNumber; }
set { if (PropertyUtility.SetStruct(ref m_SplitNumber, value)) SetVerticesDirty(); }
}
/// <summary>
/// 是否显示拖拽用的手柄(手柄能拖拽调整选中范围)。
/// </summary>
public bool calculable { get { return m_Calculable; } set { m_Calculable = value; } }
public bool calculable
{
get { return m_Calculable; }
set { if (PropertyUtility.SetStruct(ref m_Calculable, value)) SetVerticesDirty(); }
}
/// <summary>
/// 拖拽时,是否实时更新。
/// </summary>
public bool realtime { get { return m_Realtime; } set { m_Realtime = value; } }
public bool realtime
{
get { return m_Realtime; }
set { if (PropertyUtility.SetStruct(ref m_Realtime, value)) SetVerticesDirty(); }
}
/// <summary>
/// 图形的宽度,即颜色条的宽度。
/// </summary>
public float itemWidth { get { return m_ItemWidth; } set { m_ItemWidth = value; } }
public float itemWidth
{
get { return m_ItemWidth; }
set { if (PropertyUtility.SetStruct(ref m_ItemWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// 图形的高度,即颜色条的高度。
/// </summary>
public float itemHeight { get { return m_ItemHeight; } set { m_ItemHeight = value; } }
public float itemHeight
{
get { return m_ItemHeight; }
set { if (PropertyUtility.SetStruct(ref m_ItemHeight, value)) SetVerticesDirty(); }
}
/// <summary>
/// 边框线宽单位px。
/// </summary>
public float borderWidth { get { return m_BorderWidth; } set { m_BorderWidth = value; } }
public float borderWidth
{
get { return m_BorderWidth; }
set { if (PropertyUtility.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// 指定用数据的『哪个维度』,映射到视觉元素上。『数据』即 series.data。从1开始默认为0取 data 中最后一个维度。
/// </summary>
public int dimension { get { return m_Dimension; } set { m_Dimension = value; } }
public int dimension
{
get { return m_Dimension; }
set { if (PropertyUtility.SetStruct(ref m_Dimension, value)) SetVerticesDirty(); }
}
/// <summary>
/// 打开 hoverLink 功能时,鼠标悬浮到 visualMap 组件上时,鼠标位置对应的数值 在 图表中对应的图形元素,会高亮。
/// 反之,鼠标悬浮到图表中的图形元素上时,在 visualMap 组件的相应位置会有三角提示其所对应的数值。
/// </summary>
/// <value></value>
public bool hoverLink { get { return m_HoverLink; } set { m_HoverLink = value; } }
public bool hoverLink
{
get { return m_HoverLink; }
set { if (PropertyUtility.SetStruct(ref m_HoverLink, value)) SetVerticesDirty(); }
}
/// <summary>
/// Specify whether the layout of component is horizontal or vertical.
/// 布局方式是横还是竖。
/// </summary>
public Orient orient { get { return m_Orient; } set { m_Orient = value; } }
public Orient orient
{
get { return m_Orient; }
set { if (PropertyUtility.SetStruct(ref m_Orient, value)) SetVerticesDirty(); }
}
/// <summary>
/// The location of component.
/// 组件显示的位置。
/// </summary>
public Location location { get { return m_Location; } set { m_Location = value; } }
public Location location
{
get { return m_Location; }
set { if (PropertyUtility.SetClass(ref m_Location, value)) SetVerticesDirty(); }
}
/// <summary>
/// 定义 在选中范围中 的视觉颜色。
/// </summary>
public List<Color> inRange { get { return m_InRange; } set { if (value != null) m_InRange = value; } }
public List<Color> inRange
{
get { return m_InRange; }
set { if (value != null) { m_InRange = value; SetVerticesDirty(); } }
}
/// <summary>
/// 定义 在选中范围外 的视觉颜色。
/// </summary>
public List<Color> outOfRange { get { return m_OutOfRange; } set { if (value != null) m_OutOfRange = value; } }
public List<Color> outOfRange
{
get { return m_OutOfRange; }
set { if (value != null) { m_OutOfRange = value; SetVerticesDirty(); } }
}
public override bool vertsDirty { get { return m_VertsDirty || location.anyDirty; } }
internal override void ClearVerticesDirty()
{
base.ClearVerticesDirty();
location.ClearVerticesDirty();
}
internal override void ClearComponentDirty()
{
base.ClearComponentDirty();
location.ClearComponentDirty();
}
/// <summary>
/// 鼠标悬停选中的index

View File

@@ -22,7 +22,7 @@ namespace XCharts
/// </para>
/// </summary>
[Serializable]
public class Grid : MainComponent, IEquatable<Grid>
public class Grid : MainComponent
{
[SerializeField] private bool m_Show = true;
[SerializeField] private float m_Left;
@@ -35,32 +35,56 @@ namespace XCharts
/// Whether to show the grid in rectangular coordinate.
/// 是否显示直角坐标系网格。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// Distance between grid component and the left side of the container.
/// grid 组件离容器左侧的距离。
/// </summary>
public float left { get { return m_Left; } set { m_Left = value; } }
public float left
{
get { return m_Left; }
set { if (PropertyUtility.SetStruct(ref m_Left, value)) SetAllDirty(); }
}
/// <summary>
/// Distance between grid component and the right side of the container.
/// grid 组件离容器右侧的距离。
/// </summary>
public float right { get { return m_Right; } set { m_Right = value; } }
public float right
{
get { return m_Right; }
set { if (PropertyUtility.SetStruct(ref m_Right, value)) SetAllDirty(); }
}
/// <summary>
/// Distance between grid component and the top side of the container.
/// grid 组件离容器上侧的距离。
/// </summary>
public float top { get { return m_Top; } set { m_Top = value; } }
public float top
{
get { return m_Top; }
set { if (PropertyUtility.SetStruct(ref m_Top, value)) SetAllDirty(); }
}
/// <summary>
/// Distance between grid component and the bottom side of the container.
/// grid 组件离容器下侧的距离。
/// </summary>
public float bottom { get { return m_Bottom; } set { m_Bottom = value; } }
public float bottom
{
get { return m_Bottom; }
set { if (PropertyUtility.SetStruct(ref m_Bottom, value)) SetAllDirty(); }
}
/// <summary>
/// Background color of grid, which is transparent by default.
/// 网格背景色,默认透明。
/// </summary>
public Color backgroundColor { get { return m_BackgroundColor; } set { m_BackgroundColor = value; } }
public Color backgroundColor
{
get { return m_BackgroundColor; }
set { if (PropertyUtility.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
}
public static Grid defaultGrid
{
@@ -77,67 +101,5 @@ namespace XCharts
return coordinate;
}
}
public void Copy(Grid other)
{
m_Show = other.show;
m_Left = other.left;
m_Right = other.right;
m_Top = other.top;
m_Bottom = other.bottom;
m_BackgroundColor = other.backgroundColor;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
else if (obj is Grid)
{
return Equals((Grid)obj);
}
else
{
return false;
}
}
public bool Equals(Grid other)
{
if (ReferenceEquals(null, other))
{
return false;
}
return m_Show == other.show &&
m_Left == other.left &&
m_Right == other.right &&
m_Top == other.top &&
m_Bottom == other.bottom &&
ChartHelper.IsValueEqualsColor(m_BackgroundColor, other.backgroundColor);
}
public static bool operator ==(Grid left, Grid right)
{
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
{
return true;
}
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
{
return false;
}
return Equals(left, right);
}
public static bool operator !=(Grid left, Grid right)
{
return !(left == right);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
}