修复Tooltip在只有一个数据时可能异常的问题

This commit is contained in:
monitor1394
2023-04-14 20:53:31 +08:00
parent 0af76517e1
commit 59335786df
2 changed files with 18 additions and 17 deletions

View File

@@ -66,6 +66,7 @@ slug: /changelog
## master
* (2023.04.14) 修复`Tooltip`在只有一个数据时可能异常的问题
* (2023.04.14) 增加`BaseChart``TriggerTooltip()`接口尝试触发`ToolTip`
* (2023.04.12) 优化`RadarCood`设置`startAngle`时文本也跟随调整位置
* (2023.04.12) 增加`Radar`对通配符`{b}`的支持

View File

@@ -355,7 +355,7 @@ namespace XCharts.Runtime
{
var serieData = data[i];
currValue = serieData.GetData(dimension);
if (i == 0)
if (i == 0 && i + 1 < dataCount)
{
nextValue = data[i + 1].GetData(dimension);
if (axisValue <= currValue + (nextValue - currValue) / 2)
@@ -372,7 +372,7 @@ namespace XCharts.Runtime
break;
}
}
else
else if (i + 1 < dataCount)
{
nextValue = data[i + 1].GetData(dimension);
if (axisValue > (currValue - (currValue - lastValue) / 2) && axisValue <= currValue + (nextValue - currValue) / 2)