mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-28 03:58:49 +00:00
增加BarChart和HeatmapChart可通过ignore参数设置忽略数据的支持
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
* (2020.03.21) 增加`BarChart`和`HeatmapChart`可通过`ignore`参数设置忽略数据的支持
|
||||||
* (2020.03.21) 增加`ItemStyle`的`tooltipFormatter`参数可单独配置`Serie`的`Tooltip`显示
|
* (2020.03.21) 增加`ItemStyle`的`tooltipFormatter`参数可单独配置`Serie`的`Tooltip`显示
|
||||||
* (2020.03.20) 修复`X Axis 1`和`Y Axis 1`配置变更时不会自动刷新的问题
|
* (2020.03.20) 修复`X Axis 1`和`Y Axis 1`配置变更时不会自动刷新的问题
|
||||||
* (2020.03.20) 增加`AxisTick`的`width`参数可单独设置坐标轴刻度的宽度
|
* (2020.03.20) 增加`AxisTick`的`width`参数可单独设置坐标轴刻度的宽度
|
||||||
|
|||||||
@@ -172,6 +172,10 @@ namespace XCharts
|
|||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_Clip);
|
EditorGUI.PropertyField(drawRect, m_Clip);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Ignore);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_IgnoreValue);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_ItemStyle);
|
EditorGUI.PropertyField(drawRect, m_ItemStyle);
|
||||||
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
|
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
|
||||||
EditorGUI.PropertyField(drawRect, m_Label);
|
EditorGUI.PropertyField(drawRect, m_Label);
|
||||||
@@ -245,6 +249,10 @@ namespace XCharts
|
|||||||
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
|
||||||
break;
|
break;
|
||||||
case SerieType.Heatmap:
|
case SerieType.Heatmap:
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Ignore);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_IgnoreValue);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_ItemStyle);
|
EditorGUI.PropertyField(drawRect, m_ItemStyle);
|
||||||
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
|
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
|
||||||
EditorGUI.PropertyField(drawRect, m_Label);
|
EditorGUI.PropertyField(drawRect, m_Label);
|
||||||
@@ -474,7 +482,7 @@ namespace XCharts
|
|||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
|
||||||
break;
|
break;
|
||||||
case SerieType.Bar:
|
case SerieType.Bar:
|
||||||
height += 16 * EditorGUIUtility.singleLineHeight + 15 * EditorGUIUtility.standardVerticalSpacing;
|
height += 18 * EditorGUIUtility.singleLineHeight + 17 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
|
||||||
@@ -514,7 +522,7 @@ namespace XCharts
|
|||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
|
||||||
break;
|
break;
|
||||||
case SerieType.Heatmap:
|
case SerieType.Heatmap:
|
||||||
height += 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
|
height += 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
|
||||||
|
|||||||
@@ -1516,12 +1516,25 @@ namespace XCharts
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsIngoreValue(float value)
|
public bool IsIgnoreIndex(int index, int dimension)
|
||||||
|
{
|
||||||
|
if (m_Ignore)
|
||||||
|
{
|
||||||
|
var serieData = GetSerieData(index);
|
||||||
|
if (serieData != null)
|
||||||
|
{
|
||||||
|
return IsIgnoreValue(serieData.GetData(dimension));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsIgnoreValue(float value)
|
||||||
{
|
{
|
||||||
return m_Ignore && Mathf.Approximately(value, m_IgnoreValue);
|
return m_Ignore && Mathf.Approximately(value, m_IgnoreValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsIngorePoint(int index)
|
public bool IsIgnorePoint(int index)
|
||||||
{
|
{
|
||||||
if (index >= 0 && index < dataPoints.Count)
|
if (index >= 0 && index < dataPoints.Count)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ namespace XCharts
|
|||||||
string key = serie.name;
|
string key = serie.name;
|
||||||
float xValue, yValue;
|
float xValue, yValue;
|
||||||
serie.GetXYData(index, dataZoom, out xValue, out yValue);
|
serie.GetXYData(index, dataZoom, out xValue, out yValue);
|
||||||
var isIngore = serie.IsIngorePoint(index);
|
var isIngore = serie.IsIgnorePoint(index);
|
||||||
if (isCartesian)
|
if (isCartesian)
|
||||||
{
|
{
|
||||||
var serieData = serie.GetSerieData(index, dataZoom);
|
var serieData = serie.GetSerieData(index, dataZoom);
|
||||||
@@ -97,10 +97,9 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
var valueTxt = isIngore ? tooltip.ignoreDataDefaultContent :
|
var valueTxt = isIngore ? tooltip.ignoreDataDefaultContent :
|
||||||
ChartCached.FloatToStr(yValue, 0, tooltip.forceENotation);
|
ChartCached.FloatToStr(yValue, 0, tooltip.forceENotation);
|
||||||
sb.Append("\n")
|
sb.Append("<color=#").Append(themeInfo.GetColorStr(serie.index)).Append(">● </color>")
|
||||||
.Append("<color=#").Append(themeInfo.GetColorStr(serie.index)).Append(">● </color>")
|
.Append(key).Append(!string.IsNullOrEmpty(key) ? " : " : "")
|
||||||
.Append(key).Append(!string.IsNullOrEmpty(key) ? " : " : "")
|
.Append(valueTxt);
|
||||||
.Append(valueTxt);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,15 +146,17 @@ namespace XCharts
|
|||||||
if (!serie.show) continue;
|
if (!serie.show) continue;
|
||||||
var serieData = serie.GetSerieData(dataIndex, dataZoom);
|
var serieData = serie.GetSerieData(dataIndex, dataZoom);
|
||||||
var itemFormatter = GetItemFormatter(tooltip, serie, serieData);
|
var itemFormatter = GetItemFormatter(tooltip, serie, serieData);
|
||||||
if (string.IsNullOrEmpty(itemFormatter))
|
|
||||||
{
|
|
||||||
InitDefaultContent(ref sb, tooltip, serie, dataIndex, category, themeInfo, dataZoom, isCartesian);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
var percent = serieData.GetData(1) / serie.yTotal * 100;
|
var percent = serieData.GetData(1) / serie.yTotal * 100;
|
||||||
needCategory = needCategory || (serie.type == SerieType.Line || serie.type == SerieType.Bar);
|
needCategory = needCategory || (serie.type == SerieType.Line || serie.type == SerieType.Bar);
|
||||||
if (serie.show)
|
if (serie.show)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(itemFormatter))
|
||||||
|
{
|
||||||
|
if (!first) sb.Append("\n");
|
||||||
|
InitDefaultContent(ref sb, tooltip, serie, dataIndex, category, themeInfo, dataZoom, isCartesian);
|
||||||
|
first = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
string content = itemFormatter;
|
string content = itemFormatter;
|
||||||
content = content.Replace("{a}", serie.name);
|
content = content.Replace("{a}", serie.name);
|
||||||
content = content.Replace("{b}", needCategory ? category : serieData.name);
|
content = content.Replace("{b}", needCategory ? category : serieData.name);
|
||||||
|
|||||||
@@ -1461,12 +1461,14 @@ namespace XCharts
|
|||||||
var serieData = serie.data[j];
|
var serieData = serie.data[j];
|
||||||
var pos = serie.dataPoints[j];
|
var pos = serie.dataPoints[j];
|
||||||
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
|
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
|
||||||
|
var dimension = 1;
|
||||||
|
var isIgnore = serie.IsIgnoreIndex(j, 1);
|
||||||
serieData.SetGameObjectPosition(serieData.labelPosition);
|
serieData.SetGameObjectPosition(serieData.labelPosition);
|
||||||
serieData.UpdateIcon();
|
serieData.UpdateIcon();
|
||||||
if (serie.show && serieLabel.show && serieData.canShowLabel)
|
if (serie.show && serieLabel.show && serieData.canShowLabel && !isIgnore)
|
||||||
{
|
{
|
||||||
float value = 0f;
|
float value = 0f;
|
||||||
var dimension = 1;
|
|
||||||
if (serie.type == SerieType.Heatmap)
|
if (serie.type == SerieType.Heatmap)
|
||||||
{
|
{
|
||||||
dimension = m_VisualMap.enable && m_VisualMap.dimension > 0 ? m_VisualMap.dimension - 1 :
|
dimension = m_VisualMap.enable && m_VisualMap.dimension > 0 ? m_VisualMap.dimension - 1 :
|
||||||
|
|||||||
@@ -56,6 +56,11 @@ namespace XCharts
|
|||||||
seriesHig.Add(0);
|
seriesHig.Add(0);
|
||||||
}
|
}
|
||||||
var serieData = showData[i];
|
var serieData = showData[i];
|
||||||
|
if (serie.IsIgnoreValue(serieData.GetData(1)))
|
||||||
|
{
|
||||||
|
serie.dataPoints.Add(Vector3.zero);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
var highlight = (m_Tooltip.show && m_Tooltip.IsSelected(i))
|
var highlight = (m_Tooltip.show && m_Tooltip.IsSelected(i))
|
||||||
|| serie.data[i].highlighted
|
|| serie.data[i].highlighted
|
||||||
|| serie.highlighted;
|
|| serie.highlighted;
|
||||||
@@ -185,6 +190,11 @@ namespace XCharts
|
|||||||
seriesHig.Add(0);
|
seriesHig.Add(0);
|
||||||
}
|
}
|
||||||
var serieData = showData[i];
|
var serieData = showData[i];
|
||||||
|
if (serie.IsIgnoreValue(serieData.GetData(1)))
|
||||||
|
{
|
||||||
|
serie.dataPoints.Add(Vector3.zero);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
var highlight = (m_Tooltip.show && m_Tooltip.IsSelected(i))
|
var highlight = (m_Tooltip.show && m_Tooltip.IsSelected(i))
|
||||||
|| serie.data[i].highlighted
|
|| serie.data[i].highlighted
|
||||||
|| serie.highlighted;
|
|| serie.highlighted;
|
||||||
|
|||||||
@@ -147,6 +147,11 @@ namespace XCharts
|
|||||||
var serieData = dataList[dataIndex];
|
var serieData = dataList[dataIndex];
|
||||||
var dimension = m_VisualMap.enable && m_VisualMap.dimension > 0 ? m_VisualMap.dimension - 1 :
|
var dimension = m_VisualMap.enable && m_VisualMap.dimension > 0 ? m_VisualMap.dimension - 1 :
|
||||||
serieData.data.Count - 1;
|
serieData.data.Count - 1;
|
||||||
|
if (serie.IsIgnoreIndex(dataIndex, dimension))
|
||||||
|
{
|
||||||
|
serie.dataPoints.Add(Vector3.zero);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
var value = serieData.GetCurrData(dimension, dataChangeDuration);
|
var value = serieData.GetCurrData(dimension, dataChangeDuration);
|
||||||
if (serieData.IsDataChanged()) dataChanging = true;
|
if (serieData.IsDataChanged()) dataChanging = true;
|
||||||
var pos = new Vector3(zeroX + (i + 0.5f) * xWidth, zeroY + (j + 0.5f) * yWidth);
|
var pos = new Vector3(zeroX + (i + 0.5f) * xWidth, zeroY + (j + 0.5f) * yWidth);
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
for (int j = 0; j < rate; j++) seriesHig.Add(0);
|
for (int j = 0; j < rate; j++) seriesHig.Add(0);
|
||||||
}
|
}
|
||||||
if (serie.IsIngoreValue(showData[i].GetData(1)))
|
if (serie.IsIgnoreValue(showData[i].GetData(1)))
|
||||||
{
|
{
|
||||||
serie.dataPoints.Add(Vector3.zero);
|
serie.dataPoints.Add(Vector3.zero);
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
i = maxCount - 1;
|
i = maxCount - 1;
|
||||||
seriesHig.Add(0);
|
seriesHig.Add(0);
|
||||||
if (serie.IsIngoreValue(showData[i].GetData(1)))
|
if (serie.IsIgnoreValue(showData[i].GetData(1)))
|
||||||
{
|
{
|
||||||
serie.dataPoints.Add(Vector3.zero);
|
serie.dataPoints.Add(Vector3.zero);
|
||||||
}
|
}
|
||||||
@@ -181,7 +181,7 @@ namespace XCharts
|
|||||||
if (serie.minShow > 0 && serie.minShow < showData.Count)
|
if (serie.minShow > 0 && serie.minShow < showData.Count)
|
||||||
{
|
{
|
||||||
i = serie.minShow - 1;
|
i = serie.minShow - 1;
|
||||||
if (serie.IsIngoreValue(showData[i].GetData(1)))
|
if (serie.IsIgnoreValue(showData[i].GetData(1)))
|
||||||
{
|
{
|
||||||
serie.dataPoints.Add(Vector3.zero);
|
serie.dataPoints.Add(Vector3.zero);
|
||||||
}
|
}
|
||||||
@@ -198,7 +198,7 @@ namespace XCharts
|
|||||||
if (serie.maxShow > 0 && serie.maxShow < showData.Count)
|
if (serie.maxShow > 0 && serie.maxShow < showData.Count)
|
||||||
{
|
{
|
||||||
i = serie.maxShow;
|
i = serie.maxShow;
|
||||||
if (serie.IsIngoreValue(showData[i].GetData(1)))
|
if (serie.IsIgnoreValue(showData[i].GetData(1)))
|
||||||
{
|
{
|
||||||
serie.dataPoints.Add(Vector3.zero);
|
serie.dataPoints.Add(Vector3.zero);
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user