mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-27 11:40:13 +00:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95e40c6f1a | ||
|
|
8e30a370b5 | ||
|
|
d94e304058 | ||
|
|
34dc49004e | ||
|
|
61c6d68c4c | ||
|
|
50a666fecc | ||
|
|
626a187758 | ||
|
|
dee06f8d6f | ||
|
|
e6eea34a45 | ||
|
|
76b8146e53 | ||
|
|
240eda0be2 | ||
|
|
6fa093bc80 | ||
|
|
5884fd99dd | ||
|
|
f177799202 | ||
|
|
2d3f5dd51d | ||
|
|
b9ca646e0c | ||
|
|
c157c07b0d | ||
|
|
82d0788905 |
@@ -2,6 +2,9 @@
|
||||
# 更新日志
|
||||
|
||||
[branch-2.0](#branch-2.0)
|
||||
[v2.8.2](#v2.8.2)
|
||||
[v2.8.1](#v2.8.1)
|
||||
[v2.8.0](#v2.8.0)
|
||||
[v2.7.0](#v2.7.0)
|
||||
[v2.6.0](#v2.6.0)
|
||||
[v2.5.0](#v2.5.0)
|
||||
@@ -43,6 +46,27 @@
|
||||
|
||||
## branch-2.0
|
||||
|
||||
## v2.8.2
|
||||
|
||||
* (2022.08.15) Release `v2.8.2` version
|
||||
* (2022.08.15) Added support for the `HeatmapChart` formatter for custom Tooltip
|
||||
* (2022.07.13) Fixed `SerieLabel` refresh exception #215
|
||||
* (2022.06.30) Optimize `Radar` so that the `Tooltip` layer is above `Indicator`
|
||||
|
||||
## v2.8.1
|
||||
|
||||
* (2022.05.03) Added `onLegendClick`, `onLegendEnter` and `onLegendExit` delegate callbacks for `Legend`
|
||||
* (2022.04.21) Fixed bug #192 with `RingChart` `Tooltip` exception
|
||||
* (2022.04.21) Fixed error when setting `minShowNum` in `DataZoom`
|
||||
|
||||
## v2.8.0
|
||||
|
||||
* (2022.04.10) Added the debug information panel
|
||||
* (2022.04.09) Fixed `VisualMap` not working in some cases
|
||||
* (2022.04.08) Optimized `XCharts` initialization #190
|
||||
* (2022.04.08) Fixed color error #187 in `Radar`
|
||||
* (2022.03.24) Fixed `Axis` precision issue #184
|
||||
|
||||
## v2.7.0
|
||||
|
||||
* (2022.03.20) Release `v2.7.0` version
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
# 更新日志
|
||||
|
||||
[branch-2.0](#branch-2.0)
|
||||
[v2.8.2](#v2.8.2)
|
||||
[v2.8.1](#v2.8.1)
|
||||
[v2.8.0](#v2.8.0)
|
||||
[v2.7.0](#v2.7.0)
|
||||
[v2.6.0](#v2.6.0)
|
||||
[v2.5.0](#v2.5.0)
|
||||
@@ -43,6 +46,29 @@
|
||||
|
||||
## branch-2.0
|
||||
|
||||
## v2.8.2
|
||||
|
||||
* (2022.08.15) 发布`v2.8.2`版本
|
||||
* (2022.08.15) 增加`HeatmapChart`对自定义`Tooltip`的`formatter`的支持
|
||||
* (2022.07.13) 修复`SerieLabel`刷新异常的问题 #215
|
||||
* (2022.06.30) 优化`Radar`让`Tooltip`的层在`Indicator`之上
|
||||
|
||||
## v2.8.1
|
||||
|
||||
* (2022.05.06) 发布`v2.8.1`版本
|
||||
* (2022.05.03) 增加`Legend`的`onLegendClick`,`onLegendEnter`和`onLegendExit`委托回调
|
||||
* (2022.04.21) 修复`RingChart`的`Tooltip`异常的问题 #192
|
||||
* (2022.04.21) 修复`DataZoom`设置`minShowNum`时可能会报错的问题
|
||||
|
||||
## v2.8.0
|
||||
|
||||
* (2022.04.10) 发布`v2.8.0`版本
|
||||
* (2022.04.10) 增加`Debug`调试信息面板
|
||||
* (2022.04.09) 修复`VisualMap`某些情况下不生效的问题
|
||||
* (2022.04.08) 优化`XCharts`初始化 #190
|
||||
* (2022.04.08) 修复`Radar`的颜色异常问题 #187
|
||||
* (2022.03.24) 修复`Axis`的精度问题 #184
|
||||
|
||||
## v2.7.0
|
||||
|
||||
* (2022.03.20) 发布`v2.7.0`版本
|
||||
|
||||
@@ -132,7 +132,21 @@ namespace XCharts
|
||||
/// 点击饼图区域回调。参数:PointerEventData,SerieIndex,SerieDataIndex
|
||||
/// </summary>
|
||||
public Action<PointerEventData, int, int> onPointerClickPie { set { m_OnPointerClickPie = value; m_ForceOpenRaycastTarget = true; } get { return m_OnPointerClickPie; } }
|
||||
|
||||
/// <summary>
|
||||
/// the callback function of click legend.
|
||||
/// 点击图例按钮回调。参数:legendIndex, legendName, show
|
||||
/// </summary>
|
||||
public Action<int, string, bool> onLegendClick { set { m_OnLegendClick = value; } }
|
||||
/// <summary>
|
||||
/// the callback function of enter legend.
|
||||
/// 鼠标进入图例回调。参数:legendIndex, legendName
|
||||
/// </summary>
|
||||
public Action<int, string> onLegendEnter { set { m_OnLegendEnter = value; } }
|
||||
/// <summary>
|
||||
/// the callback function of exit legend.
|
||||
/// 鼠标退出图例回调。参数:legendIndex, legendName
|
||||
/// </summary>
|
||||
public Action<int, string> onLegendExit { set { m_OnLegendExit = value; } }
|
||||
/// <summary>
|
||||
/// Redraw chart in next frame.
|
||||
/// 在下一帧刷新图表。
|
||||
|
||||
@@ -88,10 +88,10 @@ namespace XCharts
|
||||
[SerializeField] protected int m_PolarIndex;
|
||||
[SerializeField] protected AxisPosition m_Position;
|
||||
[SerializeField] protected float m_Offset;
|
||||
[SerializeField] protected float m_Min;
|
||||
[SerializeField] protected float m_Max;
|
||||
[SerializeField] protected double m_Min;
|
||||
[SerializeField] protected double m_Max;
|
||||
[SerializeField] protected int m_SplitNumber = 5;
|
||||
[SerializeField] protected float m_Interval = 0;
|
||||
[SerializeField] protected double m_Interval = 0;
|
||||
[SerializeField] protected bool m_BoundaryGap = true;
|
||||
[SerializeField] protected int m_MaxCache = 0;
|
||||
[SerializeField] protected float m_LogBase = 10;
|
||||
@@ -180,7 +180,7 @@ namespace XCharts
|
||||
/// The minimun value of axis.Valid when `minMaxType` is `Custom`
|
||||
/// 设定的坐标轴刻度最小值,当minMaxType为Custom时有效。
|
||||
/// </summary>
|
||||
public float min
|
||||
public double min
|
||||
{
|
||||
get { return m_Min; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Min, value)) SetAllDirty(); }
|
||||
@@ -189,7 +189,7 @@ namespace XCharts
|
||||
/// The maximum value of axis.Valid when `minMaxType` is `Custom`
|
||||
/// 设定的坐标轴刻度最大值,当minMaxType为Custom时有效。
|
||||
/// </summary>
|
||||
public float max
|
||||
public double max
|
||||
{
|
||||
get { return m_Max; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Max, value)) SetAllDirty(); }
|
||||
@@ -207,7 +207,7 @@ namespace XCharts
|
||||
/// Compulsively set segmentation interval for axis.This is unavailable for category axis.
|
||||
/// 强制设置坐标轴分割间隔。无法在类目轴中使用。
|
||||
/// </summary>
|
||||
public float interval
|
||||
public double interval
|
||||
{
|
||||
get { return m_Interval; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Interval, value)) SetAllDirty(); }
|
||||
@@ -728,13 +728,15 @@ namespace XCharts
|
||||
filterEnd = end;
|
||||
filterMinShow = dataZoom.minShowNum;
|
||||
m_NeedUpdateFilterData = false;
|
||||
if (data.Count > 0)
|
||||
if (data.Count > 0 && filterMinShow < data.Count)
|
||||
{
|
||||
if (range < dataZoom.minShowNum)
|
||||
if (range < filterMinShow)
|
||||
{
|
||||
if (dataZoom.minShowNum > data.Count) range = data.Count;
|
||||
else range = dataZoom.minShowNum;
|
||||
if (filterMinShow > data.Count) range = data.Count;
|
||||
else range = filterMinShow;
|
||||
}
|
||||
if (range > data.Count - start - 1)
|
||||
start = data.Count - range - 1;
|
||||
filterData = data.GetRange(start, range);
|
||||
}
|
||||
else
|
||||
|
||||
154
Assets/XCharts/Runtime/Component/Main/DebugInfo.cs
Normal file
154
Assets/XCharts/Runtime/Component/Main/DebugInfo.cs
Normal file
@@ -0,0 +1,154 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
public class DebugInfo
|
||||
{
|
||||
private bool m_ShowDebugInfo = false;
|
||||
private TextStyle m_DebugInfoTextStyle = new TextStyle()
|
||||
{
|
||||
fontSize = 18,
|
||||
backgroundColor = new Color32(32, 32, 32, 170),
|
||||
color = Color.white
|
||||
};
|
||||
|
||||
private static StringBuilder s_Sb = new StringBuilder();
|
||||
|
||||
private static readonly float INTERVAL = 0.2f;
|
||||
private static readonly float MAXCACHE = 20;
|
||||
private int m_FrameCount = 0;
|
||||
private float m_LastTime = 0f;
|
||||
private float m_LastCheckShowTime = 0f;
|
||||
private int m_LastRefreshCount = 0;
|
||||
private BaseChart m_Chart;
|
||||
private ChartLabel m_Label;
|
||||
private List<float> m_FpsList = new List<float>();
|
||||
public float fps { get; private set; }
|
||||
public float avgFps { get; private set; }
|
||||
public int refreshCount { get; internal set; }
|
||||
internal int clickChartCount { get; set; }
|
||||
|
||||
public void Init(BaseChart chart)
|
||||
{
|
||||
m_Chart = chart;
|
||||
m_Label = AddDebugInfoObject("debug", chart.transform, m_DebugInfoTextStyle, chart.theme);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (clickChartCount >= 3)
|
||||
{
|
||||
m_ShowDebugInfo = !m_ShowDebugInfo;
|
||||
ChartHelper.SetActive(m_Label.gameObject.transform, m_ShowDebugInfo);
|
||||
clickChartCount = 0;
|
||||
m_LastCheckShowTime = Time.realtimeSinceStartup;
|
||||
return;
|
||||
}
|
||||
if (Time.realtimeSinceStartup - m_LastCheckShowTime > 0.5f)
|
||||
{
|
||||
m_LastCheckShowTime = Time.realtimeSinceStartup;
|
||||
clickChartCount = 0;
|
||||
}
|
||||
if (!m_ShowDebugInfo || m_Label == null)
|
||||
return;
|
||||
|
||||
m_FrameCount++;
|
||||
if (Time.realtimeSinceStartup - m_LastTime >= INTERVAL)
|
||||
{
|
||||
fps = m_FrameCount / (Time.realtimeSinceStartup - m_LastTime);
|
||||
m_FrameCount = 0;
|
||||
m_LastTime = Time.realtimeSinceStartup;
|
||||
if (m_LastRefreshCount == refreshCount)
|
||||
{
|
||||
m_LastRefreshCount = 0;
|
||||
refreshCount = 0;
|
||||
}
|
||||
m_LastRefreshCount = refreshCount;
|
||||
if (m_FpsList.Count > MAXCACHE)
|
||||
{
|
||||
m_FpsList.RemoveAt(0);
|
||||
}
|
||||
m_FpsList.Add(fps);
|
||||
avgFps = GetAvg(m_FpsList);
|
||||
if (m_Label != null)
|
||||
{
|
||||
s_Sb.Length = 0;
|
||||
s_Sb.AppendFormat("v{0}\n", XChartsMgr.version);
|
||||
s_Sb.AppendFormat("fps : {0:f0} / {1:f0}\n", fps, avgFps);
|
||||
s_Sb.AppendFormat("draw : {0}\n", refreshCount);
|
||||
|
||||
var dataCount = m_Chart.series.GetAllSerieDataCount();
|
||||
SetValueWithKInfo(s_Sb, "data", dataCount);
|
||||
|
||||
var vertCount = 0;
|
||||
foreach (var serie in m_Chart.series.list)
|
||||
vertCount += serie.runtimeVertCount;
|
||||
|
||||
SetValueWithKInfo(s_Sb, "b-vert", m_Chart.m_BasePainterVertCount);
|
||||
SetValueWithKInfo(s_Sb, "s-vert", vertCount);
|
||||
SetValueWithKInfo(s_Sb, "t-vert", m_Chart.m_TopPainterVertCount, false);
|
||||
|
||||
m_Label.SetText(s_Sb.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetValueWithKInfo(StringBuilder s_Sb, string key, int value, bool newLine = true)
|
||||
{
|
||||
if (value >= 1000)
|
||||
s_Sb.AppendFormat("{0} : {1:f1}k", key, value * 0.001f);
|
||||
else
|
||||
s_Sb.AppendFormat("{0} : {1}", key, value);
|
||||
if (newLine)
|
||||
s_Sb.Append("\n");
|
||||
}
|
||||
|
||||
private static float GetAvg(List<float> list)
|
||||
{
|
||||
var total = 0f;
|
||||
foreach (var v in list) total += v;
|
||||
return total / list.Count;
|
||||
}
|
||||
|
||||
private ChartLabel AddDebugInfoObject(string name, Transform parent, TextStyle textStyle,
|
||||
ChartTheme theme)
|
||||
{
|
||||
var anchorMax = new Vector2(0, 1);
|
||||
var anchorMin = new Vector2(0, 1);
|
||||
var pivot = new Vector2(0, 1);
|
||||
var sizeDelta = new Vector2(130, 150);
|
||||
|
||||
var labelGameObject = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);
|
||||
labelGameObject.transform.SetAsLastSibling();
|
||||
labelGameObject.hideFlags = m_Chart.chartHideFlags;
|
||||
ChartHelper.SetActive(labelGameObject, m_ShowDebugInfo);
|
||||
|
||||
var image = ChartHelper.GetOrAddComponent<Image>(labelGameObject);
|
||||
image.color = textStyle.backgroundColor;
|
||||
|
||||
var label = new ChartLabel();
|
||||
label.gameObject = labelGameObject;
|
||||
label.label = ChartHelper.AddTextObject("Text", label.gameObject.transform, anchorMin, anchorMax,
|
||||
pivot, sizeDelta, textStyle, theme.common);
|
||||
label.SetAutoSize(true);
|
||||
label.label.SetActive(true);
|
||||
label.label.SetAlignment(textStyle.GetAlignment(TextAnchor.UpperLeft));
|
||||
label.label.SetLocalPosition(new Vector2(3, -3));
|
||||
label.SetText("30");
|
||||
label.SetLabelColor(textStyle.color);
|
||||
return label;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/XCharts/Runtime/Component/Main/DebugInfo.cs.meta
Normal file
11
Assets/XCharts/Runtime/Component/Main/DebugInfo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ff63fec5c2f94046b4560565057db8c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1190,6 +1190,7 @@ namespace XCharts
|
||||
public float runtimeWidth { get; internal set; }
|
||||
public float runtimeHeight { get; internal set; }
|
||||
public Rect runtimeRect { get; internal set; }
|
||||
public int runtimeVertCount { get; internal set; }
|
||||
public List<SerieData> runtimeSortedData { get { return m_SortedData; } }
|
||||
public List<SerieData> rootData { get { return m_RootData; } }
|
||||
public bool nameDirty { get { return m_NameDirty; } }
|
||||
|
||||
@@ -98,6 +98,16 @@ namespace XCharts
|
||||
SeriesHelper.ClearNameDirty(this);
|
||||
}
|
||||
|
||||
public int GetAllSerieDataCount()
|
||||
{
|
||||
var count = 0;
|
||||
foreach (var serie in list)
|
||||
{
|
||||
count += serie.dataCount;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空所有系列的数据
|
||||
/// </summary>
|
||||
@@ -259,7 +269,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public void RemoveAll()
|
||||
{
|
||||
foreach(var serie in m_Series) serie.AnimationFadeIn();
|
||||
foreach (var serie in m_Series) serie.AnimationFadeIn();
|
||||
m_Series.Clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ namespace XCharts
|
||||
m_YAxes[0].splitNumber = 10;
|
||||
RemoveData();
|
||||
var heatmapGridWid = 10f;
|
||||
int xSplitNumber = (int)(grid.runtimeWidth / heatmapGridWid);
|
||||
int ySplitNumber = (int)(grid.runtimeHeight / heatmapGridWid);
|
||||
int xSplitNumber = (int) (grid.runtimeWidth / heatmapGridWid);
|
||||
int ySplitNumber = (int) (grid.runtimeHeight / heatmapGridWid);
|
||||
|
||||
SerieTemplate.AddDefaultHeatmapSerie(this, "serie1");
|
||||
|
||||
@@ -49,8 +49,20 @@ namespace XCharts
|
||||
visualMap.location.align = Location.Align.BottomLeft;
|
||||
visualMap.location.bottom = 100;
|
||||
visualMap.location.left = 30;
|
||||
var colors = new List<string>{"#313695", "#4575b4", "#74add1", "#abd9e9", "#e0f3f8", "#ffffbf",
|
||||
"#fee090", "#fdae61", "#f46d43", "#d73027", "#a50026"};
|
||||
var colors = new List<string>
|
||||
{
|
||||
"#313695",
|
||||
"#4575b4",
|
||||
"#74add1",
|
||||
"#abd9e9",
|
||||
"#e0f3f8",
|
||||
"#ffffbf",
|
||||
"#fee090",
|
||||
"#fdae61",
|
||||
"#f46d43",
|
||||
"#d73027",
|
||||
"#a50026"
|
||||
};
|
||||
visualMap.inRange.Clear();
|
||||
foreach (var str in colors)
|
||||
{
|
||||
@@ -80,11 +92,27 @@ namespace XCharts
|
||||
#endif
|
||||
|
||||
protected override void UpdateTooltip()
|
||||
{
|
||||
var dataIndex = GetDataIndex();
|
||||
if (dataIndex < 0) return;
|
||||
var content = TooltipHelper.GetFormatterContent(tooltip, dataIndex, this);
|
||||
TooltipHelper.SetContentAndPosition(tooltip, content, chartRect);
|
||||
tooltip.SetActive(true);
|
||||
for (int i = 0; i < m_XAxes.Count; i++)
|
||||
{
|
||||
UpdateAxisTooltipLabel(i, m_XAxes[i]);
|
||||
}
|
||||
for (int i = 0; i < m_YAxes.Count; i++)
|
||||
{
|
||||
UpdateAxisTooltipLabel(i, m_YAxes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private int GetDataIndex()
|
||||
{
|
||||
var xData = tooltip.runtimeXValues[0];
|
||||
var yData = tooltip.runtimeYValues[0];
|
||||
if (IsCategory() && (xData < 0 || yData < 0)) return;
|
||||
sb.Length = 0;
|
||||
if (IsCategory() && (xData < 0 || yData < 0)) return -1;
|
||||
for (int i = 0; i < m_Series.Count; i++)
|
||||
{
|
||||
var serie = m_Series.GetSerie(i);
|
||||
@@ -96,30 +124,11 @@ namespace XCharts
|
||||
{
|
||||
if (IsCategory())
|
||||
{
|
||||
string key = serie.name;
|
||||
var serieData = serie.data[(int)xData * yCount + (int)yData];
|
||||
var value = serieData.data[2];
|
||||
var color = visualMap.enable ? visualMap.GetColor(value) :
|
||||
m_Theme.GetColor(serie.index);
|
||||
sb.Append("\n")
|
||||
.Append(key).Append(!string.IsNullOrEmpty(key) ? "\n" : "")
|
||||
.Append("<color=#").Append(ChartCached.ColorToStr(color)).Append(">● </color>")
|
||||
.Append(xAxis.data[(int)xData]).Append(": ")
|
||||
.Append(ChartCached.FloatToStr(value, string.Empty));
|
||||
return (int) xData * yCount + (int) yData;
|
||||
}
|
||||
}
|
||||
}
|
||||
TooltipHelper.SetContentAndPosition(tooltip, sb.ToString().Trim(), chartRect);
|
||||
tooltip.SetActive(true);
|
||||
|
||||
for (int i = 0; i < m_XAxes.Count; i++)
|
||||
{
|
||||
UpdateAxisTooltipLabel(i, m_XAxes[i]);
|
||||
}
|
||||
for (int i = 0; i < m_YAxes.Count; i++)
|
||||
{
|
||||
UpdateAxisTooltipLabel(i, m_YAxes[i]);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -666,6 +666,8 @@ namespace XCharts
|
||||
if (dataZoom.minShowNum > data.Count) range = data.Count;
|
||||
else range = dataZoom.minShowNum;
|
||||
}
|
||||
if (range > data.Count - start - 1)
|
||||
start = data.Count - range - 1;
|
||||
serie.m_FilterData = data.GetRange(start, range);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace XCharts
|
||||
if (!string.IsNullOrEmpty(serieData.name))
|
||||
sb.Append(serieData.name).Append(": ");
|
||||
sb.AppendFormat("({0},{1})", ChartCached.FloatToStr(xValue, numericFormatter),
|
||||
ChartCached.FloatToStr(yValue, numericFormatter));
|
||||
ChartCached.FloatToStr(yValue, numericFormatter));
|
||||
if (i != dataIndexList.Count - 1)
|
||||
{
|
||||
sb.Append("\n");
|
||||
@@ -41,7 +41,6 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void InitPieTooltip(ref StringBuilder sb, Tooltip tooltip, Serie serie, int index,
|
||||
ChartTheme theme)
|
||||
{
|
||||
@@ -72,7 +71,7 @@ namespace XCharts
|
||||
if (!string.IsNullOrEmpty(serieData.name))
|
||||
{
|
||||
sb.Append("<color=#").Append(theme.GetColorStr(index)).Append(">● </color>")
|
||||
.Append(serieData.name).Append(": ").Append(ChartCached.FloatToStr(value, numericFormatter));
|
||||
.Append(serieData.name).Append(": ").Append(ChartCached.FloatToStr(value, numericFormatter));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -196,7 +195,7 @@ namespace XCharts
|
||||
double xValue, yValue;
|
||||
serie.GetXYData(index, dataZoom, out xValue, out yValue);
|
||||
var isIngore = serie.IsIgnorePoint(index);
|
||||
if(isIngore) return;
|
||||
if (isIngore) return;
|
||||
var serieData = serie.GetSerieData(index, dataZoom);
|
||||
var numericFormatter = GetItemNumericFormatter(tooltip, serie, serieData);
|
||||
if (isCartesian)
|
||||
@@ -234,6 +233,35 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
private static void InitHeatmapTooltip(ref StringBuilder sb, Tooltip tooltip, Serie serie, int index,
|
||||
CoordinateChart chart)
|
||||
{
|
||||
if (serie.type != SerieType.Heatmap) return;
|
||||
var xData = tooltip.runtimeXValues[0];
|
||||
var yData = tooltip.runtimeYValues[0];
|
||||
if (chart.IsCategory() && (xData < 0 || yData < 0)) return;
|
||||
sb.Length = 0;
|
||||
var xAxis = chart.GetXAxis(serie.xAxisIndex);
|
||||
var yAxis = chart.GetYAxis(serie.yAxisIndex);
|
||||
var xCount = xAxis.data.Count;
|
||||
var yCount = yAxis.data.Count;
|
||||
var visualMap = chart.visualMap;
|
||||
if (chart.IsCategory())
|
||||
{
|
||||
string key = serie.name;
|
||||
var serieData = serie.data[(int) xData * yCount + (int) yData];
|
||||
var numericFormatter = GetItemNumericFormatter(tooltip, serie, serieData);
|
||||
var value = serieData.data[2];
|
||||
var color = visualMap.enable ? visualMap.GetColor(value) :
|
||||
chart.theme.GetColor(serie.index);
|
||||
sb.Append("\n")
|
||||
.Append(key).Append(!string.IsNullOrEmpty(key) ? "\n" : "")
|
||||
.Append("<color=#").Append(ChartCached.ColorToStr(color)).Append(">● </color>")
|
||||
.Append(xAxis.data[(int) xData]).Append(": ")
|
||||
.Append(ChartCached.FloatToStr(value, numericFormatter));
|
||||
}
|
||||
}
|
||||
|
||||
private static void InitDefaultContent(ref StringBuilder sb, Tooltip tooltip, Serie serie, int index,
|
||||
BaseChart chart, DataZoom dataZoom = null, bool isCartesian = false,
|
||||
Radar radar = null)
|
||||
@@ -259,6 +287,7 @@ namespace XCharts
|
||||
InitRingTooltip(ref sb, tooltip, serie, index, chart.theme);
|
||||
break;
|
||||
case SerieType.Heatmap:
|
||||
InitHeatmapTooltip(ref sb, tooltip, serie, index, chart as CoordinateChart);
|
||||
break;
|
||||
case SerieType.Gauge:
|
||||
InitGaugeTooltip(ref sb, tooltip, serie, index, chart.theme);
|
||||
@@ -335,8 +364,8 @@ namespace XCharts
|
||||
{
|
||||
string content = itemFormatter;
|
||||
FormatterHelper.ReplaceContent(ref content, dataIndex, tooltip.numericFormatter, serie, chart, null);
|
||||
var dotColorIndex = serie.type == SerieType.Pie || serie.type == SerieType.Radar
|
||||
|| serie.type == SerieType.Ring ? dataIndex : serie.index;
|
||||
var dotColorIndex = serie.type == SerieType.Pie || serie.type == SerieType.Radar ||
|
||||
serie.type == SerieType.Ring ? dataIndex : serie.index;
|
||||
sb.Append(ChartCached.ColorToDotStr(chart.theme.GetColor(dotColorIndex)));
|
||||
sb.Append(content);
|
||||
}
|
||||
@@ -449,8 +478,8 @@ namespace XCharts
|
||||
string content = itemFormatter;
|
||||
FormatterHelper.ReplaceContent(ref content, dataIndex, tooltip.numericFormatter, serie, chart, dataZoom);
|
||||
if (!first) sb.Append(FormatterHelper.PH_NN);
|
||||
var dotColorIndex = serie.type == SerieType.Pie || serie.type == SerieType.Radar
|
||||
|| serie.type == SerieType.Ring ? dataIndex : i;
|
||||
var dotColorIndex = serie.type == SerieType.Pie || serie.type == SerieType.Radar ||
|
||||
serie.type == SerieType.Ring ? dataIndex : i;
|
||||
sb.Append(ChartCached.ColorToDotStr(chart.theme.GetColor(dotColorIndex)));
|
||||
sb.Append(content);
|
||||
first = false;
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace XCharts
|
||||
|
||||
public static bool IsNeedGradient(VisualMap visualMap)
|
||||
{
|
||||
if (!visualMap.enable || visualMap.inRange.Count <= 0) return false;
|
||||
if (!visualMap.enable || (visualMap.inRange.Count <= 0 && visualMap.pieces.Count <= 0)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,12 +74,17 @@ namespace XCharts
|
||||
protected Action<VertexHelper, Serie> m_OnCustomDrawSerieBeforeCallback;
|
||||
protected Action<VertexHelper, Serie> m_OnCustomDrawSerieAfterCallback;
|
||||
protected Action<PointerEventData, int, int> m_OnPointerClickPie;
|
||||
protected Action<int, string, bool> m_OnLegendClick;
|
||||
protected Action<int, string> m_OnLegendEnter;
|
||||
protected Action<int, string> m_OnLegendExit;
|
||||
|
||||
protected bool m_RefreshLabel = false;
|
||||
internal bool m_ReinitLabel = false;
|
||||
internal bool m_ReinitTitle = false;
|
||||
internal bool m_CheckAnimation = false;
|
||||
internal bool m_IsPlayingAnimation = false;
|
||||
internal int m_BasePainterVertCount;
|
||||
internal int m_TopPainterVertCount;
|
||||
internal protected List<string> m_LegendRealShowName = new List<string>();
|
||||
protected List<Painter> m_PainterList = new List<Painter>();
|
||||
internal Painter m_PainterTop;
|
||||
@@ -109,6 +114,8 @@ namespace XCharts
|
||||
m_ComponentHandlers.Add(new VisualMapHandler(this));
|
||||
m_ComponentHandlers.Add(new DataZoomHandler(this));
|
||||
foreach (var draw in m_ComponentHandlers) draw.Init();
|
||||
|
||||
m_DebugInfo.Init(this);
|
||||
}
|
||||
|
||||
protected override void Awake()
|
||||
@@ -161,6 +168,7 @@ namespace XCharts
|
||||
Internal_CheckAnimation();
|
||||
foreach (var draw in m_DrawSeries) draw.Update();
|
||||
foreach (var draw in m_ComponentHandlers) draw.Update();
|
||||
m_DebugInfo.Update();
|
||||
}
|
||||
|
||||
public Painter GetPainter(int index)
|
||||
@@ -520,12 +528,12 @@ namespace XCharts
|
||||
m_ChartMaxAnchor, m_ChartPivot, m_ChartSizeDelta);
|
||||
m_SerieLabelRoot.hideFlags = chartHideFlags;
|
||||
SerieLabelPool.ReleaseAll(m_SerieLabelRoot.transform);
|
||||
int count = 0;
|
||||
for (int i = 0; i < m_Series.Count; i++)
|
||||
{
|
||||
var serie = m_Series.list[i];
|
||||
serie.index = i;
|
||||
SerieHelper.UpdateCenter(serie, chartPosition, chartWidth, chartHeight);
|
||||
int count = 0;
|
||||
for (int j = 0; j < serie.data.Count; j++)
|
||||
{
|
||||
var serieData = serie.data[j];
|
||||
@@ -791,6 +799,12 @@ namespace XCharts
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
m_DebugInfo.clickChartCount++;
|
||||
base.OnPointerClick(eventData);
|
||||
}
|
||||
|
||||
public override void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
base.OnPointerDown(eventData);
|
||||
@@ -836,6 +850,8 @@ namespace XCharts
|
||||
}
|
||||
OnYMaxValueChanged();
|
||||
}
|
||||
if(m_OnLegendClick != null)
|
||||
m_OnLegendClick(index, legendName, show);
|
||||
}
|
||||
|
||||
protected virtual void OnLegendButtonEnter(int index, string legendName)
|
||||
@@ -851,6 +867,8 @@ namespace XCharts
|
||||
RefreshPainter(serie);
|
||||
}
|
||||
}
|
||||
if(m_OnLegendEnter != null)
|
||||
m_OnLegendEnter(index, legendName);
|
||||
}
|
||||
|
||||
protected virtual void OnLegendButtonExit(int index, string legendName)
|
||||
@@ -866,6 +884,8 @@ namespace XCharts
|
||||
RefreshPainter(serie);
|
||||
}
|
||||
}
|
||||
if(m_OnLegendExit != null)
|
||||
m_OnLegendExit(index, legendName);
|
||||
}
|
||||
|
||||
protected virtual void UpdateTooltip()
|
||||
@@ -883,6 +903,7 @@ namespace XCharts
|
||||
{
|
||||
m_OnCustomDrawBaseCallback(vh);
|
||||
}
|
||||
m_BasePainterVertCount = vh.currentVertCount;
|
||||
}
|
||||
|
||||
protected virtual void OnDrawPainterSerie(VertexHelper vh, Painter painter)
|
||||
@@ -892,6 +913,7 @@ namespace XCharts
|
||||
var maxSeries = m_Series.Count;
|
||||
var rate = Mathf.CeilToInt(maxSeries * 1.0f / maxPainter);
|
||||
m_PainterTop.Refresh();
|
||||
m_DebugInfo.refreshCount++;
|
||||
for (int i = painter.index * rate; i < (painter.index + 1) * rate && i < maxSeries; i++)
|
||||
{
|
||||
var serie = m_Series.GetSerie(i);
|
||||
@@ -904,6 +926,7 @@ namespace XCharts
|
||||
{
|
||||
m_OnCustomDrawSerieAfterCallback(vh, serie);
|
||||
}
|
||||
serie.runtimeVertCount = vh.currentVertCount;
|
||||
}
|
||||
m_RefreshLabel = true;
|
||||
}
|
||||
@@ -919,6 +942,7 @@ namespace XCharts
|
||||
m_OnCustomDrawTopCallback(vh);
|
||||
}
|
||||
DrawTooltip(vh);
|
||||
m_TopPainterVertCount = vh.currentVertCount;
|
||||
}
|
||||
|
||||
protected virtual void DrawPainterSerie(VertexHelper vh, Serie serie)
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace XCharts
|
||||
[SerializeField] protected bool m_DebugMode = false;
|
||||
[SerializeField] protected bool m_EnableTextMeshPro = false;
|
||||
[SerializeField] protected Background m_Background = Background.defaultBackground;
|
||||
protected DebugInfo m_DebugInfo = new DebugInfo();
|
||||
protected Painter m_Painter;
|
||||
protected int m_SiblingIndex;
|
||||
|
||||
@@ -57,7 +58,7 @@ namespace XCharts
|
||||
protected Vector2 graphAnchorMin { get { return m_GraphMaxAnchor; } }
|
||||
protected Vector2 graphPivot { get { return m_GraphPivot; } }
|
||||
public HideFlags chartHideFlags { get { return m_DebugMode ? HideFlags.None : HideFlags.HideInHierarchy; } }
|
||||
|
||||
public DebugInfo debug { get { return m_DebugInfo; } }
|
||||
private ScrollRect m_ScrollRect;
|
||||
|
||||
|
||||
@@ -129,7 +130,7 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void CheckTextMeshPro()
|
||||
{
|
||||
|
||||
@@ -266,6 +266,8 @@ namespace XCharts
|
||||
var offset = new Vector3(textStyle.offset.x, textStyle.offset.y);
|
||||
AxisHelper.AdjustCircleLabelPos(txt, pos, radar.runtimeCenterPos, txtHig, offset);
|
||||
}
|
||||
if(chart.tooltip.gameObject != null)
|
||||
chart.tooltip.gameObject.transform.SetSiblingIndex(chart.transform.childCount-1);
|
||||
chart.RefreshBasePainter();
|
||||
};
|
||||
radar.refreshComponent.Invoke();
|
||||
@@ -312,9 +314,9 @@ namespace XCharts
|
||||
serieIndex = serieNameCount;
|
||||
}
|
||||
else if (!serieNameSet.ContainsKey(dataName))
|
||||
{
|
||||
serieNameSet.Add(dataName, serieNameCount);
|
||||
{
|
||||
serieNameCount++;
|
||||
serieNameSet.Add(dataName, serieNameCount);
|
||||
serieIndex = serieNameCount;
|
||||
}
|
||||
else
|
||||
@@ -482,8 +484,8 @@ namespace XCharts
|
||||
}
|
||||
else if (!serieNameSet.ContainsKey(dataName))
|
||||
{
|
||||
serieNameSet.Add(dataName, serieNameCount);
|
||||
serieNameCount++;
|
||||
serieNameSet.Add(dataName, serieNameCount);
|
||||
serieIndex = serieNameCount;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -136,7 +136,6 @@ namespace XCharts
|
||||
public bool CheckTootipArea(Vector2 local)
|
||||
{
|
||||
if (!chart.series.Contains(SerieType.Ring)) return false;
|
||||
if (!PointerIsInRingSerie(chart.series, local)) return false;
|
||||
if (m_IsEnterLegendButtom) return false;
|
||||
bool selected = false;
|
||||
chart.tooltip.runtimeDataIndex.Clear();
|
||||
|
||||
@@ -33,8 +33,8 @@ namespace XCharts
|
||||
[ExecuteInEditMode]
|
||||
public class XChartsMgr : MonoBehaviour
|
||||
{
|
||||
internal static string _version = "2.7.0";
|
||||
internal static int _versionDate = 20220320;
|
||||
internal static string _version = "2.8.2";
|
||||
internal static int _versionDate = 20220815;
|
||||
public static string version { get { return _version; } }
|
||||
public static int versionDate { get { return _versionDate; } }
|
||||
public static string fullVersion { get { return version + "-" + versionDate; } }
|
||||
@@ -57,7 +57,9 @@ namespace XCharts
|
||||
{
|
||||
var obj = GameObject.Find("_xcharts_");
|
||||
if (obj == null) obj = new GameObject("_xcharts_");
|
||||
obj.SetActive(false);
|
||||
m_XCharts = obj.AddComponent<XChartsMgr>();
|
||||
obj.SetActive(true);
|
||||
}
|
||||
m_XCharts.m_NowVersion = fullVersion;
|
||||
}
|
||||
@@ -514,4 +516,4 @@ namespace XCharts
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "com.monitor1394.xcharts",
|
||||
"displayName": "XCharts",
|
||||
"version": "2.7.0",
|
||||
"date": "20220320",
|
||||
"checkdate": "20220320",
|
||||
"version": "2.8.2",
|
||||
"date": "20220815",
|
||||
"checkdate": "20220815",
|
||||
"desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!",
|
||||
"unity": "2018.3",
|
||||
"description": "A charting and data visualization library for Unity.",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"version": "2.7.0",
|
||||
"date": "20220320",
|
||||
"checkdate": "20220320",
|
||||
"version": "2.8.2",
|
||||
"date": "20220815",
|
||||
"checkdate": "20220815",
|
||||
"desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!",
|
||||
"homepage": "https://github.com/monitor1394/unity-ugui-XCharts"
|
||||
}
|
||||
Reference in New Issue
Block a user