mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-25 02:10:16 +00:00
优化Bar的Tooltip表现
This commit is contained in:
@@ -449,6 +449,7 @@ namespace XCharts.Runtime
|
|||||||
string category = null;
|
string category = null;
|
||||||
var showCategory = false;
|
var showCategory = false;
|
||||||
var isTriggerByAxis = false;
|
var isTriggerByAxis = false;
|
||||||
|
var isTriggerByItem = false;
|
||||||
var dataIndex = -1;
|
var dataIndex = -1;
|
||||||
tooltip.context.data.param.Clear();
|
tooltip.context.data.param.Clear();
|
||||||
tooltip.context.pointer = chart.pointerPos;
|
tooltip.context.pointer = chart.pointerPos;
|
||||||
@@ -466,12 +467,18 @@ namespace XCharts.Runtime
|
|||||||
else
|
else
|
||||||
tooltip.context.data.title = category;
|
tooltip.context.data.title = category;
|
||||||
}
|
}
|
||||||
|
else if (tooltip.trigger == Tooltip.Trigger.Item)
|
||||||
|
{
|
||||||
|
isTriggerByItem = true;
|
||||||
|
showCategory = series.Count <= 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < series.Count; i++)
|
for (int i = 0; i < series.Count; i++)
|
||||||
{
|
{
|
||||||
var serie = series[i];
|
var serie = series[i];
|
||||||
if (!serie.show) continue;
|
if (!serie.show) continue;
|
||||||
|
if (isTriggerByItem && serie.context.pointerItemDataIndex < 0) continue;
|
||||||
serie.context.isTriggerByAxis = isTriggerByAxis;
|
serie.context.isTriggerByAxis = isTriggerByAxis;
|
||||||
if (isTriggerByAxis && dataIndex >= 0 && serie.context.pointerItemDataIndex < 0)
|
if (isTriggerByAxis && dataIndex >= 0 && serie.context.pointerItemDataIndex < 0)
|
||||||
serie.context.pointerItemDataIndex = dataIndex;
|
serie.context.pointerItemDataIndex = dataIndex;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace XCharts.Runtime
|
|||||||
string marker, string itemFormatter, string numericFormatter, string ignoreDataDefaultContent,
|
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, true, category,
|
UpdateCoordSerieParams(ref paramList, ref title, dataIndex, showCategory, category,
|
||||||
marker, itemFormatter, numericFormatter, ignoreDataDefaultContent);
|
marker, itemFormatter, numericFormatter, ignoreDataDefaultContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user