mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-14 20:00:09 +00:00
3.0 - remove gauge chart to extension
This commit is contained in:
@@ -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 (MakeComponentFoldout(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 (MakeComponentFoldout(prop, "m_Show"))
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
PropertyField(prop, "m_Width");
|
||||
PropertyField(prop, "m_Length");
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dec6cfc5ef85147738a81d8de84b079a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -63,34 +63,4 @@ namespace XCharts
|
||||
PropertyField(prop, "m_ShowEndTick");
|
||||
}
|
||||
}
|
||||
|
||||
[CustomPropertyDrawer(typeof(GaugeAxisSplitLine), true)]
|
||||
public class GaugeAxisSplitDrawer : BaseLineDrawer
|
||||
{
|
||||
public override string ClassName { get { return "Split Line"; } }
|
||||
}
|
||||
|
||||
[CustomPropertyDrawer(typeof(GaugeAxisTick), true)]
|
||||
public class GaugeAxisTickDrawer : BaseLineDrawer
|
||||
{
|
||||
public override string ClassName { get { return "Axis Tick"; } }
|
||||
protected override void DrawExtendeds(SerializedProperty prop)
|
||||
{
|
||||
base.DrawExtendeds(prop);
|
||||
PropertyField(prop, "m_SplitNumber");
|
||||
}
|
||||
}
|
||||
|
||||
[CustomPropertyDrawer(typeof(GaugeAxisLine), true)]
|
||||
public class GaugeAxisLineDrawer : BaseLineDrawer
|
||||
{
|
||||
public override string ClassName { get { return "Axis Line"; } }
|
||||
protected override void DrawExtendeds(SerializedProperty prop)
|
||||
{
|
||||
base.DrawExtendeds(prop);
|
||||
PropertyField(prop, "m_BarColor");
|
||||
PropertyField(prop, "m_BarBackgroundColor");
|
||||
PropertyField(prop, "m_StageColor");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[SerieEditor(typeof(Gauge))]
|
||||
public class GaugeEditor : SerieEditor<Gauge>
|
||||
{
|
||||
public override void OnCustomInspectorGUI()
|
||||
{
|
||||
PropertyField("m_GaugeType");
|
||||
PropertyTwoFiled("m_Center");
|
||||
PropertyTwoFiled("m_Radius");
|
||||
PropertyField("m_Min");
|
||||
PropertyField("m_Max");
|
||||
PropertyField("m_StartAngle");
|
||||
PropertyField("m_EndAngle");
|
||||
PropertyFieldLimitMax("m_SplitNumber", 36);
|
||||
PropertyField("m_RoundCap");
|
||||
PropertyField("m_TitleStyle");
|
||||
PropertyField("m_GaugeAxis");
|
||||
PropertyField("m_GaugePointer");
|
||||
|
||||
PropertyField("m_ItemStyle");
|
||||
PropertyField("m_IconStyle");
|
||||
PropertyField("m_Label");
|
||||
PropertyField("m_LabelLine");
|
||||
PropertyField("m_Emphasis");
|
||||
PropertyField("m_Animation");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4a684647051344240bcf87e55653cc17
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -125,13 +125,6 @@ namespace XCharts
|
||||
AddChart<HeatmapChart>("HeatmapChart");
|
||||
}
|
||||
|
||||
[MenuItem("XCharts/GaugeChart", priority = 50)]
|
||||
[MenuItem("GameObject/XCharts/GaugeChart", priority = 50)]
|
||||
public static void AddGaugeChart()
|
||||
{
|
||||
AddChart<GaugeChart>("GaugeChart");
|
||||
}
|
||||
|
||||
[MenuItem("XCharts/RingChart", priority = 51)]
|
||||
[MenuItem("GameObject/XCharts/RingChart", priority = 51)]
|
||||
public static void AddRingChart()
|
||||
|
||||
@@ -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.GetChartComponent<Title>().text = "GaugeChart";
|
||||
chart.RemoveData();
|
||||
|
||||
var serie = chart.AddSerie<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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[AddComponentMenu("XCharts/GaugeChart", 19)]
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(RectTransform))]
|
||||
[DisallowMultipleComponent]
|
||||
public class GaugeChart : BaseChart
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
protected override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
RemoveData();
|
||||
Gauge.AddDefaultSerie(this, GenerateDefaultSerieName());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c7cdc3b6d7f9473289a599c00a2569c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
Assets/XCharts/Runtime/Component/Child/StageColor.cs
Normal file
33
Assets/XCharts/Runtime/Component/Child/StageColor.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[System.Serializable]
|
||||
public class StageColor
|
||||
{
|
||||
[SerializeField] private float m_Percent;
|
||||
[SerializeField] private Color32 m_Color;
|
||||
/// <summary>
|
||||
/// 结束位置百分比。
|
||||
/// </summary>
|
||||
public float percent { get { return m_Percent; } set { m_Percent = value; } }
|
||||
/// <summary>
|
||||
/// 颜色。
|
||||
/// </summary>
|
||||
public Color32 color { get { return m_Color; } set { m_Color = value; } }
|
||||
|
||||
public StageColor(float percent, Color32 color)
|
||||
{
|
||||
m_Percent = percent;
|
||||
m_Color = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3a7b70d5b66640dca4aaecf13d3769f
|
||||
guid: d40f9dfbc90e744858784753e0d7109d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,168 +0,0 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Settings related to gauge axis line.
|
||||
/// 仪表盘轴线相关设置。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class GaugeAxis : ChildComponent
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private GaugeAxisLine m_AxisLine = new GaugeAxisLine(true);
|
||||
[SerializeField] private GaugeAxisSplitLine m_SplitLine = new GaugeAxisSplitLine(true);
|
||||
[SerializeField] private GaugeAxisTick m_AxisTick = new GaugeAxisTick(true);
|
||||
[SerializeField] private LabelStyle m_AxisLabel = new LabelStyle();
|
||||
[SerializeField] private List<string> m_AxisLabelText = new List<string>();
|
||||
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
/// axis line style.
|
||||
/// 仪表盘轴线样式。
|
||||
/// </summary>
|
||||
public GaugeAxisLine axisLine { get { return m_AxisLine; } set { m_AxisLine = value; } }
|
||||
/// <summary>
|
||||
/// slit line style.
|
||||
/// 分割线。
|
||||
/// </summary>
|
||||
public GaugeAxisSplitLine splitLine { get { return m_SplitLine; } set { m_SplitLine = value; } }
|
||||
/// <summary>
|
||||
/// axis tick style.
|
||||
/// 刻度。
|
||||
/// </summary>
|
||||
public GaugeAxisTick axisTick { get { return m_AxisTick; } set { m_AxisTick = value; } }
|
||||
/// <summary>
|
||||
/// axis label style.
|
||||
/// 文本标签。
|
||||
/// </summary>
|
||||
public LabelStyle axisLabel { get { return m_AxisLabel; } set { m_AxisLabel = value; } }
|
||||
/// <summary>
|
||||
/// Coordinate axis scale label custom content. When the content is empty,
|
||||
/// `axisLabel` automatically displays the content according to the scale; otherwise,
|
||||
/// the content is taken from the list definition.
|
||||
///
|
||||
/// 自定义Label的内容。
|
||||
/// </summary>
|
||||
public List<string> axisLabelText { get { return m_AxisLabelText; } set { m_AxisLabelText = value; } }
|
||||
|
||||
public List<float> runtimeStageAngle = new List<float>();
|
||||
public List<Vector3> runtimeLabelPosition = new List<Vector3>();
|
||||
private List<ChartLabel> m_RuntimeLabelList = new List<ChartLabel>();
|
||||
|
||||
internal Color32 GetAxisLineColor(ThemeStyle theme, int index)
|
||||
{
|
||||
var color = !ChartHelper.IsClearColor(axisLine.barColor) ? axisLine.barColor : theme.GetColor(index);
|
||||
ChartHelper.SetColorOpacity(ref color, axisLine.lineStyle.opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
internal Color32 GetAxisLineBackgroundColor(ThemeStyle theme, int index)
|
||||
{
|
||||
var color = !ChartHelper.IsClearColor(axisLine.barBackgroundColor)
|
||||
? axisLine.barBackgroundColor : ChartConst.greyColor32;
|
||||
ChartHelper.SetColorOpacity(ref color, axisLine.lineStyle.opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
internal Color32 GetSplitLineColor(Color32 themeColor, int serieIndex, float angle)
|
||||
{
|
||||
Color32 color;
|
||||
if (!ChartHelper.IsClearColor(splitLine.lineStyle.color))
|
||||
{
|
||||
color = splitLine.lineStyle.color;
|
||||
ChartHelper.SetColorOpacity(ref color, splitLine.lineStyle.opacity);
|
||||
return color;
|
||||
}
|
||||
color = themeColor;
|
||||
ChartHelper.SetColorOpacity(ref color, splitLine.lineStyle.opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
internal Color32 GetAxisTickColor(Color32 themeColor, int serieIndex, float angle)
|
||||
{
|
||||
Color32 color;
|
||||
if (!ChartHelper.IsClearColor(axisTick.lineStyle.color))
|
||||
{
|
||||
color = axisTick.lineStyle.color;
|
||||
ChartHelper.SetColorOpacity(ref color, axisTick.lineStyle.opacity);
|
||||
return color;
|
||||
}
|
||||
color = themeColor;
|
||||
ChartHelper.SetColorOpacity(ref color, axisTick.lineStyle.opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
internal Color32 GetPointerColor(ThemeStyle theme, int serieIndex, float angle, ItemStyle itemStyle)
|
||||
{
|
||||
Color32 color;
|
||||
if (!ChartHelper.IsClearColor(itemStyle.color))
|
||||
{
|
||||
return itemStyle.GetColor();
|
||||
}
|
||||
for (int i = 0; i < runtimeStageAngle.Count; i++)
|
||||
{
|
||||
if (angle < runtimeStageAngle[i])
|
||||
{
|
||||
color = axisLine.stageColor[i].color;
|
||||
ChartHelper.SetColorOpacity(ref color, itemStyle.opacity);
|
||||
return color;
|
||||
}
|
||||
}
|
||||
color = theme.GetColor(serieIndex);
|
||||
ChartHelper.SetColorOpacity(ref color, itemStyle.opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
public void ClearLabelObject()
|
||||
{
|
||||
m_RuntimeLabelList.Clear();
|
||||
}
|
||||
|
||||
public void AddLabelObject(ChartLabel label)
|
||||
{
|
||||
m_RuntimeLabelList.Add(label);
|
||||
}
|
||||
|
||||
public ChartLabel GetLabelObject(int index)
|
||||
{
|
||||
if (index >= 0 && index < m_RuntimeLabelList.Count)
|
||||
{
|
||||
return m_RuntimeLabelList[index];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void SetLabelObjectPosition(int index, Vector3 pos)
|
||||
{
|
||||
if (index >= 0 && index < m_RuntimeLabelList.Count)
|
||||
{
|
||||
m_RuntimeLabelList[index].SetPosition(pos);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetLabelObjectText(int index, string text)
|
||||
{
|
||||
if (index >= 0 && index < m_RuntimeLabelList.Count)
|
||||
{
|
||||
m_RuntimeLabelList[index].SetText(text);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetLabelObjectActive(bool flag)
|
||||
{
|
||||
foreach (var label in m_RuntimeLabelList)
|
||||
{
|
||||
label.SetActive(flag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 604f6e6ae2ba440668799c4c5b5c556d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,63 +0,0 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[System.Serializable]
|
||||
public class StageColor
|
||||
{
|
||||
[SerializeField] private float m_Percent;
|
||||
[SerializeField] private Color32 m_Color;
|
||||
/// <summary>
|
||||
/// 结束位置百分比。
|
||||
/// </summary>
|
||||
public float percent { get { return m_Percent; } set { m_Percent = value; } }
|
||||
/// <summary>
|
||||
/// 颜色。
|
||||
/// </summary>
|
||||
public Color32 color { get { return m_Color; } set { m_Color = value; } }
|
||||
|
||||
public StageColor(float percent, Color32 color)
|
||||
{
|
||||
m_Percent = percent;
|
||||
m_Color = color;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class GaugeAxisLine : BaseLine
|
||||
{
|
||||
[SerializeField] private Color32 m_BarColor;
|
||||
[SerializeField] private Color32 m_BarBackgroundColor = new Color32(200, 200, 200, 255);
|
||||
[SerializeField]
|
||||
private List<StageColor> m_StageColor = new List<StageColor>()
|
||||
{
|
||||
new StageColor(0.2f,new Color32(145,199,174,255)),
|
||||
new StageColor(0.8f,new Color32(99,134,158,255)),
|
||||
new StageColor(1.0f,new Color32(194,53,49,255)),
|
||||
};
|
||||
/// <summary>
|
||||
/// 进度条颜色。
|
||||
/// </summary>
|
||||
public Color32 barColor { get { return m_BarColor; } set { m_BarColor = value; } }
|
||||
/// <summary>
|
||||
/// 进度条背景颜色。
|
||||
/// </summary>
|
||||
public Color32 barBackgroundColor { get { return m_BarBackgroundColor; } set { m_BarBackgroundColor = value; } }
|
||||
/// <summary>
|
||||
/// 阶段颜色。
|
||||
/// </summary>
|
||||
public List<StageColor> stageColor { get { return m_StageColor; } set { m_StageColor = value; } }
|
||||
|
||||
public GaugeAxisLine(bool show) : base(show)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a9f25f2502d7451fa5c5a01a3b3643a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,20 +0,0 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// 分割线
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class GaugeAxisSplitLine : BaseLine
|
||||
{
|
||||
public GaugeAxisSplitLine(bool show) : base(show)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b8581023fe934a70a01b4a2368220bd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,27 +0,0 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// 刻度
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class GaugeAxisTick : BaseLine
|
||||
{
|
||||
[SerializeField] private float m_SplitNumber = 5;
|
||||
/// <summary>
|
||||
/// 分割线之间的分割段数。
|
||||
/// </summary>
|
||||
public float splitNumber { get { return m_SplitNumber; } set { m_SplitNumber = value; } }
|
||||
public GaugeAxisTick(bool show) : base(show)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c826c4dcd580e4f03a8439f182edec45
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,53 +0,0 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Settings related to gauge pointer.
|
||||
/// 仪表盘指针相关设置。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class GaugePointer : ChildComponent
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private float m_Length = 0.8f;
|
||||
[SerializeField] private float m_Width = 15;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to display a pointer.
|
||||
/// 是否显示指针。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Pointer length. It can be an absolute value, or it can be a percentage relative to the radius (0-1).
|
||||
/// 指针长度。可以是绝对值,也可以是相对于半径的百分比(0-1的浮点数)。
|
||||
/// </summary>
|
||||
public float length
|
||||
{
|
||||
get { return m_Length; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Length, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Pointer width.
|
||||
/// 指针宽度。
|
||||
/// </summary>
|
||||
public float width
|
||||
{
|
||||
get { return m_Width; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47709abe074734f0cba29abb9d150433
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -234,77 +234,49 @@ namespace XCharts
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool CheckDataShow(List<Serie> series, string legendName, bool show)
|
||||
public static bool CheckDataShow(Serie serie, string legendName, bool show)
|
||||
{
|
||||
bool needShow = false;
|
||||
foreach (var serie in series)
|
||||
if (legendName.Equals(serie.serieName))
|
||||
{
|
||||
if (legendName.Equals(serie.serieName))
|
||||
serie.show = show;
|
||||
serie.highlight = false;
|
||||
if (serie.show) needShow = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var data in serie.data)
|
||||
{
|
||||
serie.show = show;
|
||||
serie.highlight = false;
|
||||
if (serie.show) needShow = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var data in serie.data)
|
||||
if (legendName.Equals(data.name))
|
||||
{
|
||||
if (legendName.Equals(data.name))
|
||||
{
|
||||
data.show = show;
|
||||
data.context.highlight = false;
|
||||
if (data.show) needShow = true;
|
||||
}
|
||||
data.show = show;
|
||||
data.context.highlight = false;
|
||||
if (data.show) needShow = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return needShow;
|
||||
}
|
||||
|
||||
public static bool CheckDataHighlighted(List<Serie> series, string legendName, bool heighlight)
|
||||
public static bool CheckDataHighlighted(Serie serie, string legendName, bool heighlight)
|
||||
{
|
||||
bool show = false;
|
||||
foreach (var serie in series)
|
||||
if (legendName.Equals(serie.serieName))
|
||||
{
|
||||
if (legendName.Equals(serie.serieName))
|
||||
serie.highlight = heighlight;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var data in serie.data)
|
||||
{
|
||||
serie.highlight = heighlight;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var data in serie.data)
|
||||
if (legendName.Equals(data.name))
|
||||
{
|
||||
if (legendName.Equals(data.name))
|
||||
{
|
||||
data.context.highlight = heighlight;
|
||||
if (data.context.highlight) show = true;
|
||||
}
|
||||
data.context.highlight = heighlight;
|
||||
if (data.context.highlight) show = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return show;
|
||||
}
|
||||
|
||||
public static bool IsSerieLegend<T>(BaseChart chart, string legendName) where T : Serie
|
||||
{
|
||||
foreach (var serie in chart.series)
|
||||
{
|
||||
if (serie is T)
|
||||
{
|
||||
if (serie is Pie || serie is Radar || serie is Ring)
|
||||
{
|
||||
foreach (var serieData in serie.data)
|
||||
{
|
||||
if (legendName.Equals(serieData.name)) return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (legendName.Equals(serie.serieName)) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,47 +11,6 @@ namespace XCharts
|
||||
{
|
||||
public static class SerieLabelHelper
|
||||
{
|
||||
public static void CheckLabel(Serie serie, ref bool m_ReinitLabel, ref bool m_UpdateLabelText)
|
||||
{
|
||||
if (serie is Gauge || serie is Ring)
|
||||
{
|
||||
var serieData = serie.GetSerieData(0);
|
||||
if (serieData != null)
|
||||
{
|
||||
if (serie.label.show && serie.show)
|
||||
{
|
||||
if (serieData.labelObject != null)
|
||||
{
|
||||
serieData.SetLabelActive(true);
|
||||
m_UpdateLabelText = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ReinitLabel = true;
|
||||
}
|
||||
}
|
||||
else if (serieData.labelObject != null)
|
||||
{
|
||||
serieData.SetLabelActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateLabelText(List<Serie> series, ThemeStyle theme, List<string> legendRealShowName)
|
||||
{
|
||||
foreach (var serie in series)
|
||||
{
|
||||
if (!serie.label.show) continue;
|
||||
var colorIndex = legendRealShowName.IndexOf(serie.serieName);
|
||||
if (serie is Gauge)
|
||||
SetGaugeLabelText(serie);
|
||||
else if (serie is Ring)
|
||||
SetRingLabelText(serie, theme);
|
||||
else if (serie is Liquid)
|
||||
SetLiquidLabelText(serie, theme, colorIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public static Color GetLabelColor(Serie serie, ThemeStyle theme, int index)
|
||||
{
|
||||
|
||||
@@ -50,7 +50,6 @@ namespace XCharts
|
||||
[SerializeField] [ListForSerie(typeof(Bar))] private List<Bar> m_SerieBars = new List<Bar>();
|
||||
[SerializeField] [ListForSerie(typeof(Candlestick))] private List<Candlestick> m_SerieCandlesticks = new List<Candlestick>();
|
||||
[SerializeField] [ListForSerie(typeof(EffectScatter))] private List<EffectScatter> m_SerieEffectScatters = new List<EffectScatter>();
|
||||
[SerializeField] [ListForSerie(typeof(Gauge))] private List<Gauge> m_SerieGauges = new List<Gauge>();
|
||||
[SerializeField] [ListForSerie(typeof(Heatmap))] private List<Heatmap> m_SerieHeatmaps = new List<Heatmap>();
|
||||
[SerializeField] [ListForSerie(typeof(Line))] private List<Line> m_SerieLines = new List<Line>();
|
||||
[SerializeField] [ListForSerie(typeof(Liquid))] private List<Liquid> m_SerieLiquids = new List<Liquid>();
|
||||
@@ -495,56 +494,20 @@ namespace XCharts
|
||||
|
||||
public virtual void OnLegendButtonClick(int index, string legendName, bool show)
|
||||
{
|
||||
var clicked = false;
|
||||
foreach (var handler in m_SerieHandlers)
|
||||
clicked = clicked || handler.OnLegendButtonClick(index, legendName, show);
|
||||
if (!clicked)
|
||||
{
|
||||
foreach (var serie in m_Series)
|
||||
{
|
||||
if (legendName.Equals(serie.serieName))
|
||||
{
|
||||
SetSerieActive(serie.index, show);
|
||||
RefreshPainter(serie);
|
||||
}
|
||||
}
|
||||
}
|
||||
handler.OnLegendButtonClick(index, legendName, show);
|
||||
}
|
||||
|
||||
public virtual void OnLegendButtonEnter(int index, string legendName)
|
||||
{
|
||||
var enter = false;
|
||||
foreach (var handler in m_SerieHandlers)
|
||||
enter = enter || handler.OnLegendButtonEnter(index, legendName);
|
||||
if (!enter)
|
||||
{
|
||||
foreach (var serie in m_Series)
|
||||
{
|
||||
if (legendName.Equals(serie.serieName))
|
||||
{
|
||||
serie.highlight = true;
|
||||
RefreshPainter(serie);
|
||||
}
|
||||
}
|
||||
}
|
||||
handler.OnLegendButtonEnter(index, legendName);
|
||||
}
|
||||
|
||||
public virtual void OnLegendButtonExit(int index, string legendName)
|
||||
{
|
||||
var exit = false;
|
||||
foreach (var handler in m_SerieHandlers)
|
||||
exit = exit || handler.OnLegendButtonExit(index, legendName);
|
||||
if (!exit)
|
||||
{
|
||||
foreach (var serie in m_Series)
|
||||
{
|
||||
if (legendName.Equals(serie.serieName))
|
||||
{
|
||||
serie.highlight = false;
|
||||
RefreshPainter(serie);
|
||||
}
|
||||
}
|
||||
}
|
||||
handler.OnLegendButtonExit(index, legendName);
|
||||
}
|
||||
|
||||
protected override void OnDrawPainterBase(VertexHelper vh, Painter painter)
|
||||
|
||||
@@ -11,7 +11,7 @@ using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
internal static class SerieLabelPool
|
||||
public static class SerieLabelPool
|
||||
{
|
||||
private static readonly Stack<GameObject> m_Stack = new Stack<GameObject>(200);
|
||||
private static Dictionary<int, bool> m_ReleaseDic = new Dictionary<int, bool>(1000);
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace XCharts
|
||||
return s_ColorDotStr[color];
|
||||
}
|
||||
|
||||
internal static string GetSerieLabelName(string prefix, int i, int j)
|
||||
public static string GetSerieLabelName(string prefix, int i, int j)
|
||||
{
|
||||
int key = i * 10000000 + j;
|
||||
if (s_SerieLabelName.ContainsKey(key))
|
||||
|
||||
@@ -33,26 +33,6 @@ namespace XCharts
|
||||
marker, itemFormatter, numericFormatter);
|
||||
}
|
||||
|
||||
public override bool OnLegendButtonEnter(int index, string legendName)
|
||||
{
|
||||
if (chart.GetLegendRealShowNameIndex(serie.serieName) == index)
|
||||
{
|
||||
serie.context.isLegendEnter = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool OnLegendButtonExit(int index, string legendName)
|
||||
{
|
||||
if (chart.GetLegendRealShowNameIndex(serie.serieName) == index)
|
||||
{
|
||||
serie.context.isLegendEnter = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void DrawSerie(VertexHelper vh)
|
||||
{
|
||||
DrawBarSerie(vh, serie, serie.context.colorIndex);
|
||||
@@ -63,7 +43,7 @@ namespace XCharts
|
||||
if (m_SerieGrid == null)
|
||||
return;
|
||||
|
||||
var needCheck = (chart.isPointerInChart && m_SerieGrid.IsPointerEnter()) || serie.context.isLegendEnter;
|
||||
var needCheck = (chart.isPointerInChart && m_SerieGrid.IsPointerEnter()) || m_LegendEnter;
|
||||
var needInteract = false;
|
||||
if (!needCheck)
|
||||
{
|
||||
@@ -86,7 +66,7 @@ namespace XCharts
|
||||
return;
|
||||
}
|
||||
m_LastCheckContextFlag = needCheck;
|
||||
if (serie.context.isLegendEnter)
|
||||
if (m_LegendEnter)
|
||||
{
|
||||
serie.context.pointerEnter = true;
|
||||
foreach (var serieData in serie.data)
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[System.Serializable]
|
||||
[SerieHandler(typeof(GaugeHandler), true)]
|
||||
public class Gauge : Serie
|
||||
{
|
||||
[SerializeField] private GaugeType m_GaugeType = GaugeType.Pointer;
|
||||
[SerializeField] private GaugeAxis m_GaugeAxis = new GaugeAxis();
|
||||
[SerializeField] private GaugePointer m_GaugePointer = new GaugePointer();
|
||||
/// <summary>
|
||||
/// 仪表盘轴线。
|
||||
/// </summary>
|
||||
public GaugeAxis gaugeAxis
|
||||
{
|
||||
get { return m_GaugeAxis; }
|
||||
set { if (PropertyUtil.SetClass(ref m_GaugeAxis, value, true)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 仪表盘指针。
|
||||
/// </summary>
|
||||
public GaugePointer gaugePointer
|
||||
{
|
||||
get { return m_GaugePointer; }
|
||||
set { if (PropertyUtil.SetClass(ref m_GaugePointer, value, true)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 仪表盘类型。
|
||||
/// </summary>
|
||||
public GaugeType gaugeType
|
||||
{
|
||||
get { return m_GaugeType; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_GaugeType, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public static void AddDefaultSerie(BaseChart chart, string serieName)
|
||||
{
|
||||
var serie = chart.AddSerie<Gauge>(serieName);
|
||||
serie.min = 0;
|
||||
serie.max = 100;
|
||||
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.titleStyle.show = true;
|
||||
serie.titleStyle.textStyle.offset = new Vector2(0, 20);
|
||||
serie.label.show = true;
|
||||
serie.label.offset = new Vector3(0, -30);
|
||||
serie.itemStyle.show = true;
|
||||
serie.gaugeAxis.axisLabel.show = true;
|
||||
serie.gaugeAxis.axisLabel.margin = 18;
|
||||
chart.AddData(serie.index, UnityEngine.Random.Range(10, 90), "title");
|
||||
}
|
||||
|
||||
public override bool vertsDirty
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.vertsDirty
|
||||
|| gaugeAxis.vertsDirty
|
||||
|| gaugePointer.vertsDirty;
|
||||
}
|
||||
}
|
||||
|
||||
public override void ClearVerticesDirty()
|
||||
{
|
||||
base.ClearVerticesDirty();
|
||||
gaugeAxis.ClearVerticesDirty();
|
||||
gaugePointer.ClearVerticesDirty();
|
||||
}
|
||||
|
||||
public override void ClearComponentDirty()
|
||||
{
|
||||
base.ClearComponentDirty();
|
||||
gaugeAxis.ClearComponentDirty();
|
||||
gaugePointer.ClearComponentDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 705acf20a71cf43b591ef2a38ec5e4e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,368 +0,0 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XUGL;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[UnityEngine.Scripting.Preserve]
|
||||
internal sealed class GaugeHandler : SerieHandler<Gauge>
|
||||
{
|
||||
private static readonly string s_SerieLabelObjectName = "label";
|
||||
private static readonly string s_AxisLabelObjectName = "axis_label";
|
||||
private bool m_UpdateTitleText = false;
|
||||
private bool m_UpdateLabelText = false;
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (m_UpdateTitleText)
|
||||
{
|
||||
m_UpdateTitleText = false;
|
||||
|
||||
foreach (var serie in chart.series)
|
||||
{
|
||||
if (serie is Gauge)
|
||||
{
|
||||
serie.titleStyle.SetText(serie.serieName);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m_UpdateLabelText)
|
||||
{
|
||||
m_UpdateLabelText = false;
|
||||
foreach (var serie in chart.series)
|
||||
{
|
||||
if (serie is Gauge)
|
||||
{
|
||||
SerieLabelHelper.SetGaugeLabelText(serie);
|
||||
UpdateAxisLabel(serie as Gauge);
|
||||
}
|
||||
}
|
||||
}
|
||||
serie.context.pointerEnter = false;
|
||||
serie.context.pointerItemDataIndex = -1;
|
||||
foreach (var serieData in serie.data)
|
||||
{
|
||||
if (serieData.IsInPolygon(chart.pointerPos))
|
||||
{
|
||||
serie.context.pointerEnter = true;
|
||||
serie.context.pointerItemDataIndex = serieData.index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
|
||||
string marker, string itemFormatter, string numericFormatter,
|
||||
ref List<SerieParams> paramList, ref string title)
|
||||
{
|
||||
UpdateItemSerieParams(ref paramList, ref title, dataIndex, category,
|
||||
marker, itemFormatter, numericFormatter);
|
||||
}
|
||||
|
||||
public override void DrawSerie(VertexHelper vh)
|
||||
{
|
||||
DrawGauge(vh, serie);
|
||||
}
|
||||
|
||||
private void InitAxisLabel()
|
||||
{
|
||||
if (!chart.HasSerie<Gauge>())
|
||||
return;
|
||||
|
||||
var labelObject = ChartHelper.AddObject(s_AxisLabelObjectName, chart.transform, chart.chartMinAnchor,
|
||||
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
||||
labelObject.hideFlags = chart.chartHideFlags;
|
||||
SerieLabelPool.ReleaseAll(labelObject.transform);
|
||||
|
||||
for (int i = 0; i < chart.series.Count; i++)
|
||||
{
|
||||
if (!(chart.series[i] is Gauge))
|
||||
continue;
|
||||
|
||||
var serie = chart.series[i] as Gauge;
|
||||
var serieLabel = serie.gaugeAxis.axisLabel;
|
||||
var count = serie.splitNumber > 36 ? 36 : (serie.splitNumber + 1);
|
||||
var startAngle = serie.startAngle;
|
||||
var textColor = serieLabel.textStyle.GetColor(chart.theme.gauge.textColor);
|
||||
serie.gaugeAxis.ClearLabelObject();
|
||||
SerieHelper.UpdateCenter(serie, chart.chartPosition, chart.chartWidth, chart.chartHeight);
|
||||
for (int j = 0; j < count; j++)
|
||||
{
|
||||
var textName = ChartCached.GetSerieLabelName(s_SerieLabelObjectName, i, j);
|
||||
var labelObj = SerieLabelPool.Get(textName, labelObject.transform, serieLabel, textColor, 100, 100, chart.theme);
|
||||
var iconImage = labelObj.transform.Find("Icon").GetComponent<Image>();
|
||||
var isAutoSize = serieLabel.backgroundWidth == 0 || serieLabel.backgroundHeight == 0;
|
||||
var item = ChartHelper.GetOrAddComponent<ChartLabel>(labelObj);
|
||||
item.SetLabel(labelObj, isAutoSize, serieLabel.paddingLeftRight, serieLabel.paddingTopBottom);
|
||||
item.SetIcon(iconImage);
|
||||
item.SetIconActive(false);
|
||||
serie.gaugeAxis.AddLabelObject(item);
|
||||
}
|
||||
UpdateAxisLabel(serie);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAxisLabel()
|
||||
{
|
||||
foreach (var serie in chart.series)
|
||||
{
|
||||
if (serie is Gauge)
|
||||
{
|
||||
UpdateAxisLabel(serie as Gauge);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAxisLabel(Gauge serie)
|
||||
{
|
||||
var show = serie.gaugeAxis.show && serie.gaugeAxis.axisLabel.show;
|
||||
serie.gaugeAxis.SetLabelObjectActive(show);
|
||||
if (!show)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var count = serie.splitNumber > 36 ? 36 : serie.splitNumber;
|
||||
var startAngle = serie.startAngle;
|
||||
var totalAngle = serie.endAngle - serie.startAngle;
|
||||
var totalValue = serie.max - serie.min;
|
||||
var diffAngle = totalAngle / count;
|
||||
var diffValue = totalValue / count;
|
||||
var radius = serie.context.insideRadius - serie.gaugeAxis.axisLabel.margin;
|
||||
var serieData = serie.GetSerieData(0);
|
||||
var customLabelText = serie.gaugeAxis.axisLabelText;
|
||||
for (int j = 0; j <= count; j++)
|
||||
{
|
||||
var angle = serie.startAngle + j * diffAngle;
|
||||
var value = serie.min + j * diffValue;
|
||||
var pos = ChartHelper.GetPosition(serie.context.center, angle, radius);
|
||||
var text = customLabelText != null && j < customLabelText.Count ? customLabelText[j] :
|
||||
SerieLabelHelper.GetFormatterContent(serie, serieData, value, totalValue,
|
||||
serie.gaugeAxis.axisLabel, Color.clear);
|
||||
serie.gaugeAxis.SetLabelObjectText(j, text);
|
||||
serie.gaugeAxis.SetLabelObjectPosition(j, pos + serie.gaugeAxis.axisLabel.offset);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawGauge(VertexHelper vh, Gauge serie)
|
||||
{
|
||||
SerieHelper.UpdateCenter(serie, chart.chartPosition, chart.chartWidth, chart.chartHeight);
|
||||
var destAngle = GetCurrAngle(serie, true);
|
||||
serie.animation.InitProgress(serie.startAngle, destAngle);
|
||||
var currAngle = serie.animation.IsFinish() ? GetCurrAngle(serie, false) : serie.animation.GetCurrDetail();
|
||||
DrawProgressBar(vh, serie, (float)currAngle);
|
||||
DrawStageColor(vh, serie);
|
||||
DrawLineStyle(vh, serie);
|
||||
DrawAxisTick(vh, serie);
|
||||
DrawPointer(vh, serie, (float)currAngle);
|
||||
//TitleStyleHelper.CheckTitle(serie, ref chart.m_ReinitTitle, ref m_UpdateTitleText);
|
||||
//SerieLabelHelper.CheckLabel(serie, ref chart.m_ReinitLabel, ref m_UpdateLabelText);
|
||||
CheckAnimation(serie);
|
||||
if (!serie.animation.IsFinish())
|
||||
{
|
||||
serie.animation.CheckProgress(destAngle - serie.startAngle);
|
||||
chart.RefreshPainter(serie);
|
||||
}
|
||||
else if (NeedRefresh(serie))
|
||||
{
|
||||
chart.RefreshPainter(serie);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawProgressBar(VertexHelper vh, Gauge serie, float currAngle)
|
||||
{
|
||||
if (serie.gaugeType != GaugeType.ProgressBar) return;
|
||||
if (!serie.gaugeAxis.show || !serie.gaugeAxis.axisLine.show) return;
|
||||
var color = serie.gaugeAxis.GetAxisLineColor(chart.theme, serie.index);
|
||||
var backgroundColor = serie.gaugeAxis.GetAxisLineBackgroundColor(chart.theme, serie.index);
|
||||
var lineWidth = serie.gaugeAxis.axisLine.GetWidth(chart.theme.gauge.lineWidth);
|
||||
var outsideRadius = serie.context.insideRadius + lineWidth;
|
||||
var borderWidth = serie.itemStyle.borderWidth;
|
||||
var borderColor = serie.itemStyle.borderColor;
|
||||
UGL.DrawDoughnut(vh, serie.context.center, serie.context.insideRadius, outsideRadius,
|
||||
backgroundColor, backgroundColor, Color.clear, serie.startAngle, serie.endAngle, 0, Color.clear,
|
||||
0, chart.settings.cicleSmoothness, serie.roundCap);
|
||||
UGL.DrawDoughnut(vh, serie.context.center, serie.context.insideRadius, outsideRadius,
|
||||
color, color, Color.clear, serie.startAngle, currAngle, 0, Color.clear,
|
||||
0, chart.settings.cicleSmoothness, serie.roundCap);
|
||||
}
|
||||
|
||||
private void DrawStageColor(VertexHelper vh, Gauge serie)
|
||||
{
|
||||
if (serie.gaugeType != GaugeType.Pointer) return;
|
||||
if (!serie.gaugeAxis.show || !serie.gaugeAxis.axisLine.show) return;
|
||||
var totalAngle = serie.endAngle - serie.startAngle;
|
||||
var tempStartAngle = serie.startAngle;
|
||||
var tempEndAngle = serie.startAngle;
|
||||
var lineWidth = serie.gaugeAxis.axisLine.GetWidth(chart.theme.gauge.lineWidth);
|
||||
var outsideRadius = serie.context.insideRadius + lineWidth;
|
||||
serie.gaugeAxis.runtimeStageAngle.Clear();
|
||||
for (int i = 0; i < serie.gaugeAxis.axisLine.stageColor.Count; i++)
|
||||
{
|
||||
var stageColor = serie.gaugeAxis.axisLine.stageColor[i];
|
||||
tempEndAngle = serie.startAngle + totalAngle * stageColor.percent;
|
||||
serie.gaugeAxis.runtimeStageAngle.Add(tempEndAngle);
|
||||
UGL.DrawDoughnut(vh, serie.context.center, serie.context.insideRadius, outsideRadius,
|
||||
stageColor.color, stageColor.color, Color.clear, tempStartAngle, tempEndAngle, 0, Color.clear,
|
||||
0, chart.settings.cicleSmoothness);
|
||||
tempStartAngle = tempEndAngle;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawPointer(VertexHelper vh, Gauge serie, float currAngle)
|
||||
{
|
||||
if (!serie.gaugePointer.show) return;
|
||||
var pointerColor = serie.gaugeAxis.GetPointerColor(chart.theme, serie.index, currAngle, serie.itemStyle);
|
||||
var pointerToColor = !ChartHelper.IsClearColor(serie.itemStyle.toColor) ? serie.itemStyle.toColor : pointerColor;
|
||||
var len = serie.gaugePointer.length < 1 && serie.gaugePointer.length > -1 ?
|
||||
serie.context.insideRadius * serie.gaugePointer.length :
|
||||
serie.gaugePointer.length;
|
||||
var p1 = ChartHelper.GetPosition(serie.context.center, currAngle, len);
|
||||
var p2 = ChartHelper.GetPosition(serie.context.center, currAngle + 180, serie.gaugePointer.width);
|
||||
var p3 = ChartHelper.GetPosition(serie.context.center, currAngle - 90, serie.gaugePointer.width / 2);
|
||||
var p4 = ChartHelper.GetPosition(serie.context.center, currAngle + 90, serie.gaugePointer.width / 2);
|
||||
UGL.DrawTriangle(vh, p2, p3, p1, pointerColor, pointerColor, pointerToColor);
|
||||
UGL.DrawTriangle(vh, p4, p2, p1, pointerColor, pointerColor, pointerToColor);
|
||||
if (serie.data.Count > 0)
|
||||
serie.data[0].SetPolygon(p1, p2, p3, p4);
|
||||
}
|
||||
|
||||
private void DrawLineStyle(VertexHelper vh, Gauge serie)
|
||||
{
|
||||
if (serie.gaugeType != GaugeType.Pointer) return;
|
||||
if (!serie.gaugeAxis.show || !serie.gaugeAxis.splitLine.show) return;
|
||||
if (serie.splitNumber <= 0) return;
|
||||
var splitLine = serie.gaugeAxis.splitLine;
|
||||
var totalAngle = serie.endAngle - serie.startAngle;
|
||||
var diffAngle = totalAngle / serie.splitNumber;
|
||||
var lineWidth = serie.gaugeAxis.axisLine.GetWidth(chart.theme.gauge.lineWidth);
|
||||
var splitLineWidth = splitLine.GetWidth(chart.theme.gauge.splitLineWidth);
|
||||
var splitLineLength = splitLine.GetLength(chart.theme.gauge.splitLineLength);
|
||||
var outsideRadius = serie.context.insideRadius + lineWidth;
|
||||
var insideRadius = outsideRadius - splitLineLength;
|
||||
for (int i = 0; i < serie.splitNumber + 1; i++)
|
||||
{
|
||||
var angle = serie.startAngle + i * diffAngle;
|
||||
var lineColor = serie.gaugeAxis.GetSplitLineColor(chart.theme.gauge.splitLineColor, serie.index, angle);
|
||||
var p1 = ChartHelper.GetPosition(serie.context.center, angle, insideRadius);
|
||||
var p2 = ChartHelper.GetPosition(serie.context.center, angle, outsideRadius);
|
||||
UGL.DrawLine(vh, p1, p2, splitLineWidth, lineColor);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawAxisTick(VertexHelper vh, Gauge serie)
|
||||
{
|
||||
if (serie.gaugeType != GaugeType.Pointer) return;
|
||||
if (!serie.gaugeAxis.show || !serie.gaugeAxis.axisTick.show) return;
|
||||
if (serie.splitNumber <= 0) return;
|
||||
var axisTick = serie.gaugeAxis.axisTick;
|
||||
var totalAngle = serie.endAngle - serie.startAngle;
|
||||
var diffAngle = totalAngle / serie.splitNumber;
|
||||
var lineWidth = serie.gaugeAxis.axisLine.GetWidth(chart.theme.gauge.lineWidth);
|
||||
var tickWidth = axisTick.GetWidth(chart.theme.gauge.tickWidth);
|
||||
var tickLength = axisTick.GetLength(chart.theme.gauge.tickLength);
|
||||
var outsideRadius = serie.context.insideRadius + lineWidth;
|
||||
|
||||
var insideRadius = outsideRadius - (tickLength < 1 ? lineWidth * tickLength : tickLength);
|
||||
for (int i = 0; i < serie.splitNumber; i++)
|
||||
{
|
||||
for (int j = 1; j < axisTick.splitNumber; j++)
|
||||
{
|
||||
var angle = serie.startAngle + i * diffAngle + j * (diffAngle / axisTick.splitNumber);
|
||||
var lineColor = serie.gaugeAxis.GetSplitLineColor(chart.theme.gauge.tickColor, serie.index, angle);
|
||||
var p1 = ChartHelper.GetPosition(serie.context.center, angle, insideRadius);
|
||||
var p2 = ChartHelper.GetPosition(serie.context.center, angle, outsideRadius);
|
||||
UGL.DrawLine(vh, p1, p2, tickWidth, lineColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private float GetCurrAngle(Serie serie, bool dest)
|
||||
{
|
||||
if (serie.animation.HasFadeOut())
|
||||
{
|
||||
return (float)serie.animation.GetCurrDetail();
|
||||
}
|
||||
float rangeValue = serie.max - serie.min;
|
||||
float rangeAngle = serie.endAngle - serie.startAngle;
|
||||
double value = 0;
|
||||
float angle = serie.startAngle;
|
||||
if (serie.dataCount > 0)
|
||||
{
|
||||
var serieData = serie.data[0];
|
||||
serieData.context.labelPosition = serie.context.center + serie.label.offset;
|
||||
value = dest ? serieData.GetData(1)
|
||||
: serieData.GetCurrData(1, serie.animation.GetUpdateAnimationDuration());
|
||||
value = MathUtil.Clamp(value, serie.min, serie.max);
|
||||
}
|
||||
if (rangeValue > 0)
|
||||
{
|
||||
angle += rangeAngle * (float)(value - serie.min) / rangeValue;
|
||||
}
|
||||
return angle;
|
||||
}
|
||||
|
||||
private void CheckAnimation(Serie serie)
|
||||
{
|
||||
var serieData = serie.GetSerieData(0);
|
||||
if (serieData != null)
|
||||
{
|
||||
var value = serieData.GetCurrData(1, serie.animation.GetUpdateAnimationDuration());
|
||||
var data = serieData.GetData(1);
|
||||
if (value != data) chart.RefreshPainter(serie);
|
||||
}
|
||||
}
|
||||
|
||||
private bool NeedRefresh(Serie serie)
|
||||
{
|
||||
if (serie is Gauge)
|
||||
{
|
||||
var serieData = serie.GetSerieData(0);
|
||||
if (serieData != null)
|
||||
{
|
||||
var destValue = serieData.GetData(1);
|
||||
var currValue = serieData.GetCurrData(1, serie.animation.GetUpdateAnimationDuration());
|
||||
return destValue != currValue;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Serie GetPointerInSerieIndex(List<Serie> series, Vector2 local)
|
||||
{
|
||||
foreach (var gauge in series)
|
||||
{
|
||||
if (!(gauge is Gauge))
|
||||
continue;
|
||||
|
||||
var serie = gauge as Gauge;
|
||||
if (!serie.gaugePointer.show)
|
||||
continue;
|
||||
|
||||
var len = serie.gaugePointer.length < 1 && serie.gaugePointer.length > -1
|
||||
? serie.context.insideRadius * serie.gaugePointer.length
|
||||
: serie.gaugePointer.length;
|
||||
if (Vector3.Distance(local, serie.context.center) > len) continue;
|
||||
var currAngle = (float)(serie.animation.IsFinish() ? GetCurrAngle(serie, false) : serie.animation.GetCurrDetail());
|
||||
var p1 = ChartHelper.GetPosition(serie.context.center, currAngle, len);
|
||||
var p2 = ChartHelper.GetPosition(serie.context.center, currAngle + 180, serie.gaugePointer.width);
|
||||
var p3 = ChartHelper.GetPosition(serie.context.center, currAngle - 90, serie.gaugePointer.width / 2);
|
||||
var p4 = ChartHelper.GetPosition(serie.context.center, currAngle + 90, serie.gaugePointer.width / 2);
|
||||
if (ChartHelper.IsPointInQuadrilateral(local, p1, p3, p2, p4))
|
||||
{
|
||||
return serie;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7036662c4d1214f46994a5f4d26d1fce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -67,32 +67,12 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnLegendButtonEnter(int index, string legendName)
|
||||
{
|
||||
if (chart.GetLegendRealShowNameIndex(serie.serieName) == index)
|
||||
{
|
||||
serie.context.isLegendEnter = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool OnLegendButtonExit(int index, string legendName)
|
||||
{
|
||||
if (chart.GetLegendRealShowNameIndex(serie.serieName) == index)
|
||||
{
|
||||
serie.context.isLegendEnter = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void UpdateSerieContext()
|
||||
{
|
||||
if (m_SerieGrid == null)
|
||||
return;
|
||||
|
||||
var needCheck = (chart.isPointerInChart && m_SerieGrid.IsPointerEnter()) || serie.context.isLegendEnter;
|
||||
var needCheck = (chart.isPointerInChart && m_SerieGrid.IsPointerEnter()) || m_LegendEnter;
|
||||
var lineWidth = 0f;
|
||||
if (!needCheck)
|
||||
{
|
||||
@@ -127,7 +107,7 @@ namespace XCharts
|
||||
lineWidth = serie.lineStyle.GetWidth(chart.theme.serie.lineWidth);
|
||||
|
||||
var needInteract = false;
|
||||
if (serie.context.isLegendEnter)
|
||||
if (m_LegendEnter)
|
||||
{
|
||||
serie.interact.SetValue(ref needInteract, lineWidth, true, chart.theme.serie.selectedRate);
|
||||
for (int i = 0; i < serie.dataCount; i++)
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
@@ -56,32 +55,29 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnLegendButtonClick(int index, string legendName, bool show)
|
||||
public override void OnLegendButtonClick(int index, string legendName, bool show)
|
||||
{
|
||||
if (!chart.HasSerie<Pie>()) return false;
|
||||
if (!LegendHelper.IsSerieLegend<Pie>(chart, legendName)) return false;
|
||||
LegendHelper.CheckDataShow(chart.series, legendName, show);
|
||||
if (!serie.IsLegendName(legendName))
|
||||
return;
|
||||
LegendHelper.CheckDataShow(serie, legendName, show);
|
||||
chart.UpdateLegendColor(legendName, show);
|
||||
chart.RefreshChart();
|
||||
return true;
|
||||
chart.RefreshPainter(serie);
|
||||
}
|
||||
|
||||
public override bool OnLegendButtonEnter(int index, string legendName)
|
||||
public override void OnLegendButtonEnter(int index, string legendName)
|
||||
{
|
||||
if (!chart.HasSerie<Pie>()) return false;
|
||||
if (!LegendHelper.IsSerieLegend<Pie>(chart, legendName)) return false;
|
||||
LegendHelper.CheckDataHighlighted(chart.series, legendName, true);
|
||||
chart.RefreshChart();
|
||||
return true;
|
||||
if (!serie.IsLegendName(legendName))
|
||||
return;
|
||||
LegendHelper.CheckDataHighlighted(serie, legendName, true);
|
||||
chart.RefreshPainter(serie);
|
||||
}
|
||||
|
||||
public override bool OnLegendButtonExit(int index, string legendName)
|
||||
public override void OnLegendButtonExit(int index, string legendName)
|
||||
{
|
||||
if (!chart.HasSerie<Pie>()) return false;
|
||||
if (!LegendHelper.IsSerieLegend<Pie>(chart, legendName)) return false;
|
||||
LegendHelper.CheckDataHighlighted(chart.series, legendName, false);
|
||||
chart.RefreshChart();
|
||||
return true;
|
||||
if (!serie.IsLegendName(legendName))
|
||||
return;
|
||||
LegendHelper.CheckDataHighlighted(serie, legendName, false);
|
||||
chart.RefreshPainter(serie);
|
||||
}
|
||||
|
||||
public override void OnPointerDown(PointerEventData eventData)
|
||||
@@ -113,7 +109,7 @@ namespace XCharts
|
||||
|
||||
private void UpdateSerieContext()
|
||||
{
|
||||
var needCheck = serie.context.isLegendEnter
|
||||
var needCheck = m_LegendEnter
|
||||
|| (chart.isPointerInChart && PointerIsInPieSerie(serie, chart.pointerPos));
|
||||
var needInteract = false;
|
||||
if (!needCheck)
|
||||
@@ -143,7 +139,7 @@ namespace XCharts
|
||||
for (int i = 0; i < serie.dataCount; i++)
|
||||
{
|
||||
var serieData = serie.data[i];
|
||||
if (dataIndex == i || (serie.context.isLegendEnter && serie.context.legendEnterIndex == i))
|
||||
if (dataIndex == i || (m_LegendEnter && m_LegendEnterIndex == i))
|
||||
{
|
||||
serie.context.pointerItemDataIndex = i;
|
||||
serieData.context.highlight = true;
|
||||
|
||||
@@ -133,37 +133,34 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnLegendButtonClick(int index, string legendName, bool show)
|
||||
public override void OnLegendButtonClick(int index, string legendName, bool show)
|
||||
{
|
||||
if (!chart.HasSerie<Radar>()) return false;
|
||||
if (!LegendHelper.IsSerieLegend<Radar>(chart, legendName)) return false;
|
||||
LegendHelper.CheckDataShow(chart.series, legendName, show);
|
||||
if (!serie.IsLegendName(legendName))
|
||||
return;
|
||||
LegendHelper.CheckDataShow(serie, legendName, show);
|
||||
chart.UpdateLegendColor(legendName, show);
|
||||
chart.RefreshChart();
|
||||
return true;
|
||||
chart.RefreshPainter(serie);
|
||||
}
|
||||
|
||||
public override bool OnLegendButtonEnter(int index, string legendName)
|
||||
public override void OnLegendButtonEnter(int index, string legendName)
|
||||
{
|
||||
if (!chart.HasSerie<Radar>()) return false;
|
||||
if (!LegendHelper.IsSerieLegend<Radar>(chart, legendName)) return false;
|
||||
LegendHelper.CheckDataHighlighted(chart.series, legendName, true);
|
||||
chart.RefreshChart();
|
||||
return true;
|
||||
if (!serie.IsLegendName(legendName))
|
||||
return;
|
||||
LegendHelper.CheckDataHighlighted(serie, legendName, true);
|
||||
chart.RefreshPainter(serie);
|
||||
}
|
||||
|
||||
public override bool OnLegendButtonExit(int index, string legendName)
|
||||
public override void OnLegendButtonExit(int index, string legendName)
|
||||
{
|
||||
if (!chart.HasSerie<Radar>()) return false;
|
||||
if (!LegendHelper.IsSerieLegend<Radar>(chart, legendName)) return false;
|
||||
LegendHelper.CheckDataHighlighted(chart.series, legendName, false);
|
||||
chart.RefreshChart();
|
||||
return true;
|
||||
if (!serie.IsLegendName(legendName))
|
||||
return;
|
||||
LegendHelper.CheckDataHighlighted(serie, legendName, false);
|
||||
chart.RefreshPainter(serie);
|
||||
}
|
||||
|
||||
private void UpdateSerieContext()
|
||||
{
|
||||
var needCheck = serie.context.isLegendEnter || (chart.isPointerInChart && m_RadarCoord.IsPointerEnter());
|
||||
var needCheck = m_LegendEnter || (chart.isPointerInChart && m_RadarCoord.IsPointerEnter());
|
||||
var needInteract = false;
|
||||
var needHideAll = false;
|
||||
if (!needCheck)
|
||||
@@ -184,7 +181,7 @@ namespace XCharts
|
||||
serieData.index = i;
|
||||
var symbol = SerieHelper.GetSerieSymbol(serie, serieData);
|
||||
var symbolSize = symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize);
|
||||
if (needHideAll || serie.context.isLegendEnter)
|
||||
if (needHideAll || m_LegendEnter)
|
||||
{
|
||||
serieData.context.highlight = needHideAll ? false : true;
|
||||
serieData.interact.SetValue(ref needInteract, symbolSize, serieData.context.highlight);
|
||||
|
||||
@@ -149,32 +149,29 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnLegendButtonClick(int index, string legendName, bool show)
|
||||
public override void OnLegendButtonClick(int index, string legendName, bool show)
|
||||
{
|
||||
if (!chart.HasSerie<Ring>()) return false;
|
||||
if (!LegendHelper.IsSerieLegend<Ring>(chart, legendName)) return false;
|
||||
LegendHelper.CheckDataShow(chart.series, legendName, show);
|
||||
if (!serie.IsLegendName(legendName))
|
||||
return;
|
||||
LegendHelper.CheckDataShow(serie, legendName, show);
|
||||
chart.UpdateLegendColor(legendName, show);
|
||||
chart.RefreshChart();
|
||||
return true;
|
||||
chart.RefreshPainter(serie);
|
||||
}
|
||||
|
||||
public override bool OnLegendButtonEnter(int index, string legendName)
|
||||
public override void OnLegendButtonEnter(int index, string legendName)
|
||||
{
|
||||
if (!chart.HasSerie<Ring>()) return false;
|
||||
if (!LegendHelper.IsSerieLegend<Ring>(chart, legendName)) return false;
|
||||
LegendHelper.CheckDataHighlighted(chart.series, legendName, true);
|
||||
chart.RefreshChart();
|
||||
return true;
|
||||
if (!serie.IsLegendName(legendName))
|
||||
return;
|
||||
LegendHelper.CheckDataHighlighted(serie, legendName, true);
|
||||
chart.RefreshPainter(serie);
|
||||
}
|
||||
|
||||
public override bool OnLegendButtonExit(int index, string legendName)
|
||||
public override void OnLegendButtonExit(int index, string legendName)
|
||||
{
|
||||
if (!chart.HasSerie<Ring>()) return false;
|
||||
if (!LegendHelper.IsSerieLegend<Ring>(chart, legendName)) return false;
|
||||
LegendHelper.CheckDataHighlighted(chart.series, legendName, false);
|
||||
chart.RefreshChart();
|
||||
return true;
|
||||
if (!serie.IsLegendName(legendName))
|
||||
return;
|
||||
LegendHelper.CheckDataHighlighted(serie, legendName, false);
|
||||
chart.RefreshPainter(serie);
|
||||
}
|
||||
|
||||
public override void OnPointerDown(PointerEventData eventData)
|
||||
|
||||
@@ -56,26 +56,6 @@ namespace XCharts
|
||||
paramList.Add(param);
|
||||
}
|
||||
|
||||
public override bool OnLegendButtonEnter(int index, string legendName)
|
||||
{
|
||||
if (chart.GetLegendRealShowNameIndex(serie.serieName) == index)
|
||||
{
|
||||
serie.context.isLegendEnter = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool OnLegendButtonExit(int index, string legendName)
|
||||
{
|
||||
if (chart.GetLegendRealShowNameIndex(serie.serieName) == index)
|
||||
{
|
||||
serie.context.isLegendEnter = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void DrawSerie(VertexHelper vh)
|
||||
{
|
||||
var colorIndex = chart.GetLegendRealShowNameIndex(serie.legendName);
|
||||
@@ -92,7 +72,7 @@ namespace XCharts
|
||||
|
||||
private void UpdateSerieContext()
|
||||
{
|
||||
var needCheck = serie.context.isLegendEnter || (chart.isPointerInChart && (m_Grid == null || m_Grid.IsPointerEnter()));
|
||||
var needCheck = m_LegendEnter || (chart.isPointerInChart && (m_Grid == null || m_Grid.IsPointerEnter()));
|
||||
|
||||
var needHideAll = false;
|
||||
if (!needCheck)
|
||||
@@ -113,7 +93,7 @@ namespace XCharts
|
||||
var symbol = SerieHelper.GetSerieSymbol(serie, serieData);
|
||||
var symbolSize = symbol.GetSize(serieData.data, themeSymbolSize);
|
||||
var symbolSelectedSize = symbol.GetSelectedSize(serieData.data, themeSymbolSelectedSize);
|
||||
if (serie.context.isLegendEnter ||
|
||||
if (m_LegendEnter ||
|
||||
(!needHideAll && Vector3.Distance(serieData.context.position, chart.pointerPos) <= symbolSize))
|
||||
{
|
||||
serie.context.pointerItemDataIndex = i;
|
||||
|
||||
@@ -82,20 +82,7 @@ namespace XCharts
|
||||
Capsule
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 仪表盘类型
|
||||
/// </summary>
|
||||
public enum GaugeType
|
||||
{
|
||||
/// <summary>
|
||||
/// 指针型
|
||||
/// </summary>
|
||||
Pointer,
|
||||
/// <summary>
|
||||
/// 进度条型
|
||||
/// </summary>
|
||||
ProgressBar
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 雷达图类型
|
||||
@@ -1661,6 +1648,33 @@ namespace XCharts
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsLegendName(string legendName)
|
||||
{
|
||||
if (useDataNameForColor)
|
||||
{
|
||||
return IsSerieDataLegendName(legendName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return IsSerieLegendName(legendName);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSerieLegendName(string legendName)
|
||||
{
|
||||
return legendName.Equals(this.legendName);
|
||||
}
|
||||
|
||||
public bool IsSerieDataLegendName(string legendName)
|
||||
{
|
||||
foreach (var serieData in m_Data)
|
||||
{
|
||||
if (legendName.Equals(serieData.legendName))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置指定index的数据图标的尺寸
|
||||
/// </summary>
|
||||
|
||||
@@ -37,8 +37,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public List<int> pointerAxisDataIndexs = new List<int>();
|
||||
public bool isTriggerByAxis = false;
|
||||
public bool isLegendEnter = false;
|
||||
public int legendEnterIndex;
|
||||
|
||||
/// <summary>
|
||||
/// 中心点
|
||||
/// </summary>
|
||||
|
||||
@@ -37,9 +37,9 @@ namespace XCharts
|
||||
public virtual void RefreshLabelNextFrame() { }
|
||||
public virtual void RefreshLabelInternal() { }
|
||||
public virtual void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category, string marker, string itemFormatter, string numericFormatter, ref List<SerieParams> paramList, ref string title) { }
|
||||
public virtual bool OnLegendButtonClick(int index, string legendName, bool show) { return false; }
|
||||
public virtual bool OnLegendButtonEnter(int index, string legendName) { return false; }
|
||||
public virtual bool OnLegendButtonExit(int index, string legendName) { return false; }
|
||||
public virtual void OnLegendButtonClick(int index, string legendName, bool show) { }
|
||||
public virtual void OnLegendButtonEnter(int index, string legendName) { }
|
||||
public virtual void OnLegendButtonExit(int index, string legendName) { }
|
||||
internal abstract void SetSerie(Serie serie);
|
||||
}
|
||||
|
||||
@@ -51,6 +51,8 @@ namespace XCharts
|
||||
protected bool m_InitedLabel;
|
||||
protected bool m_RefreshLabel;
|
||||
protected bool m_LastCheckContextFlag = false;
|
||||
protected bool m_LegendEnter = false;
|
||||
protected int m_LegendEnterIndex;
|
||||
|
||||
public T serie { get; internal set; }
|
||||
|
||||
@@ -113,6 +115,33 @@ namespace XCharts
|
||||
ChartHelper.SetActive(m_SerieRoot, false);
|
||||
}
|
||||
|
||||
public override void OnLegendButtonClick(int index, string legendName, bool show)
|
||||
{
|
||||
if (serie.IsLegendName(legendName))
|
||||
{
|
||||
chart.SetSerieActive(serie, show);
|
||||
chart.RefreshPainter(serie);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnLegendButtonEnter(int index, string legendName)
|
||||
{
|
||||
if (serie.IsLegendName(legendName))
|
||||
{
|
||||
m_LegendEnter = true;
|
||||
chart.RefreshPainter(serie);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnLegendButtonExit(int index, string legendName)
|
||||
{
|
||||
if (serie.IsLegendName(legendName))
|
||||
{
|
||||
m_LegendEnter = false;
|
||||
chart.RefreshPainter(serie);
|
||||
}
|
||||
}
|
||||
|
||||
private void InitRoot()
|
||||
{
|
||||
m_InitedLabel = false;
|
||||
|
||||
Reference in New Issue
Block a user