diff --git a/CHANGELOG.md b/CHANGELOG.md index a977f428..d45b9baf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,7 @@ ### 日志详情 +* (2022.08.11) 优化`Tooltip`支持`ignoreDataDefaultContent` * (2022.08.10) 修复`Chart`在3D相机下部分组件显示异常的问题 * (2022.08.10) 修复`RemoveSerie()`接口不生效的问题 (#219) * (2022.08.10) 优化`Theme`的字体同步操作 diff --git a/Documentation/XChartsConfiguration-EN.md b/Documentation/XChartsConfiguration-EN.md index f3834748..ed930332 100644 --- a/Documentation/XChartsConfiguration-EN.md +++ b/Documentation/XChartsConfiguration-EN.md @@ -215,7 +215,7 @@ The style of area. |`color`|||the color of area,default use serie color. |`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. -|`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` diff --git a/Documentation/XChartsConfiguration-ZH.md b/Documentation/XChartsConfiguration-ZH.md index 4a42b6a8..fbeed47d 100644 --- a/Documentation/XChartsConfiguration-ZH.md +++ b/Documentation/XChartsConfiguration-ZH.md @@ -215,7 +215,7 @@ Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieExtraComponent |`color`|||区域填充的颜色,如果toColor不是默认值,则表示渐变色的起点颜色。 |`toColor`|||渐变色的终点颜色。 |`opacity`|0.6f||图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。 -|`fill`|true|v3.2.0|是否只填充多边形区域。目前只支持凸多边形。 +|`innerFill`||v3.2.0|是否只填充多边形区域。目前只支持凸多边形。 ## `ArrowStyle` @@ -1433,7 +1433,7 @@ Inherits or Implemented: [MainComponent](#MainComponent) |`paddingLeftRight`|10||左右边距。 |`paddingTopBottom`|10||上下边距。 |`ignoreDataShow`|false||是否显示忽略数据在tooltip上。 -|`ignoreDataDefaultContent`|||被忽略数据的默认显示字符信息。 +|`ignoreDataDefaultContent`|||被忽略数据的默认显示字符信息。如果设置为空,则表示完全不显示忽略数据。 |`showContent`|true||是否显示提示框浮层,默认显示。只需tooltip触发事件或显示axisPointer而不需要显示内容时可配置该项为false。 |`alwayShowContent`|false||是否触发后一直显示提示框浮层。 |`offset`|Vector2(18f, -25f)||提示框相对于鼠标位置的偏移。 diff --git a/Runtime/Component/Tooltip/Tooltip.cs b/Runtime/Component/Tooltip/Tooltip.cs index 6b34a910..418c679a 100644 --- a/Runtime/Component/Tooltip/Tooltip.cs +++ b/Runtime/Component/Tooltip/Tooltip.cs @@ -250,7 +250,7 @@ namespace XCharts.Runtime public bool ignoreDataShow { get { return m_IgnoreDataShow; } set { m_IgnoreDataShow = value; } } /// /// The default display character information for ignored data. - /// |被忽略数据的默认显示字符信息。 + /// |被忽略数据的默认显示字符信息。如果设置为空,则表示完全不显示忽略数据。 /// public string ignoreDataDefaultContent { get { return m_IgnoreDataDefaultContent; } set { m_IgnoreDataDefaultContent = value; } } /// diff --git a/Runtime/Component/Tooltip/TooltipHandler.cs b/Runtime/Component/Tooltip/TooltipHandler.cs index 67bac520..4012efd2 100644 --- a/Runtime/Component/Tooltip/TooltipHandler.cs +++ b/Runtime/Component/Tooltip/TooltipHandler.cs @@ -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); } diff --git a/Runtime/Component/Tooltip/TooltipView.cs b/Runtime/Component/Tooltip/TooltipView.cs index 959283c0..3e47f94d 100644 --- a/Runtime/Component/Tooltip/TooltipView.cs +++ b/Runtime/Component/Tooltip/TooltipView.cs @@ -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(); } diff --git a/Runtime/Serie/Bar/BarHandler.cs b/Runtime/Serie/Bar/BarHandler.cs index 92b8d54d..bd0b62a8 100644 --- a/Runtime/Serie/Bar/BarHandler.cs +++ b/Runtime/Serie/Bar/BarHandler.cs @@ -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 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) diff --git a/Runtime/Serie/Bar/SimplifiedBarHandler.cs b/Runtime/Serie/Bar/SimplifiedBarHandler.cs index ca4a92ce..fdcf7b01 100644 --- a/Runtime/Serie/Bar/SimplifiedBarHandler.cs +++ b/Runtime/Serie/Bar/SimplifiedBarHandler.cs @@ -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 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) diff --git a/Runtime/Serie/Candlestick/CandlestickHandler.cs b/Runtime/Serie/Candlestick/CandlestickHandler.cs index 3eafef1b..19d3aaf8 100644 --- a/Runtime/Serie/Candlestick/CandlestickHandler.cs +++ b/Runtime/Serie/Candlestick/CandlestickHandler.cs @@ -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 paramList, ref string title) { if (dataIndex < 0) diff --git a/Runtime/Serie/Candlestick/SimplifiedCandlestickHandler.cs b/Runtime/Serie/Candlestick/SimplifiedCandlestickHandler.cs index 0bbb90dd..3b83497b 100644 --- a/Runtime/Serie/Candlestick/SimplifiedCandlestickHandler.cs +++ b/Runtime/Serie/Candlestick/SimplifiedCandlestickHandler.cs @@ -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 paramList, ref string title) { if (dataIndex < 0) diff --git a/Runtime/Serie/Heatmap/HeatmapHandler.cs b/Runtime/Serie/Heatmap/HeatmapHandler.cs index 51aade31..9f9fc7bc 100644 --- a/Runtime/Serie/Heatmap/HeatmapHandler.cs +++ b/Runtime/Serie/Heatmap/HeatmapHandler.cs @@ -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 paramList, ref string title) { dataIndex = serie.context.pointerItemDataIndex; diff --git a/Runtime/Serie/Line/LineHandler.cs b/Runtime/Serie/Line/LineHandler.cs index 889fb776..9d9efa1a 100644 --- a/Runtime/Serie/Line/LineHandler.cs +++ b/Runtime/Serie/Line/LineHandler.cs @@ -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 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) diff --git a/Runtime/Serie/Line/SimplifiedLineHandler.cs b/Runtime/Serie/Line/SimplifiedLineHandler.cs index 73c9c82b..6dc172d2 100644 --- a/Runtime/Serie/Line/SimplifiedLineHandler.cs +++ b/Runtime/Serie/Line/SimplifiedLineHandler.cs @@ -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 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) diff --git a/Runtime/Serie/Pie/PieHandler.cs b/Runtime/Serie/Pie/PieHandler.cs index e7ec59bd..c06a4a18 100644 --- a/Runtime/Serie/Pie/PieHandler.cs +++ b/Runtime/Serie/Pie/PieHandler.cs @@ -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 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) diff --git a/Runtime/Serie/Radar/RadarHandler.cs b/Runtime/Serie/Radar/RadarHandler.cs index 5b7b7fc7..403a35fa 100644 --- a/Runtime/Serie/Radar/RadarHandler.cs +++ b/Runtime/Serie/Radar/RadarHandler.cs @@ -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 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; } diff --git a/Runtime/Serie/Ring/RingHandler.cs b/Runtime/Serie/Ring/RingHandler.cs index df5a27f1..643b6711 100644 --- a/Runtime/Serie/Ring/RingHandler.cs +++ b/Runtime/Serie/Ring/RingHandler.cs @@ -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 paramList, ref string title) { if (dataIndex < 0) diff --git a/Runtime/Serie/Scatter/BaseScatterHandler.cs b/Runtime/Serie/Scatter/BaseScatterHandler.cs index f1a0cab4..fa703995 100644 --- a/Runtime/Serie/Scatter/BaseScatterHandler.cs +++ b/Runtime/Serie/Scatter/BaseScatterHandler.cs @@ -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 paramList, ref string title) { dataIndex = serie.context.pointerItemDataIndex; diff --git a/Runtime/Serie/SerieHandler.cs b/Runtime/Serie/SerieHandler.cs index 3c0db474..c8cc95ce 100644 --- a/Runtime/Serie/SerieHandler.cs +++ b/Runtime/Serie/SerieHandler.cs @@ -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 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 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 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); } diff --git a/Runtime/Serie/SerieParams.cs b/Runtime/Serie/SerieParams.cs index d2948a8c..1118baa8 100644 --- a/Runtime/Serie/SerieParams.cs +++ b/Runtime/Serie/SerieParams.cs @@ -19,6 +19,7 @@ namespace XCharts.Runtime public Color32 color; public string itemFormatter; public string numericFormatter; + public bool ignore; public List columns = new List(); } } \ No newline at end of file