mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 09:20:08 +00:00
[feature][tooltip] support ignoreDataDefaultContent
This commit is contained in:
@@ -250,7 +250,7 @@ namespace XCharts.Runtime
|
||||
public bool ignoreDataShow { get { return m_IgnoreDataShow; } set { m_IgnoreDataShow = value; } }
|
||||
/// <summary>
|
||||
/// The default display character information for ignored data.
|
||||
/// |被忽略数据的默认显示字符信息。
|
||||
/// |被忽略数据的默认显示字符信息。如果设置为空,则表示完全不显示忽略数据。
|
||||
/// </summary>
|
||||
public string ignoreDataDefaultContent { get { return m_IgnoreDataDefaultContent; } set { m_IgnoreDataDefaultContent = value; } }
|
||||
/// <summary>
|
||||
|
||||
@@ -374,7 +374,7 @@ namespace XCharts.Runtime
|
||||
tooltip.context.pointer = chart.pointerPos;
|
||||
|
||||
serie.handler.UpdateTooltipSerieParams(serie.context.pointerItemDataIndex, false, null,
|
||||
tooltip.marker, tooltip.itemFormatter, tooltip.numericFormatter,
|
||||
tooltip.marker, tooltip.itemFormatter, tooltip.numericFormatter, tooltip.ignoreDataDefaultContent,
|
||||
ref tooltip.context.data.param,
|
||||
ref tooltip.context.data.title);
|
||||
TooltipHelper.ResetTooltipParamsByItemFormatter(tooltip, chart);
|
||||
@@ -423,6 +423,7 @@ namespace XCharts.Runtime
|
||||
serie.context.pointerItemDataIndex = dataIndex;
|
||||
serie.handler.UpdateTooltipSerieParams(dataIndex, showCategory, category,
|
||||
tooltip.marker, tooltip.itemFormatter, tooltip.numericFormatter,
|
||||
tooltip.ignoreDataDefaultContent,
|
||||
ref tooltip.context.data.param,
|
||||
ref tooltip.context.data.title);
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (tooltip == null) return;
|
||||
var data = tooltip.context.data;
|
||||
var ignoreColumn = string.IsNullOrEmpty(tooltip.ignoreDataDefaultContent);
|
||||
|
||||
var titleActive = !string.IsNullOrEmpty(data.title);
|
||||
if (titleActive != title.gameObject.activeSelf)
|
||||
@@ -80,7 +81,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
var item = GetItem(i);
|
||||
var param = data.param[i];
|
||||
if (param.columns.Count <= 0)
|
||||
if (param.columns.Count <= 0 || (ignoreColumn && param.ignore))
|
||||
{
|
||||
item.gameObject.SetActive(false);
|
||||
continue;
|
||||
@@ -112,9 +113,6 @@ namespace XCharts.Runtime
|
||||
m_Items[i].gameObject.SetActive(false);
|
||||
}
|
||||
ResetSize();
|
||||
// border.effectColor = data.param.Count == 1
|
||||
// ? data.param[0].color
|
||||
// : tooltip.borderColor;
|
||||
UpdatePosition(tooltip.context.pointer + tooltip.offset);
|
||||
tooltip.gameObject.transform.SetAsLastSibling();
|
||||
}
|
||||
|
||||
@@ -20,11 +20,11 @@ namespace XCharts.Runtime
|
||||
}
|
||||
|
||||
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
|
||||
string marker, string itemFormatter, string numericFormatter,
|
||||
string marker, string itemFormatter, string numericFormatter, string ignoreDataDefaultContent,
|
||||
ref List<SerieParams> paramList, ref string title)
|
||||
{
|
||||
UpdateCoordSerieParams(ref paramList, ref title, dataIndex, showCategory, category,
|
||||
marker, itemFormatter, numericFormatter);
|
||||
marker, itemFormatter, numericFormatter, ignoreDataDefaultContent);
|
||||
}
|
||||
|
||||
public override void DrawSerie(VertexHelper vh)
|
||||
|
||||
@@ -18,11 +18,11 @@ namespace XCharts.Runtime
|
||||
}
|
||||
|
||||
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
|
||||
string marker, string itemFormatter, string numericFormatter,
|
||||
string marker, string itemFormatter, string numericFormatter, string ignoreDataDefaultContent,
|
||||
ref List<SerieParams> paramList, ref string title)
|
||||
{
|
||||
UpdateCoordSerieParams(ref paramList, ref title, dataIndex, showCategory, category,
|
||||
marker, itemFormatter, numericFormatter);
|
||||
marker, itemFormatter, numericFormatter, ignoreDataDefaultContent);
|
||||
}
|
||||
|
||||
public override void DrawSerie(VertexHelper vh)
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
|
||||
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
|
||||
string marker, string itemFormatter, string numericFormatter,
|
||||
string marker, string itemFormatter, string numericFormatter, string ignoreDataDefaultContent,
|
||||
ref List<SerieParams> paramList, ref string title)
|
||||
{
|
||||
if (dataIndex < 0)
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
|
||||
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
|
||||
string marker, string itemFormatter, string numericFormatter,
|
||||
string marker, string itemFormatter, string numericFormatter, string ignoreDataDefaultContent,
|
||||
ref List<SerieParams> paramList, ref string title)
|
||||
{
|
||||
if (dataIndex < 0)
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
|
||||
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
|
||||
string marker, string itemFormatter, string numericFormatter,
|
||||
string marker, string itemFormatter, string numericFormatter, string ignoreDataDefaultContent,
|
||||
ref List<SerieParams> paramList, ref string title)
|
||||
{
|
||||
dataIndex = serie.context.pointerItemDataIndex;
|
||||
|
||||
@@ -22,11 +22,11 @@ namespace XCharts.Runtime
|
||||
}
|
||||
|
||||
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
|
||||
string marker, string itemFormatter, string numericFormatter,
|
||||
string marker, string itemFormatter, string numericFormatter, string ignoreDataDefaultContent,
|
||||
ref List<SerieParams> paramList, ref string title)
|
||||
{
|
||||
UpdateCoordSerieParams(ref paramList, ref title, dataIndex, showCategory, category,
|
||||
marker, itemFormatter, numericFormatter);
|
||||
marker, itemFormatter, numericFormatter, ignoreDataDefaultContent);
|
||||
}
|
||||
|
||||
public override void DrawSerie(VertexHelper vh)
|
||||
|
||||
@@ -19,11 +19,11 @@ namespace XCharts.Runtime
|
||||
}
|
||||
|
||||
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
|
||||
string marker, string itemFormatter, string numericFormatter,
|
||||
string marker, string itemFormatter, string numericFormatter, string ignoreDataDefaultContent,
|
||||
ref List<SerieParams> paramList, ref string title)
|
||||
{
|
||||
UpdateCoordSerieParams(ref paramList, ref title, dataIndex, showCategory, category,
|
||||
marker, itemFormatter, numericFormatter);
|
||||
marker, itemFormatter, numericFormatter, ignoreDataDefaultContent);
|
||||
}
|
||||
|
||||
public override void DrawSerie(VertexHelper vh)
|
||||
|
||||
@@ -34,11 +34,11 @@ namespace XCharts.Runtime
|
||||
}
|
||||
|
||||
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
|
||||
string marker, string itemFormatter, string numericFormatter,
|
||||
string marker, string itemFormatter, string numericFormatter, string ignoreDataDefaultContent,
|
||||
ref List<SerieParams> paramList, ref string title)
|
||||
{
|
||||
UpdateItemSerieParams(ref paramList, ref title, dataIndex, category,
|
||||
marker, itemFormatter, numericFormatter);
|
||||
marker, itemFormatter, numericFormatter, ignoreDataDefaultContent);
|
||||
}
|
||||
|
||||
public override Vector3 GetSerieDataLabelPosition(SerieData serieData, LabelStyle label)
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
|
||||
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
|
||||
string marker, string itemFormatter, string numericFormatter,
|
||||
string marker, string itemFormatter, string numericFormatter, string ignoreDataDefaultContent,
|
||||
ref List<SerieParams> paramList, ref string title)
|
||||
{
|
||||
if (!serie.context.pointerEnter)
|
||||
@@ -43,7 +43,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
var colorIndex1 = serie.colorByData ? dataIndex : serie.context.colorIndex;
|
||||
UpdateItemSerieParams(ref paramList, ref title, dataIndex, category,
|
||||
marker, itemFormatter, numericFormatter, 1, colorIndex1);
|
||||
marker, itemFormatter, numericFormatter, ignoreDataDefaultContent, 1, colorIndex1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
|
||||
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
|
||||
string marker, string itemFormatter, string numericFormatter,
|
||||
string marker, string itemFormatter, string numericFormatter, string ignoreDataDefaultContent,
|
||||
ref List<SerieParams> paramList, ref string title)
|
||||
{
|
||||
if (dataIndex < 0)
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
|
||||
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
|
||||
string marker, string itemFormatter, string numericFormatter,
|
||||
string marker, string itemFormatter, string numericFormatter, string ignoreDataDefaultContent,
|
||||
ref List<SerieParams> paramList, ref string title)
|
||||
{
|
||||
dataIndex = serie.context.pointerItemDataIndex;
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace XCharts.Runtime
|
||||
public virtual void RefreshLabelInternal() { }
|
||||
public virtual void UpdateTooltipSerieParams(int dataIndex, bool showCategory,
|
||||
string category, string marker,
|
||||
string itemFormatter, string numericFormatter,
|
||||
string itemFormatter, string numericFormatter, string ignoreDataDefaultContent,
|
||||
ref List<SerieParams> paramList, ref string title) { }
|
||||
public virtual void OnLegendButtonClick(int index, string legendName, bool show) { }
|
||||
public virtual void OnLegendButtonEnter(int index, string legendName) { }
|
||||
@@ -492,8 +492,9 @@ namespace XCharts.Runtime
|
||||
|
||||
protected void UpdateCoordSerieParams(ref List<SerieParams> paramList, ref string title,
|
||||
int dataIndex, bool showCategory, string category, string marker,
|
||||
string itemFormatter, string numericFormatter)
|
||||
string itemFormatter, string numericFormatter, string ignoreDataDefaultContent)
|
||||
{
|
||||
var dimension = 1;
|
||||
if (dataIndex < 0)
|
||||
dataIndex = serie.context.pointerItemDataIndex;
|
||||
|
||||
@@ -504,6 +505,10 @@ namespace XCharts.Runtime
|
||||
if (serieData == null)
|
||||
return;
|
||||
|
||||
var ignore = serie.IsIgnoreValue(serieData, dimension);
|
||||
if (ignore && string.IsNullOrEmpty(ignoreDataDefaultContent))
|
||||
return;
|
||||
|
||||
itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
|
||||
if (serie.placeHolder || TooltipHelper.IsIgnoreFormatter(itemFormatter))
|
||||
return;
|
||||
@@ -512,10 +517,11 @@ namespace XCharts.Runtime
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.category = category;
|
||||
param.dimension = 1;
|
||||
param.dimension = dimension;
|
||||
param.serieData = serieData;
|
||||
param.dataCount = serie.dataCount;
|
||||
param.value = serieData.GetData(1);
|
||||
param.value = serieData.GetData(dimension);
|
||||
param.ignore = ignore;
|
||||
param.total = serie.yTotal;
|
||||
param.color = chart.GetItemColor(serie, serieData);
|
||||
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||
@@ -525,14 +531,15 @@ namespace XCharts.Runtime
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add(showCategory ? category : serie.serieName);
|
||||
param.columns.Add(ChartCached.NumberToStr(param.value, param.numericFormatter));
|
||||
param.columns.Add(ignore?ignoreDataDefaultContent : ChartCached.NumberToStr(param.value, param.numericFormatter));
|
||||
|
||||
paramList.Add(param);
|
||||
}
|
||||
|
||||
protected void UpdateItemSerieParams(ref List<SerieParams> paramList, ref string title,
|
||||
int dataIndex, string category, string marker,
|
||||
string itemFormatter, string numericFormatter, int dimension = 1, int colorIndex = -1)
|
||||
string itemFormatter, string numericFormatter, string ignoreDataDefaultContent,
|
||||
int dimension = 1, int colorIndex = -1)
|
||||
{
|
||||
if (dataIndex < 0)
|
||||
dataIndex = serie.context.pointerItemDataIndex;
|
||||
@@ -544,6 +551,10 @@ namespace XCharts.Runtime
|
||||
if (serieData == null)
|
||||
return;
|
||||
|
||||
var ignore = serie.IsIgnoreValue(serieData, dimension);
|
||||
if (ignore && string.IsNullOrEmpty(ignoreDataDefaultContent))
|
||||
return;
|
||||
|
||||
itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
|
||||
if (serie.placeHolder || TooltipHelper.IsIgnoreFormatter(itemFormatter))
|
||||
return;
|
||||
@@ -556,11 +567,13 @@ namespace XCharts.Runtime
|
||||
var param = serie.context.param;
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
|
||||
param.category = category;
|
||||
param.dimension = dimension;
|
||||
param.serieData = serieData;
|
||||
param.dataCount = serie.dataCount;
|
||||
param.value = serieData.GetData(param.dimension);
|
||||
param.ignore = ignore;
|
||||
param.total = SerieHelper.GetMaxData(serie, dimension);
|
||||
param.color = color;
|
||||
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||
@@ -570,7 +583,8 @@ namespace XCharts.Runtime
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add(serieData.name);
|
||||
param.columns.Add(ChartCached.NumberToStr(param.value, param.numericFormatter));
|
||||
|
||||
param.columns.Add(ignore?ignoreDataDefaultContent : ChartCached.NumberToStr(param.value, param.numericFormatter));
|
||||
|
||||
paramList.Add(param);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace XCharts.Runtime
|
||||
public Color32 color;
|
||||
public string itemFormatter;
|
||||
public string numericFormatter;
|
||||
public bool ignore;
|
||||
public List<string> columns = new List<string>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user