diff --git a/Runtime/Component/Main/Serie.cs b/Runtime/Component/Main/Serie.cs
index 790265db..51c49997 100644
--- a/Runtime/Component/Main/Serie.cs
+++ b/Runtime/Component/Main/Serie.cs
@@ -943,7 +943,6 @@ namespace XCharts
///
public float runtimePieDataTotal { get; internal set; }
public float runtimeWaveSpeed { get; internal set; }
- internal int runtimeLastCheckDataCount { get; set; }
internal float runtimeCheckValue { get; set; }
public bool nameDirty { get { return m_NameDirty; } }
@@ -1547,22 +1546,21 @@ namespace XCharts
public void ClearHighlight()
{
highlighted = false;
- foreach (var sd in m_Data)
+ foreach (var serieData in m_Data)
{
- sd.highlighted = false;
+ serieData.highlighted = false;
}
}
///
/// 设置指定索引的数据为高亮状态
///
- ///
- public void SetHighlight(int index)
+ public void SetHighlight(int index, bool flag)
{
- if (index <= 0) return;
- for (int i = 0; i < m_Data.Count; i++)
+ var serieData = GetSerieData(index);
+ if (serieData != null)
{
- m_Data[i].highlighted = index == i;
+ serieData.highlighted = flag;
}
}
@@ -1572,13 +1570,6 @@ namespace XCharts
else return m_BarWidth * categoryWidth;
}
- internal float GetBarGap(float categoryWidth)
- {
- if (m_BarGap == -1) return 0;
- else if (m_BarGap <= 1) return GetBarWidth(categoryWidth) * m_BarGap;
- else return m_BarGap;
- }
-
///
/// 设置所有数据的图标是否显示
///
@@ -1633,15 +1624,6 @@ namespace XCharts
}
}
- internal bool IsNeedShowDataIcon()
- {
- foreach (var data in m_Data)
- {
- if (data.iconStyle.show) return true;
- }
- return false;
- }
-
public bool IsIgnoreIndex(int index, int dimension)
{
if (m_Ignore)
diff --git a/Runtime/Component/Main/Vessel.cs b/Runtime/Component/Main/Vessel.cs
index 28dd80f0..f80f1b00 100644
--- a/Runtime/Component/Main/Vessel.cs
+++ b/Runtime/Component/Main/Vessel.cs
@@ -14,7 +14,7 @@ namespace XCharts
/// Vessel component for liquid chart.
///
/// 容器组件。
- /// 一般用于LiquidChart。
+ /// 一般用于LiquidChart。可以有多个Vessel,Serie中用vesselIndex来对应。
///
///
[Serializable]
@@ -73,6 +73,7 @@ namespace XCharts
set { if (PropertyUtility.SetStruct(ref m_Shape, value)) SetVerticesDirty(); }
}
///
+ /// Thickness of vessel.
/// 容器厚度。
///
public float shapeWidth
@@ -81,6 +82,7 @@ namespace XCharts
set { if (PropertyUtility.SetStruct(ref m_ShapeWidth, value)) SetVerticesDirty(); }
}
///
+ /// The gap between the vessel and the liquid.
/// 间隙。容器和液体的间隙。
///
public float gap
@@ -152,7 +154,8 @@ namespace XCharts
///
public float runtimeRadius { get; internal set; }
///
- /// 运行时内半径。
+ /// The actual radius after deducting shapeWidth and gap.
+ /// 运行时内半径。扣除厚度和间隙后的实际半径。
///
public float runtimeInnerRadius { get; internal set; }
public static Vessel defaultVessel
diff --git a/Runtime/Helper/SerieHelper.cs b/Runtime/Helper/SerieHelper.cs
new file mode 100644
index 00000000..0b97c5ea
--- /dev/null
+++ b/Runtime/Helper/SerieHelper.cs
@@ -0,0 +1,86 @@
+/******************************************/
+/* */
+/* Copyright (c) 2018 monitor1394 */
+/* https://github.com/monitor1394 */
+/* */
+/******************************************/
+
+using System.Text;
+using UnityEngine;
+
+namespace XCharts
+{
+ public static partial class SerieHelper
+ {
+ ///
+ /// Gets the maximum and minimum values of the specified dimension of a serie.
+ /// 获得系列指定维数的最大最小值。
+ ///
+ /// 指定系列
+ /// 指定维数
+ /// 最小值
+ /// 最大值
+ /// 缩放组件,默认null
+ public static void GetMinMaxData(Serie serie, int dimension, out float min, out float max, DataZoom dataZoom = null)
+ {
+ max = float.MinValue;
+ min = float.MaxValue;
+ var dataList = serie.GetDataList(dataZoom);
+ for (int i = 0; i < dataList.Count; i++)
+ {
+ var serieData = dataList[i];
+ if (serieData.show && serieData.data.Count > dimension)
+ {
+ var value = serieData.data[dimension];
+ if (value > max) max = value;
+ if (value < min) min = value;
+ }
+ }
+ }
+
+ ///
+ /// Gets the maximum and minimum values of all data in the serie.
+ /// 获得系列所有数据的最大最小值。
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static void GetMinMaxData(Serie serie, out float min, out float max, DataZoom dataZoom = null)
+ {
+ max = float.MinValue;
+ min = float.MaxValue;
+ var dataList = serie.GetDataList(dataZoom);
+ for (int i = 0; i < dataList.Count; i++)
+ {
+ var serieData = dataList[i];
+ if (serieData.show)
+ {
+ var count = serie.showDataDimension > serieData.data.Count ? serieData.data.Count : serie.showDataDimension;
+ for (int j = 0; j < count; j++)
+ {
+ var value = serieData.data[j];
+ if (value > max) max = value;
+ if (value < min) min = value;
+ }
+ }
+ }
+ }
+
+ ///
+ /// Whether the data for the specified dimension of serie are all 0.
+ /// 系列指定维数的数据是否全部为0。
+ ///
+ /// 系列
+ /// 指定维数
+ ///
+ public static bool IsAllZeroValue(Serie serie, int dimension = 1)
+ {
+ foreach (var serieData in serie.data)
+ {
+ if (serieData.GetData(dimension) != 0) return false;
+ }
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Runtime/Helper/SerieHelper.cs.meta b/Runtime/Helper/SerieHelper.cs.meta
new file mode 100644
index 00000000..a2ba9d14
--- /dev/null
+++ b/Runtime/Helper/SerieHelper.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 8c031417514104eebb5bbd60dd1f90fd
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Internal/Helper/SerieDataHelper.cs b/Runtime/Internal/Helper/SerieDataHelper.cs
deleted file mode 100644
index d412e75c..00000000
--- a/Runtime/Internal/Helper/SerieDataHelper.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-/******************************************/
-/* */
-/* Copyright (c) 2018 monitor1394 */
-/* https://github.com/monitor1394 */
-/* */
-/******************************************/
-using UnityEngine;
-using UnityEngine.UI;
-
-namespace XCharts
-{
- internal static class SerieDataHelper
- {
- }
-}
\ No newline at end of file
diff --git a/Runtime/Internal/Helper/SerieHelper.cs b/Runtime/Internal/Helper/SerieHelper.cs
index 90a7f8f4..3e8c24d5 100644
--- a/Runtime/Internal/Helper/SerieHelper.cs
+++ b/Runtime/Internal/Helper/SerieHelper.cs
@@ -4,14 +4,15 @@
/* https://github.com/monitor1394 */
/* */
/******************************************/
+
using UnityEngine;
-using UnityEngine.UI;
namespace XCharts
{
- internal static class SerieHelper
+ public static partial class SerieHelper
{
- internal static Color GetItemBackgroundColor(Serie serie, SerieData serieData, ThemeInfo theme, int index, bool highlight, bool useDefault = true)
+ internal static Color GetItemBackgroundColor(Serie serie, SerieData serieData, ThemeInfo theme, int index,
+ bool highlight, bool useDefault = true)
{
var color = Color.clear;
if (highlight)
@@ -109,7 +110,7 @@ namespace XCharts
}
}
- public static bool IsDownPoint(Serie serie, int index)
+ internal static bool IsDownPoint(Serie serie, int index)
{
var dataPoints = serie.dataPoints;
if (dataPoints.Count < 2) return false;
@@ -135,7 +136,7 @@ namespace XCharts
}
}
- public static ItemStyle GetItemStyle(Serie serie, SerieData serieData, bool highlight = false)
+ internal static ItemStyle GetItemStyle(Serie serie, SerieData serieData, bool highlight = false)
{
if (highlight)
{
@@ -148,7 +149,7 @@ namespace XCharts
else return serie.itemStyle;
}
- public static ItemStyle GetItemStyleEmphasis(Serie serie, SerieData serieData)
+ internal static ItemStyle GetItemStyleEmphasis(Serie serie, SerieData serieData)
{
if (!serie.IsPerformanceMode() && serieData != null && serieData.enableEmphasis && serieData.emphasis.show)
return serieData.emphasis.itemStyle;
@@ -156,7 +157,7 @@ namespace XCharts
else return null;
}
- public static SerieLabel GetSerieLabel(Serie serie, SerieData serieData, bool highlight = false)
+ internal static SerieLabel GetSerieLabel(Serie serie, SerieData serieData, bool highlight = false)
{
if (highlight)
{
@@ -172,13 +173,13 @@ namespace XCharts
}
}
- public static SerieSymbol GetSerieSymbol(Serie serie, SerieData serieData)
+ internal static SerieSymbol GetSerieSymbol(Serie serie, SerieData serieData)
{
if (!serie.IsPerformanceMode() && serieData.enableSymbol) return serieData.symbol;
else return serie.symbol;
}
- public static Color GetAreaColor(Serie serie, ThemeInfo theme, int index, bool highlight)
+ internal static Color GetAreaColor(Serie serie, ThemeInfo theme, int index, bool highlight)
{
var areaStyle = serie.areaStyle;
var color = !ChartHelper.IsClearColor(areaStyle.color) ? areaStyle.color : (Color)theme.GetColor(index);
@@ -191,7 +192,7 @@ namespace XCharts
return color;
}
- public static Color GetAreaToColor(Serie serie, ThemeInfo theme, int index, bool highlight)
+ internal static Color GetAreaToColor(Serie serie, ThemeInfo theme, int index, bool highlight)
{
var areaStyle = serie.areaStyle;
if (!ChartHelper.IsClearColor(areaStyle.toColor))
@@ -211,7 +212,7 @@ namespace XCharts
}
}
- public static Color GetLineColor(Serie serie, ThemeInfo theme, int index, bool highlight)
+ internal static Color GetLineColor(Serie serie, ThemeInfo theme, int index, bool highlight)
{
var color = Color.clear;
if (highlight)
@@ -235,7 +236,7 @@ namespace XCharts
return color;
}
- public static float GetSymbolBorder(Serie serie, SerieData serieData, bool highlight, bool useLineWidth = true)
+ internal static float GetSymbolBorder(Serie serie, SerieData serieData, bool highlight, bool useLineWidth = true)
{
var itemStyle = GetItemStyle(serie, serieData, highlight);
if (itemStyle != null && itemStyle.borderWidth != 0) return itemStyle.borderWidth;
@@ -243,7 +244,7 @@ namespace XCharts
else return 0;
}
- public static float[] GetSymbolCornerRadius(Serie serie, SerieData serieData, bool highlight)
+ internal static float[] GetSymbolCornerRadius(Serie serie, SerieData serieData, bool highlight)
{
var itemStyle = GetItemStyle(serie, serieData, highlight);
if (itemStyle != null) return itemStyle.cornerRadius;
@@ -266,27 +267,23 @@ namespace XCharts
serie.runtimeOutsideRadius = serie.radius[1] <= 1 ? minWidth * serie.radius[1] : serie.radius[1];
}
+ internal static string GetNumericFormatter(Serie serie, SerieData serieData)
+ {
+ var itemStyle = SerieHelper.GetItemStyle(serie, serieData);
+ if (!string.IsNullOrEmpty(itemStyle.numericFormatter)) return itemStyle.numericFormatter;
+ else return string.Empty;
+ }
+
///
/// 获得指定维数的最大最小值
///
///
///
///
- public static void GetDimensionMinMaxData(Serie serie, int dimension, int ceilRate = 0, DataZoom dataZoom = null)
+ internal static void UpdateMinMaxData(Serie serie, int dimension, int ceilRate = 0, DataZoom dataZoom = null)
{
- var dataList = serie.GetDataList(dataZoom);
- float max = float.MinValue;
- float min = float.MaxValue;
- for (int i = 0; i < dataList.Count; i++)
- {
- var serieData = dataList[i];
- if (serieData.show && serieData.data.Count > dimension)
- {
- var value = serieData.data[dimension];
- if (value > max) max = value;
- if (value < min) min = value;
- }
- }
+ float min = 0, max = 0;
+ GetMinMaxData(serie, dimension, out min, out max, dataZoom);
if (ceilRate < 0)
{
serie.runtimeDataMin = min;
@@ -299,43 +296,20 @@ namespace XCharts
}
}
- public static void GetAllMinMaxData(Serie serie, int ceilRate = 0, DataZoom dataZoom = null)
+ internal static void GetAllMinMaxData(Serie serie, int ceilRate = 0, DataZoom dataZoom = null)
{
- var dataList = serie.GetDataList(dataZoom);
- float max = float.MinValue;
- float min = float.MaxValue;
- for (int i = 0; i < dataList.Count; i++)
+ float min = 0, max = 0;
+ GetMinMaxData(serie, out min, out max, dataZoom);
+ if (ceilRate < 0)
{
- var serieData = dataList[i];
- if (serieData.show)
- {
- var count = serie.showDataDimension > serieData.data.Count ? serieData.data.Count : serie.showDataDimension;
- for (int j = 0; j < count; j++)
- {
- var value = serieData.data[j];
- if (value > max) max = value;
- if (value < min) min = value;
- }
- }
+ serie.runtimeDataMin = min;
+ serie.runtimeDataMax = max;
}
- serie.runtimeDataMin = ChartHelper.GetMinDivisibleValue(min, ceilRate);
- serie.runtimeDataMax = ChartHelper.GetMaxDivisibleValue(max, ceilRate);
- }
-
- public static bool IsAllZeroValue(Serie serie, int dimension = 1)
- {
- foreach (var serieData in serie.data)
+ else
{
- if (serieData.GetData(dimension) != 0) return false;
+ serie.runtimeDataMin = ChartHelper.GetMinDivisibleValue(min, ceilRate);
+ serie.runtimeDataMax = ChartHelper.GetMaxDivisibleValue(max, ceilRate);
}
- return true;
- }
-
- public static string GetNumericFormatter(Serie serie, SerieData serieData)
- {
- var itemStyle = SerieHelper.GetItemStyle(serie, serieData);
- if (!string.IsNullOrEmpty(itemStyle.numericFormatter)) return itemStyle.numericFormatter;
- else return string.Empty;
}
}
}
\ No newline at end of file
diff --git a/Runtime/Internal/Helper/VisualMapHelper.cs b/Runtime/Internal/Helper/VisualMapHelper.cs
deleted file mode 100644
index 553dd06c..00000000
--- a/Runtime/Internal/Helper/VisualMapHelper.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-/******************************************/
-/* */
-/* Copyright (c) 2018 monitor1394 */
-/* https://github.com/monitor1394 */
-/* */
-/******************************************/
-
-namespace XCharts
-{
- public static class VisualMapHelper
- {
-
- }
-}
\ No newline at end of file
diff --git a/Runtime/PolarChart.cs b/Runtime/PolarChart.cs
index b3886ffa..4c404d12 100644
--- a/Runtime/PolarChart.cs
+++ b/Runtime/PolarChart.cs
@@ -550,7 +550,7 @@ namespace XCharts
case SerieType.Line:
bool refresh = false;
var count = serie.data.Count;
- SerieHelper.GetDimensionMinMaxData(serie, 1, -1);
+ SerieHelper.UpdateMinMaxData(serie, 1, -1);
var diff = (serie.runtimeDataMax - serie.runtimeDataMin) / (count - 1);
for (int j = 0; j < count; j++)
{
diff --git a/Runtime/RadarChart.cs b/Runtime/RadarChart.cs
index 7c19f51e..fd399957 100644
--- a/Runtime/RadarChart.cs
+++ b/Runtime/RadarChart.cs
@@ -375,7 +375,7 @@ namespace XCharts
var pointList = radar.runtimeDataPosList[key];
var startIndex = GetStartShowIndex(serie);
var endIndex = GetEndShowIndex(serie);
- SerieHelper.GetDimensionMinMaxData(serie, 1, radar.ceilRate);
+ SerieHelper.UpdateMinMaxData(serie, 1, radar.ceilRate);
for (int j = 0; j < serie.data.Count; j++)
{
var serieData = serie.data[j];