Tooltip is not displayed for area and line series with a single value.

This commit is contained in:
Atanas Korchev
2022-08-01 21:51:07 +03:00
parent fe6deb559b
commit 1d357aab0a
2 changed files with 56 additions and 18 deletions

View File

@@ -84,19 +84,17 @@ namespace Radzen.Blazor
var valueTicks = Chart.ValueScale.Ticks(Chart.ValueAxis.TickDistance);
var axisY = Chart.ValueScale.Scale(Math.Max(0, valueTicks.Start));
if (points.Any())
if (points.Length > 0)
{
for (var i = 0; i < points.Length - 1; i++)
if (points.Length == 1)
{
var start = points[i];
var end = points[i + 1];
var point = points[0];
var polygon = new[]
{
new Point { X = start.X, Y = start.Y - tolerance },
new Point { X = end.X, Y = end.Y - tolerance },
new Point { X = end.X, Y = axisY },
new Point { X = start.X, Y = axisY },
var polygon = new[] {
new Point { X = point.X - tolerance, Y = point.Y - tolerance },
new Point { X = point.X - tolerance, Y = point.Y + tolerance },
new Point { X = point.X + tolerance, Y = point.Y + tolerance },
new Point { X = point.X + tolerance, Y = point.Y - tolerance },
};
if (InsidePolygon(new Point { X = x, Y = y }, polygon))
@@ -104,6 +102,27 @@ namespace Radzen.Blazor
return true;
}
}
else
{
for (var i = 0; i < points.Length - 1; i++)
{
var start = points[i];
var end = points[i + 1];
var polygon = new[]
{
new Point { X = start.X, Y = start.Y - tolerance },
new Point { X = end.X, Y = end.Y - tolerance },
new Point { X = end.X, Y = axisY },
new Point { X = start.X, Y = axisY },
};
if (InsidePolygon(new Point { X = x, Y = y }, polygon))
{
return true;
}
}
}
}
return false;

View File

@@ -73,18 +73,17 @@ namespace Radzen.Blazor
var points = Items.Select(item => new Point { X = category(item), Y = value(item) }).ToArray();
if (points.Any())
if (points.Length > 0)
{
for (var i = 0; i < points.Length - 1; i++)
if (points.Length == 1)
{
var start = points[i];
var end = points[i + 1];
var point = points[0];
var polygon = new[] {
new Point { X = start.X, Y = start.Y - tolerance },
new Point { X = end.X, Y = end.Y - tolerance },
new Point { X = end.X, Y = end.Y + tolerance },
new Point { X = start.X, Y = start.Y + tolerance },
new Point { X = point.X - tolerance, Y = point.Y - tolerance },
new Point { X = point.X - tolerance, Y = point.Y + tolerance },
new Point { X = point.X + tolerance, Y = point.Y + tolerance },
new Point { X = point.X + tolerance, Y = point.Y - tolerance },
};
if (InsidePolygon(new Point { X = x, Y = y }, polygon))
@@ -92,6 +91,26 @@ namespace Radzen.Blazor
return true;
}
}
else
{
for (var i = 0; i < points.Length - 1; i++)
{
var start = points[i];
var end = points[i + 1];
var polygon = new[] {
new Point { X = start.X, Y = start.Y - tolerance },
new Point { X = end.X, Y = end.Y - tolerance },
new Point { X = end.X, Y = end.Y + tolerance },
new Point { X = start.X, Y = start.Y + tolerance },
};
if (InsidePolygon(new Point { X = x, Y = y }, polygon))
{
return true;
}
}
}
}
return false;