mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-14 20:00:09 +00:00
[feature][tooltip] support ignoreDataDefaultContent
This commit is contained in:
@@ -69,6 +69,7 @@
|
||||
|
||||
### 日志详情
|
||||
|
||||
* (2022.08.11) 优化`Tooltip`支持`ignoreDataDefaultContent`
|
||||
* (2022.08.10) 修复`Chart`在3D相机下部分组件显示异常的问题
|
||||
* (2022.08.10) 修复`RemoveSerie()`接口不生效的问题 (#219)
|
||||
* (2022.08.10) 优化`Theme`的字体同步操作
|
||||
|
||||
@@ -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`
|
||||
|
||||
|
||||
@@ -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)||提示框相对于鼠标位置的偏移。
|
||||
|
||||
@@ -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