Compare commits

...

38 Commits

Author SHA1 Message Date
monitor1394
d6c45aaf6b 3.0 2022-03-09 08:23:15 +08:00
monitor1394
115a47a5df 3.0 2022-03-09 08:18:59 +08:00
monitor1394
7582a76d1f 3.0 2022-03-09 07:26:15 +08:00
monitor1394
5745fea9a1 3.0 - optimize code 2022-03-04 22:17:32 +08:00
monitor1394
1ee0df09eb 3.0 - inspector 2022-02-25 08:10:09 +08:00
monitor1394
e72349a69f 3.0 - namespace 2022-02-19 22:37:57 +08:00
monitor1394
ce5aeb2d98 3.0 - guage chart 2022-02-19 17:35:22 +08:00
monitor1394
a19b796a02 3.0 - tooltip 2022-02-12 20:10:29 +08:00
monitor1394
cc4ee3735c 3.0 - polar chart 2022-01-26 20:47:14 +08:00
monitor1394
a32f5f5bcf 3.0 - liquid chart and ring chart 2022-01-22 22:58:55 +08:00
monitor1394
d9840bef52 3.0 - radar chart 2022-01-22 21:08:26 +08:00
monitor1394
a8b2068029 3.0 - scatter chart and candlestick chart 2022-01-16 22:16:33 +08:00
monitor1394
c9addaf02c 3.0 - bar chart 2022-01-13 21:45:59 +08:00
monitor1394
0282dae582 compatibility 2022-01-07 09:48:59 +08:00
monitor1394
228a4b2840 3.0 - unitypackage 2022-01-05 21:40:48 +08:00
monitor1394
c160867765 3.0 - optimize vert 2022-01-05 07:46:30 +08:00
monitor1394
d20f27b610 3.0 - simplified serie 2021-12-31 13:00:17 +08:00
monitor1394
3a41f1e00e 3.0 - serie extra component 2021-12-28 08:18:24 +08:00
monitor1394
90cb25b74f 3.0 - cleanup code 2021-12-24 13:33:09 +08:00
monitor1394
fa3137eb55 3.0 - remove gauge chart to extension 2021-12-24 07:38:10 +08:00
monitor1394
18ed060c67 3.0 - interaction 2021-12-23 13:23:18 +08:00
monitor1394
761ae595c2 3.0 - tooltip 2021-12-19 20:53:55 +08:00
monitor1394
0aa476e757 3.0 - animation 2021-12-12 18:05:26 +08:00
monitor1394
9c69774d35 3.0 - bar chart 2021-12-11 18:26:28 +08:00
monitor1394
081cd4b503 3.0 - serie clone and covert 2021-12-09 21:35:23 +08:00
monitor1394
cd1a36cc18 3.0 - serie data context 2021-12-09 07:12:15 +08:00
monitor1394
6109b62eb7 3.0 - serie context 2021-12-08 13:36:02 +08:00
monitor1394
a5469c0996 3.0 - LineChart 2021-12-08 08:31:32 +08:00
monitor1394
f39cddaa5e 3.0 - ParallelChart 2021-11-28 20:31:41 +08:00
monitor1394
1b3fa7fb43 3.0 commit 2021-11-23 13:20:07 +08:00
monitor1394
d87e0f8267 Fixed the problem of displaying exceptions after adding data again when DataZoom is enable (#163) 2021-08-16 14:47:02 +08:00
monitor1394
3590d1ebbc Improved Axis's AxisLabel text rotate setting to avoid inconsistency offset in DataZoom (#163) 2021-08-15 22:35:27 +08:00
monitor1394
6fae151c8e Added Legend's textAutoColor to set the text color match with Serie color (#163) 2021-08-14 15:05:37 +08:00
monitor1394
92ee57baf8 优化BarChart设置Corner时正负柱条圆角对称 2021-08-12 22:16:00 +08:00
monitor1394
b5098d5682 优化Serie的数据全为0时Y轴不显示的问题 2021-08-03 08:23:23 +08:00
monitor1394
a4963435d7 修复Serie开启ignore时被忽略的数据还会参与计算的问题 (#161) 2021-07-29 08:28:07 +08:00
monitor1394
25972f0382 完善BarChartZebra斑马柱图渐变支持 2021-07-29 08:27:59 +08:00
monitor1394
708b08e701 修复TextMeshPro Enable时找不到XCharts路径的问题 (#160) 2021-07-26 21:29:13 +08:00
992 changed files with 31346 additions and 1746663 deletions

20
.gitignore vendored
View File

@@ -1,26 +1,6 @@
/.vs
/.vscode
.vs
/XCharts-ios
/Library
/Temp
/Logs
/obj
/UnityPackageManager
/Packages
/ProjectSettings/XRSettings.asset
/Assets/Res
/Assets/Res.meta
/Assets/Package
/Assets/Package.meta
/Assets/TextMesh Pro
/Assets/TextMesh Pro.meta
/Doc/*.meta
/Assets/XChartsDemo/demo_test.unity
/Assets/XChartsDemo/demo_test.unity.meta
/Assets/XChartsDemo/empty.unity
/Assets/XChartsDemo/empty.unity.meta
*.sln
*.csproj

View File

@@ -1,10 +0,0 @@
fileFormatVersion: 2
guid: 3e77b3cfd5a4d2646964841d2b14dcb2
folderAsset: yes
timeCreated: 1536101212
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,35 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
namespace XCharts
{
/// <summary>
/// Editor class used to edit UI BarChart.
/// </summary>
[CustomEditor(typeof(BarChart), false)]
public class BarChartEditor : CoordinateChartEditor
{
protected override void OnEnable()
{
base.OnEnable();
if(target == null) return;
m_Chart = (BarChart)target;
}
protected override void OnEndInspectorGUI()
{
base.OnEndInspectorGUI();
if (m_Chart == null && target == null)
{
return;
}
}
}
}

View File

@@ -1,335 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using System.Text;
namespace XCharts
{
/// <summary>
/// Editor class used to edit UI BaseChart.
/// </summary>
[CustomEditor(typeof(BaseChart), false)]
public class BaseChartEditor : Editor
{
#if UNITY_2019_3_OR_NEWER
private const float k_IconWidth = 14;
private const float k_IconGap = 0f;
private const float k_IconXOffset = 10f;
private const float k_IconYOffset = -1.5f;
#else
private const float k_IconWidth = 14;
private const float k_IconGap = 0f;
private const float k_IconXOffset = 4f;
private const float k_IconYOffset = -3f;
#endif
protected BaseChart m_Chart;
protected SerializedProperty m_Script;
protected SerializedProperty m_MultiComponentMode;
protected SerializedProperty m_EnableTextMeshPro;
protected SerializedProperty m_ChartWidth;
protected SerializedProperty m_ChartHeight;
protected SerializedProperty m_Settings;
protected SerializedProperty m_Theme;
protected SerializedProperty m_Background;
protected SerializedProperty m_Titles;
protected SerializedProperty m_Legends;
protected SerializedProperty m_Tooltips;
protected SerializedProperty m_Vessels;
protected SerializedProperty m_Radars;
protected SerializedProperty m_Series;
protected SerializedProperty m_Large;
protected SerializedProperty m_ChartName;
protected SerializedProperty m_DebugMode;
protected float m_DefaultLabelWidth;
protected float m_DefaultFieldWidth;
private int m_SeriesSize;
private Vector2 scrollPos;
private bool m_CheckWarning = false;
private StringBuilder sb = new StringBuilder();
private bool m_BaseFoldout;
private bool m_CustomFoldout;
protected bool m_ShowAllComponent;
protected Dictionary<string, bool> m_Flodouts = new Dictionary<string, bool>();
protected virtual void OnEnable()
{
if (target == null) return;
m_Chart = (BaseChart)target;
m_Script = serializedObject.FindProperty("m_Script");
m_MultiComponentMode = serializedObject.FindProperty("m_MultiComponentMode");
m_EnableTextMeshPro = serializedObject.FindProperty("m_EnableTextMeshPro");
m_ChartName = serializedObject.FindProperty("m_ChartName");
m_ChartWidth = serializedObject.FindProperty("m_ChartWidth");
m_ChartHeight = serializedObject.FindProperty("m_ChartHeight");
m_Theme = serializedObject.FindProperty("m_Theme");
m_Settings = serializedObject.FindProperty("m_Settings");
m_Background = serializedObject.FindProperty("m_Background");
m_Titles = serializedObject.FindProperty("m_Titles");
m_Legends = serializedObject.FindProperty("m_Legends");
m_Tooltips = serializedObject.FindProperty("m_Tooltips");
m_Vessels = serializedObject.FindProperty("m_Vessels");
m_Series = serializedObject.FindProperty("m_Series");
m_Radars = serializedObject.FindProperty("m_Radars");
m_Large = serializedObject.FindProperty("m_Large");
m_DebugMode = serializedObject.FindProperty("m_DebugMode");
}
public override void OnInspectorGUI()
{
if (m_Chart == null && target == null)
{
base.OnInspectorGUI();
return;
}
serializedObject.Update();
m_DefaultLabelWidth = EditorGUIUtility.labelWidth;
m_DefaultFieldWidth = EditorGUIUtility.fieldWidth;
OnStartInspectorGUI();
OnMiddleInspectorGUI();
OnEndInspectorGUI();
OnDebugInspectorGUI();
EditorGUILayout.Space();
serializedObject.ApplyModifiedProperties();
}
protected virtual void OnStartInspectorGUI()
{
BlockStart();
EditorGUILayout.BeginHorizontal();
var version = string.Format("v{0}_{1}", XChartsMgr.version, XChartsMgr.versionDate);
if (m_EnableTextMeshPro.boolValue)
{
version += " TMP";
}
EditorGUILayout.LabelField(version);
if (GUILayout.Button("Github"))
{
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts");
}
EditorGUILayout.EndHorizontal();
BlockEnd();
BlockStart();
m_BaseFoldout = EditorGUILayout.Foldout(m_BaseFoldout, "Base", true);
if (m_BaseFoldout)
{
EditorGUILayout.PropertyField(m_Script);
EditorGUILayout.PropertyField(m_ChartName);
var fileds = m_Chart.GetCustomChartInspectorShowFileds();
if (fileds != null && fileds.Length > 0)
{
foreach (var filed in fileds)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty(filed));
}
}
}
BlockEnd();
BlockField(m_Theme);
BlockField(m_Settings);
BlockField(m_Background);
m_ShowAllComponent = m_MultiComponentMode.boolValue;
BlockListField(m_ShowAllComponent, m_Titles);
BlockListField(m_ShowAllComponent, m_Legends);
BlockListField(m_ShowAllComponent, m_Tooltips);
BlockListField(m_ShowAllComponent, SerieType.Liquid, m_Vessels);
BlockListField(m_ShowAllComponent, SerieType.Radar, m_Radars);
}
protected virtual void OnMiddleInspectorGUI()
{
BlockField(m_Series);
}
protected virtual void OnEndInspectorGUI()
{
}
protected virtual void OnDebugInspectorGUI()
{
BlockStart();
EditorGUILayout.PropertyField(m_DebugMode);
EditorGUILayout.PropertyField(m_MultiComponentMode);
EditorGUILayout.Space();
EditorGUILayout.Space();
MoreDebugInspector();
CheckWarning();
BlockEnd();
}
protected virtual void MoreDebugInspector()
{
}
protected void BlockStart()
{
if (XChartsSettings.editorBlockEnable) EditorGUILayout.BeginVertical(EditorStyles.helpBox);
}
protected void BlockEnd()
{
if (XChartsSettings.editorBlockEnable) EditorGUILayout.EndVertical();
}
protected void BlockField(params SerializedProperty[] props)
{
if (props.Length == 0) return;
BlockStart();
foreach (var prop in props)
EditorGUILayout.PropertyField(prop, true);
BlockEnd();
}
protected void BlockListField(bool all, params SerializedProperty[] props)
{
if (props.Length == 0) return;
BlockStart();
foreach (var prop in props)
{
if (all)
{
var flag = m_Flodouts.ContainsKey(prop.displayName) && m_Flodouts[prop.displayName];
m_Flodouts[prop.displayName] = EditorGUILayout.Foldout(flag, prop.displayName, true);
if (m_Flodouts[prop.displayName])
{
EditorGUI.indentLevel++;
var currRect = EditorGUILayout.GetControlRect(GUILayout.Height(0));
currRect.y -= EditorGUIUtility.singleLineHeight;
var rect1 = new Rect(currRect.width + k_IconXOffset,
currRect.y + k_IconYOffset,
k_IconWidth, EditorGUIUtility.singleLineHeight);
if (GUI.Button(rect1, ChartEditorHelper.Styles.iconAdd, ChartEditorHelper.Styles.invisibleButton))
{
prop.InsertArrayElementAtIndex(prop.arraySize > 0 ? prop.arraySize - 1 : 0);
var chart = prop.GetArrayElementAtIndex(0).serializedObject.targetObject as BaseChart;
serializedObject.ApplyModifiedProperties();
chart.RemoveChartObject();
chart.RefreshAllComponent();
}
for (int i = 0; i < prop.arraySize; i++)
{
EditorGUILayout.PropertyField(prop.GetArrayElementAtIndex(i), true);
currRect = EditorGUILayout.GetControlRect(GUILayout.Height(0));
currRect.y -= EditorGUI.GetPropertyHeight(prop.GetArrayElementAtIndex(i));
rect1 = new Rect(currRect.width + k_IconXOffset,
currRect.y + k_IconYOffset,
k_IconWidth, EditorGUIUtility.singleLineHeight);
var oldColor = GUI.contentColor;
GUI.contentColor = Color.black;
if (GUI.Button(rect1, ChartEditorHelper.Styles.iconRemove, ChartEditorHelper.Styles.invisibleButton))
{
if (prop.arraySize == 1)
{
if (EditorUtility.DisplayDialog("Delete component", "Confirm to delete last component?", "Sure", "Cancel"))
{
var chart = prop.GetArrayElementAtIndex(0).serializedObject.targetObject as BaseChart;
prop.DeleteArrayElementAtIndex(i);
serializedObject.ApplyModifiedProperties();
chart.RemoveChartObject();
chart.RefreshAllComponent();
}
}
else if (i < prop.arraySize && i >= 0)
{
var chart = prop.GetArrayElementAtIndex(0).serializedObject.targetObject as BaseChart;
prop.DeleteArrayElementAtIndex(i);
serializedObject.ApplyModifiedProperties();
chart.RemoveChartObject();
chart.RefreshAllComponent();
}
}
var rect2 = new Rect(currRect.width + k_IconXOffset - k_IconWidth - k_IconGap,
currRect.y + k_IconYOffset,
k_IconWidth, EditorGUIUtility.singleLineHeight);
if (GUI.Button(rect2, ChartEditorHelper.Styles.iconDown, ChartEditorHelper.Styles.invisibleButton))
{
if (i < prop.arraySize - 1) prop.MoveArrayElement(i, i + 1);
}
var rect3 = new Rect(currRect.width + k_IconXOffset - 2 * (k_IconWidth + k_IconGap),
currRect.y + k_IconYOffset,
k_IconWidth, EditorGUIUtility.singleLineHeight);
if (GUI.Button(rect3, ChartEditorHelper.Styles.iconUp, ChartEditorHelper.Styles.invisibleButton))
{
if (i > 0) prop.MoveArrayElement(i, i - 1);
}
GUI.contentColor = oldColor;
}
EditorGUI.indentLevel--;
}
}
else if (prop.arraySize > 0) EditorGUILayout.PropertyField(prop.GetArrayElementAtIndex(0), true);
}
BlockEnd();
}
protected void BlockListField(bool all, SerieType serieType, params SerializedProperty[] props)
{
if (!m_Chart.ContainsSerie(serieType)) return;
BlockListField(all, props);
}
private void CheckWarning()
{
if (GUILayout.Button("Remove All Chart Object"))
{
m_Chart.RemoveChartObject();
}
// if (GUILayout.Button("Check XCharts Update"))
// {
// CheckVersionEditor.ShowWindow();
// }
if (m_CheckWarning)
{
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("Check Warning"))
{
m_CheckWarning = true;
m_Chart.CheckWarning();
}
if (GUILayout.Button("Hide Warning"))
{
m_CheckWarning = false;
}
EditorGUILayout.EndHorizontal();
sb.Length = 0;
sb.AppendFormat("v{0}", XChartsMgr.fullVersion);
if (!string.IsNullOrEmpty(m_Chart.warningInfo))
{
sb.AppendLine();
sb.Append(m_Chart.warningInfo);
}
else
{
sb.AppendLine();
sb.Append("Perfect! No warning!");
}
EditorGUILayout.HelpBox(sb.ToString(), MessageType.Warning);
}
else
{
if (GUILayout.Button("Check warning"))
{
m_CheckWarning = true;
m_Chart.CheckWarning();
}
}
EditorGUILayout.Space();
}
}
}

View File

@@ -1,25 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
namespace XCharts
{
/// <summary>
/// Editor class used to edit UI CandlestickChart.
/// </summary>
[CustomEditor(typeof(CandlestickChart), false)]
public class CandlestickChartEditor : CoordinateChartEditor
{
protected override void OnEnable()
{
base.OnEnable();
if(target == null) return;
m_Chart = (CandlestickChart)target;
}
}
}

View File

@@ -1,63 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts
{
/// <summary>
/// Editor class used to edit UI CoordinateChart.
/// </summary>
[CustomEditor(typeof(CoordinateChart), false)]
public class CoordinateChartEditor : BaseChartEditor
{
protected SerializedProperty m_Grids;
protected SerializedProperty m_MultipleXAxis;
protected SerializedProperty m_XAxes;
protected SerializedProperty m_MultipleYAxis;
protected SerializedProperty m_YAxes;
protected SerializedProperty m_DataZooms;
protected SerializedProperty m_VisualMaps;
protected override void OnEnable()
{
base.OnEnable();
if(target == null) return;
m_Chart = (CoordinateChart)target;
m_Grids = serializedObject.FindProperty("m_Grids");
m_XAxes = serializedObject.FindProperty("m_XAxes");
m_YAxes = serializedObject.FindProperty("m_YAxes");
m_DataZooms = serializedObject.FindProperty("m_DataZooms");
m_VisualMaps = serializedObject.FindProperty("m_VisualMaps");
}
protected override void OnStartInspectorGUI()
{
base.OnStartInspectorGUI();
BlockListField(m_ShowAllComponent, m_DataZooms);
BlockListField(m_ShowAllComponent, m_VisualMaps);
BlockListField(m_ShowAllComponent, m_Grids);
BlockListField(m_ShowAllComponent, m_XAxes);
BlockListField(m_ShowAllComponent, m_YAxes);
}
protected override void MoreDebugInspector()
{
base.MoreDebugInspector();
CovertXYAxis();
}
private void CovertXYAxis()
{
if (GUILayout.Button("Covert XY Axis"))
{
(m_Chart as CoordinateChart).CovertXYAxis(0);
}
}
}
}

View File

@@ -1,25 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
namespace XCharts
{
/// <summary>
/// Editor class used to edit UI GaugeChart.
/// </summary>
[CustomEditor(typeof(GaugeChart), false)]
public class GaugeChartEditor : BaseChartEditor
{
protected override void OnEnable()
{
base.OnEnable();
if(target == null) return;
m_Chart = (GaugeChart)target;
}
}
}

View File

@@ -1,25 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
namespace XCharts
{
/// <summary>
/// Editor class used to edit UI HeatmapChart.
/// </summary>
[CustomEditor(typeof(HeatmapChart), false)]
public class HeatmapChartEditor : CoordinateChartEditor
{
protected override void OnEnable()
{
base.OnEnable();
if(target == null) return;
m_Chart = (HeatmapChart)target;
}
}
}

View File

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

View File

@@ -1,25 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
namespace XCharts
{
/// <summary>
/// Editor class used to edit UI LineChart.
/// </summary>
[CustomEditor(typeof(LineChart), false)]
public class LineChartEditor : CoordinateChartEditor
{
protected override void OnEnable()
{
base.OnEnable();
if(target == null) return;
m_Chart = (LineChart)target;
}
}
}

View File

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

View File

@@ -1,20 +0,0 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
namespace XCharts
{
/// <summary>
/// Editor class used to edit UI LiquidChart.
/// </summary>
[CustomEditor(typeof(LiquidChart), false)]
public class LiquidChartEditor : BaseChartEditor
{
}
}

View File

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

View File

@@ -1,25 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
namespace XCharts
{
/// <summary>
/// Editor class used to edit UI PieChart.
/// </summary>
[CustomEditor(typeof(PieChart), false)]
public class PieChartEditor : BaseChartEditor
{
protected override void OnEnable()
{
base.OnEnable();
if(target == null) return;
m_Chart = (PieChart)target;
}
}
}

View File

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

View File

@@ -1,41 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
namespace XCharts
{
/// <summary>
/// Editor class used to edit UI PolarChart.
/// </summary>
[CustomEditor(typeof(PolarChart), false)]
public class PolarChartEditor : BaseChartEditor
{
protected SerializedProperty m_Polars;
protected SerializedProperty m_RadiusAxes;
protected SerializedProperty m_AngleAxes;
protected override void OnEnable()
{
base.OnEnable();
if(target == null) return;
m_Chart = (PolarChart)target;
m_Polars = serializedObject.FindProperty("m_Polars");
m_RadiusAxes = serializedObject.FindProperty("m_RadiusAxes");
m_AngleAxes = serializedObject.FindProperty("m_AngleAxes");
}
protected override void OnStartInspectorGUI()
{
base.OnStartInspectorGUI();
var showAll = m_MultiComponentMode.boolValue;
BlockListField(showAll, m_Polars);
BlockListField(showAll, m_RadiusAxes);
BlockListField(showAll, m_AngleAxes);
}
}
}

View File

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

View File

@@ -1,188 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(Axis), true)]
public class AxisDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "Axis"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeFoldout(prop, "m_Show"))
{
SerializedProperty m_Type = prop.FindPropertyRelative("m_Type");
SerializedProperty m_LogBase = prop.FindPropertyRelative("m_LogBase");
SerializedProperty m_MinMaxType = prop.FindPropertyRelative("m_MinMaxType");
Axis.AxisType type = (Axis.AxisType)m_Type.enumValueIndex;
var chart = prop.serializedObject.targetObject as BaseChart;
var isPolar = chart is PolarChart;
EditorGUI.indentLevel++;
PropertyField(prop, isPolar ? "m_PolarIndex" : "m_GridIndex");
PropertyField(prop, "m_Type");
PropertyField(prop, "m_Position");
PropertyField(prop, "m_Offset");
if (type == Axis.AxisType.Log)
{
PropertyField(prop, "m_LogBaseE");
EditorGUI.BeginChangeCheck();
PropertyField(prop, "m_LogBase");
if (m_LogBase.floatValue <= 0 || m_LogBase.floatValue == 1)
{
m_LogBase.floatValue = 10;
}
EditorGUI.EndChangeCheck();
}
if (type == Axis.AxisType.Value || type == Axis.AxisType.Time)
{
PropertyField(prop, "m_MinMaxType");
Axis.AxisMinMaxType minMaxType = (Axis.AxisMinMaxType)m_MinMaxType.enumValueIndex;
switch (minMaxType)
{
case Axis.AxisMinMaxType.Default:
break;
case Axis.AxisMinMaxType.MinMax:
break;
case Axis.AxisMinMaxType.Custom:
EditorGUI.indentLevel++;
PropertyField(prop, "m_Min");
PropertyField(prop, "m_Max");
EditorGUI.indentLevel--;
break;
}
PropertyField(prop, "m_CeilRate");
if (type == Axis.AxisType.Value)
{
PropertyField(prop, "m_Inverse");
}
}
PropertyField(prop, "m_SplitNumber");
if (type == Axis.AxisType.Category)
{
PropertyField(prop, "m_InsertDataToHead");
PropertyField(prop, "m_MaxCache");
PropertyField(prop, "m_BoundaryGap");
}
else
{
PropertyField(prop, "m_Interval");
}
DrawExtendeds(prop);
PropertyField(prop, "m_AxisLine");
PropertyField(prop, "m_AxisName");
PropertyField(prop, "m_AxisTick");
PropertyField(prop, "m_AxisLabel");
PropertyField(prop, "m_SplitLine");
PropertyField(prop, "m_SplitArea");
PropertyField(prop, "m_IconStyle");
PropertyListField(prop, "m_Icons", true);
if (type == Axis.AxisType.Category)
{
PropertyListField(prop, "m_Data", true);
}
EditorGUI.indentLevel--;
}
}
}
[CustomPropertyDrawer(typeof(XAxis), true)]
public class XAxisDrawer : AxisDrawer
{
public override string ClassName { get { return "XAxis"; } }
}
[CustomPropertyDrawer(typeof(YAxis), true)]
public class YAxisDrawer : AxisDrawer
{
public override string ClassName { get { return "YAxis"; } }
}
[CustomPropertyDrawer(typeof(AngleAxis), true)]
public class AngleAxisDrawer : AxisDrawer
{
public override string ClassName { get { return "AngleAxis"; } }
protected override void DrawExtendeds(SerializedProperty prop)
{
base.DrawExtendeds(prop);
PropertyField(prop, "m_StartAngle");
PropertyField(prop, "m_Clockwise");
}
}
[CustomPropertyDrawer(typeof(RadiusAxis), true)]
public class RadiusAxisDrawer : AxisDrawer
{
public override string ClassName { get { return "RadiusAxis"; } }
}
[CustomPropertyDrawer(typeof(AxisLabel), true)]
public class AxisLabelDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "AxisLabel"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeFoldout(prop, "m_Show"))
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Inside");
PropertyField(prop, "m_Interval");
PropertyField(prop, "m_Margin");
PropertyField(prop, "m_Width");
PropertyField(prop, "m_Height");
PropertyField(prop, "m_Formatter");
PropertyField(prop, "m_NumericFormatter");
PropertyField(prop, "m_ShowAsPositiveNumber");
PropertyField(prop, "m_OnZero");
PropertyField(prop, "m_ShowStartLabel");
PropertyField(prop, "m_ShowEndLabel");
PropertyField(prop, "m_TextLimit");
PropertyField(prop, "m_TextStyle");
--EditorGUI.indentLevel;
}
}
}
[CustomPropertyDrawer(typeof(AxisName), true)]
public class AxisNameDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "AxisName"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeFoldout(prop, "m_Show"))
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Name");
PropertyField(prop, "m_Location");
PropertyField(prop, "m_TextStyle");
--EditorGUI.indentLevel;
}
}
}
[CustomPropertyDrawer(typeof(AxisSplitArea), true)]
public class AxisSplitAreaDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "SplitArea"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeFoldout(prop, "m_Show"))
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Color");
--EditorGUI.indentLevel;
}
}
}
}

View File

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

View File

@@ -1,31 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(Background), true)]
public class BackgroundDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "Background"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeFoldout(prop, "m_Show"))
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Image");
PropertyField(prop, "m_ImageType");
PropertyField(prop, "m_ImageColor");
PropertyField(prop, "m_HideThemeBackgroundColor");
--EditorGUI.indentLevel;
}
}
}
}

View File

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

View File

@@ -1,72 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(DataZoom), true)]
public class DataZoomDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "DataZoom"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeFoldout(prop, "m_Enable"))
{
var m_SupportInside = prop.FindPropertyRelative("m_SupportInside");
var m_SupportSlider = prop.FindPropertyRelative("m_SupportSlider");
var m_Start = prop.FindPropertyRelative("m_Start");
var m_End = prop.FindPropertyRelative("m_End");
var m_MinShowNum = prop.FindPropertyRelative("m_MinShowNum");
++EditorGUI.indentLevel;
PropertyField(prop, "m_Orient");
PropertyField(prop, "m_SupportInside");
if (m_SupportInside.boolValue)
{
PropertyField(prop, "m_SupportInsideScroll");
PropertyField(prop, "m_SupportInsideDrag");
}
PropertyField(prop, m_SupportSlider);
PropertyField(prop, "m_ZoomLock");
PropertyField(prop, "m_ScrollSensitivity");
PropertyField(prop, "m_RangeMode");
PropertyField(prop, m_Start);
PropertyField(prop, m_End);
PropertyField(prop, m_MinShowNum);
if (m_Start.floatValue < 0) m_Start.floatValue = 0;
if (m_End.floatValue > 100) m_End.floatValue = 100;
if (m_MinShowNum.intValue < 0) m_MinShowNum.intValue = 0;
if (m_SupportSlider.boolValue)
{
PropertyField(prop, "m_ShowDataShadow");
PropertyField(prop, "m_ShowDetail");
PropertyField(prop, "m_BackgroundColor");
PropertyField(prop, "m_BorderWidth");
PropertyField(prop, "m_BorderColor");
PropertyField(prop, "m_FillerColor");
PropertyField(prop, "m_Left");
PropertyField(prop, "m_Right");
PropertyField(prop, "m_Top");
PropertyField(prop, "m_Bottom");
PropertyField(prop, "m_LineStyle");
PropertyField(prop, "m_AreaStyle");
PropertyListField(prop, "m_XAxisIndexs", true);
PropertyListField(prop, "m_YAxisIndexs", true);
PropertyField(prop, "m_TextStyle");
}
else
{
PropertyListField(prop, "m_XAxisIndexs", true);
PropertyListField(prop, "m_YAxisIndexs", true);
}
--EditorGUI.indentLevel;
}
}
}
}

View File

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

View File

@@ -1,70 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(GaugeAxis), true)]
public class GaugeAxisDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "Gauge Axis"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeFoldout(prop, "m_Show"))
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_AxisLine");
PropertyField(prop, "m_SplitLine");
PropertyField(prop, "m_AxisTick");
PropertyField(prop, "m_AxisLabel");
PropertyField(prop, "m_AxisLabelText");
--EditorGUI.indentLevel;
}
}
}
[CustomPropertyDrawer(typeof(StageColor), true)]
public class GaugeAxisLineStageColorDrawer : BasePropertyDrawer
{
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
Rect drawRect = pos;
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty m_Percent = prop.FindPropertyRelative("m_Percent");
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
ChartEditorHelper.MakeTwoField(ref drawRect, drawRect.width, m_Percent, m_Color, "Stage");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
}
}
[CustomPropertyDrawer(typeof(GaugePointer), true)]
public class GaugePointerDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "Gauge Pointer"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeFoldout(prop, "m_Show"))
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Width");
PropertyField(prop, "m_Length");
--EditorGUI.indentLevel;
}
}
}
}

View File

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

View File

@@ -1,32 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(Grid), true)]
public class GridDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "Grid"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeFoldout(prop, "m_Show"))
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Left");
PropertyField(prop, "m_Right");
PropertyField(prop, "m_Top");
PropertyField(prop, "m_Bottom");
PropertyField(prop, "m_BackgroundColor");
--EditorGUI.indentLevel;
}
}
}
}

View File

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

View File

@@ -1,39 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(Legend), true)]
public class LegendDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "Legend"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeFoldout(prop, "m_Show"))
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_IconType");
PropertyField(prop, "m_ItemWidth");
PropertyField(prop, "m_ItemHeight");
PropertyField(prop, "m_ItemGap");
PropertyField(prop, "m_ItemAutoColor");
PropertyField(prop, "m_SelectedMode");
PropertyField(prop, "m_Orient");
PropertyField(prop, "m_Location");
PropertyField(prop, "m_Formatter");
PropertyField(prop, "m_TextStyle");
PropertyListField(prop, "m_Icons");
PropertyListField(prop, "m_Data");
--EditorGUI.indentLevel;
}
}
}
}

View File

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

View File

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

View File

@@ -1,30 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(Polar), true)]
public class PolarDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "Polar"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeFoldout(prop, "m_Show"))
{
++EditorGUI.indentLevel;
PropertyTwoFiled(prop, "m_Center");
PropertyField(prop, "m_Radius");
PropertyField(prop, "m_BackgroundColor");
--EditorGUI.indentLevel;
}
}
}
}

View File

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

View File

@@ -1,58 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(Radar), true)]
public class RadarDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "Radar"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeFoldout(prop, "m_Show"))
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Shape");
PropertyField(prop, "m_PositionType");
PropertyTwoFiled(prop, "m_Center");
PropertyField(prop, "m_Radius");
PropertyField(prop, "m_SplitNumber");
PropertyField(prop, "m_CeilRate");
PropertyField(prop, "m_IsAxisTooltip");
PropertyField(prop, "m_AxisLine");
PropertyField(prop, "m_SplitLine");
PropertyField(prop, "m_SplitArea");
PropertyField(prop, "m_IndicatorList");
--EditorGUI.indentLevel;
}
}
}
[CustomPropertyDrawer(typeof(Radar.Indicator), true)]
public class RadarIndicatorDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "Indicator"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeFoldout(prop, ""))
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Name");
PropertyField(prop, "m_Min");
PropertyField(prop, "m_Max");
PropertyField(prop, "m_TextStyle");
--EditorGUI.indentLevel;
}
}
}
}

View File

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

View File

@@ -1,452 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(Serie), true)]
public class SerieDrawer : BasePropertyDrawer
{
private bool m_IsPolar = false;
private List<bool> m_DataFoldout = new List<bool>();
public override string ClassName { get { return "Serie"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
pos.width -= 9;
base.OnGUI(pos, prop, label);
var chart = prop.serializedObject.targetObject as BaseChart;
var type = prop.FindPropertyRelative("m_Type");
var serieType = (SerieType)type.enumValueIndex;
if (!MakeFoldout(prop, "m_Show"))
{
var orderButton = 48;
var gap = 4;
var drawRect = pos;
drawRect.x += EditorGUIUtility.labelWidth + gap;
drawRect.width = pos.width - drawRect.x + ChartEditorHelper.BOOL_WIDTH - orderButton;
type.enumValueIndex = EditorGUI.Popup(drawRect, (int)serieType, GetChartSerieTypeNames(chart));
}
else
{
m_IsPolar = chart is PolarChart;
++EditorGUI.indentLevel;
type.enumValueIndex = EditorGUI.Popup(m_DrawRect, "Type", (int)serieType, GetChartSerieTypeNames(chart));
var hig = EditorGUI.GetPropertyHeight(prop);
m_DrawRect.y += hig;
m_Heights[m_KeyName] += hig;
PropertyField(prop, "m_InsertDataToHead");
PropertyField(prop, "m_Name");
switch (serieType)
{
case SerieType.Line:
PropertyField(prop, "m_Stack");
if (m_IsPolar)
{
PropertyField(prop, "m_PolarIndex");
}
else
{
PropertyField(prop, "m_XAxisIndex");
PropertyField(prop, "m_YAxisIndex");
}
PropertyFieldLimitMin(prop, "m_MinShow", 0);
PropertyFieldLimitMin(prop, "m_MaxShow", 0);
PropertyFieldLimitMin(prop, "m_MaxCache", 0);
PropertyField(prop, "m_LineType");
PropertyField(prop, "m_SampleDist");
PropertyField(prop, "m_SampleType");
PropertyField(prop, "m_SampleAverage");
PropertyField(prop, "m_Clip");
PropertyField(prop, "m_Ignore");
PropertyField(prop, "m_IgnoreValue");
PropertyField(prop, "m_ShowAsPositiveNumber");
PropertyField(prop, "m_Large");
PropertyField(prop, "m_LargeThreshold");
PropertyField(prop, "m_Symbol");
PropertyField(prop, "m_LineStyle");
PropertyField(prop, "m_LineArrow");
PropertyField(prop, "m_AreaStyle");
PropertyField(prop, "m_MarkLine");
break;
case SerieType.Bar:
PropertyField(prop, "m_Stack");
if (m_IsPolar)
{
PropertyField(prop, "m_PolarIndex");
}
else
{
PropertyField(prop, "m_XAxisIndex");
PropertyField(prop, "m_YAxisIndex");
}
PropertyFieldLimitMin(prop, "m_MinShow", 0);
PropertyFieldLimitMin(prop, "m_MaxShow", 0);
PropertyFieldLimitMin(prop, "m_MaxCache", 0);
PropertyField(prop, "m_BarType");
PropertyField(prop, "m_BarPercentStack");
PropertyField(prop, "m_BarWidth");
PropertyField(prop, "m_BarGap");
PropertyField(prop, "m_BarZebraWidth");
PropertyField(prop, "m_BarZebraGap");
PropertyField(prop, "m_Clip");
PropertyField(prop, "m_Ignore");
PropertyField(prop, "m_IgnoreValue");
PropertyField(prop, "m_ShowAsPositiveNumber");
PropertyField(prop, "m_Large");
PropertyField(prop, "m_LargeThreshold");
PropertyField(prop, "m_MarkLine");
break;
case SerieType.Pie:
PropertyField(prop, "m_RoseType");
PropertyField(prop, "m_Space");
PropertyTwoFiled(prop, "m_Center");
PropertyTwoFiled(prop, "m_Radius");
PropertyField(prop, "m_MinAngle");
PropertyField(prop, "m_RoundCap");
PropertyField(prop, "m_Ignore");
PropertyField(prop, "m_IgnoreValue");
PropertyField(prop, "m_AvoidLabelOverlap");
break;
case SerieType.Ring:
PropertyTwoFiled(prop, "m_Center");
PropertyTwoFiled(prop, "m_Radius");
PropertyField(prop, "m_StartAngle");
PropertyField(prop, "m_RingGap");
PropertyField(prop, "m_RoundCap");
PropertyField(prop, "m_Clockwise");
PropertyField(prop, "m_TitleStyle");
break;
case SerieType.Radar:
PropertyField(prop, "m_RadarType");
PropertyField(prop, "m_RadarIndex");
PropertyField(prop, "m_Symbol");
PropertyField(prop, "m_LineStyle");
PropertyField(prop, "m_AreaStyle");
break;
case SerieType.Scatter:
case SerieType.EffectScatter:
PropertyField(prop, "m_Clip");
PropertyField(prop, "m_Symbol");
break;
case SerieType.Heatmap:
PropertyField(prop, "m_Ignore");
PropertyField(prop, "m_IgnoreValue");
break;
case SerieType.Gauge:
PropertyField(prop, "m_GaugeType");
PropertyTwoFiled(prop, "m_Center");
PropertyTwoFiled(prop, "m_Radius");
PropertyField(prop, "m_Min");
PropertyField(prop, "m_Max");
PropertyField(prop, "m_StartAngle");
PropertyField(prop, "m_EndAngle");
PropertyFieldLimitMax(prop, "m_SplitNumber", 36);
PropertyField(prop, "m_RoundCap");
PropertyField(prop, "m_TitleStyle");
PropertyField(prop, "m_GaugeAxis");
PropertyField(prop, "m_GaugePointer");
break;
case SerieType.Liquid:
PropertyField(prop, "m_VesselIndex");
PropertyField(prop, "m_Min");
PropertyField(prop, "m_Max");
PropertyField(prop, "m_WaveLength");
PropertyField(prop, "m_WaveHeight");
PropertyField(prop, "m_WaveSpeed");
PropertyField(prop, "m_WaveOffset");
break;
case SerieType.Candlestick:
PropertyField(prop, "m_XAxisIndex");
PropertyField(prop, "m_YAxisIndex");
PropertyFieldLimitMin(prop, "m_MinShow", 0);
PropertyFieldLimitMin(prop, "m_MaxShow", 0);
PropertyFieldLimitMin(prop, "m_MaxCache", 0);
PropertyField(prop, "m_BarWidth");
PropertyField(prop, "m_Clip");
PropertyField(prop, "m_ShowAsPositiveNumber");
PropertyField(prop, "m_Large");
PropertyField(prop, "m_LargeThreshold");
break;
case SerieType.Custom:
var fileds = chart.GetCustomSerieInspectorShowFileds();
if (fileds != null && fileds.Length > 0)
{
foreach (var filed in fileds)
{
PropertyField(prop, filed);
}
}
var customs = chart.GetCustomSerieInspectorCustomFileds();
if (customs != null && customs.Length > 0)
{
foreach (var custom in customs)
{
var customProp = prop.FindPropertyRelative(custom[0]);
var anatherName = custom[1] + " (" + customProp.displayName + ")";
EditorGUI.PropertyField(m_DrawRect, customProp, new GUIContent(anatherName));
m_DrawRect.y += EditorGUI.GetPropertyHeight(prop);
m_Heights[m_KeyName] += hig;
}
}
break;
}
PropertyField(prop, "m_ItemStyle");
PropertyField(prop, "m_IconStyle");
PropertyField(prop, "m_Label");
PropertyField(prop, "m_Emphasis");
PropertyField(prop, "m_Animation");
DrawData(pos, prop, serieType, ref m_DrawRect);
--EditorGUI.indentLevel;
}
}
private string[] GetChartSerieTypeNames(BaseChart chart)
{
var list = System.Enum.GetNames(typeof(SerieType));
for (int i = 0; i < list.Length; i++)
{
if (list[i].Equals("Custom"))
{
var customName = chart.GetCustomSerieTypeName();
if (!string.IsNullOrEmpty(customName))
{
list[i] = customName;
}
}
}
return list;
}
private void DrawData(Rect pos, SerializedProperty prop, SerieType serieType, ref Rect drawRect)
{
SerializedProperty m_Datas = prop.FindPropertyRelative("m_Data");
SerializedProperty m_DataDimension = prop.FindPropertyRelative("m_ShowDataDimension");
SerializedProperty m_ShowDataName = prop.FindPropertyRelative("m_ShowDataName");
SerializedProperty m_ShowDataIcon = prop.FindPropertyRelative("m_ShowDataIcon");
int index = InitToggle(prop);
drawRect.width = EditorGUIUtility.labelWidth + 10;
m_DataFoldout[index] = EditorGUI.Foldout(drawRect, m_DataFoldout[index], "Data", true);
drawRect.width = pos.width;
AddSingleLineHeight();
if (m_DataFoldout[index])
{
EditorGUI.indentLevel++;
float nameWid = 45;
#if UNITY_2019_3_OR_NEWER
var gap = 2;
var namegap = 3;
#else
var gap = 0;
var namegap = 0;
#endif
EditorGUI.PropertyField(new Rect(drawRect.x, drawRect.y, pos.width - 2 * nameWid - 2, pos.height),
m_DataDimension);
var nameRect = new Rect(pos.width - 2 * nameWid + 14 + gap, drawRect.y, nameWid - gap, pos.height);
if (XChartsSettings.editorBlockEnable)
{
nameRect.x += ChartEditorHelper.BLOCK_WIDTH;
}
if (GUI.Button(nameRect, new GUIContent("name")))
{
m_ShowDataName.boolValue = !m_ShowDataName.boolValue;
}
var iconRect = new Rect(pos.width - nameWid + 14, drawRect.y, nameWid + namegap, pos.height);
if (XChartsSettings.editorBlockEnable)
{
iconRect.x += ChartEditorHelper.BLOCK_WIDTH;
}
if (GUI.Button(iconRect, new GUIContent("more")))
{
m_ShowDataIcon.boolValue = !m_ShowDataIcon.boolValue;
}
var jsonRect = new Rect(pos.width - 70, drawRect.y - pos.height - 2, 90, pos.height);
if (GUI.Button(jsonRect, new GUIContent("data from json")))
{
PraseJsonDataEditor.chart = prop.serializedObject.targetObject as BaseChart;
PraseJsonDataEditor.serieIndex = index;
PraseJsonDataEditor.ShowWindow();
}
AddSingleLineHeight();
var listSize = m_Datas.arraySize;
listSize = EditorGUI.IntField(drawRect, "Size", listSize);
AddSingleLineHeight();
if (listSize < 0) listSize = 0;
if (m_DataDimension.intValue < 1) m_DataDimension.intValue = 1;
int dimension = m_DataDimension.intValue;
bool showName = m_ShowDataName.boolValue;
bool showIcon = m_ShowDataIcon.boolValue;
bool showSelected = (serieType == SerieType.Pie);
if (listSize != m_Datas.arraySize)
{
while (listSize > m_Datas.arraySize) m_Datas.arraySize++;
while (listSize < m_Datas.arraySize) m_Datas.arraySize--;
}
if (listSize > 30 && !XChartsSettings.editorShowAllListData)
{
int num = listSize > 10 ? 10 : listSize;
for (int i = 0; i < num; i++)
{
DrawDataElement(ref drawRect, dimension, m_Datas, showName, showIcon, showSelected, i, pos.width);
}
if (num >= 10)
{
EditorGUI.LabelField(drawRect, "...");
AddSingleLineHeight();
DrawDataElement(ref drawRect, dimension, m_Datas, showName, showIcon, showSelected, listSize - 1, pos.width);
}
}
else
{
for (int i = 0; i < m_Datas.arraySize; i++)
{
DrawDataElement(ref drawRect, dimension, m_Datas, showName, showIcon, showSelected, i, pos.width);
}
}
AddHeight(EditorGUIUtility.standardVerticalSpacing);
EditorGUI.indentLevel--;
}
}
private void DrawDataElement(ref Rect drawRect, int dimension, SerializedProperty m_Datas, bool showName,
bool showDetail, bool showSelected, int index, float currentWidth)
{
var lastX = drawRect.x;
var lastWid = drawRect.width;
var lastFieldWid = EditorGUIUtility.fieldWidth;
var lastLabelWid = EditorGUIUtility.labelWidth;
var serieData = m_Datas.GetArrayElementAtIndex(index);
var sereName = serieData.FindPropertyRelative("m_Name");
var selected = serieData.FindPropertyRelative("m_Selected");
var data = serieData.FindPropertyRelative("m_Data");
var fieldCount = dimension + (showName ? 1 : 0);
if (fieldCount <= 1)
{
while (2 > data.arraySize)
{
var value = data.arraySize == 0 ? index : 0;
data.arraySize++;
data.GetArrayElementAtIndex(data.arraySize - 1).floatValue = value;
}
SerializedProperty element = data.GetArrayElementAtIndex(1);
if (showSelected)
{
drawRect.width = drawRect.width - 18;
EditorGUI.PropertyField(drawRect, element, new GUIContent("Element " + index));
drawRect.x = currentWidth - 40;
EditorGUI.PropertyField(drawRect, selected, GUIContent.none);
drawRect.x = lastX;
drawRect.width = lastWid;
}
else
{
EditorGUI.PropertyField(drawRect, element, new GUIContent("Element " + index));
}
AddHeight(EditorGUI.GetPropertyHeight(element));
}
else
{
#if UNITY_2019_3_OR_NEWER
var gap = 2;
var namegap = 3;
#else
var gap = 0;
var namegap = 0;
#endif
EditorGUI.LabelField(drawRect, "Element " + index);
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15 + gap;
var dataWidTotal = (currentWidth - (startX + 20.5f + 1));
var dataWid = dataWidTotal / fieldCount;
var xWid = dataWid - 2;
for (int i = 0; i < dimension; i++)
{
var dataCount = i < 1 ? 2 : i + 1;
while (dataCount > data.arraySize)
{
var value = data.arraySize == 0 ? index : 0;
data.arraySize++;
data.GetArrayElementAtIndex(data.arraySize - 1).floatValue = value;
}
drawRect.x = startX + i * xWid;
drawRect.width = dataWid + 40;
SerializedProperty element = data.GetArrayElementAtIndex(dimension <= 1 ? 1 : i);
EditorGUI.PropertyField(drawRect, element, GUIContent.none);
}
if (showName)
{
drawRect.x = startX + (fieldCount - 1) * xWid;
drawRect.width = dataWid + 40 + dimension * namegap;
EditorGUI.PropertyField(drawRect, sereName, GUIContent.none);
}
AddSingleLineHeight();
drawRect.x = lastX;
drawRect.width = lastWid;
EditorGUIUtility.fieldWidth = lastFieldWid;
EditorGUIUtility.labelWidth = lastLabelWid;
}
if (showDetail)
{
EditorGUI.indentLevel += 2;
var m_Ignore = serieData.FindPropertyRelative("m_Ignore");
var m_EnableIcon = serieData.FindPropertyRelative("m_EnableIconStyle");
var m_Icon = serieData.FindPropertyRelative("m_IconStyle");
var m_EnableLabel = serieData.FindPropertyRelative("m_EnableLabel");
var m_Label = serieData.FindPropertyRelative("m_Label");
var m_EnableItemStyle = serieData.FindPropertyRelative("m_EnableItemStyle");
var m_ItemStyle = serieData.FindPropertyRelative("m_ItemStyle");
var m_EnableEmphasis = serieData.FindPropertyRelative("m_EnableEmphasis");
var m_Emphasis = serieData.FindPropertyRelative("m_Emphasis");
var m_EnableSymbol = serieData.FindPropertyRelative("m_EnableSymbol");
var m_Symbol = serieData.FindPropertyRelative("m_Symbol");
EditorGUI.PropertyField(drawRect, m_Ignore);
AddHeight(EditorGUI.GetPropertyHeight(m_Ignore));
EditorGUI.PropertyField(drawRect, m_Icon);
ChartEditorHelper.MakeBool(drawRect, m_EnableIcon, 1, "(enable)");
AddHeight(EditorGUI.GetPropertyHeight(m_Icon));
EditorGUI.PropertyField(drawRect, m_Symbol);
ChartEditorHelper.MakeBool(drawRect, m_EnableSymbol, 1, "(enable)");
AddHeight(EditorGUI.GetPropertyHeight(m_Symbol));
EditorGUI.PropertyField(drawRect, m_Label);
ChartEditorHelper.MakeBool(drawRect, m_EnableLabel, 1, "(enable)");
AddHeight(EditorGUI.GetPropertyHeight(m_Label));
EditorGUI.PropertyField(drawRect, m_ItemStyle);
ChartEditorHelper.MakeBool(drawRect, m_EnableItemStyle, 1, "(enable)");
AddHeight(EditorGUI.GetPropertyHeight(m_ItemStyle));
EditorGUI.PropertyField(drawRect, m_Emphasis);
ChartEditorHelper.MakeBool(drawRect, m_EnableEmphasis, 1, "(enable)");
AddHeight(EditorGUI.GetPropertyHeight(m_Emphasis));
EditorGUI.indentLevel -= 2;
}
}
private int InitToggle(SerializedProperty prop)
{
int index = 0;
var sindex = prop.propertyPath.LastIndexOf('[');
var eindex = prop.propertyPath.LastIndexOf(']');
if (sindex >= 0 && eindex >= 0)
{
var str = prop.propertyPath.Substring(sindex + 1, eindex - sindex - 1);
int.TryParse(str, out index);
}
while (index >= m_DataFoldout.Count)
{
m_DataFoldout.Add(false);
}
return index;
}
}
}

View File

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

View File

@@ -1,48 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(SerieLabel), true)]
public class SerieLabelDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "Label"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeFoldout(prop, "m_Show"))
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Position");
PropertyField(prop, "m_Offset");
PropertyField(prop, "m_AutoOffset");
PropertyField(prop, "m_Margin");
PropertyField(prop, "m_Formatter");
PropertyField(prop, "m_NumericFormatter");
PropertyField(prop, "m_BackgroundWidth");
PropertyField(prop, "m_BackgroundHeight");
PropertyField(prop, "m_PaddingLeftRight");
PropertyField(prop, "m_PaddingTopBottom");
PropertyField(prop, "m_Border");
PropertyField(prop, "m_BorderWidth");
PropertyField(prop, "m_BorderColor");
PropertyField(prop, "m_Line");
PropertyField(prop, "m_LineType");
PropertyField(prop, "m_LineColor");
PropertyField(prop, "m_LineWidth");
PropertyField(prop, "m_LineGap");
PropertyField(prop, "m_LineLength1");
PropertyField(prop, "m_LineLength2");
PropertyField(prop, "m_TextStyle");
--EditorGUI.indentLevel;
}
}
}
}

View File

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

View File

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

View File

@@ -1,43 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(Series), true)]
public class SeriesDrawer : PropertyDrawer
{
private bool m_SeriesModuleToggle = false;
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
Rect drawRect = pos;
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty m_Series = prop.FindPropertyRelative("m_Series");
m_SeriesModuleToggle = ChartEditorHelper.MakeListWithFoldout(ref drawRect,
m_Series, m_SeriesModuleToggle, true, true);
}
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
float height = 0;
if (m_SeriesModuleToggle)
{
SerializedProperty m_Data = prop.FindPropertyRelative("m_Series");
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
for (int i = 0; i < m_Data.arraySize; i++)
{
height += EditorGUI.GetPropertyHeight(m_Data.GetArrayElementAtIndex(i)) + EditorGUIUtility.standardVerticalSpacing;
}
}
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
return height;
}
}
}

View File

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

View File

@@ -1,172 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.IO;
using UnityEditor;
using UnityEngine;
#if dUI_TextMeshPro
using TMPro;
#endif
namespace XCharts
{
[CustomPropertyDrawer(typeof(ChartTheme), true)]
public class ThemeDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "Theme"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
var defaultWidth = pos.width;
var defaultX = pos.x;
var btnWidth = 50;
if (MakeFoldout(prop, ""))
{
var btnRect = new Rect(m_DrawRect);
btnRect.x = defaultX + defaultWidth - 2 * btnWidth - 2;
btnRect.y = m_DrawRect.y - EditorGUIUtility.singleLineHeight - 3;
btnRect.width = btnWidth;
var chart = prop.serializedObject.targetObject as BaseChart;
if (GUI.Button(btnRect, new GUIContent("Reset", "Reset to theme default color")))
{
chart.theme.ResetTheme();
chart.RefreshAllComponent();
}
btnRect.x = defaultX + defaultWidth - btnWidth;
btnRect.width = btnWidth;
if (GUI.Button(btnRect, new GUIContent("Export", "Export theme to asset for a new theme")))
{
ExportThemeWindow.target = chart;
EditorWindow.GetWindow(typeof(ExportThemeWindow));
}
++EditorGUI.indentLevel;
var chartNameList = XThemeMgr.GetAllThemeNames();
var lastIndex = chartNameList.IndexOf(chart.theme.themeName);
var y = pos.y + EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
var selectedIndex = EditorGUI.Popup(new Rect(pos.x, y, pos.width, EditorGUIUtility.singleLineHeight),
"Theme", lastIndex, chartNameList.ToArray());
AddSingleLineHeight();
if (lastIndex != selectedIndex)
{
XThemeMgr.SwitchTheme(chart, chartNameList[selectedIndex]);
}
#if dUI_TextMeshPro
PropertyField(prop, "m_TMPFont");
if(chart.theme.tmpFont == null && !string.IsNullOrEmpty(chart.theme.tmpFontName))
{
var msg = string.Format("Can't find theme font asset:{0} in project.", chart.theme.tmpFontName);
EditorGUILayout.HelpBox(msg, MessageType.Error);
}
#else
PropertyField(prop, "m_Font");
if (chart.theme.font == null && !string.IsNullOrEmpty(chart.theme.fontName))
{
var msg = string.Format("Can't find theme font asset:{0} in project.", chart.theme.fontName);
EditorGUILayout.HelpBox(msg, MessageType.Error);
}
#endif
PropertyField(prop, "m_ContrastColor");
PropertyField(prop, "m_BackgroundColor");
PropertyField(prop, "m_ColorPalette");
PropertyField(prop, "m_Common");
PropertyField(prop, "m_Title");
PropertyField(prop, "m_SubTitle");
PropertyField(prop, "m_Legend");
PropertyField(prop, "m_Axis");
PropertyField(prop, "m_RadiusAxis");
PropertyField(prop, "m_AngleAxis");
PropertyField(prop, "m_Polar");
PropertyField(prop, "m_Gauge");
PropertyField(prop, "m_Radar");
PropertyField(prop, "m_Tooltip");
PropertyField(prop, "m_DataZoom");
PropertyField(prop, "m_VisualMap");
PropertyField(prop, "m_Serie");
--EditorGUI.indentLevel;
}
}
private void AddPropertyField(Rect pos, SerializedProperty prop, ref float y)
{
float height = EditorGUI.GetPropertyHeight(prop, new GUIContent(prop.displayName), true);
EditorGUI.PropertyField(new Rect(pos.x, y, pos.width, height), prop, true);
y += height + EditorGUIUtility.standardVerticalSpacing;
m_Heights[m_KeyName] += height + EditorGUIUtility.standardVerticalSpacing;
}
}
public class ExportThemeWindow : EditorWindow
{
public static BaseChart target;
private static ExportThemeWindow window;
private string m_ChartName;
static void Init()
{
window = (ExportThemeWindow)EditorWindow.GetWindow(typeof(ExportThemeWindow), false, "Export Theme", true);
window.minSize = new Vector2(600, 50);
window.maxSize = new Vector2(600, 50);
window.Show();
}
void OnInspectorUpdate()
{
Repaint();
}
private void OnGUI()
{
if (target == null)
{
Close();
return;
}
GUILayout.Space(10);
GUILayout.Label("Input a new name for theme:");
m_ChartName = GUILayout.TextField(m_ChartName);
GUILayout.Space(10);
GUILayout.Label("Export path:");
if (string.IsNullOrEmpty(m_ChartName))
{
GUILayout.Label("Need input a new name.");
}
else
{
GUILayout.Label(XThemeMgr.GetThemeAssetPath(m_ChartName));
}
GUILayout.Space(20);
if (GUILayout.Button("Export"))
{
if (string.IsNullOrEmpty(m_ChartName))
{
ShowNotification(new GUIContent("ERROR:Need input a new name!"));
}
else if (XThemeMgr.ContainsTheme(m_ChartName))
{
ShowNotification(new GUIContent("ERROR:The name you entered is already in use!"));
}
else if (IsAssetsExist(XThemeMgr.GetThemeAssetPath(m_ChartName)))
{
ShowNotification(new GUIContent("ERROR:The asset is exist! \npath="
+ XThemeMgr.GetThemeAssetPath(m_ChartName)));
}
else
{
XThemeMgr.ExportTheme(target.theme, m_ChartName);
ShowNotification(new GUIContent("SUCCESS:The theme is exported. \npath="
+ XThemeMgr.GetThemeAssetPath(m_ChartName)));
}
}
}
private bool IsAssetsExist(string path)
{
return File.Exists(Application.dataPath + "/../" + path);
}
}
}

View File

@@ -1,33 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(Title), true)]
public class TitleDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "Title"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeFoldout(prop, "m_Show"))
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Text");
PropertyField(prop, "m_SubText");
PropertyField(prop, "m_ItemGap");
PropertyField(prop, "m_Location");
PropertyField(prop, "m_TextStyle");
PropertyField(prop, "m_SubTextStyle");
--EditorGUI.indentLevel;
}
}
}
}

View File

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

View File

@@ -1,43 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(Tooltip), true)]
public class TooltipDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "Tooltip"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeFoldout(prop, "m_Show"))
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Type");
PropertyField(prop, "m_Formatter");
PropertyField(prop, "m_TitleFormatter");
PropertyField(prop, "m_ItemFormatter");
PropertyField(prop, "m_NumericFormatter");
PropertyField(prop, "m_FixedWidth");
PropertyField(prop, "m_FixedHeight");
PropertyField(prop, "m_MinWidth");
PropertyField(prop, "m_MinHeight");
PropertyField(prop, "m_PaddingLeftRight");
PropertyField(prop, "m_PaddingTopBottom");
PropertyField(prop, "m_BackgroundImage");
PropertyField(prop, "m_IgnoreDataDefaultContent");
PropertyField(prop, "m_Offset");
PropertyField(prop, "m_LineStyle");
PropertyField(prop, "m_TextStyle");
--EditorGUI.indentLevel;
}
}
}
}

View File

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

View File

@@ -1,47 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(Vessel), true)]
public class VesselDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "Vessel"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeFoldout(prop, "m_Show"))
{
++EditorGUI.indentLevel;
var shape = (Vessel.Shape)prop.FindPropertyRelative("m_Shape").intValue;
PropertyField(prop, "m_Shape");
PropertyField(prop, "m_ShapeWidth");
PropertyField(prop, "m_Gap");
PropertyTwoFiled(prop, "m_Center");
PropertyField(prop, "m_BackgroundColor");
PropertyField(prop, "m_Color");
PropertyField(prop, "m_AutoColor");
switch (shape)
{
case Vessel.Shape.Circle:
PropertyField(prop, "m_Radius");
PropertyField(prop, "m_Smoothness");
break;
case Vessel.Shape.Rect:
PropertyField(prop, "m_Width");
PropertyField(prop, "m_Height");
PropertyField(prop, "m_CornerRadius");
break;
}
--EditorGUI.indentLevel;
}
}
}
}

View File

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

View File

@@ -1,72 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(VisualMap), true)]
public class VisualMapDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "VisualMap"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeFoldout(prop, "m_Enable"))
{
++EditorGUI.indentLevel;
var type = (VisualMap.Type)prop.FindPropertyRelative("m_Type").enumValueIndex;
var isPiece = type == VisualMap.Type.Piecewise;
PropertyField(prop, "m_Type");
PropertyField(prop, "m_AutoMinMax");
PropertyField(prop, "m_Min");
PropertyField(prop, "m_Max");
PropertyField(prop, "m_SplitNumber");
PropertyField(prop, "m_Dimension");
PropertyListField(prop, "m_OutOfRange");
PropertyListField(prop, isPiece ? "m_Pieces" : "m_InRange");
PropertyField(prop, "m_Show");
if (prop.FindPropertyRelative("m_Show").boolValue)
{
PropertyField(prop, "m_SelectedMode");
PropertyTwoFiled(prop, "m_Range");
PropertyTwoFiled(prop, "m_Text");
PropertyTwoFiled(prop, "m_TextGap");
PropertyField(prop, "m_HoverLink");
PropertyField(prop, "m_Calculable");
PropertyField(prop, "m_ItemWidth");
PropertyField(prop, "m_ItemHeight");
if (isPiece) PropertyField(prop, "m_ItemGap");
PropertyField(prop, "m_BorderWidth");
PropertyField(prop, "m_Orient");
PropertyField(prop, "m_Location");
}
--EditorGUI.indentLevel;
}
}
}
[CustomPropertyDrawer(typeof(VisualMap.Pieces), true)]
public class PiecesDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "Pieces"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeFoldout(prop, ""))
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Min");
PropertyField(prop, "m_Max");
PropertyField(prop, "m_Label");
PropertyField(prop, "m_Color");
--EditorGUI.indentLevel;
}
}
}
}

View File

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

View File

@@ -1,20 +0,0 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
namespace XCharts
{
/// <summary>
/// Editor class used to edit UI RadarChart.
/// </summary>
[CustomEditor(typeof(RadarChart), false)]
public class RadarChartEditor : BaseChartEditor
{
}
}

View File

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

View File

@@ -1,25 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
namespace XCharts
{
/// <summary>
/// Editor class used to edit UI RingChart.
/// </summary>
[CustomEditor(typeof(RingChart), false)]
public class RingChartEditor : BaseChartEditor
{
protected override void OnEnable()
{
base.OnEnable();
if(target == null) return;
m_Chart = (RingChart)target;
}
}
}

View File

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

View File

@@ -1,25 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
namespace XCharts
{
/// <summary>
/// Editor class used to edit UI ScatterChart.
/// </summary>
[CustomEditor(typeof(ScatterChart), false)]
public class ScatterChartEditor : CoordinateChartEditor
{
protected override void OnEnable()
{
base.OnEnable();
if(target == null) return;
m_Chart = (ScatterChart)target;
}
}
}

View File

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

View File

@@ -1,27 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
using UnityEditor.Build;
namespace XCharts
{
[System.Obsolete]
public class XChartsBuild : IPreprocessBuild, IPostprocessBuild
{
public int callbackOrder { get { return 1; } }
public void OnPostprocessBuild(BuildTarget target, string path)
{
}
public void OnPreprocessBuild(BuildTarget target, string path)
{
XThemeMgr.ExportAllCustomTheme();
}
}
}

View File

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

View File

@@ -1,57 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace XCharts
{
public class AddSerieEditor : EditorWindow
{
public static BaseChart chart;
private static AddSerieEditor window;
private static string serieName;
private SerieType serieType;
public static void ShowWindow()
{
serieName = "serie" + (chart.series.Count + 1);
window = GetWindow<AddSerieEditor>();
window.titleContent = new GUIContent("Add Serie");
window.minSize = new Vector2(350, window.minSize.y);
window.Focus();
window.Show();
}
void OnInspectorUpdate()
{
Repaint();
}
private void OnGUI()
{
if (chart == null)
{
Close();
return;
}
var iconRect = new Rect(5, 10, position.width - 10, EditorGUIUtility.singleLineHeight);
serieType = (SerieType)EditorGUI.EnumPopup(iconRect, "Serie Type", serieType);
iconRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
serieName = EditorGUI.TextField(iconRect, "Serie Name", serieName);
iconRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
GUILayout.Space(iconRect.y + 5);
if (GUILayout.Button("Add"))
{
SerieTemplate.AddDefaultSerie(chart, serieType, serieName);
chart.RefreshAllComponent();
}
}
}
}

View File

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

View File

@@ -1,108 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts
{
public class CheckVersionEditor : EditorWindow
{
private Vector2 scrollPos;
private static CheckVersionEditor window;
[MenuItem("XCharts/Upgrade Check")]
public static void ShowWindow()
{
window = GetWindow<CheckVersionEditor>();
window.titleContent = new GUIContent("XCharts Upgrade Check");
window.minSize = new Vector2(550, window.minSize.y);
window.Show();
XChartsMgr.Instance.CheckVersion();
}
void OnInspectorUpdate()
{
Repaint();
}
private void OnGUI()
{
var mgr = XChartsMgr.Instance;
GUILayout.Label("");
GUILayout.Label("The current version: " + mgr.nowVersion);
if (mgr.needUpdate && !mgr.isCheck)
{
GUILayout.Label("The remote version: " + mgr.newVersion);
GUILayout.Label("");
if (mgr.isCheck) GUILayout.Label("check ...");
else if (mgr.isNetworkError) GUILayout.Label("check failed: " + mgr.networkError);
else
{
GUILayout.Label("There is a new version to upgrade!");
}
GUILayout.Label("");
if (!string.IsNullOrEmpty(mgr.desc))
{
GUILayout.Label(mgr.desc);
}
if (GUILayout.Button("Github Homepage"))
{
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts");
}
if (GUILayout.Button("Star Support"))
{
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/stargazers");
}
if (GUILayout.Button("Issues"))
{
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/issues");
}
if (!string.IsNullOrEmpty(mgr.changeLog))
{
scrollPos = GUILayout.BeginScrollView(scrollPos);
GUILayout.TextArea(mgr.changeLog);
GUILayout.EndScrollView();
}
}
else
{
if (mgr.isCheck) GUILayout.Label("The remote version: checking ...");
else if (mgr.isNetworkError) GUILayout.Label("check failed: " + mgr.networkError);
else GUILayout.Label("The remote version: " + mgr.newVersion);
GUILayout.Label("");
if (!mgr.isNetworkError && !mgr.needUpdate && !mgr.isCheck)
{
GUILayout.Label("It is the latest version!");
}
GUILayout.Label("");
if (!string.IsNullOrEmpty(mgr.desc))
{
GUILayout.Label(mgr.desc);
}
if (GUILayout.Button("Github Homepage"))
{
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts");
}
if (GUILayout.Button("Star Support"))
{
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/stargazers");
}
if (GUILayout.Button("Issues"))
{
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/issues");
}
if (mgr.isNetworkError && GUILayout.Button("Check Again"))
{
XChartsMgr.Instance.CheckVersion();
}
}
}
}
}

View File

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

View File

@@ -1,54 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace XCharts
{
public class PraseJsonDataEditor : EditorWindow
{
public static BaseChart chart;
public static int serieIndex;
private static PraseJsonDataEditor window;
private string inputJsonText = "";
public static void ShowWindow()
{
window = GetWindow<PraseJsonDataEditor>();
window.titleContent = new GUIContent("PraseJsonData");
window.minSize = new Vector2(450, 550);
window.Focus();
window.Show();
}
void OnInspectorUpdate()
{
Repaint();
}
private void OnGUI()
{
if (chart == null)
{
Close();
return;
}
EditorGUILayout.LabelField("Input json data, or echarts serie data:");
inputJsonText = EditorGUILayout.TextArea(inputJsonText, GUILayout.Height(400));
if (GUILayout.Button("Add"))
{
var serie = chart.series.GetSerie(serieIndex);
if (serie != null)
{
serie.ParseJsonData(inputJsonText);
}
}
}
}
}

View File

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

View File

@@ -1,62 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts
{
/// <summary>
/// Editor class used to edit UI XChartsMgr.
/// </summary>
[CustomEditor(typeof(XChartsMgr), false)]
public class XChartsMgrEditor : Editor
{
protected XChartsMgr m_Target;
protected SerializedProperty m_Script;
protected SerializedProperty m_NowVersion;
protected SerializedProperty m_NewVersion;
protected virtual void OnEnable()
{
m_Target = (XChartsMgr)target;
m_Script = serializedObject.FindProperty("m_Script");
m_NowVersion = serializedObject.FindProperty("m_NowVersion");
m_NewVersion = serializedObject.FindProperty("m_NewVersion");
}
public override void OnInspectorGUI()
{
if (m_Target == null && target == null)
{
base.OnInspectorGUI();
return;
}
serializedObject.Update();
EditorGUILayout.PropertyField(m_NowVersion);
EditorGUILayout.PropertyField(m_NewVersion);
if (GUILayout.Button("Check Update"))
{
CheckVersionEditor.ShowWindow();
}
if (GUILayout.Button("Github Homepage"))
{
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts");
}
if (GUILayout.Button("Star Support"))
{
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/stargazers");
}
if (GUILayout.Button("Issues"))
{
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/issues");
}
serializedObject.ApplyModifiedProperties();
}
}
}

View File

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

View File

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

View File

@@ -1,51 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
namespace XCharts.Examples
{
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Example13_LineSimple : MonoBehaviour
{
void Awake()
{
var chart = gameObject.GetComponent<LineChart>();
if (chart == null)
{
chart = gameObject.AddComponent<LineChart>();
chart.SetSize(580, 300);//代码动态添加图表需要设置尺寸或直接操作chart.rectTransform
}
chart.title.show = true;
chart.title.text = "Line Simple";
chart.tooltip.show = true;
chart.legend.show = false;
chart.xAxes[0].show = true;
chart.xAxes[1].show = false;
chart.yAxes[0].show = true;
chart.yAxes[1].show = false;
chart.xAxes[0].type = Axis.AxisType.Category;
chart.yAxes[0].type = Axis.AxisType.Value;
chart.xAxes[0].splitNumber = 10;
chart.xAxes[0].boundaryGap = true;
chart.RemoveData();
chart.AddSerie(SerieType.Line);
chart.AddSerie(SerieType.Line);
for (int i = 0; i < 2000; i++)
{
chart.AddXAxisData("x" + i);
chart.AddData(0, Random.Range(10, 20));
chart.AddData(1, Random.Range(10, 20));
}
}
}
}

View File

@@ -1,124 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace XCharts.Examples
{
[DisallowMultipleComponent]
public class Example40_Radar : MonoBehaviour
{
private RadarChart chart;
private Serie serie, serie1;
void Awake()
{
LoopDemo();
}
private void OnEnable()
{
LoopDemo();
}
void LoopDemo()
{
StopAllCoroutines();
StartCoroutine(RadarDemo());
}
IEnumerator RadarDemo()
{
StartCoroutine(RadarAdd());
yield return new WaitForSeconds(2);
StartCoroutine(RadarUpdate());
yield return new WaitForSeconds(2);
StartCoroutine(RadarAddMultiple());
yield return new WaitForSeconds(2);
LoopDemo();
}
IEnumerator RadarAdd()
{
chart = gameObject.GetComponent<RadarChart>();
if (chart == null) chart = gameObject.AddComponent<RadarChart>();
chart.RemoveRadar();
chart.RemoveData();
chart.title.text = "RadarChart - 雷达图";
chart.title.subText = "";
chart.legend.show = true;
chart.legend.location.align = Location.Align.TopLeft;
chart.legend.location.top = 60;
chart.legend.location.left = 2;
chart.legend.itemWidth = 70;
chart.legend.itemHeight = 20;
chart.legend.orient = Orient.Vertical;
chart.AddRadar(Radar.Shape.Polygon, new Vector2(0.5f, 0.4f), 0.4f);
chart.AddIndicator(0, "indicator1", 0, 100);
chart.AddIndicator(0, "indicator2", 0, 100);
chart.AddIndicator(0, "indicator3", 0, 100);
chart.AddIndicator(0, "indicator4", 0, 100);
chart.AddIndicator(0, "indicator5", 0, 100);
serie = chart.AddSerie(SerieType.Radar, "test");
serie.radarIndex = 0;
chart.AddData(0, new List<double> { 10, 20, 60, 40, 20 }, "data1");
chart.AddData(0, new List<double> { 40, 60, 90, 80, 70 }, "data2");
yield return new WaitForSeconds(1);
}
IEnumerator RadarUpdate()
{
chart.UpdateIndicator(0, 0, "new1", 0, 100);
chart.UpdateData(0, 0, new List<double> { 15, 30, 50, 60, 50 });
chart.UpdateDataName(0, 0, "new1");
yield return new WaitForSeconds(1);
}
IEnumerator RadarAddMultiple()
{
chart.RemoveRadar();
chart.RemoveData();
chart.title.text = "RadarChart - 多雷达图";
chart.title.subText = "";
chart.legend.show = true;
chart.legend.location.align = Location.Align.TopLeft;
chart.legend.location.top = 60;
chart.legend.location.left = 2;
chart.legend.itemWidth = 70;
chart.legend.itemHeight = 20;
chart.legend.orient = Orient.Vertical;
chart.AddRadar(Radar.Shape.Polygon, new Vector2(0.25f, 0.4f), 0.25f);
for (int i = 1; i <= 5; i++)
{
chart.AddIndicator(0, "radar1" + i, 0, 100);
}
chart.AddRadar(Radar.Shape.Circle, new Vector2(0.75f, 0.4f), 0.25f);
for (int i = 1; i <= 5; i++)
{
chart.AddIndicator(1, "radar2" + i, 0, 100);
}
serie = chart.AddSerie(SerieType.Radar, "test1");
serie.radarIndex = 0;
chart.AddData(0, new List<double> { 10, 20, 60, 40, 20 }, "data1");
serie1 = chart.AddSerie(SerieType.Radar, "test2");
serie1.radarIndex = 1;
chart.AddData(1, new List<double> { 10, 20, 60, 40, 20 }, "data2");
yield return new WaitForSeconds(1);
}
}
}

View File

@@ -1,70 +0,0 @@
using System.Runtime.InteropServices;
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
namespace XCharts.Examples
{
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Example70_Gauge : MonoBehaviour
{
private GaugeChart chart;
private float updateTime;
void Awake()
{
chart = gameObject.GetComponent<GaugeChart>();
if (chart == null)
{
chart = gameObject.AddComponent<GaugeChart>();
}
chart.title.text = "GaugeChart";
chart.RemoveData();
var serie = chart.AddSerie(SerieType.Gauge, "速度");
serie.min = 0;
serie.max = 220;
serie.startAngle = -125;
serie.endAngle = 125;
serie.center[0] = 0.5f;
serie.center[1] = 0.5f;
serie.radius[0] = 80;
serie.splitNumber = 5;
serie.animation.dataChangeEnable = true;
serie.roundCap = true;
serie.titleStyle.show = true;
serie.titleStyle.textStyle.offset = new Vector2(0, 20);
serie.label.show = true;
serie.label.offset = new Vector3(0, -20);
serie.gaugeAxis.show = true;
serie.gaugeAxis.axisLine.lineStyle.width = 15;
serie.gaugePointer.show = true;
serie.gaugePointer.width = 15;
var value = UnityEngine.Random.Range(serie.min, serie.max);
chart.AddData(0, value, "km/h");
}
void Update()
{
updateTime += Time.deltaTime;
if (updateTime > 2)
{
updateTime = 0;
var value = UnityEngine.Random.Range(0, 220);
chart.UpdateData(0, 0, value);
}
}
}
}

View File

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

View File

@@ -1,57 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
namespace XCharts.Examples
{
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Example80_Polar : MonoBehaviour
{
private PolarChart chart;
private float updateTime;
void Awake()
{
chart = gameObject.GetComponent<PolarChart>();
if (chart == null)
{
chart = gameObject.AddComponent<PolarChart>();
}
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
AddData();
}
}
void AddData()
{
chart.RemoveData();
chart.tooltip.type = Tooltip.Type.Corss;
chart.angleAxis.type = Axis.AxisType.Value;
chart.angleAxis.minMaxType = Axis.AxisMinMaxType.Custom;
chart.angleAxis.min = 0;
chart.angleAxis.max = 360;
chart.angleAxis.startAngle = Random.Range(0, 90);
chart.AddSerie(SerieType.Line, "line1");
var rate = Random.Range(1, 4);
for (int i = 0; i <= 360; i++)
{
var t = i / 180f * Mathf.PI;
var r = Mathf.Sin(2 * t) * Mathf.Cos(2 * t) * rate;
chart.AddData(0, Mathf.Abs(r), i);
}
}
}
}

View File

@@ -1,54 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
namespace XCharts.Examples
{
[DisallowMultipleComponent]
[ExecuteInEditMode]
[RequireComponent(typeof(CoordinateChart))]
public class Example_LargeData : MonoBehaviour
{
public int maxCacheDataNumber = 3000;
public float initDataTime = 5;
private CoordinateChart chart;
private float initTime;
private int initCount = 0;
private System.DateTime timeNow;
void Awake()
{
chart = gameObject.GetComponentInChildren<CoordinateChart>();
timeNow = System.DateTime.Now;
chart.ClearAxisData();
chart.series.ClearData();
chart.SetMaxCache(maxCacheDataNumber);
chart.title.text = maxCacheDataNumber + "数据";
}
private void Update()
{
if (initCount < maxCacheDataNumber)
{
for (int i = 0; i < 10; i++)
{
initCount++;
if (initCount > maxCacheDataNumber) break;
chart.title.text = initCount + "数据";
timeNow = timeNow.AddSeconds(1);
float xvalue = Mathf.PI / 180 * initCount;
float yvalue = Mathf.Sin(xvalue);
chart.AddData(0, 15 + yvalue * 2);
chart.AddXAxisData(timeNow.ToString("hh:mm:ss"));
}
}
}
}
}

View File

@@ -1,58 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
using UnityEngine.UI;
namespace XCharts.Examples
{
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Example_Test : MonoBehaviour
{
LineChart chart;
void Awake()
{
chart = gameObject.GetComponent<LineChart>();
var btnTrans = transform.parent.Find("Button");
if (btnTrans)
{
btnTrans.gameObject.GetComponent<Button>().onClick.AddListener(OnTestBtn);
}
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
//AddData();
OnTestBtn();
}
}
void OnTestBtn()
{
int index = Random.Range(0, chart.series.Count);
var serie = chart.series.GetSerie(index);
chart.UpdateData(index, Random.Range(0, serie.dataCount), Random.Range(50, 100));
}
void AddData()
{
chart.ClearData();
int count = Random.Range(5, 100);
for (int i = 0; i < count; i++)
{
(chart as CoordinateChart).AddXAxisData("x" + i);
if (Random.Range(1, 3) == 2)
chart.AddData(0, Random.Range(-110, 200));
else
chart.AddData(0, Random.Range(-100, 100));
}
}
}
}

View File

@@ -1,210 +0,0 @@
<p align="center">
<a href="">
<img src="" alt="" width="" height="">
</a>
</p>
<h2 align="center">XCharts</h3>
<p align="center">
A powerful, easy-to-use, configurable charting and data visualization library for Unity.
<br>
一款基于UGUI的数据可视化图表插件。
<br>
</p>
<p align="center">
<a href="https://github.com/monitor1394/unity-ugui-XCharts/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/monitor1394/unity-ugui-XCharts">
</a>
<a href="https://github.com/monitor1394/unity-ugui-XCharts/releases">
<img src="https://img.shields.io/github/v/release/monitor1394/unity-ugui-XCharts?include_prereleases">
</a>
<a href="">
<img src="https://img.shields.io/github/languages/code-size/monitor1394/unity-ugui-xcharts">
</a>
<a href="https://www.npmjs.org/package/unity-ugui-xcharts">
<img src="https://img.shields.io/npm/dm/unity-ugui-xcharts?label=npm%20downloads%20">
</a>
<a href="">
<img src="https://img.shields.io/badge/Unity-5.6+-green">
</a>
<a href="">
<img src="https://img.shields.io/badge/TextMeshPro-YES-green">
</a>
</p>
<p align="center">
<a href="">
<img src="https://img.shields.io/github/stars/monitor1394/unity-ugui-XCharts?style=social">
</a>
<a href="">
<img src="https://img.shields.io/github/forks/monitor1394/unity-ugui-XCharts?style=social">
</a>
<a href="">
<img src="https://img.shields.io/github/issues-closed/monitor1394/unity-ugui-XCharts?color=green&label=%20%20%20%20issues&logoColor=green&style=social">
</a>
</p>
A powerful, easy-to-use, configurable charting and data visualization library for Unity. Supporting line, bar, pie, radar, scatter, heatmap, gauge, ring, polar, liquid and other common chart.
[XCharts Homepage](https://github.com/monitor1394/unity-ugui-XCharts)
[XCharts Q&A](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/xcharts-questions-and-answers-EN.md)
[XCharts API](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/xcharts-api-EN.md)
[XCharts Configuration](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/xcharts-configuration-EN.md)
[XCharts Changelog](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/CHANGELOG-EN.md)
[Tutorial - Get start with XCharts in 5 minute](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/tutorial--get-start-with-xcharts-in-5-minute-EN.md)
## XCharts 2.0
* Underlevel reconstruction, layered rendering, optimized scalability, support more data.
* Support for multi-component patterns.
* Support for any combination of most charts.
* Support theme customization, import and export, and more theme configuration parameters.
* Support global adjustment of configuration parameters.
* Added support for `TextMeshPro`.
* Added `CandlestickChart`.
* __ Note:__ `2.0` has undergone a lot of refactoring and adjustments and is not fully compatible with version `1.0`, so `1.0` should not be directly upgraded to `2.0`. Some parameter Settings may be reset to default values after upgrading.
## Features
* Rich built-in examples and templates, parameter visualization configuration, effect real-time preview, pure code drawing.
* Support line, bar, pie, radar, scatter, heatmaps, gauge, ring, polar, liquid and other common chart.
* Support line graph, curve graph, area graph, step graph and other LineChart.
* Support parallel bar, stack bar, stack percentage bar, zebra bar and other BarChart.
* Support ring, rose and other PieChart.
* Support line-bar chart, scatter-line chart and other combination chart.
* Support solid line, curve, ladder line, dotted line, dash line, dot line, double dot line and other lines.
* Support custom theme, built-in theme switching.
* Support custom chart content drawing, drawing points, line, curve, triangle, quadrilateral, circle, ring, sector, border, arrow and other drawing API.
* Support interactive operations such as data filtering, view zooming and detail display on PC and mobile terminals.
* Support 10,000-level big data rendering.
## Screenshot
![linechart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-line.png)
![barchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-bar.png)
![piechart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-pie.png)
![radarchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-radar.png)
![scatterchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-scatter.png)
![heatmapchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-heatmap.png)
![gaugechart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-gauge.png)
![ringchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-ring.png)
![polarchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-polar.png)
![liquidchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-liquid.png)
![combinations](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-combinations.png)
## Cheat Sheet
![cheatsheet](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-cheatsheet.gif)
`XCharts` consist of components and data. Different components and data can be combined into different types of charts. The component is divided into main component and sub component. The main component contains the sub components.
`XCharts` main components:
* `Theme` theme component, which can configure the default colors, fonts and so on.
* `Title` title component, which contains the main title and subtitle.
* `Legend` legend component, which represent different sets of symbols, colors, and names. You can control which series are not displayed by clicking on the legend.
* `Grid` grid component, drawing grid in rectangular coordinate system. Up to two X axes and two Y axes can be placed within a grid component. You can draw line, bar and scatter chart on the grid.
* `Axis` axis component, the axis of a rectangular coordinate system. Supports the upper and lower X axes and the left and right Y axes.
* `Series` series component, a list of serie. A chart can contain many different series, and each series determines its own chart type by type.
* `Tooltip` tooltip component, feedback more details of the data indicated by the mouse at the time.
* `DataZoom` data zoom component, used for area zooming so you can focus on detailed data information, or overview the data as a whole, or remove the impact of outliers.
* `VisualMap` visual mapping component, you can map data in different colors.
* `Radar` radar component, suitable for radar chart only.
* `Settings` global Settings component, Some global parameters can be adjusted. Use the default values in general and adjust them as needed.
`XCharts` support chart:
* `LineChart`
* `BarChart`
* `PieChart`
* `RadarChart`
* `ScatterChart`
* `HeatmapChart`
* `GuageChart`
* `RingChart`
* `PolarChart`
* `LiquidChart`
The following is the relationship structure of LineChart:
``` js
.
├── LineChart
. ├── ThemeInfo
├── Title
│ └── Location
├── Legend
│ └── Location
├── Tooltip
├── DataZoom
├── VisualMap
├── Grid
├── Axis
│ ├── AxisLine
│ ├── AxisName
│ ├── AxisLabel
│ ├── AxisTick
│ └── AxisSplitArea
├── Series
│ ├── ItemStyle
│ ├── AreaStyle
│ ├── SerieSymbol
│ ├── LineStyle
│ ├── LineArrow
│ ├── SerieLabel
│ ├── Emphasis
│ ├── Animation
│ └── SerieData
└── Settings
```
## Environment
* Unity2017.4.27f1
* .Net 3.5
* macOS 10.15.4
## Usage
* This project was developed under `Unity 2017.4.27f1` and `.net 3.5`, tested normally on `Unity 5`, `Unity 2018` and `Unity 2019`. It can theoretically run on any version that supports `UGUI`.
* Download the source code or `unitypackage` to import into your project. If `Unity` version are `2018.3` or above, it is recommended to import packages through `Package Manager`:
1. Open the `manifest.json` file under `Packages` directory and add under `dependencies`:
``` json
"com.monitor1394.xcharts": "https://github.com/monitor1394/unity-ugui-XCharts.git#2.0-upm",
```
2. Going back to `Unity`, it may take 3 to 5 minutes to download.
3. If you want to delete `XCharts`, just delete the content added in step 1.
4. If you want to update `XCharts`, open `manifest.json` file , delete the content about `com.monitor1394.xcharts` under `lock`, it will download anagain. Also can check For update in `components-> XCharts -> Check For Update`.
* Add a chart in Editor quickly:
1. In `Hierarchy`, right-click menu `XChart->LineChart`.
2. In unity menu bar, `Component->XCharts->LineChart`.
3. In `Inspector`,`Add Component->LineChart`.
4. Then a simple line chart is done.
5. In `Inspector` you can adjust the parameters of components, and in `Game` will feedback the adjustment effect in realtime 。the detail of parameters go to see: [XCharts Configuration](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/xcharts-configuration-EN.md).
* See more examples of code dynamic control: [Tutorial - Get start with XCharts in 5 minute](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/tutorial--get-start-with-xcharts-in-5-minute-EN.md).
* Enable TextMeshPro:
1. `XCharts -> TextMeshPro Enable` or `Project Setting -> XCharts -> Enable TextMeshPro`
2. `Project Setting -> XCharts -> Settings -> TMP Font` set the TextMeshPro font.
3. If the chart does not initialize properly, you can use the `Remove All Chart Object` button to clean up the chart and reinitialize it.
## Documents
* [XCharts Homepage](https://github.com/monitor1394/unity-ugui-XCharts)
* [XCharts Q&A](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/xcharts-questions-and-answers-EN.md)
* [XCharts API](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/xcharts-api-EN.md)
* [XCharts Configuration](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/xcharts-configuration-EN.md)
* [XCharts Changelog](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/CHANGELOG-EN.md)
* [XCharts Tutorial: Get start with XCharts in 5 minute](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/tutorial--get-start-with-xcharts-in-5-minute-EN.md)
## Changelog
[XCharts Changelog](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/CHANGELOG.md)
## Licenses
[MIT License](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/LICENSE.md)
## Contact
gmail: monitor1394@gmail.com

View File

@@ -1,22 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
using System;
using UnityEngine.EventSystems;
namespace XCharts
{
public partial class BarChart
{
/// <summary>
/// the callback function of click bar.
/// 点击柱形图柱条回调。参数eventData, dataIndex
/// </summary>
public Action<PointerEventData, int> onPointerClickBar { set { m_OnPointerClickBar = value; m_ForceOpenRaycastTarget = true; } }
}
}

View File

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

View File

@@ -1,833 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
using System.Collections.Generic;
using System;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using System.Text;
namespace XCharts
{
/// <summary>
/// The base class of all charts.
/// 所有Chart的基类。
/// </summary>
public partial class BaseChart
{
/// <summary>
/// The name of chart.
/// </summary>
public string chartName
{
get { return m_ChartName; }
set
{
if (!string.IsNullOrEmpty(value) && XChartsMgr.Instance.ContainsChart(value))
{
Debug.LogError("chartName repeated:" + value);
}
else
{
m_ChartName = value;
}
}
}
/// <summary>
/// The theme.
/// </summary>
public ChartTheme theme { get { return m_Theme; } set { m_Theme = value; } }
/// <summary>
/// The title setting of chart.
/// 标题组件
/// </summary>
public Title title { get { return m_Titles.Count > 0 ? m_Titles[0] : null; } }
public List<Title> titles { get { return m_Titles; } }
/// <summary>
/// The legend setting of chart.
/// 图例组件
/// </summary>
public Legend legend { get { return m_Legends.Count > 0 ? m_Legends[0] : null; } }
public List<Legend> legends { get { return m_Legends; } }
/// <summary>
/// The tooltip setting of chart.
/// 提示框组件
/// </summary>
public Tooltip tooltip { get { return m_Tooltips.Count > 0 ? m_Tooltips[0] : null; } }
/// <summary>
/// The series setting of chart.
/// 系列列表
/// </summary>
public Series series { get { return m_Series; } }
/// <summary>
/// Global parameter setting component.
/// 全局设置组件。
/// </summary>
public Settings settings { get { return m_Settings; } }
/// <summary>
/// dataZoom component.
/// 区域缩放组件。
/// </summary>
public DataZoom dataZoom { get { return m_DataZooms.Count > 0 ? m_DataZooms[0] : null; } }
public List<DataZoom> dataZooms { get { return m_DataZooms; } }
/// <summary>
/// visualMap component.
/// 视觉映射组件。
/// </summary>
public VisualMap visualMap { get { return m_VisualMaps.Count > 0 ? m_VisualMaps[0] : null; } }
public List<VisualMap> visualMaps { get { return m_VisualMaps; } }
/// <summary>
/// The x of chart.
/// 图表的X
/// </summary>
public float chartX { get { return m_ChartX; } }
/// <summary>
/// The y of chart.
/// 图表的Y
/// </summary>
public float chartY { get { return m_ChartY; } }
/// <summary>
/// The width of chart.
/// 图表的宽
/// </summary>
public float chartWidth { get { return m_ChartWidth; } }
/// <summary>
/// The height of chart.
/// 图表的高
/// </summary>
public float chartHeight { get { return m_ChartHeight; } }
public Vector2 chartMinAnchor { get { return m_ChartMinAnchor; } }
public Vector2 chartMaxAnchor { get { return m_ChartMaxAnchor; } }
public Vector2 chartPivot { get { return m_ChartPivot; } }
public Vector2 chartSizeDelta { get { return m_ChartSizeDelta; } }
/// <summary>
/// The position of chart.
/// 图表的左下角起始坐标。
/// </summary>
public Vector3 chartPosition { get { return m_ChartPosition; } }
public Rect chartRect { get { return m_ChartRect; } }
/// <summary>
/// 自定义绘制回调。在绘制Serie前调用。
/// </summary>
public Action<VertexHelper> onCustomDraw { set { m_OnCustomDrawBaseCallback = value; } }
/// <summary>
/// 自定义Serie绘制回调。在每个Serie绘制完前调用。
/// </summary>
public Action<VertexHelper, Serie> onCustomDrawBeforeSerie { set { m_OnCustomDrawSerieBeforeCallback = value; } }
/// <summary>
/// 自定义Serie绘制回调。在每个Serie绘制完后调用。
/// </summary>
public Action<VertexHelper, Serie> onCustomDrawAfterSerie { set { m_OnCustomDrawSerieAfterCallback = value; } }
/// <summary>
/// 自定义Top绘制回调。在绘制Tooltip前调用。
/// </summary>
public Action<VertexHelper> onCustomDrawTop { set { m_OnCustomDrawTopCallback = value; } }
/// <summary>
/// the callback function of click pie area.
/// 点击饼图区域回调。参数PointerEventDataSerieIndexSerieDataIndex
/// </summary>
public Action<PointerEventData, int, int> onPointerClickPie { set { m_OnPointerClickPie = value; m_ForceOpenRaycastTarget = true; } get { return m_OnPointerClickPie; } }
/// <summary>
/// Redraw chart in next frame.
/// 在下一帧刷新图表。
/// </summary>
public void RefreshChart()
{
m_RefreshChart = true;
if (m_Painter) m_Painter.Refresh();
}
/// <summary>
/// Remove all series and legend data.
/// It just emptying all of serie's data without emptying the list of series.
/// 清除所有数据,系列中只是移除数据,列表会保留。
/// </summary>
public virtual void ClearData()
{
m_Series.ClearData();
foreach (var legend in m_Legends) legend.ClearData();
tooltip.ClearValue();
m_CheckAnimation = false;
m_ReinitLabel = true;
RefreshChart();
}
/// <summary>
/// Remove all data from series and legend.
/// The series list is also cleared.
/// 清除所有系列和图例数据,系列的列表也会被清除。
/// </summary>
public virtual void RemoveData()
{
foreach (var legend in m_Legends) legend.ClearData();
foreach (var radar in m_Radars) radar.indicatorList.Clear();
m_Series.RemoveAll();
tooltip.ClearValue();
m_CheckAnimation = false;
m_ReinitLabel = true;
m_SerieLabelRoot = null;
RefreshChart();
}
/// <summary>
/// Remove legend and serie by name.
/// 清除指定系列名称的数据。
/// </summary>
/// <param name="serieName">the name of serie</param>
public virtual void RemoveData(string serieName)
{
m_Series.RemoveSerie(serieName);
foreach (var legend in m_Legends) legend.RemoveData(serieName);
m_SerieLabelRoot = null;
RefreshChart();
}
/// <summary>
/// Add a serie to serie list.
/// 添加一个系列到系列列表中。
/// </summary>
/// <param name="serieName">the name of serie</param>
/// <param name="type">the type of serie</param>
/// <param name="show">whether to show this serie</param>
/// <returns>the added serie</returns>
public virtual Serie AddSerie(SerieType type, string serieName = null, bool show = true, bool addToHead = false)
{
return m_Series.AddSerie(type, serieName, show, addToHead);
}
/// <summary>
/// Add a serie to serie list.
/// 通过字符串类型的serieType添加一个系列到系列列表中。如果serieType不是已定义的SerieType类型则设置为Custom类型。
/// </summary>
/// <param name="serieType"></param>
/// <param name="serieName"></param>
/// <param name="show"></param>
/// <returns></returns>
public virtual Serie AddSerie(string serieType, string serieName = null, bool show = true, bool addToHead = false)
{
var type = SerieType.Custom;
var list = Enum.GetNames(typeof(SerieType));
foreach (var t in list)
{
if (t.Equals(serieType)) type = (SerieType)Enum.Parse(typeof(SerieType), t);
}
return AddSerie(type, serieName, show, addToHead);
}
public virtual Serie InsertSerie(int index, SerieType serieType, string serieName = null, bool show = true)
{
return m_Series.InsertSerie(index, serieType, serieName, show);
}
/// <summary>
/// Add a data to serie.
/// If serieName doesn't exist in legend,will be add to legend.
/// 添加一个数据到指定的系列中。
/// </summary>
/// <param name="serieName">the name of serie</param>
/// <param name="data">the data to add</param>
/// <param name="dataName">the name of data</param>
/// <returns>Returns True on success</returns>
public virtual SerieData AddData(string serieName, double data, string dataName = null)
{
var serieData = m_Series.AddData(serieName, data, dataName);
if (serieData != null)
{
var serie = m_Series.GetSerie(serieName);
if (SerieHelper.GetSerieLabel(serie, serieData).show)
{
RefreshLabel();
}
RefreshPainter(serie);
}
return serieData;
}
/// <summary>
/// Add a data to serie.
/// 添加一个数据到指定的系列中。
/// </summary>
/// <param name="serieIndex">the index of serie</param>
/// <param name="data">the data to add</param>
/// <param name="dataName">the name of data</param>
/// <returns>Returns True on success</returns>
public virtual SerieData AddData(int serieIndex, double data, string dataName = null)
{
var serieData = m_Series.AddData(serieIndex, data, dataName);
if (serieData != null)
{
var serie = m_Series.GetSerie(serieIndex);
if (SerieHelper.GetSerieLabel(serie, serieData).show)
{
RefreshLabel();
}
RefreshPainter(serie);
}
return serieData;
}
/// <summary>
/// Add an arbitray dimension data to serie,such as (x,y,z,...).
/// 添加多维数据x,y,z...)到指定的系列中。
/// </summary>
/// <param name="serieName">the name of serie</param>
/// <param name="multidimensionalData">the (x,y,z,...) data</param>
/// <param name="dataName">the name of data</param>
/// <returns>Returns True on success</returns>
public virtual SerieData AddData(string serieName, List<double> multidimensionalData, string dataName = null)
{
var serieData = m_Series.AddData(serieName, multidimensionalData, dataName);
if (serieData != null)
{
var serie = m_Series.GetSerie(serieName);
if (SerieHelper.GetSerieLabel(serie, serieData).show)
{
RefreshLabel();
}
RefreshPainter(serie);
}
return serieData;
}
/// <summary>
/// Add an arbitray dimension data to serie,such as (x,y,z,...).
/// 添加多维数据x,y,z...)到指定的系列中。
/// </summary>
/// <param name="serieIndex">the index of serie,index starts at 0</param>
/// <param name="multidimensionalData">the (x,y,z,...) data</param>
/// <param name="dataName">the name of data</param>
/// <returns>Returns True on success</returns>
public virtual SerieData AddData(int serieIndex, List<double> multidimensionalData, string dataName = null)
{
var serieData = m_Series.AddData(serieIndex, multidimensionalData, dataName);
if (serieData != null)
{
var serie = m_Series.GetSerie(serieIndex);
if (SerieHelper.GetSerieLabel(serie, serieData).show)
{
RefreshLabel();
}
RefreshPainter(serie);
}
return serieData;
}
/// <summary>
/// Add a (x,y) data to serie.
/// 添加x,y数据到指定系列中。
/// </summary>
/// <param name="serieName">the name of serie</param>
/// <param name="xValue">x data</param>
/// <param name="yValue">y data</param>
/// <param name="dataName">the name of data</param>
/// <returns>Returns True on success</returns>
public virtual SerieData AddData(string serieName, double xValue, double yValue, string dataName = null)
{
var serieData = m_Series.AddXYData(serieName, xValue, yValue, dataName);
if (serieData != null)
{
var serie = m_Series.GetSerie(serieName);
if (SerieHelper.GetSerieLabel(serie, serieData).show)
{
RefreshLabel();
}
RefreshPainter(serie);
}
return serieData;
}
/// <summary>
/// Add a (x,y) data to serie.
/// 添加x,y数据到指定系列中。
/// </summary>
/// <param name="serieIndex">the index of serie</param>
/// <param name="xValue">x data</param>
/// <param name="yValue">y data</param>
/// <param name="dataName">the name of data</param>
/// <returns>Returns True on success</returns>
public virtual SerieData AddData(int serieIndex, double xValue, double yValue, string dataName = null)
{
var serieData = m_Series.AddXYData(serieIndex, xValue, yValue, dataName);
if (serieData != null)
{
var serie = m_Series.GetSerie(serieIndex);
if (SerieHelper.GetSerieLabel(serie, serieData).show)
{
RefreshLabel();
}
RefreshPainter(serie);
}
return serieData;
}
public virtual SerieData AddData(int serieIndex, double open, double close, double lowest, double heighest, string dataName = null)
{
var serieData = m_Series.AddData(serieIndex, open, close, lowest, heighest, dataName);
if (serieData != null)
{
var serie = m_Series.GetSerie(serieIndex);
if (SerieHelper.GetSerieLabel(serie, serieData).show)
{
RefreshLabel();
}
RefreshPainter(serie);
}
return serieData;
}
/// <summary>
/// Update serie data by serie name.
/// 更新指定系列中的指定索引数据。
/// </summary>
/// <param name="serieName">the name of serie</param>
/// <param name="dataIndex">the index of data</param>
/// <param name="value">the data will be update</param>
public virtual bool UpdateData(string serieName, int dataIndex, double value)
{
if (m_Series.UpdateData(serieName, dataIndex, value))
{
RefreshPainter(m_Series.GetSerie(serieName));
return true;
}
return false;
}
/// <summary>
/// Update serie data by serie index.
/// 更新指定系列中的指定索引数据。
/// </summary>
/// <param name="serieIndex">the index of serie</param>
/// <param name="dataIndex">the index of data</param>
/// <param name="value">the data will be update</param>
public virtual bool UpdateData(int serieIndex, int dataIndex, double value)
{
if (m_Series.UpdateData(serieIndex, dataIndex, value))
{
RefreshPainter(m_Series.GetSerie(serieIndex));
return true;
}
return false;
}
/// <summary>
/// 更新指定系列指定索引的数据项的多维数据。
/// </summary>
/// <param name="serieName"></param>
/// <param name="dataIndex"></param>
/// <param name="multidimensionalData">一个数据项的多维数据列表,而不是多个数据项的数据</param>
public virtual bool UpdateData(string serieName, int dataIndex, List<double> multidimensionalData)
{
if (m_Series.UpdateData(serieName, dataIndex, multidimensionalData))
{
RefreshPainter(m_Series.GetSerie(serieName));
return true;
}
return false;
}
/// <summary>
/// 更新指定系列指定索引的数据项的多维数据。
/// </summary>
/// <param name="serieIndex"></param>
/// <param name="dataIndex"></param>
/// <param name="multidimensionalData">一个数据项的多维数据列表,而不是多个数据项的数据</param>
public virtual bool UpdateData(int serieIndex, int dataIndex, List<double> multidimensionalData)
{
if (m_Series.UpdateData(serieIndex, dataIndex, multidimensionalData))
{
RefreshPainter(m_Series.GetSerie(serieIndex));
return true;
}
return false;
}
/// <summary>
/// 更新指定系列指定索引指定维数的数据。维数从0开始。
/// </summary>
/// <param name="serieName"></param>
/// <param name="dataIndex"></param>
/// <param name="dimension">指定维数从0开始</param>
/// <param name="value"></param>
public virtual bool UpdateData(string serieName, int dataIndex, int dimension, double value)
{
if (m_Series.UpdateData(serieName, dataIndex, dimension, value))
{
RefreshPainter(m_Series.GetSerie(serieName));
return true;
}
return false;
}
/// <summary>
/// 更新指定系列指定索引指定维数的数据。维数从0开始。
/// </summary>
/// <param name="serieIndex"></param>
/// <param name="dataIndex"></param>
/// <param name="dimension">指定维数从0开始</param>
/// <param name="value"></param>
public virtual bool UpdateData(int serieIndex, int dataIndex, int dimension, double value)
{
if (m_Series.UpdateData(serieIndex, dataIndex, dimension, value))
{
RefreshPainter(m_Series.GetSerie(serieIndex));
return true;
}
return false;
}
/// <summary>
/// Update serie data name.
/// 更新指定系列中的指定索引数据名称。
/// </summary>
/// <param name="serieName"></param>
/// <param name="dataIndex"></param>
/// <param name="dataName"></param>
public virtual bool UpdateDataName(string serieName, int dataIndex, string dataName)
{
return m_Series.UpdateDataName(serieName, dataIndex, dataName);
}
/// <summary>
/// Update serie data name.
/// 更新指定系列中的指定索引数据名称。
/// </summary>
/// <param name="serieIndex"></param>
/// <param name="dataName"></param>
/// <param name="dataIndex"></param>
public virtual bool UpdateDataName(int serieIndex, int dataIndex, string dataName)
{
return m_Series.UpdateDataName(serieIndex, dataIndex, dataName);
}
/// <summary>
/// Whether to show serie.
/// 设置指定系列是否显示。
/// </summary>
/// <param name="serieName">the name of serie</param>
/// <param name="active">Active or not</param>
public virtual void SetActive(string serieName, bool active)
{
var serie = m_Series.GetSerie(serieName);
if (serie != null)
{
SetActive(serie.index, active);
}
}
/// <summary>
/// Whether to show serie.
/// 设置指定系列是否显示。
/// </summary>
/// <param name="serieIndex">the index of serie</param>
/// <param name="active">Active or not</param>
public virtual void SetActive(int serieIndex, bool active)
{
m_Series.SetActive(serieIndex, active);
var serie = m_Series.GetSerie(serieIndex);
if (serie != null && !string.IsNullOrEmpty(serie.name))
{
UpdateLegendColor(serie.name, active);
}
}
public virtual void UpdateLegendColor(string legendName, bool active)
{
var legendIndex = m_LegendRealShowName.IndexOf(legendName);
if (legendIndex >= 0)
{
foreach (var legend in m_Legends)
{
var iconColor = LegendHelper.GetIconColor(this, legendIndex, legendName, active);
var contentColor = LegendHelper.GetContentColor(legend, m_Theme, active);
legend.UpdateButtonColor(legendName, iconColor);
legend.UpdateContentColor(legendName, contentColor);
}
}
}
/// <summary>
/// Whether serie is activated.
/// 获取指定系列是否显示。
/// </summary>
/// <param name="serieName">the name of serie</param>
/// <returns>True when activated</returns>
public virtual bool IsActive(string serieName)
{
return m_Series.IsActive(serieName);
}
/// <summary>
/// Whether serie is activated.
/// 获取指定系列是否显示。
/// </summary>
/// <param name="serieIndex">the index of serie</param>
/// <returns>True when activated</returns>
public virtual bool IsActive(int serieIndex)
{
return m_Series.IsActive(serieIndex);
}
/// <summary>
/// Whether serie is activated.
/// 获得指定图例名字的系列是否显示。
/// </summary>
/// <param name="legendName"></param>
/// <returns></returns>
public virtual bool IsActiveByLegend(string legendName)
{
foreach (var serie in m_Series.list)
{
if (serie.show && legendName.Equals(serie.name))
{
return true;
}
else
{
foreach (var serieData in serie.data)
{
if (serieData.show && legendName.Equals(serieData.name))
{
return true;
}
}
}
}
return false;
}
/// <summary>
/// 刷新文本标签Label重新初始化当有改动Label参数时手动调用改接口
/// </summary>
public void RefreshLabel()
{
m_ReinitLabel = true;
m_SerieLabelRoot = null;
}
/// <summary>
/// 刷新Tooltip组件。
/// </summary>
public void RefreshTooltip()
{
InitTooltip();
}
/// <summary>
/// Update chart theme.
/// 切换内置主题。
/// </summary>
/// <param name="theme">theme</param>
public bool UpdateTheme(Theme theme)
{
if (theme == Theme.Custom)
{
Debug.LogError("UpdateTheme: not support switch to Custom theme.");
return false;
}
m_Theme.theme = theme;
return true;
}
/// <summary>
/// Update chart theme info.
/// 切换图表主题。
/// </summary>
/// <param name="theme">theme</param>
public void UpdateTheme(ChartTheme theme)
{
m_Theme.CopyTheme(theme);
SetAllComponentDirty();
}
/// <summary>
/// Whether series animation enabel.
/// 启用或关闭起始动画。
/// </summary>
/// <param name="flag"></param>
public void AnimationEnable(bool flag)
{
foreach (var serie in m_Series.list) serie.AnimationEnable(flag);
}
/// <summary>
/// fadeIn animation.
/// 开始渐入动画。
/// </summary>
public void AnimationFadeIn()
{
foreach (var serie in m_Series.list) serie.AnimationFadeIn();
}
/// <summary>
/// fadeIn animation.
/// 开始渐出动画。
/// </summary>
public void AnimationFadeOut()
{
foreach (var serie in m_Series.list) serie.AnimationFadeOut();
}
/// <summary>
/// Pause animation.
/// 暂停动画。
/// </summary>
public void AnimationPause()
{
foreach (var serie in m_Series.list) serie.AnimationPause();
}
/// <summary>
/// Stop play animation.
/// 继续动画。
/// </summary>
public void AnimationResume()
{
foreach (var serie in m_Series.list) serie.AnimationResume();
}
/// <summary>
/// Reset animation.
/// 重置动画。
/// </summary>
public void AnimationReset()
{
foreach (var serie in m_Series.list) serie.AnimationReset();
}
/// <summary>
/// 点击图例按钮
/// </summary>
/// <param name="legendIndex">图例按钮索引</param>
/// <param name="legendName">图例按钮名称</param>
/// <param name="show">显示还是隐藏</param>
public void ClickLegendButton(int legendIndex, string legendName, bool show)
{
OnLegendButtonClick(legendIndex, legendName, show);
RefreshChart();
}
/// <summary>
/// 坐标是否在图表范围内
/// </summary>
/// <param name="local"></param>
/// <returns></returns>
public bool IsInChart(Vector2 local)
{
return IsInChart(local.x, local.y);
}
public bool IsInChart(float x, float y)
{
if (x < m_ChartX || x > m_ChartX + m_ChartWidth ||
y < m_ChartY || y > m_ChartY + m_ChartHeight)
{
return false;
}
return true;
}
public void ClampInChart(ref Vector3 pos)
{
if (!IsInChart(pos.x, pos.y))
{
if (pos.x < m_ChartX) pos.x = m_ChartX;
if (pos.x > m_ChartX + m_ChartWidth) pos.x = m_ChartX + m_ChartWidth;
if (pos.y < m_ChartY) pos.y = m_ChartY;
if (pos.y > m_ChartY + m_ChartHeight) pos.y = m_ChartY + m_ChartHeight;
}
}
public Vector3 GetTitlePosition(Title title)
{
return chartPosition + title.location.GetPosition(chartWidth, chartHeight);
}
public bool ContainsSerie(SerieType serieType)
{
return SeriesHelper.ContainsSerie(m_Series, serieType);
}
public virtual bool AddDefaultCustomSerie(string serieName, int dataCount = 5)
{
return false;
}
public virtual string[] GetCustomSerieInspectorShowFileds()
{
return null;
}
public virtual string[][] GetCustomSerieInspectorCustomFileds()
{
return null;
}
public virtual string[] GetCustomChartInspectorShowFileds()
{
return null;
}
public virtual string GetCustomSerieTypeName()
{
return null;
}
public virtual bool GetCustomSerieDataNameForColor()
{
return false;
}
public int GetLegendRealShowNameIndex(string name)
{
return m_LegendRealShowName.IndexOf(name);
}
public virtual void InitCustomSerieTooltip(ref StringBuilder stringBuilder, Serie serie, int index)
{
}
/// <summary>
/// 设置Base Painter的材质球
/// </summary>
/// <param name="material"></param>
public void SetBasePainterMaterial(Material material)
{
settings.basePainterMaterial = material;
if (m_Painter != null)
{
m_Painter.material = material;
}
}
/// <summary>
/// 设置Serie Painter的材质球
/// </summary>
/// <param name="material"></param>
public void SetSeriePainterMaterial(Material material)
{
settings.basePainterMaterial = material;
if (m_PainterList != null)
{
foreach (var painter in m_PainterList)
painter.material = material;
}
}
/// <summary>
/// 设置Top Painter的材质球
/// </summary>
/// <param name="material"></param>
public void SetTopPainterMaterial(Material material)
{
settings.topPainterMaterial = material;
if (m_PainterTop != null)
{
m_PainterTop.material = material;
}
}
}
}

View File

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

View File

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

View File

@@ -1,399 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections.Generic;
using UnityEngine;
namespace XCharts
{
/// <summary>
/// The basic class of rectangular coordinate chartsuch as LineChart,BarChart and ScatterChart.
/// 直角坐标系类型图表的基类如折线图LineChart柱状图BarChart散点图ScatterChart都属于这类型的图表。
/// 不可用直接将CoordinateChart绑定到GameObject上。
/// </summary>
public partial class CoordinateChart
{
/// <summary>
/// grid component.
/// 网格组件。
/// </summary>
public Grid grid { get { return m_Grids.Count > 0 ? m_Grids[0] : null; } }
public List<Grid> grids { get { return m_Grids; } }
/// <summary>
/// the x AxesxAxes[0] is the first x axis, xAxes[1] is the second x axis.
/// 两个x轴。
/// </summary>
public List<XAxis> xAxes { get { return m_XAxes; } }
/// <summary>
/// the y Axes, yAxes[0] is the first y axis, yAxes[1] is the second y axis.
/// 两个y轴。
/// </summary>
public List<YAxis> yAxes { get { return m_YAxes; } }
/// <summary>
/// X轴
/// </summary>
public XAxis xAxis0 { get { return m_XAxes.Count > 0 ? m_XAxes[0] : null; } }
/// <summary>
/// X轴
/// </summary>
public XAxis xAxis1 { get { return m_XAxes.Count > 1 ? m_XAxes[1] : null; } }
/// <summary>
/// Y轴
/// </summary>
public YAxis yAxis0 { get { return m_YAxes.Count > 0 ? m_YAxes[0] : null; } }
/// <summary>
/// Y轴
/// </summary>
public YAxis yAxis1 { get { return m_YAxes.Count > 1 ? m_YAxes[1] : null; } }
/// <summary>
/// Remove all data from series,legend and axis.
/// It just emptying all of serie's data without emptying the list of series.
/// 清空所有图例,系列和坐标轴类目数据。系列中指示清空系列中的数据,会保留系列列表。
/// </summary>
public override void ClearData()
{
base.ClearData();
ClearAxisData();
}
/// <summary>
/// Remove all data from series,legend and axis.
/// The series list is also cleared.
/// 清空所有图例,系列和坐标轴类目数据。系列的列表也会被清空。
/// </summary>
public override void RemoveData()
{
base.RemoveData();
ClearAxisData();
}
/// <summary>
/// Remove all data of Axes.
/// 清除所有x轴和y轴的类目数据。
/// </summary>
public void ClearAxisData()
{
foreach (var axis in m_XAxes)
{
axis.data.Clear();
axis.SetAllDirty();
}
foreach (var axis in m_YAxes)
{
axis.data.Clear();
axis.SetAllDirty();
}
}
/// <summary>
/// Add a category data to xAxis.
/// 添加一个类目数据到指定的x轴。
/// </summary>
/// <param name="category">the category data</param>
/// <param name="xAxisIndex">which xAxis should category add to</param>
public void AddXAxisData(string category, int xAxisIndex = 0)
{
var xAxis = GetXAxis(xAxisIndex);
if (xAxis != null)
{
xAxis.AddData(category);
}
}
/// <summary>
/// Update category data.
/// 更新X轴类目数据。
/// </summary>
/// <param name="index">the index of category data</param>
/// <param name="category"></param>
/// <param name="xAxisIndex">which xAxis index to update to</param>
public void UpdateXAxisData(int index, string category, int xAxisIndex = 0)
{
var xAxis = GetXAxis(xAxisIndex);
if (xAxis != null)
{
xAxis.UpdateData(index, category);
}
}
/// <summary>
/// Add an icon to xAxis.
/// 添加一个图标到指定的x轴。
/// </summary>
/// <param name="icon"></param>
/// <param name="xAxisIndex"></param>
public void AddXAxisIcon(Sprite icon, int xAxisIndex = 0)
{
var xAxis = GetXAxis(xAxisIndex);
if (xAxis != null)
{
xAxis.AddIcon(icon);
}
}
/// <summary>
/// Update xAxis icon.
/// 更新X轴图标。
/// </summary>
/// <param name="index"></param>
/// <param name="icon"></param>
/// <param name="xAxisIndex"></param>
public void UdpateXAxisIcon(int index, Sprite icon, int xAxisIndex = 0)
{
var xAxis = GetXAxis(xAxisIndex);
if (xAxis != null)
{
xAxis.UpdateIcon(index, icon);
}
}
/// <summary>
/// Add a category data to yAxis.
/// 添加一个类目数据到指定的y轴。
/// </summary>
/// <param name="category">the category data</param>
/// <param name="yAxisIndex">which yAxis should category add to</param>
public void AddYAxisData(string category, int yAxisIndex = 0)
{
var yAxis = GetYAxis(yAxisIndex);
if (yAxis != null)
{
yAxis.AddData(category);
}
}
/// <summary>
/// Update category data.
/// 更新Y轴类目数据。
/// </summary>
/// <param name="index">the index of category data</param>
/// <param name="category"></param>
/// <param name="yAxisIndex">which yAxis index to update to</param>
public void UpdateYAxisData(int index, string category, int yAxisIndex = 0)
{
var yAxis = GetYAxis(yAxisIndex);
if (yAxis != null)
{
yAxis.UpdateData(index, category);
}
}
/// <summary>
/// Add an icon to yAxis.
/// 添加一个图标到指定的y轴。
/// </summary>
/// <param name="icon"></param>
/// <param name="yAxisIndex"></param>
public void AddYAxisIcon(Sprite icon, int yAxisIndex = 0)
{
var yAxis = GetYAxis(yAxisIndex);
if (yAxis != null)
{
yAxis.AddIcon(icon);
}
}
/// <summary>
/// 更新Y轴图标。
/// </summary>
/// <param name="index"></param>
/// <param name="icon"></param>
/// <param name="yAxisIndex"></param>
public void UpdateYAxisIcon(int index, Sprite icon, int yAxisIndex = 0)
{
var yAxis = GetYAxis(yAxisIndex);
if (yAxis != null)
{
yAxis.UpdateIcon(index, icon);
}
}
/// <summary>
/// reutrn true when all the show axis is `Value` type.
/// 纯数值坐标轴(数值轴或对数轴)。
/// </summary>
public bool IsValue()
{
foreach (var axis in m_XAxes)
{
if (axis.show && !axis.IsValue() && !axis.IsLog()) return false;
}
foreach (var axis in m_YAxes)
{
if (axis.show && !axis.IsValue() && !axis.IsLog()) return false;
}
return true;
}
/// <summary>
/// 纯类目轴。
/// </summary>
public bool IsCategory()
{
foreach (var axis in m_XAxes)
{
if (axis.show && !axis.IsCategory()) return false;
}
foreach (var axis in m_YAxes)
{
if (axis.show && !axis.IsCategory()) return false;
}
return true;
}
/// <summary>
/// 坐标是否在坐标轴内。
/// </summary>
public bool IsInGrid(Grid grid, Vector2 local)
{
return IsInGrid(grid, local.x, local.y);
}
public bool IsInGrid(Grid grid, Vector3 local)
{
return IsInGrid(grid, local.x, local.y);
}
public bool IsInGrid(Grid grid, float x, float y)
{
if (x < grid.runtimeX - 1 || x > grid.runtimeX + grid.runtimeWidth + 1 ||
y < grid.runtimeY - 1 || y > grid.runtimeY + grid.runtimeHeight + 1)
{
return false;
}
return true;
}
public bool IsInAnyGrid(Vector2 local)
{
foreach (var grid in m_Grids)
{
if (IsInGrid(grid, local)) return true;
}
return false;
}
public Grid GetGrid(Vector2 local)
{
for (int i = 0; i < m_Grids.Count; i++)
{
var grid = m_Grids[i];
grid.index = i;
if (IsInGrid(grid, local)) return grid;
}
return null;
}
/// <summary>
/// 在下一帧刷新DataZoom
/// </summary>
public void RefreshDataZoom()
{
foreach (var handler in m_ComponentHandlers)
{
if (handler is DataZoomHandler)
{
(handler as DataZoomHandler).RefreshDataZoomLabel();
}
}
}
/// <summary>
/// 立即刷新数值坐标轴的最大最小值
/// </summary>
public void RefreshAxisMinMaxValue()
{
CheckMinMaxValue();
}
public Vector3 ClampInGrid(Grid grid, Vector3 pos)
{
if (IsInGrid(grid, pos)) return pos;
else
{
// var pos = new Vector3(pos.x, pos.y);
if (pos.x < grid.runtimeX) pos.x = grid.runtimeX;
if (pos.x > grid.runtimeX + grid.runtimeWidth) pos.x = grid.runtimeX + grid.runtimeWidth;
if (pos.y < grid.runtimeY) pos.y = grid.runtimeY;
if (pos.y > grid.runtimeY + grid.runtimeHeight) pos.y = grid.runtimeY + grid.runtimeHeight;
return pos;
}
}
/// <summary>
/// 转换X轴和Y轴的配置
/// </summary>
/// <param name="index">坐标轴索引0或1</param>
public void CovertXYAxis(int index)
{
if (index >= 0 && index <= 1)
{
var xAxis = m_XAxes[index];
var yAxis = m_YAxes[index];
var tempX = m_XAxes[index].Clone();
xAxis.Copy(m_YAxes[index]);
yAxis.Copy(tempX);
xAxis.runtimeZeroXOffset = 0;
xAxis.runtimeZeroYOffset = 0;
yAxis.runtimeZeroXOffset = 0;
yAxis.runtimeZeroYOffset = 0;
xAxis.runtimeMinValue = 0;
xAxis.runtimeMaxValue = 0;
yAxis.runtimeMinValue = 0;
yAxis.runtimeMaxValue = 0;
RefreshChart();
}
}
/// <summary>
/// 更新坐标系原点和宽高
/// </summary>
public void UpdateCoordinate()
{
foreach (var grid in m_Grids)
{
grid.UpdateRuntimeData(m_ChartX, m_ChartY, m_ChartWidth, m_ChartHeight);
}
foreach (var dataZoom in m_DataZooms)
{
dataZoom.UpdateRuntimeData(m_ChartX, m_ChartY, m_ChartWidth, m_ChartHeight);
}
}
/// <summary>
/// 设置可缓存的最大数据量。当数据量超过该值时,会自动删除第一个值再加入最新值。
/// </summary>
public void SetMaxCache(int maxCache)
{
foreach (var serie in m_Series.list) serie.maxCache = maxCache;
foreach (var axis in m_XAxes) axis.maxCache = maxCache;
foreach (var axis in m_YAxes) axis.maxCache = maxCache;
}
public Grid GetGrid(int index)
{
if (index >= 0 && index < m_Grids.Count) return m_Grids[index];
else return null;
}
public XAxis GetXAxis(int index)
{
if (index >= 0 && index < m_XAxes.Count) return m_XAxes[index];
else return null;
}
public YAxis GetYAxis(int index)
{
if (index >= 0 && index < m_YAxes.Count) return m_YAxes[index];
else return null;
}
}
}

View File

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

View File

@@ -1,62 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections.Generic;
using UnityEngine;
namespace XCharts
{
public partial class BaseChart
{
public Vessel vessel { get { return m_Vessels.Count > 0 ? m_Vessels[0] : null; } }
/// <summary>
/// 容器组件列表。
/// </summary>
public List<Vessel> vessels { get { return m_Vessels; } }
/// <summary>
/// 移除所有容器组件。
/// </summary>
public void RemoveVessel()
{
m_Vessels.Clear();
}
/// <summary>
/// 添加容器组件。
/// </summary>
public void AddVessel(Vessel vessel)
{
m_Vessels.Add(vessel);
}
/// <summary>
/// 添加容器组件。
/// </summary>
public Vessel AddVessel(Vessel.Shape shape, Vector2 center, float radius)
{
var vessel = new Vessel();
vessel.shape = shape;
vessel.radius = radius;
vessel.center[0] = center.x;
vessel.center[1] = center.y;
AddVessel(vessel);
return vessel;
}
/// <summary>
/// 获得指定索引的容器组件。
/// </summary>
/// <param name="radarIndex"></param>
/// <returns></returns>
public Vessel GetVessel(int vesselIndex)
{
if (vesselIndex < 0 || vesselIndex > m_Vessels.Count - 1) return null;
return m_Vessels[vesselIndex];
}
}
}

View File

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

View File

@@ -1,27 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
namespace XCharts
{
public partial class BaseChart
{
/// <summary>
/// 极坐标。
/// </summary>
public Polar polar { get { return m_Polars.Count > 0 ? m_Polars[0] : null; } }
/// <summary>
/// Angle axis of Polar Coordinate.
/// 极坐标系的角度轴。
/// </summary>
public AngleAxis angleAxis { get { return m_AngleAxes.Count > 0 ? m_AngleAxes[0] : null; } }
/// <summary>
/// Radial axis of polar coordinate.
/// 极坐标系的径向轴。
/// </summary>
public RadiusAxis radiusAxis { get { return m_RadiusAxes.Count > 0 ? m_RadiusAxes[0] : null; } }
}
}

View File

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

View File

@@ -1,138 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections.Generic;
using UnityEngine;
namespace XCharts
{
public partial class BaseChart
{
public Radar radar { get { return m_Radars.Count > 0 ? m_Radars[0] : null; } }
/// <summary>
/// 雷达坐标系组件列表。
/// </summary>
public List<Radar> radars { get { return m_Radars; } }
/// <summary>
/// 移除所有雷达坐标系组件。
/// </summary>
public void RemoveRadar()
{
m_Radars.Clear();
}
/// <summary>
/// 移除指定Radar的所有Indicator。
/// </summary>
/// <param name="radarIndex"></param>
public void RemoveIndicator(int radarIndex)
{
var radar = GetRadar(radarIndex);
if (radar == null) return;
radar.indicatorList.Clear();
}
/// <summary>
/// 添加雷达坐标系组件。
/// </summary>
public void AddRadar(Radar radar)
{
m_Radars.Add(radar);
}
/// <summary>
/// 添加雷达坐标系组件。
/// </summary>
/// <param name="shape">形状,圆形还是多边形</param>
/// <param name="center">中心点0-1浮点数时表示百分比</param>
/// <param name="radius">半径0-1浮点数时表示百分比</param>
/// <param name="splitNumber">指示器轴的分割段数</param>
/// <param name="lineWidth">线条宽</param>
/// <param name="showIndicator">是否显示指示器名称</param>
/// <param name="showSplitArea">是否显示分割区域</param>
/// <returns></returns>
public Radar AddRadar(Radar.Shape shape, Vector2 center, float radius, int splitNumber = 5,
float lineWidth = 0f, bool showIndicator = true, bool showSplitArea = true)
{
var radar = new Radar();
radar.shape = shape;
radar.splitNumber = splitNumber;
radar.radius = radius;
radar.indicator = showIndicator;
radar.center[0] = center.x;
radar.center[1] = center.y;
radar.splitArea.show = showSplitArea;
radar.splitLine.lineStyle.width = lineWidth;
m_Radars.Add(radar);
return radar;
}
public bool AddIndicator(int radarIndex, Radar.Indicator indicator)
{
var radar = GetRadar(radarIndex);
if (radar == null) return false;
radar.AddIndicator(indicator);
return true;
}
/// <summary>
/// 添加指示器。
/// </summary>
/// <param name="radarIndex">雷达坐标系组件索引从0开始</param>
/// <param name="name">指示器名称</param>
/// <param name="min">指示器最小值</param>
/// <param name="max">指示器最大值</param>
/// <returns></returns>
public Radar.Indicator AddIndicator(int radarIndex, string name, float min, float max)
{
var radar = GetRadar(radarIndex);
if (radar == null) return null;
return radar.AddIndicator(name, min, max);
}
/// <summary>
/// 更新指示器。
/// </summary>
/// <param name="radarIndex">雷达坐标系组件的索引从0开始</param>
/// <param name="indicatorIndex">指示器索引从0开始</param>
/// <param name="name">指示器名称</param>
/// <param name="min">指示器最小值</param>
/// <param name="max">指示器最大值</param>
/// <returns></returns>
public bool UpdateIndicator(int radarIndex, int indicatorIndex, string name, float min, float max)
{
var radar = GetRadar(radarIndex);
if (radar == null) return false;
return radar.UpdateIndicator(indicatorIndex, name, min, max);
}
/// <summary>
/// 获得指定索引的雷达坐标系组件。
/// </summary>
/// <param name="radarIndex"></param>
/// <returns></returns>
public Radar GetRadar(int radarIndex)
{
if (radarIndex < 0 || radarIndex > m_Radars.Count - 1) return null;
return m_Radars[radarIndex];
}
/// <summary>
/// 获得指定雷达坐标系组件指定索引的指示器。
/// </summary>
/// <param name="radarIndex"></param>
/// <param name="indicatorIndex"></param>
/// <returns></returns>
public Radar.Indicator GetIndicator(int radarIndex, int indicatorIndex)
{
var radar = GetRadar(radarIndex);
if (radar != null) return radar.GetIndicator(indicatorIndex);
else return null;
}
}
}

View File

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

View File

@@ -1,88 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
namespace XCharts
{
public partial class RingChart
{
/// <summary>
/// 更新指定系列执行数据项的最大值
/// </summary>
/// <param name="serieIndex"></param>
/// <param name="dataIndex"></param>
/// <param name="value"></param>
/// <returns></returns>
public bool UpdateMax(int serieIndex, int dataIndex, double value)
{
var serie = m_Series.GetSerie(serieIndex);
if (serie != null)
{
return serie.UpdateData(dataIndex, 1, value);
}
return false;
}
/// <summary>
/// 更新指定系列的所有数据项的最大值
/// </summary>
/// <param name="serieIndex"></param>
/// <param name="value"></param>
/// <returns></returns>
public bool UpdateMax(int serieIndex, double value)
{
var serie = m_Series.GetSerie(serieIndex);
if (serie != null)
{
var flag = true;
for (int i = 0; i < serie.dataCount; i++)
{
if (serie.UpdateData(i, 1, value)) flag = false;
}
return flag;
}
return false;
}
/// <summary>
/// 更新第一个系列第一个数据项的最大值
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public bool UpdateMax(double value)
{
return UpdateMax(0, 0, value);
}
/// <summary>
/// Adds the data with the specified maximum value to the specified serie.
/// 添加指定最大值的数据到指定系列中。
/// </summary>
/// <param name="serieName">the name of serie</param>
/// <param name="value">the data</param>
/// <param name="max">the max data</param>
/// <param name="dataName">the name of data</param>
/// <returns>Returns True on success</returns>
public override SerieData AddData(string serieName, double value, double max, string dataName = null)
{
return base.AddData(serieName, value, max, dataName);
}
/// <summary>
/// Adds the data with the specified maximum value to the specified serie.
/// 添加指定最大值的数据到指定系列中。
/// </summary>
/// <param name="serieIndex">the index of serie</param>
/// <param name="value">the data</param>
/// <param name="max">the max data</param>
/// <param name="dataName">the name of data</param>
/// <returns>Returns True on success</returns>
public override SerieData AddData(int serieIndex, double value, double max, string dataName = null)
{
return base.AddData(serieIndex, value, max, dataName);
}
}
}

View File

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

View File

@@ -1,53 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System;
using UnityEngine;
using UnityEngine.EventSystems;
namespace XCharts
{
[AddComponentMenu("XCharts/BarChart", 14)]
[ExecuteInEditMode]
[RequireComponent(typeof(RectTransform))]
[DisallowMultipleComponent]
public partial class BarChart : CoordinateChart
{
protected override void Awake()
{
base.Awake();
raycastTarget = false;
}
#if UNITY_EDITOR
protected override void Reset()
{
base.Reset();
title.text = "BarChart";
tooltip.type = Tooltip.Type.Shadow;
RemoveData();
SerieTemplate.AddDefaultBarSerie(this, "serie1");
for (int i = 0; i < 5; i++)
{
AddXAxisData("x" + (i + 1));
}
}
#endif
public override void OnPointerDown(PointerEventData eventData)
{
base.OnPointerDown(eventData);
if (m_OnPointerClickBar == null) return;
if (pointerPos == Vector2.zero) return;
UpdateTooltipValue(pointerPos);
var dataIndex = tooltip.runtimeDataIndex[0];
if (dataIndex >= 0)
{
m_OnPointerClickBar(eventData, dataIndex);
}
}
}
}

View File

@@ -1,36 +0,0 @@

/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
namespace XCharts
{
[AddComponentMenu("XCharts/CandlestickChart", 23)]
[ExecuteInEditMode]
[RequireComponent(typeof(RectTransform))]
[DisallowMultipleComponent]
public class CandlestickChart : CoordinateChart
{
#if UNITY_EDITOR
protected override void Reset()
{
base.Reset();
title.text = "CandlestickChart";
tooltip.type = Tooltip.Type.Corss;
RemoveData();
var defaultDataCount = SerieTemplate.AddDefaultCandlestickSerie(this, "serie1");
for (int i = 0; i < defaultDataCount; i++)
{
AddXAxisData("x" + (i + 1));
}
}
#endif
}
}

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -1,696 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
using System.Collections.Generic;
using System;
namespace XCharts
{
/// <summary>
/// the list of series.
/// 系列列表。每个系列通过 type 决定自己的图表类型。
/// </summary>
[System.Serializable]
public class Series : MainComponent
{
[SerializeField] protected List<Serie> m_Series;
[NonSerialized] private bool m_LabelDirty;
/// <summary>
/// the list of serie
/// 系列列表。
/// </summary>
public List<Serie> list { get { return m_Series; } }
/// <summary>
/// the size of serie list.
/// 系列个数。
/// </summary>
public int Count { get { return m_Series.Count; } }
public bool labelDirty { get { return m_LabelDirty; } set { m_LabelDirty = value; } }
public static Series defaultSeries
{
get
{
var series = new Series
{
m_Series = new List<Serie>(){new Serie(){
show = true,
name = "serie1",
index = 0
}}
};
return series;
}
}
public override bool vertsDirty
{
get
{
if (m_VertsDirty) return true;
foreach (var serie in m_Series)
{
if (serie.vertsDirty) return true;
}
return false;
}
}
public void SetLabelDirty()
{
m_LabelDirty = true;
}
public 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();
}
public override void ClearDirty()
{
base.ClearDirty();
ClearLabelDirty();
SeriesHelper.ClearNameDirty(this);
}
/// <summary>
/// 清空所有系列的数据
/// </summary>
public void ClearData()
{
foreach (var serie in m_Series)
{
serie.AnimationFadeIn();
serie.ClearData();
}
}
/// <summary>
/// 获得指定序列指定索引的数据值
/// </summary>
/// <param name="serieIndex"></param>
/// <param name="dataIndex"></param>
/// <returns></returns>
public double GetData(int serieIndex, int dataIndex)
{
if (serieIndex >= 0 && serieIndex < Count)
{
return m_Series[serieIndex].GetYData(dataIndex);
}
else
{
return 0;
}
}
public double GetCurrData(int serieIndex, int dataIndex)
{
if (serieIndex >= 0 && serieIndex < Count)
{
return m_Series[serieIndex].GetYCurrData(dataIndex);
}
else
{
return 0;
}
}
/// <summary>
/// 获得指定系列名的第一个系列
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public Serie GetSerie(string name)
{
for (int i = 0; i < m_Series.Count; i++)
{
bool match = false;
if (string.IsNullOrEmpty(name))
{
if (string.IsNullOrEmpty(m_Series[i].name)) match = true;
}
else if (name.Equals(m_Series[i].name))
{
match = true;
}
if (match)
{
m_Series[i].index = i;
return m_Series[i];
}
}
return null;
}
/// <summary>
/// 获得指定系列名的所有系列
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public List<Serie> GetSeries(string name)
{
var list = new List<Serie>();
if (name == null) return list;
foreach (var serie in m_Series)
{
if (name.Equals(serie.name)) list.Add(serie);
}
return list;
}
/// <summary>
/// 获得指定索引的系列
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public Serie GetSerie(int index)
{
if (index >= 0 && index < m_Series.Count)
{
return m_Series[index];
}
return null;
}
/// <summary>
/// 是否包含指定名字的系列
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public bool Contains(string name)
{
for (int i = 0; i < m_Series.Count; i++)
{
if (name.Equals(m_Series[i].name))
{
return true;
}
}
return false;
}
public bool Contains(SerieType type)
{
foreach (var serie in m_Series)
{
if (serie.type == type) return true;
}
return false;
}
/// <summary>
/// Remove serie from series.
/// 移除指定名字的系列。
/// </summary>
/// <param name="serieName">the name of serie</param>
public bool RemoveSerie(string serieName)
{
var serie = GetSerie(serieName);
return RemoveSerie(serie);
}
public bool RemoveSerie(int serieIndex)
{
var serie = GetSerie(serieIndex);
return RemoveSerie(serie);
}
public bool RemoveSerie(Serie serie)
{
if (serie != null && m_Series.Remove(serie))
{
SetVerticesDirty();
return true;
}
else
{
return false;
}
}
/// <summary>
/// Remove all serie from series.
/// 移除所有系列。
/// </summary>
public void RemoveAll()
{
foreach(var serie in m_Series) serie.AnimationFadeIn();
m_Series.Clear();
}
/// <summary>
/// 添加一个系列到列表中。
/// </summary>
/// <param name="serieName"></param>
/// <param name="type"></param>
/// <param name="show"></param>
/// <returns></returns>
public Serie AddSerie(SerieType type, string serieName, bool show = true, bool addToHead = false)
{
return InsertSerie(-1, type, serieName, show, addToHead);
}
public Serie InsertSerie(int index, SerieType type, string serieName, bool show = true)
{
return InsertSerie(index, type, serieName, show, false);
}
private Serie InsertSerie(int index, SerieType type, string serieName, bool show = true, bool addToHead = false)
{
var serie = new Serie();
serie.type = type;
serie.show = show;
serie.name = serieName;
serie.index = m_Series.Count;
if (type == SerieType.Scatter)
{
serie.symbol.show = true;
serie.symbol.type = SerieSymbolType.Circle;
}
else if (type == SerieType.Line)
{
serie.symbol.show = true;
serie.symbol.type = SerieSymbolType.EmptyCircle;
}
else
{
serie.symbol.show = false;
}
serie.AnimationRestart();
if (addToHead) m_Series.Insert(0, serie);
else if (index >= 0) m_Series.Insert(index, serie);
else m_Series.Add(serie);
for (int i = 0; i < m_Series.Count; i++)
{
m_Series[i].index = i;
}
SetVerticesDirty();
return serie;
}
/// <summary>
/// 添加一个数据到指定系列的维度Y数据中
/// </summary>
/// <param name="serieName"></param>
/// <param name="value"></param>
/// <param name="dataName"></param>
/// <returns>添加成功返回SerieData否则返回null</returns>
public SerieData AddData(string serieName, double value, string dataName = null)
{
var serie = GetSerie(serieName);
if (serie != null)
{
return serie.AddYData(value, dataName);
}
return null;
}
/// <summary>
/// 添加一个数据到指定系列的维度Y中
/// </summary>
/// <param name="index"></param>
/// <param name="value"></param>
/// <param name="dataName"></param>
/// <returns>添加成功返回SerieData否则返回null</returns>
public SerieData AddData(int index, double value, string dataName = null)
{
var serie = GetSerie(index);
if (serie != null)
{
return serie.AddYData(value, dataName);
}
return null;
}
/// <summary>
/// 添加[open, close, lowest, highest]数据
/// </summary>
/// <param name="index"></param>
/// <param name="open"></param>
/// <param name="close"></param>
/// <param name="lowest"></param>
/// <param name="heighest"></param>
/// <param name="dataName"></param>
/// <returns></returns>
public SerieData AddData(int index, double open, double close, double lowest, double heighest, string dataName = null)
{
var serie = GetSerie(index);
if (serie != null)
{
return serie.AddData(open, close, lowest, heighest, dataName);
}
return null;
}
public SerieData AddData(string serieName, double open, double close, double lowest, double heighest, string dataName = null)
{
var serie = GetSerie(serieName);
if (serie != null)
{
return serie.AddData(open, close, lowest, heighest, dataName);
}
return null;
}
/// <summary>
/// 添加一组数据到指定的系列中
/// </summary>
/// <param name="serieName"></param>
/// <param name="multidimensionalData"></param>
/// <param name="dataName"></param>
/// <returns>添加成功返回SerieData否则返回null</returns>
public SerieData AddData(string serieName, List<double> multidimensionalData, string dataName = null)
{
var serie = GetSerie(serieName);
if (serie != null)
{
return serie.AddData(multidimensionalData, dataName);
}
return null;
}
/// <summary>
/// 添加一组数据到指定的系列中
/// </summary>
/// <param name="serieIndex"></param>
/// <param name="multidimensionalData"></param>
/// <param name="dataName"></param>
/// <returns>添加成功返回SerieData否则返回null</returns>
public SerieData AddData(int serieIndex, List<double> multidimensionalData, string dataName = null)
{
var serie = GetSerie(serieIndex);
if (serie != null)
{
return serie.AddData(multidimensionalData, dataName);
}
return null;
}
/// <summary>
/// 添加(x,y)数据到指定的系列中
/// </summary>
/// <param name="serieName"></param>
/// <param name="xValue"></param>
/// <param name="yValue"></param>
/// <param name="dataName"></param>
/// <returns>添加成功返回SerieData否则返回null</returns>
public SerieData AddXYData(string serieName, double xValue, double yValue, string dataName = null)
{
var serie = GetSerie(serieName);
if (serie != null)
{
return serie.AddXYData(xValue, yValue, dataName);
}
return null;
}
/// <summary>
/// 添加(x,y)数据到指定的系列中
/// </summary>
/// <param name="index"></param>
/// <param name="xValue"></param>
/// <param name="yValue"></param>
/// <param name="dataName"></param>
/// <returns>添加成功返回SerieData否则返回null</returns>
public SerieData AddXYData(int index, double xValue, double yValue, string dataName = null)
{
var serie = GetSerie(index);
if (serie != null)
{
return serie.AddXYData(xValue, yValue, dataName);
}
return null;
}
/// <summary>
/// 更新指定系列的维度Y数据
/// </summary>
/// <param name="name"></param>
/// <param name="value"></param>
/// <param name="dataIndex"></param>
public bool UpdateData(string serieName, int dataIndex, double value)
{
var serie = GetSerie(serieName);
if (serie != null)
{
return serie.UpdateYData(dataIndex, value);
}
return false;
}
/// <summary>
/// 更新指定系列的数据项名称
/// </summary>
/// <param name="serieName"></param>
/// <param name="dataIndex"></param>
/// <param name="dataName"></param>
public bool UpdateDataName(string serieName, int dataIndex, string dataName)
{
var serie = GetSerie(serieName);
if (serie != null)
{
return serie.UpdateDataName(dataIndex, dataName);
}
return false;
}
/// <summary>
/// 更新指定系列的数据项名称
/// </summary>
/// <param name="serieIndex"></param>
/// <param name="dataIndex"></param>
/// <param name="dataName"></param>
public bool UpdateDataName(int serieIndex, int dataIndex, string dataName)
{
var serie = GetSerie(serieIndex);
if (serie != null)
{
return serie.UpdateDataName(dataIndex, dataName);
}
return false;
}
/// <summary>
/// 更新指定系列的维度Y数据项的值
/// </summary>
/// <param name="serieIndex"></param>
/// <param name="dataIndex"></param>
/// <param name="value"></param>
public bool UpdateData(int serieIndex, int dataIndex, double value)
{
var serie = GetSerie(serieIndex);
if (serie != null)
{
return serie.UpdateYData(dataIndex, value);
}
return false;
}
public bool UpdateData(string serieName, int dataIndex, List<double> values)
{
var serie = GetSerie(serieName);
if (serie != null)
{
return serie.UpdateData(dataIndex, values);
}
return false;
}
public bool UpdateData(int serieIndex, int dataIndex, List<double> values)
{
var serie = GetSerie(serieIndex);
if (serie != null)
{
return serie.UpdateData(dataIndex, values);
}
return false;
}
/// <summary>
/// 更新指定系列指定数据项指定维度的数据值
/// </summary>
/// <param name="serieIndex">系列</param>
/// <param name="dataIndex">数据项</param>
/// <param name="dimension">数据维数从0开始</param>
/// <param name="value">值</param>
public bool UpdateData(int serieIndex, int dataIndex, int dimension, double value)
{
var serie = GetSerie(serieIndex);
if (serie != null)
{
return serie.UpdateData(dataIndex, dimension, value);
}
return false;
}
/// <summary>
/// 更新指定系列指定数据项指定维度的数据值
/// </summary>
/// <param name="serieName"></param>
/// <param name="dataIndex"></param>
/// <param name="dimension">数据维数从0开始</param>
/// <param name="value"></param>
public bool UpdateData(string serieName, int dataIndex, int dimension, double value)
{
var serie = GetSerie(serieName);
if (serie != null)
{
return serie.UpdateData(dataIndex, dimension, value);
}
return false;
}
/// <summary>
/// 更新指定系列的维度X和维度Y数据
/// </summary>
/// <param name="serieName"></param>
/// <param name="dataIndex"></param>
/// <param name="xValue"></param>
/// <param name="yValue"></param>
public bool UpdateXYData(string serieName, int dataIndex, float xValue, float yValue)
{
var serie = GetSerie(serieName);
if (serie != null)
{
return serie.UpdateXYData(dataIndex, xValue, yValue);
}
return false;
}
/// <summary>
/// 更新指定系列的维度X和维度Y数据
/// </summary>
/// <param name="serieIndex"></param>
/// <param name="dataIndex"></param>
/// <param name="xValue"></param>
/// <param name="yValue"></param>
public bool UpdateXYData(int serieIndex, int dataIndex, float xValue, float yValue)
{
var serie = GetSerie(serieIndex);
if (serie != null)
{
return serie.UpdateXYData(dataIndex, xValue, yValue);
}
return false;
}
/// <summary>
/// dataZoom由变化是更新系列的缓存数据
/// </summary>
/// <param name="dataZoom"></param>
internal void UpdateFilterData(DataZoom dataZoom)
{
if (dataZoom != null && dataZoom.enable)
{
for (int i = 0; i < m_Series.Count; i++)
{
SerieHelper.UpdateFilterData(m_Series[i], dataZoom);
}
}
}
/// <summary>
/// 指定系列是否显示
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public bool IsActive(string name)
{
var serie = GetSerie(name);
return serie == null ? false : serie.show;
}
/// <summary>
/// 指定系列是否显示
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public bool IsActive(int index)
{
var serie = GetSerie(index);
return serie == null ? false : serie.show;
}
/// <summary>
/// 设置指定系列是否显示
/// </summary>
/// <param name="name"></param>
/// <param name="active"></param>
public void SetActive(string name, bool active)
{
var serie = GetSerie(name);
if (serie != null)
{
serie.show = active;
}
}
/// <summary>
/// 设置指定系列是否显示
/// </summary>
/// <param name="index"></param>
/// <param name="active"></param>
public void SetActive(int index, bool active)
{
var serie = GetSerie(index);
if (serie != null)
{
serie.show = active;
serie.AnimationReset();
if (active) serie.AnimationFadeIn();
}
}
/// <summary>
/// 指定系列是否处于高亮选中状态
/// </summary>
/// <param name="serieIndex"></param>
/// <returns></returns>
public bool IsHighlight(int serieIndex)
{
var serie = GetSerie(serieIndex);
if (serie != null) return serie.highlighted;
else return false;
}
/// <summary>
/// 设置获得标志图形大小的回调
/// </summary>
/// <param name="size"></param>
/// <param name="selectedSize"></param>
public void SetSerieSymbolSizeCallback(SymbolSizeCallback size, SymbolSizeCallback selectedSize)
{
foreach (var serie in m_Series)
{
serie.symbol.sizeCallback = size;
serie.symbol.selectedSizeCallback = selectedSize;
}
}
}
}

View File

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

View File

@@ -1,234 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System;
using UnityEngine;
namespace XCharts
{
/// <summary>
/// Vessel component for liquid chart. There can be multiple vessels in a Chart, which can be matched by vesselIndex in Serie.
/// <para>
/// 容器组件。
/// 一般用于LiquidChart。一个Chart中可以有多个VesselSerie中用vesselIndex来对应。
/// </para>
/// </summary>
[Serializable]
public class Vessel : MainComponent
{
public enum Shape
{
/// <summary>
/// 圆形
/// </summary>
Circle,
/// <summary>
/// 正方形。
/// </summary>
Rect,
/// <summary>
/// 三角形。
/// </summary>
Triangle,
/// <summary>
/// 菱形。
/// </summary>
Diamond,
/// <summary>
/// 不显示标记。
/// </summary>
None,
}
[SerializeField] private bool m_Show = true;
[SerializeField] private Shape m_Shape = Shape.Circle;
[SerializeField] private float m_ShapeWidth = 5f;
[SerializeField] private float m_Gap = 5f;
[SerializeField] private Color32 m_Color;
[SerializeField] private Color32 m_BackgroundColor;
[SerializeField] private bool m_AutoColor = true;
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.5f };
[SerializeField] private float m_Radius = 0.35f;
[SerializeField] [Range(0.5f, 10f)] private float m_Smoothness = 1f;
[SerializeField] private float m_Width = 0.5f;
[SerializeField] private float m_Height = 0.7f;
[SerializeField] private float[] m_CornerRadius = new float[] { 0, 0, 0, 0 };
/// <summary>
/// Whether to show the vessel.
/// 是否显示容器组件。
/// [defaut: true]
/// </summary>
public bool show
{
get { return m_Show; }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// The shape of vessel.
/// 容器形状。
/// [default: Shape.Circle]
/// </summary>
public Shape shape
{
get { return m_Shape; }
set { if (PropertyUtil.SetStruct(ref m_Shape, value)) SetVerticesDirty(); }
}
/// <summary>
/// Thickness of vessel.
/// 容器厚度。
/// [defaut: 5f]
/// </summary>
public float shapeWidth
{
get { return m_ShapeWidth; }
set { if (PropertyUtil.SetStruct(ref m_ShapeWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// The gap between the vessel and the liquid.
/// 间隙。容器和液体的间隙。
/// [defaut: 10f]
/// </summary>
public float gap
{
get { return m_Gap; }
set { if (PropertyUtil.SetStruct(ref m_Gap, value)) SetVerticesDirty(); }
}
/// <summary>
/// The center of vesselß. The center[0] is the x-coordinate, and the center[1] is the y-coordinate.
/// When value between 0 and 1 represents a percentage relative to the chart.
/// 中心点。数组的第一项是横坐标,第二项是纵坐标。
/// 当值为0-1之间时表示百分比设置成百分比时表示图表宽高最小值的百分比。
/// [default:[0.5f,0.45f]]
/// </summary>
public float[] center
{
get { return m_Center; }
set { if (value != null) { m_Center = value; SetAllDirty(); } }
}
/// <summary>
/// The radius of vessel.
/// When value between 0 and 1 represents a percentage relative to the chart.
/// 半径。
/// [default: 0.35f]
/// </summary>
public float radius
{
get { return m_Radius; }
set { if (PropertyUtil.SetStruct(ref m_Radius, value)) SetAllDirty(); }
}
/// <summary>
/// The width of vessel.
/// When value between 0 and 1 represents a percentage relative to the chart.
/// 容器的宽。shape为Rect时有效。
/// [default: 0.35f]
/// </summary>
public float width
{
get { return m_Width; }
set { if (PropertyUtil.SetStruct(ref m_Width, value)) SetAllDirty(); }
}
/// <summary>
/// The height of vessel.
/// When value between 0 and 1 represents a percentage relative to the chart.
/// 容器的高。shape为Rect时有效。
/// [default: 0.35f]
/// </summary>
public float height
{
get { return m_Height; }
set { if (PropertyUtil.SetStruct(ref m_Height, value)) SetAllDirty(); }
}
/// <summary>
/// The smoothness of wave.
/// 水波平滑度。
/// [default: 1f]
/// </summary>
public float smoothness
{
get { return m_Smoothness; }
set { if (PropertyUtil.SetStruct(ref m_Smoothness, value)) SetAllDirty(); }
}
/// <summary>
/// Background color of polar, which is transparent by default.
/// 背景色,默认透明。
/// [default: `Color.clear`]
/// </summary>
public Color32 backgroundColor
{
get { return m_BackgroundColor; }
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// Vessel color. The default is consistent with Serie.
/// 容器颜色。默认和serie一致。
/// </summary>
public Color32 color
{
get { return m_Color; }
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether automatic color. If true, the color matches serie.
/// 是否自动颜色。为true时颜色会和serie一致。
/// [default: true]
/// </summary>
public bool autoColor
{
get { return m_AutoColor; }
set { if (PropertyUtil.SetStruct(ref m_AutoColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// The radius of rounded corner. Its unit is px. Use array to respectively specify the 4 corner radiuses((clockwise upper left, upper right, bottom right and bottom left)).
/// 容器的圆角半径。用数组分别指定4个圆角半径顺时针左上右上右下左下。shape为Rect时有效。
/// </summary>
public float[] cornerRadius
{
get { return m_CornerRadius; }
set { if (PropertyUtil.SetClass(ref m_CornerRadius, value, true)) SetVerticesDirty(); }
}
public int index { get; internal set; }
/// <summary>
/// the runtime center position of vessel.
/// 运行时中心点。
/// </summary>
public Vector3 runtimeCenterPos { get; internal set; }
/// <summary>
/// the runtime radius of vessel.
/// 运行时半径。
/// </summary>
public float runtimeRadius { get; internal set; }
/// <summary>
/// The actual radius after deducting shapeWidth and gap.
/// 运行时内半径。扣除厚度和间隙后的实际半径。
/// </summary>
public float runtimeInnerRadius { get; internal set; }
public float runtimeWidth { get; set; }
public float runtimeHeight { get; set; }
public static Vessel defaultVessel
{
get
{
var vessel = new Vessel
{
m_Show = true,
m_Shape = Shape.Circle,
m_ShapeWidth = 5,
m_Gap = 5,
m_Radius = 0.35f,
m_Width = 0.5f,
m_Height = 0.7f,
m_AutoColor = true,
m_Color = new Color32(70, 70, 240, 255),
m_Smoothness = 1
};
vessel.center[0] = 0.5f;
vessel.center[1] = 0.45f;
return vessel;
}
}
}
}

View File

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

View File

@@ -1,999 +0,0 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using XUGL;
namespace XCharts
{
/// <summary>
/// VisualMap component. Mapping data to visual elements such as colors.
/// 视觉映射组件。用于进行『视觉编码』,也就是将数据映射到视觉元素(视觉通道)。
/// </summary>
[System.Serializable]
public class VisualMap : MainComponent
{
/// <summary>
/// 类型。分为连续型和分段型。
/// </summary>
public enum Type
{
/// <summary>
/// 连续型。
/// </summary>
Continuous,
/// <summary>
/// 分段型。
/// </summary>
Piecewise
}
/// <summary>
/// 选择模式
/// </summary>
public enum SelectedMode
{
/// <summary>
/// 多选。
/// </summary>
Multiple,
/// <summary>
/// 单选。
/// </summary>
Single
}
[System.Serializable]
public class Pieces
{
[SerializeField] private double m_Min;
[SerializeField] private double m_Max;
[SerializeField] private string m_Label;
[SerializeField] private Color32 m_Color;
/// <summary>
/// 范围最小值
/// </summary>
public double min { get { return m_Min; } set { m_Min = value; } }
/// <summary>
/// 范围最大值
/// </summary>
public double max { get { return m_Max; } set { m_Max = value; } }
/// <summary>
/// 文字描述
/// </summary>
public string label { get { return m_Label; } set { m_Label = value; } }
/// <summary>
/// 颜色
/// </summary>
public Color32 color { get { return m_Color; } set { m_Color = value; } }
public bool Contains(double value, double minMaxRange)
{
var cmin = System.Math.Abs(m_Min) < 1 ? minMaxRange * m_Min : m_Min;
var cmax = System.Math.Abs(m_Max) < 1 ? minMaxRange * m_Max : m_Max;
return value >= cmin && value < cmax;
}
}
[SerializeField] private bool m_Enable = false;
[SerializeField] private bool m_Show = true;
[SerializeField] private Type m_Type = Type.Continuous;
[SerializeField] private SelectedMode m_SelectedMode = SelectedMode.Multiple;
[SerializeField] private double m_Min = 0;
[SerializeField] private double m_Max = 100;
[SerializeField] private double[] m_Range = new double[2] { 0, 100 };
[SerializeField] private string[] m_Text = new string[2] { "", "" };
[SerializeField] private float[] m_TextGap = new float[2] { 10f, 10f };
[SerializeField] private int m_SplitNumber = 5;
[SerializeField] private bool m_Calculable = false;
[SerializeField] private bool m_Realtime = true;
[SerializeField] private float m_ItemWidth = 20f;
[SerializeField] private float m_ItemHeight = 140f;
[SerializeField] private float m_ItemGap = 10f;
[SerializeField] private float m_BorderWidth = 0;
[SerializeField] private int m_Dimension = -1;
[SerializeField] private bool m_HoverLink = true;
[SerializeField] private bool m_AutoMinMax = true;
[SerializeField] private Orient m_Orient = Orient.Horizonal;
[SerializeField] private Location m_Location = Location.defaultLeft;
[SerializeField] private List<Color32> m_InRange = new List<Color32>();
[SerializeField] private List<Color32> m_OutOfRange = new List<Color32>() { Color.gray };
[SerializeField] private List<Pieces> m_Pieces = new List<Pieces>();
/// <summary>
/// Whether enable visualMap component.
///
/// 是否开启组件功能。
///
/// [default: false]
/// </summary>
public bool enable
{
get { return m_Enable; }
set { if (PropertyUtil.SetStruct(ref m_Enable, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether to display components. If set to false, it will not show up, but the data mapping function still exists.
///
/// 是否显示组件。如果设置为 false不会显示但是数据映射的功能还存在。
///
/// [default: true]
/// </summary>
public bool show
{
get { return m_Show; }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// the type of visualmap component.
/// 组件类型。
/// </summary>
public Type type
{
get { return m_Type; }
set { if (PropertyUtil.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
}
/// <summary>
/// the selected mode for Piecewise visualMap.
/// 选择模式。
/// </summary>
public SelectedMode selectedMode
{
get { return m_SelectedMode; }
set { if (PropertyUtil.SetStruct(ref m_SelectedMode, value)) SetVerticesDirty(); }
}
/// <summary>
/// The minimum allowed. 'min' must be user specified. [visualmap.min, visualmap.max] forms the "domain" of the visualMap.
///
/// 允许的最小值。`autoMinMax`为`false`时必须指定。[visualMap.min, visualMap.max] 形成了视觉映射的『定义域』。
/// </summary>
public double min
{
get { return m_Min; }
set { if (PropertyUtil.SetStruct(ref m_Min, value)) SetVerticesDirty(); }
}
/// <summary>
/// The maximum allowed. 'max' must be user specified. [visualmap.min, visualmap.max] forms the "domain" of the visualMap.
///
/// 允许的最大值。`autoMinMax`为`false`时必须指定。[visualMap.min, visualMax.max] 形成了视觉映射的『定义域』。
/// </summary>
public double max
{
get { return m_Max; }
set { m_Max = (value < min ? min + 1 : value); SetVerticesDirty(); }
}
/// <summary>
/// Specifies the position of the numeric value corresponding to the handle. Range should be within the range of [min,max].
///
/// 指定手柄对应数值的位置。range 应在[min,max]范围内。
/// </summary>
public double[] range { get { return m_Range; } }
/// <summary>
/// Text on both ends.
/// 两端的文本,如 ['High', 'Low']。
/// </summary>
public string[] text { get { return m_Text; } }
/// <summary>
/// The distance between the two text bodies.
/// 两端文字主体之间的距离单位为px。
/// </summary>
public float[] textGap { get { return m_TextGap; } }
/// <summary>
/// For continuous data, it is automatically evenly divided into several segments
/// and automatically matches the size of inRange color list when the default is 0.
///
/// 对于连续型数据自动平均切分成几段默认为0时自动匹配inRange颜色列表大小。
/// </summary>
/// <value></value>
public int splitNumber
{
get { return m_SplitNumber; }
set { if (PropertyUtil.SetStruct(ref m_SplitNumber, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether the handle used for dragging is displayed (the handle can be dragged to adjust the selected range).
///
/// 是否显示拖拽用的手柄(手柄能拖拽调整选中范围)。
/// </summary>
public bool calculable
{
get { return m_Calculable; }
set { if (PropertyUtil.SetStruct(ref m_Calculable, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether to update in real time while dragging.
///
/// 拖拽时,是否实时更新。
/// </summary>
public bool realtime
{
get { return m_Realtime; }
set { if (PropertyUtil.SetStruct(ref m_Realtime, value)) SetVerticesDirty(); }
}
/// <summary>
/// The width of the figure, that is, the width of the color bar.
///
/// 图形的宽度,即颜色条的宽度。
/// </summary>
public float itemWidth
{
get { return m_ItemWidth; }
set { if (PropertyUtil.SetStruct(ref m_ItemWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// The height of the figure, that is, the height of the color bar.
///
/// 图形的高度,即颜色条的高度。
/// </summary>
public float itemHeight
{
get { return m_ItemHeight; }
set { if (PropertyUtil.SetStruct(ref m_ItemHeight, value)) SetVerticesDirty(); }
}
/// <summary>
/// 每个图元之间的间隔距离。
/// </summary>
public float itemGap
{
get { return m_ItemGap; }
set { if (PropertyUtil.SetStruct(ref m_ItemGap, value)) SetVerticesDirty(); }
}
/// <summary>
/// Border line width.
///
/// 边框线宽单位px。
/// </summary>
public float borderWidth
{
get { return m_BorderWidth; }
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// Specifies "which dimension" of the data to map to the visual element. "Data" is series.data.
/// Starting at 1, the default is 0 to take the last dimension in data.
///
/// 指定用数据的『哪个维度』,映射到视觉元素上。『数据』即 series.data。从1开始默认为0取 data 中最后一个维度。
/// </summary>
public int dimension
{
get { return m_Dimension; }
set { if (PropertyUtil.SetStruct(ref m_Dimension, value)) SetVerticesDirty(); }
}
/// <summary>
/// When the hoverLink function is turned on, when the mouse hovers over the visualMap component,
/// the corresponding value of the mouse position is highlighted in the corresponding graphic element in the diagram.
/// Conversely, when the mouse hovers over a graphic element in a diagram,
/// the corresponding value of the visualMap component is triangulated in the corresponding position.
///
/// 打开 hoverLink 功能时,鼠标悬浮到 visualMap 组件上时,鼠标位置对应的数值 在 图表中对应的图形元素,会高亮。
/// 反之,鼠标悬浮到图表中的图形元素上时,在 visualMap 组件的相应位置会有三角提示其所对应的数值。
/// </summary>
/// <value></value>
public bool hoverLink
{
get { return m_HoverLink; }
set { if (PropertyUtil.SetStruct(ref m_HoverLink, value)) SetVerticesDirty(); }
}
/// <summary>
/// Automatically set min, Max value
/// 自动设置minmax的值
/// </summary>
public bool autoMinMax
{
get { return m_AutoMinMax; }
set { if (PropertyUtil.SetStruct(ref m_AutoMinMax, value)) SetVerticesDirty(); }
}
/// <summary>
/// Specify whether the layout of component is horizontal or vertical.
///
/// 布局方式是横还是竖。
/// </summary>
public Orient orient
{
get { return m_Orient; }
set { if (PropertyUtil.SetStruct(ref m_Orient, value)) SetVerticesDirty(); }
}
/// <summary>
/// The location of component.
/// 组件显示的位置。
/// </summary>
public Location location
{
get { return m_Location; }
set { if (PropertyUtil.SetClass(ref m_Location, value)) SetVerticesDirty(); }
}
/// <summary>
/// Defines the visual color in the selected range.
/// 定义 在选中范围中 的视觉颜色。
/// </summary>
public List<Color32> inRange
{
get { return m_InRange; }
set { if (value != null) { m_InRange = value; SetVerticesDirty(); } }
}
/// <summary>
/// Defines a visual color outside of the selected range.
/// 定义 在选中范围外 的视觉颜色。
/// </summary>
public List<Color32> outOfRange
{
get { return m_OutOfRange; }
set { if (value != null) { m_OutOfRange = value; SetVerticesDirty(); } }
}
/// <summary>
/// 分段式每一段的相关配置。
/// </summary>
public List<Pieces> pieces
{
get { return m_Pieces; }
set { if (value != null) { m_Pieces = value; SetVerticesDirty(); } }
}
public override bool vertsDirty { get { return m_VertsDirty || location.anyDirty; } }
public override void ClearVerticesDirty()
{
base.ClearVerticesDirty();
location.ClearVerticesDirty();
}
public override void ClearComponentDirty()
{
base.ClearComponentDirty();
location.ClearComponentDirty();
}
/// <summary>
/// 鼠标悬停选中的index
/// </summary>
/// <value></value>
public int runtimeSelectedIndex { get; set; }
public double runtimeSelectedValue { get; set; }
/// <summary>
/// the current pointer position.
/// 当前鼠标位置。
/// </summary>
public Vector2 runtimePointerPos { get; set; }
public bool runtimeIsVertical { get { return orient == Orient.Vertical; } }
public double rangeMin
{
get
{
if (m_Range[0] < min || m_Range[0] > max) return min;
else return m_Range[0];
}
set
{
if (value >= min && value <= m_Range[1]) m_Range[0] = value;
}
}
public double rangeMax
{
get
{
if (m_Range[1] >= m_Range[0] && m_Range[1] < max) return m_Range[1];
else return max;
}
set
{
if (value >= m_Range[0] && value <= max) m_Range[1] = value;
}
}
public int runtimeSplitNumber
{
get
{
if (splitNumber > 0 && splitNumber <= m_InRange.Count) return splitNumber;
else return m_InRange.Count;
}
}
public float runtimeRangeMinHeight { get { return (float)((rangeMin - min) / (max - min) * itemHeight); } }
public float runtimeRangeMaxHeight { get { return (float)((rangeMax - min) / (max - min) * itemHeight); } }
public bool runtimeMinDrag { get; internal set; }
public bool runtimeMaxDrag { get; internal set; }
private List<Color32> m_RtInRange = new List<Color32>();
public List<Color32> runtimeInRange
{
get
{
if (splitNumber == 0 || m_InRange.Count >= splitNumber || m_InRange.Count < 1 || IsPiecewise())
{
return m_InRange;
}
else
{
if (m_RtInRange.Count != runtimeSplitNumber)
{
m_RtInRange.Clear();
var total = max - min;
var diff1 = total / (m_InRange.Count - 1);
var diff2 = total / splitNumber;
var inCount = 0;
var inValue = min;
var rtValue = min;
for (int i = 0; i < splitNumber; i++)
{
rtValue += diff2;
if (rtValue > inValue + diff1)
{
inValue += diff1;
inCount++;
}
if (i == splitNumber - 1)
{
m_RtInRange.Add(m_InRange[m_InRange.Count - 1]);
}
else
{
var rate = (float)((rtValue - inValue) / diff1);
m_RtInRange.Add(Color32.Lerp(m_InRange[inCount], m_InRange[inCount + 1], rate));
}
}
}
return m_RtInRange;
}
}
}
public Color32 GetColor(double value)
{
switch (type)
{
case Type.Continuous:
return GetContinuousColor(value);
case Type.Piecewise:
return GetPiecesColor(value);
default:
return ColorUtil.clearColor32;
}
}
private Color32 GetPiecesColor(double value)
{
foreach (var piece in m_Pieces)
{
if (piece.Contains(value, max - min))
{
return piece.color;
}
}
if (m_OutOfRange.Count > 0) return m_OutOfRange[0];
else return ChartConst.clearColor32;
}
private Color32 GetContinuousColor(double value)
{
if (value < m_Min || value > m_Max)
{
if (m_OutOfRange.Count > 0) return m_OutOfRange[0];
else return ChartConst.clearColor32;
}
int splitNumber = runtimeInRange.Count;
if (splitNumber <= 0) return ChartConst.clearColor32;
var index = GetIndex(value);
if (m_Type == VisualMap.Type.Piecewise)
{
if (index >= 0 && index < runtimeInRange.Count)
return runtimeInRange[index];
else return ChartConst.clearColor32;
}
else
{
var diff = (m_Max - m_Min) / (splitNumber - 1);
var nowMin = m_Min + index * diff;
var rate = (value - nowMin) / diff;
if (index == splitNumber - 1) return runtimeInRange[index];
else return Color32.Lerp(runtimeInRange[index], runtimeInRange[index + 1], (float)rate);
}
}
public int GetIndex(double value)
{
int splitNumber = runtimeInRange.Count;
if (splitNumber <= 0) return -1;
value = MathUtil.Clamp(value, m_Min, m_Max);
var diff = (m_Max - m_Min) / (splitNumber - 1);
var index = -1;
for (int i = 0; i < splitNumber; i++)
{
if (value <= m_Min + (i + 1) * diff)
{
index = i;
break;
}
}
return index;
}
public bool IsPiecewise()
{
return m_Type == VisualMap.Type.Piecewise;
}
public bool IsInSelectedValue(double value)
{
if (runtimeSelectedIndex < 0) return true;
else
{
return runtimeSelectedIndex == GetIndex(value);
}
}
public double GetValue(Vector3 pos, Rect chartRect)
{
var centerPos = new Vector3(chartRect.x, chartRect.y) + location.GetPosition(chartRect.width, chartRect.height);
var pos1 = centerPos + (runtimeIsVertical ? Vector3.down : Vector3.left) * itemHeight / 2;
var pos2 = centerPos + (runtimeIsVertical ? Vector3.up : Vector3.right) * itemHeight / 2;
if (runtimeIsVertical)
{
if (pos.y < pos1.y) return min;
else if (pos.y > pos2.y) return max;
else return min + (pos.y - pos1.y) / (pos2.y - pos1.y) * (max - min);
}
else
{
if (pos.x < pos1.x) return min;
else if (pos.x > pos2.x) return max;
else return min + (pos.x - pos1.x) / (pos2.x - pos1.x) * (max - min);
}
}
public bool IsInRect(Vector3 local, Rect chartRect, float triangleLen = 20)
{
var centerPos = new Vector3(chartRect.x, chartRect.y) + location.GetPosition(chartRect.width, chartRect.height);
var diff = calculable ? triangleLen : 0;
if (local.x >= centerPos.x - itemWidth / 2 - diff && local.x <= centerPos.x + itemWidth / 2 + diff &&
local.y >= centerPos.y - itemHeight / 2 - diff && local.y <= centerPos.y + itemHeight / 2 + diff)
{
return true;
}
else
{
return false;
}
}
public bool IsInRangeRect(Vector3 local, Rect chartRect)
{
var centerPos = new Vector3(chartRect.x, chartRect.y) + location.GetPosition(chartRect.width, chartRect.height);
if (orient == Orient.Vertical)
{
var pos1 = centerPos + Vector3.down * itemHeight / 2;
return local.x >= centerPos.x - itemWidth / 2 && local.x <= centerPos.x + itemWidth / 2 &&
local.y >= pos1.y + runtimeRangeMinHeight && local.y <= pos1.y + runtimeRangeMaxHeight;
}
else
{
var pos1 = centerPos + Vector3.left * itemHeight / 2;
return local.x >= pos1.x + runtimeRangeMinHeight && local.x <= pos1.x + runtimeRangeMaxHeight &&
local.y >= centerPos.y - itemWidth / 2 && local.y <= centerPos.y + itemWidth / 2;
}
}
public bool IsInRangeMinRect(Vector3 local, Rect chartRect, float triangleLen)
{
var centerPos = new Vector3(chartRect.x, chartRect.y) + location.GetPosition(chartRect.width, chartRect.height);
if (orient == Orient.Vertical)
{
var radius = triangleLen / 2;
var pos1 = centerPos + Vector3.down * itemHeight / 2;
var cpos = new Vector3(pos1.x + itemWidth / 2 + radius, pos1.y + runtimeRangeMinHeight - radius);
return local.x >= cpos.x - radius && local.x <= cpos.x + radius &&
local.y >= cpos.y - radius && local.y <= cpos.y + radius;
}
else
{
var radius = triangleLen / 2;
var pos1 = centerPos + Vector3.left * itemHeight / 2;
var cpos = new Vector3(pos1.x + runtimeRangeMinHeight, pos1.y + itemWidth / 2 + radius);
return local.x >= cpos.x - radius && local.x <= cpos.x + radius &&
local.y >= cpos.y - radius && local.y <= cpos.y + radius;
}
}
public bool IsInRangeMaxRect(Vector3 local, Rect chartRect, float triangleLen)
{
var centerPos = new Vector3(chartRect.x, chartRect.y) + location.GetPosition(chartRect.width, chartRect.height);
if (orient == Orient.Vertical)
{
var radius = triangleLen / 2;
var pos1 = centerPos + Vector3.down * itemHeight / 2;
var cpos = new Vector3(pos1.x + itemWidth / 2 + radius, pos1.y + runtimeRangeMaxHeight + radius);
return local.x >= cpos.x - radius && local.x <= cpos.x + radius &&
local.y >= cpos.y - radius && local.y <= cpos.y + radius;
}
else
{
var radius = triangleLen / 2;
var pos1 = centerPos + Vector3.left * itemHeight / 2;
var cpos = new Vector3(pos1.x + runtimeRangeMaxHeight + radius, pos1.y + itemWidth / 2 + radius);
return local.x >= cpos.x - radius && local.x <= cpos.x + radius &&
local.y >= cpos.y - radius && local.y <= cpos.y + radius;
}
}
}
internal class VisualMapHandler : IComponentHandler
{
public BaseChart chart;
public VisualMapHandler(BaseChart chart)
{
this.chart = chart;
}
public void Init() { }
public void OnBeginDrag(PointerEventData eventData)
{
foreach (var visualMap in chart.visualMaps)
{
OnDragVisualMapStart(visualMap);
}
}
public void OnDrag(PointerEventData eventData)
{
foreach (var visualMap in chart.visualMaps)
{
OnDragVisualMap(visualMap);
}
}
public void OnEndDrag(PointerEventData eventData)
{
foreach (var visualMap in chart.visualMaps)
{
OnDragVisualMapEnd(visualMap);
}
}
public void OnPointerDown(PointerEventData eventData) { }
public void OnScroll(PointerEventData eventData) { }
public void Update()
{
foreach (var visualMap in chart.visualMaps)
{
CheckVisualMap(visualMap);
}
}
public void DrawBase(VertexHelper vh)
{
foreach (var visualMap in chart.visualMaps)
{
if (!visualMap.enable || !visualMap.show) continue;
switch (visualMap.type)
{
case VisualMap.Type.Continuous:
DrawContinuousVisualMap(vh, visualMap);
break;
case VisualMap.Type.Piecewise:
//DrawPiecewiseVisualMap(vh, visualMap);
break;
}
}
}
public void DrawTop(VertexHelper vh)
{
}
private void CheckVisualMap(VisualMap visualMap)
{
if (visualMap == null || !visualMap.enable || !visualMap.show) return;
Vector2 local;
if (chart.canvas == null) return;
if (!chart.ScreenPointToChartPoint(Input.mousePosition, out local))
{
if (visualMap.runtimeSelectedIndex >= 0)
{
visualMap.runtimeSelectedIndex = -1;
chart.RefreshChart();
}
return;
}
if (local.x < chart.chartX || local.x > chart.chartX + chart.chartWidth ||
local.y < chart.chartY || local.y > chart.chartY + chart.chartHeight ||
!visualMap.IsInRangeRect(local, chart.chartRect))
{
if (visualMap.runtimeSelectedIndex >= 0)
{
visualMap.runtimeSelectedIndex = -1;
chart.RefreshChart();
}
return;
}
var pos1 = Vector3.zero;
var pos2 = Vector3.zero;
var halfHig = visualMap.itemHeight / 2;
var centerPos = chart.chartPosition + visualMap.location.GetPosition(chart.chartWidth, chart.chartHeight);
var selectedIndex = -1;
double value = 0;
switch (visualMap.orient)
{
case Orient.Horizonal:
pos1 = centerPos + Vector3.left * halfHig;
pos2 = centerPos + Vector3.right * halfHig;
value = visualMap.min + (local.x - pos1.x) / (pos2.x - pos1.x) * (visualMap.max - visualMap.min);
selectedIndex = visualMap.GetIndex(value);
break;
case Orient.Vertical:
pos1 = centerPos + Vector3.down * halfHig;
pos2 = centerPos + Vector3.up * halfHig;
value = visualMap.min + (local.y - pos1.y) / (pos2.y - pos1.y) * (visualMap.max - visualMap.min);
selectedIndex = visualMap.GetIndex(value);
break;
}
visualMap.runtimeSelectedValue = value;
visualMap.runtimeSelectedIndex = selectedIndex;
chart.RefreshChart();
}
private void DrawContinuousVisualMap(VertexHelper vh, VisualMap visualMap)
{
var centerPos = chart.chartPosition + visualMap.location.GetPosition(chart.chartWidth, chart.chartHeight);
var pos1 = Vector3.zero;
var pos2 = Vector3.zero;
var dir = Vector3.zero;
var halfWid = visualMap.itemWidth / 2;
var halfHig = visualMap.itemHeight / 2;
var xRadius = 0f;
var yRadius = 0f;
var splitNum = visualMap.runtimeInRange.Count;
var splitWid = visualMap.itemHeight / (splitNum - 1);
var isVertical = false;
var colors = visualMap.runtimeInRange;
var triangeLen = chart.theme.visualMap.triangeLen;
switch (visualMap.orient)
{
case Orient.Horizonal:
pos1 = centerPos + Vector3.left * halfHig;
pos2 = centerPos + Vector3.right * halfHig;
dir = Vector3.right;
xRadius = splitWid / 2;
yRadius = halfWid;
isVertical = false;
if (visualMap.calculable)
{
var p0 = pos1 + Vector3.right * visualMap.runtimeRangeMinHeight;
var p1 = p0 + Vector3.up * halfWid;
var p2 = p0 + Vector3.up * (halfWid + triangeLen);
var p3 = p2 + Vector3.left * triangeLen;
var color = visualMap.GetColor(visualMap.rangeMin);
UGL.DrawTriangle(vh, p1, p2, p3, color);
p0 = pos1 + Vector3.right * visualMap.runtimeRangeMaxHeight;
p1 = p0 + Vector3.up * halfWid;
p2 = p0 + Vector3.up * (halfWid + triangeLen);
p3 = p2 + Vector3.right * triangeLen;
color = visualMap.GetColor(visualMap.rangeMax);
UGL.DrawTriangle(vh, p1, p2, p3, color);
}
break;
case Orient.Vertical:
pos1 = centerPos + Vector3.down * halfHig;
pos2 = centerPos + Vector3.up * halfHig;
dir = Vector3.up;
xRadius = halfWid;
yRadius = splitWid / 2;
isVertical = true;
if (visualMap.calculable)
{
var p0 = pos1 + Vector3.up * visualMap.runtimeRangeMinHeight;
var p1 = p0 + Vector3.right * halfWid;
var p2 = p0 + Vector3.right * (halfWid + triangeLen);
var p3 = p2 + Vector3.down * triangeLen;
var color = visualMap.GetColor(visualMap.rangeMin);
UGL.DrawTriangle(vh, p1, p2, p3, color);
p0 = pos1 + Vector3.up * visualMap.runtimeRangeMaxHeight;
p1 = p0 + Vector3.right * halfWid;
p2 = p0 + Vector3.right * (halfWid + triangeLen);
p3 = p2 + Vector3.up * triangeLen;
color = visualMap.GetColor(visualMap.rangeMax);
UGL.DrawTriangle(vh, p1, p2, p3, color);
}
break;
}
if (visualMap.calculable && (visualMap.rangeMin > visualMap.min
|| visualMap.rangeMax < visualMap.max))
{
var rangeMin = visualMap.rangeMin;
var rangeMax = visualMap.rangeMax;
var diff = (visualMap.max - visualMap.min) / (splitNum - 1);
for (int i = 1; i < splitNum; i++)
{
var splitMin = visualMap.min + (i - 1) * diff;
var splitMax = splitMin + diff;
if (rangeMin > splitMax || rangeMax < splitMin)
{
continue;
}
else if (rangeMin <= splitMin && rangeMax >= splitMax)
{
var splitPos = pos1 + dir * (i - 1 + 0.5f) * splitWid;
var startColor = colors[i - 1];
var toColor = visualMap.IsPiecewise() ? startColor : colors[i];
UGL.DrawRectangle(vh, splitPos, xRadius, yRadius, startColor, toColor, isVertical);
}
else if (rangeMin > splitMin && rangeMax >= splitMax)
{
var p0 = pos1 + dir * visualMap.runtimeRangeMinHeight;
var splitMaxPos = pos1 + dir * i * splitWid;
var splitPos = p0 + (splitMaxPos - p0) / 2;
var startColor = visualMap.GetColor(visualMap.rangeMin);
var toColor = visualMap.IsPiecewise() ? startColor : colors[i];
var yRadius1 = Vector3.Distance(p0, splitMaxPos) / 2;
if (visualMap.orient == Orient.Vertical)
UGL.DrawRectangle(vh, splitPos, xRadius, yRadius1, startColor, toColor, isVertical);
else
UGL.DrawRectangle(vh, splitPos, yRadius1, yRadius, startColor, toColor, isVertical);
}
else if (rangeMax < splitMax && rangeMin <= splitMin)
{
var p0 = pos1 + dir * visualMap.runtimeRangeMaxHeight;
var splitMinPos = pos1 + dir * (i - 1) * splitWid;
var splitPos = splitMinPos + (p0 - splitMinPos) / 2;
var startColor = colors[i - 1];
var toColor = visualMap.IsPiecewise() ? startColor : visualMap.GetColor(visualMap.rangeMax);
var yRadius1 = Vector3.Distance(p0, splitMinPos) / 2;
if (visualMap.orient == Orient.Vertical)
UGL.DrawRectangle(vh, splitPos, xRadius, yRadius1, startColor, toColor, isVertical);
else
UGL.DrawRectangle(vh, splitPos, yRadius1, yRadius, startColor, toColor, isVertical);
}
else
{
var p0 = pos1 + dir * visualMap.runtimeRangeMinHeight;
var p1 = pos1 + dir * visualMap.runtimeRangeMaxHeight;
var splitPos = (p0 + p1) / 2;
var startColor = visualMap.GetColor(visualMap.rangeMin);
var toColor = visualMap.GetColor(visualMap.rangeMax);
var yRadius1 = Vector3.Distance(p0, p1) / 2;
if (visualMap.orient == Orient.Vertical)
UGL.DrawRectangle(vh, splitPos, xRadius, yRadius1, startColor, toColor, isVertical);
else
UGL.DrawRectangle(vh, splitPos, yRadius1, yRadius, startColor, toColor, isVertical);
}
}
}
else
{
for (int i = 1; i < splitNum; i++)
{
var splitPos = pos1 + dir * (i - 1 + 0.5f) * splitWid;
var startColor = colors[i - 1];
var toColor = visualMap.IsPiecewise() ? startColor : colors[i];
UGL.DrawRectangle(vh, splitPos, xRadius, yRadius, startColor, toColor, isVertical);
}
}
if (visualMap.rangeMin > visualMap.min)
{
var p0 = pos1 + dir * visualMap.runtimeRangeMinHeight;
UGL.DrawRectangle(vh, pos1, p0, visualMap.itemWidth / 2, chart.theme.visualMap.backgroundColor);
}
if (visualMap.rangeMax < visualMap.max)
{
var p1 = pos1 + dir * visualMap.runtimeRangeMaxHeight;
UGL.DrawRectangle(vh, p1, pos2, visualMap.itemWidth / 2, chart.theme.visualMap.backgroundColor);
}
if (visualMap.hoverLink)
{
if (visualMap.runtimeSelectedIndex >= 0)
{
var p0 = pos1 + dir * visualMap.runtimeRangeMinHeight;
var p1 = pos1 + dir * visualMap.runtimeRangeMaxHeight;
var pointerPos = chart.pointerPos;
if (visualMap.orient == Orient.Vertical)
{
var p2 = new Vector3(centerPos.x + halfWid, Mathf.Clamp(pointerPos.y + (triangeLen / 2), p0.y, p1.y));
var p3 = new Vector3(centerPos.x + halfWid, Mathf.Clamp(pointerPos.y - (triangeLen / 2), p0.y, p1.y));
var p4 = new Vector3(centerPos.x + halfWid + triangeLen / 2, pointerPos.y);
UGL.DrawTriangle(vh, p2, p3, p4, colors[visualMap.runtimeSelectedIndex]);
}
else
{
var p2 = new Vector3(Mathf.Clamp(pointerPos.x + (triangeLen / 2), p0.x, p1.x), centerPos.y + halfWid);
var p3 = new Vector3(Mathf.Clamp(pointerPos.x - (triangeLen / 2), p0.x, p1.x), centerPos.y + halfWid);
var p4 = new Vector3(pointerPos.x, centerPos.y + halfWid + triangeLen / 2);
UGL.DrawTriangle(vh, p2, p3, p4, colors[visualMap.runtimeSelectedIndex]);
}
}
}
}
private void DrawPiecewiseVisualMap(VertexHelper vh, VisualMap visualMap)
{
var centerPos = chart.chartPosition + visualMap.location.GetPosition(chart.chartWidth, chart.chartHeight);
var pos1 = Vector3.zero;
var pos2 = Vector3.zero;
var dir = Vector3.zero;
var halfWid = visualMap.itemWidth / 2;
var halfHig = visualMap.itemHeight / 2;
var splitNum = visualMap.runtimeInRange.Count;
var colors = visualMap.runtimeInRange;
switch (visualMap.orient)
{
case Orient.Horizonal:
for (int i = 0; i < visualMap.pieces.Count; i++)
{
var piece = visualMap.pieces[i];
}
break;
case Orient.Vertical:
var each = visualMap.itemHeight + visualMap.itemGap;
for (int i = 0; i < visualMap.pieces.Count; i++)
{
var piece = visualMap.pieces[i];
var pos = new Vector3(centerPos.x, centerPos.y - each * i);
UGL.DrawRectangle(vh, pos, halfWid, halfHig, piece.color);
}
break;
}
}
protected void OnDragVisualMapStart(VisualMap visualMap)
{
if (!visualMap.enable || !visualMap.show || !visualMap.calculable) return;
var inMinRect = visualMap.IsInRangeMinRect(chart.pointerPos, chart.chartRect, chart.theme.visualMap.triangeLen);
var inMaxRect = visualMap.IsInRangeMaxRect(chart.pointerPos, chart.chartRect, chart.theme.visualMap.triangeLen);
if (inMinRect || inMaxRect)
{
if (inMinRect)
{
visualMap.runtimeMinDrag = true;
}
else
{
visualMap.runtimeMaxDrag = true;
}
}
}
protected void OnDragVisualMap(VisualMap visualMap)
{
if (!visualMap.enable || !visualMap.show || !visualMap.calculable) return;
if (!visualMap.runtimeMinDrag && !visualMap.runtimeMaxDrag) return;
var value = visualMap.GetValue(chart.pointerPos, chart.chartRect);
if (visualMap.runtimeMinDrag)
{
visualMap.rangeMin = value;
}
else
{
visualMap.rangeMax = value;
}
chart.RefreshChart();
}
protected void OnDragVisualMapEnd(VisualMap visualMap)
{
if (!visualMap.enable || !visualMap.show || !visualMap.calculable) return;
if (visualMap.runtimeMinDrag || visualMap.runtimeMaxDrag)
{
chart.RefreshChart();
visualMap.runtimeMinDrag = false;
visualMap.runtimeMaxDrag = false;
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More