[feature][tooltip] support ignoreDataDefaultContent

This commit is contained in:
monitor1394
2022-08-11 08:11:43 +08:00
parent 34b132735d
commit ca5470a351
19 changed files with 48 additions and 33 deletions

View File

@@ -69,6 +69,7 @@
### 日志详情 ### 日志详情
* (2022.08.11) 优化`Tooltip`支持`ignoreDataDefaultContent`
* (2022.08.10) 修复`Chart`在3D相机下部分组件显示异常的问题 * (2022.08.10) 修复`Chart`在3D相机下部分组件显示异常的问题
* (2022.08.10) 修复`RemoveSerie()`接口不生效的问题 (#219) * (2022.08.10) 修复`RemoveSerie()`接口不生效的问题 (#219)
* (2022.08.10) 优化`Theme`的字体同步操作 * (2022.08.10) 优化`Theme`的字体同步操作

View File

@@ -215,7 +215,7 @@ The style of area.
|`color`|||the color of area,default use serie color. |`color`|||the color of area,default use serie color.
|`toColor`|||Gradient color, start color to toColor. |`toColor`|||Gradient color, start color to toColor.
|`opacity`|0.6f||Opacity of the component. Supports value from 0 to 1, and the component will not be drawn when set to 0. |`opacity`|0.6f||Opacity of the component. Supports value from 0 to 1, and the component will not be drawn when set to 0.
|`fill`|true|v3.2.0|Whether to fill only polygonal areas. Currently, only convex polygons are supported. |`innerFill`||v3.2.0|Whether to fill only polygonal areas. Currently, only convex polygons are supported.
## `ArrowStyle` ## `ArrowStyle`

View File

@@ -215,7 +215,7 @@ Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieExtraComponent
|`color`|||区域填充的颜色如果toColor不是默认值则表示渐变色的起点颜色。 |`color`|||区域填充的颜色如果toColor不是默认值则表示渐变色的起点颜色。
|`toColor`|||渐变色的终点颜色。 |`toColor`|||渐变色的终点颜色。
|`opacity`|0.6f||图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。 |`opacity`|0.6f||图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
|`fill`|true|v3.2.0|是否只填充多边形区域。目前只支持凸多边形。 |`innerFill`||v3.2.0|是否只填充多边形区域。目前只支持凸多边形。
## `ArrowStyle` ## `ArrowStyle`
@@ -1433,7 +1433,7 @@ Inherits or Implemented: [MainComponent](#MainComponent)
|`paddingLeftRight`|10||左右边距。 |`paddingLeftRight`|10||左右边距。
|`paddingTopBottom`|10||上下边距。 |`paddingTopBottom`|10||上下边距。
|`ignoreDataShow`|false||是否显示忽略数据在tooltip上。 |`ignoreDataShow`|false||是否显示忽略数据在tooltip上。
|`ignoreDataDefaultContent`|||被忽略数据的默认显示字符信息。 |`ignoreDataDefaultContent`|||被忽略数据的默认显示字符信息。如果设置为空,则表示完全不显示忽略数据。
|`showContent`|true||是否显示提示框浮层默认显示。只需tooltip触发事件或显示axisPointer而不需要显示内容时可配置该项为false。 |`showContent`|true||是否显示提示框浮层默认显示。只需tooltip触发事件或显示axisPointer而不需要显示内容时可配置该项为false。
|`alwayShowContent`|false||是否触发后一直显示提示框浮层。 |`alwayShowContent`|false||是否触发后一直显示提示框浮层。
|`offset`|Vector2(18f, -25f)||提示框相对于鼠标位置的偏移。 |`offset`|Vector2(18f, -25f)||提示框相对于鼠标位置的偏移。

View File

@@ -250,7 +250,7 @@ namespace XCharts.Runtime
public bool ignoreDataShow { get { return m_IgnoreDataShow; } set { m_IgnoreDataShow = value; } } public bool ignoreDataShow { get { return m_IgnoreDataShow; } set { m_IgnoreDataShow = value; } }
/// <summary> /// <summary>
/// The default display character information for ignored data. /// The default display character information for ignored data.
/// |被忽略数据的默认显示字符信息。 /// |被忽略数据的默认显示字符信息。如果设置为空,则表示完全不显示忽略数据。
/// </summary> /// </summary>
public string ignoreDataDefaultContent { get { return m_IgnoreDataDefaultContent; } set { m_IgnoreDataDefaultContent = value; } } public string ignoreDataDefaultContent { get { return m_IgnoreDataDefaultContent; } set { m_IgnoreDataDefaultContent = value; } }
/// <summary> /// <summary>

View File

@@ -374,7 +374,7 @@ namespace XCharts.Runtime
tooltip.context.pointer = chart.pointerPos; tooltip.context.pointer = chart.pointerPos;
serie.handler.UpdateTooltipSerieParams(serie.context.pointerItemDataIndex, false, null, 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.param,
ref tooltip.context.data.title); ref tooltip.context.data.title);
TooltipHelper.ResetTooltipParamsByItemFormatter(tooltip, chart); TooltipHelper.ResetTooltipParamsByItemFormatter(tooltip, chart);
@@ -423,6 +423,7 @@ namespace XCharts.Runtime
serie.context.pointerItemDataIndex = dataIndex; serie.context.pointerItemDataIndex = dataIndex;
serie.handler.UpdateTooltipSerieParams(dataIndex, showCategory, category, serie.handler.UpdateTooltipSerieParams(dataIndex, showCategory, category,
tooltip.marker, tooltip.itemFormatter, tooltip.numericFormatter, tooltip.marker, tooltip.itemFormatter, tooltip.numericFormatter,
tooltip.ignoreDataDefaultContent,
ref tooltip.context.data.param, ref tooltip.context.data.param,
ref tooltip.context.data.title); ref tooltip.context.data.title);
} }

View File

@@ -69,6 +69,7 @@ namespace XCharts.Runtime
{ {
if (tooltip == null) return; if (tooltip == null) return;
var data = tooltip.context.data; var data = tooltip.context.data;
var ignoreColumn = string.IsNullOrEmpty(tooltip.ignoreDataDefaultContent);
var titleActive = !string.IsNullOrEmpty(data.title); var titleActive = !string.IsNullOrEmpty(data.title);
if (titleActive != title.gameObject.activeSelf) if (titleActive != title.gameObject.activeSelf)
@@ -80,7 +81,7 @@ namespace XCharts.Runtime
{ {
var item = GetItem(i); var item = GetItem(i);
var param = data.param[i]; var param = data.param[i];
if (param.columns.Count <= 0) if (param.columns.Count <= 0 || (ignoreColumn && param.ignore))
{ {
item.gameObject.SetActive(false); item.gameObject.SetActive(false);
continue; continue;
@@ -112,9 +113,6 @@ namespace XCharts.Runtime
m_Items[i].gameObject.SetActive(false); m_Items[i].gameObject.SetActive(false);
} }
ResetSize(); ResetSize();
// border.effectColor = data.param.Count == 1
// ? data.param[0].color
// : tooltip.borderColor;
UpdatePosition(tooltip.context.pointer + tooltip.offset); UpdatePosition(tooltip.context.pointer + tooltip.offset);
tooltip.gameObject.transform.SetAsLastSibling(); tooltip.gameObject.transform.SetAsLastSibling();
} }

View File

@@ -20,11 +20,11 @@ namespace XCharts.Runtime
} }
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category, 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) ref List<SerieParams> paramList, ref string title)
{ {
UpdateCoordSerieParams(ref paramList, ref title, dataIndex, showCategory, category, UpdateCoordSerieParams(ref paramList, ref title, dataIndex, showCategory, category,
marker, itemFormatter, numericFormatter); marker, itemFormatter, numericFormatter, ignoreDataDefaultContent);
} }
public override void DrawSerie(VertexHelper vh) public override void DrawSerie(VertexHelper vh)

View File

@@ -18,11 +18,11 @@ namespace XCharts.Runtime
} }
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category, 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) ref List<SerieParams> paramList, ref string title)
{ {
UpdateCoordSerieParams(ref paramList, ref title, dataIndex, showCategory, category, UpdateCoordSerieParams(ref paramList, ref title, dataIndex, showCategory, category,
marker, itemFormatter, numericFormatter); marker, itemFormatter, numericFormatter, ignoreDataDefaultContent);
} }
public override void DrawSerie(VertexHelper vh) public override void DrawSerie(VertexHelper vh)

View File

@@ -14,7 +14,7 @@ namespace XCharts.Runtime
} }
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category, 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) ref List<SerieParams> paramList, ref string title)
{ {
if (dataIndex < 0) if (dataIndex < 0)

View File

@@ -14,7 +14,7 @@ namespace XCharts.Runtime
} }
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category, 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) ref List<SerieParams> paramList, ref string title)
{ {
if (dataIndex < 0) if (dataIndex < 0)

View File

@@ -24,7 +24,7 @@ namespace XCharts.Runtime
} }
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category, 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) ref List<SerieParams> paramList, ref string title)
{ {
dataIndex = serie.context.pointerItemDataIndex; dataIndex = serie.context.pointerItemDataIndex;

View File

@@ -22,11 +22,11 @@ namespace XCharts.Runtime
} }
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category, 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) ref List<SerieParams> paramList, ref string title)
{ {
UpdateCoordSerieParams(ref paramList, ref title, dataIndex, showCategory, category, UpdateCoordSerieParams(ref paramList, ref title, dataIndex, showCategory, category,
marker, itemFormatter, numericFormatter); marker, itemFormatter, numericFormatter, ignoreDataDefaultContent);
} }
public override void DrawSerie(VertexHelper vh) public override void DrawSerie(VertexHelper vh)

View File

@@ -19,11 +19,11 @@ namespace XCharts.Runtime
} }
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category, 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) ref List<SerieParams> paramList, ref string title)
{ {
UpdateCoordSerieParams(ref paramList, ref title, dataIndex, showCategory, category, UpdateCoordSerieParams(ref paramList, ref title, dataIndex, showCategory, category,
marker, itemFormatter, numericFormatter); marker, itemFormatter, numericFormatter, ignoreDataDefaultContent);
} }
public override void DrawSerie(VertexHelper vh) public override void DrawSerie(VertexHelper vh)

View File

@@ -34,11 +34,11 @@ namespace XCharts.Runtime
} }
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category, 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) ref List<SerieParams> paramList, ref string title)
{ {
UpdateItemSerieParams(ref paramList, ref title, dataIndex, category, UpdateItemSerieParams(ref paramList, ref title, dataIndex, category,
marker, itemFormatter, numericFormatter); marker, itemFormatter, numericFormatter, ignoreDataDefaultContent);
} }
public override Vector3 GetSerieDataLabelPosition(SerieData serieData, LabelStyle label) public override Vector3 GetSerieDataLabelPosition(SerieData serieData, LabelStyle label)

View File

@@ -30,7 +30,7 @@ namespace XCharts.Runtime
} }
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category, 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) ref List<SerieParams> paramList, ref string title)
{ {
if (!serie.context.pointerEnter) if (!serie.context.pointerEnter)
@@ -43,7 +43,7 @@ namespace XCharts.Runtime
{ {
var colorIndex1 = serie.colorByData ? dataIndex : serie.context.colorIndex; var colorIndex1 = serie.colorByData ? dataIndex : serie.context.colorIndex;
UpdateItemSerieParams(ref paramList, ref title, dataIndex, category, UpdateItemSerieParams(ref paramList, ref title, dataIndex, category,
marker, itemFormatter, numericFormatter, 1, colorIndex1); marker, itemFormatter, numericFormatter, ignoreDataDefaultContent, 1, colorIndex1);
return; return;
} }

View File

@@ -74,7 +74,7 @@ namespace XCharts.Runtime
} }
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category, 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) ref List<SerieParams> paramList, ref string title)
{ {
if (dataIndex < 0) if (dataIndex < 0)

View File

@@ -16,7 +16,7 @@ namespace XCharts.Runtime
} }
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category, 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) ref List<SerieParams> paramList, ref string title)
{ {
dataIndex = serie.context.pointerItemDataIndex; dataIndex = serie.context.pointerItemDataIndex;

View File

@@ -33,7 +33,7 @@ namespace XCharts.Runtime
public virtual void RefreshLabelInternal() { } public virtual void RefreshLabelInternal() { }
public virtual void UpdateTooltipSerieParams(int dataIndex, bool showCategory, public virtual void UpdateTooltipSerieParams(int dataIndex, bool showCategory,
string category, string marker, string category, string marker,
string itemFormatter, string numericFormatter, string itemFormatter, string numericFormatter, string ignoreDataDefaultContent,
ref List<SerieParams> paramList, ref string title) { } ref List<SerieParams> paramList, ref string title) { }
public virtual void OnLegendButtonClick(int index, string legendName, bool show) { } public virtual void OnLegendButtonClick(int index, string legendName, bool show) { }
public virtual void OnLegendButtonEnter(int index, string legendName) { } 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, protected void UpdateCoordSerieParams(ref List<SerieParams> paramList, ref string title,
int dataIndex, bool showCategory, string category, string marker, int dataIndex, bool showCategory, string category, string marker,
string itemFormatter, string numericFormatter) string itemFormatter, string numericFormatter, string ignoreDataDefaultContent)
{ {
var dimension = 1;
if (dataIndex < 0) if (dataIndex < 0)
dataIndex = serie.context.pointerItemDataIndex; dataIndex = serie.context.pointerItemDataIndex;
@@ -504,6 +505,10 @@ namespace XCharts.Runtime
if (serieData == null) if (serieData == null)
return; return;
var ignore = serie.IsIgnoreValue(serieData, dimension);
if (ignore && string.IsNullOrEmpty(ignoreDataDefaultContent))
return;
itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter); itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
if (serie.placeHolder || TooltipHelper.IsIgnoreFormatter(itemFormatter)) if (serie.placeHolder || TooltipHelper.IsIgnoreFormatter(itemFormatter))
return; return;
@@ -512,10 +517,11 @@ namespace XCharts.Runtime
param.serieName = serie.serieName; param.serieName = serie.serieName;
param.serieIndex = serie.index; param.serieIndex = serie.index;
param.category = category; param.category = category;
param.dimension = 1; param.dimension = dimension;
param.serieData = serieData; param.serieData = serieData;
param.dataCount = serie.dataCount; param.dataCount = serie.dataCount;
param.value = serieData.GetData(1); param.value = serieData.GetData(dimension);
param.ignore = ignore;
param.total = serie.yTotal; param.total = serie.yTotal;
param.color = chart.GetItemColor(serie, serieData); param.color = chart.GetItemColor(serie, serieData);
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker); param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
@@ -525,14 +531,15 @@ namespace XCharts.Runtime
param.columns.Add(param.marker); param.columns.Add(param.marker);
param.columns.Add(showCategory ? category : serie.serieName); 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); paramList.Add(param);
} }
protected void UpdateItemSerieParams(ref List<SerieParams> paramList, ref string title, protected void UpdateItemSerieParams(ref List<SerieParams> paramList, ref string title,
int dataIndex, string category, string marker, 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) if (dataIndex < 0)
dataIndex = serie.context.pointerItemDataIndex; dataIndex = serie.context.pointerItemDataIndex;
@@ -544,6 +551,10 @@ namespace XCharts.Runtime
if (serieData == null) if (serieData == null)
return; return;
var ignore = serie.IsIgnoreValue(serieData, dimension);
if (ignore && string.IsNullOrEmpty(ignoreDataDefaultContent))
return;
itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter); itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
if (serie.placeHolder || TooltipHelper.IsIgnoreFormatter(itemFormatter)) if (serie.placeHolder || TooltipHelper.IsIgnoreFormatter(itemFormatter))
return; return;
@@ -556,11 +567,13 @@ namespace XCharts.Runtime
var param = serie.context.param; var param = serie.context.param;
param.serieName = serie.serieName; param.serieName = serie.serieName;
param.serieIndex = serie.index; param.serieIndex = serie.index;
param.category = category; param.category = category;
param.dimension = dimension; param.dimension = dimension;
param.serieData = serieData; param.serieData = serieData;
param.dataCount = serie.dataCount; param.dataCount = serie.dataCount;
param.value = serieData.GetData(param.dimension); param.value = serieData.GetData(param.dimension);
param.ignore = ignore;
param.total = SerieHelper.GetMaxData(serie, dimension); param.total = SerieHelper.GetMaxData(serie, dimension);
param.color = color; param.color = color;
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker); param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
@@ -570,7 +583,8 @@ namespace XCharts.Runtime
param.columns.Add(param.marker); param.columns.Add(param.marker);
param.columns.Add(serieData.name); 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); paramList.Add(param);
} }

View File

@@ -19,6 +19,7 @@ namespace XCharts.Runtime
public Color32 color; public Color32 color;
public string itemFormatter; public string itemFormatter;
public string numericFormatter; public string numericFormatter;
public bool ignore;
public List<string> columns = new List<string>(); public List<string> columns = new List<string>();
} }
} }