Column and bar radius is not applied in some cases. Fixes #1464.

This commit is contained in:
Atanas Korchev
2024-04-22 12:52:15 +03:00
parent df87b51e63
commit 831c3c4fa4
6 changed files with 52 additions and 4 deletions

View File

@@ -16,5 +16,11 @@ namespace Radzen.Blazor
/// Gets the values for category.
/// </summary>
IEnumerable<double> ValuesForCategory(double category);
/// <summary>
/// Gets the items for category.
/// </summary>
/// <param name="category"></param>
/// <returns></returns>
IEnumerable<object> ItemsForCategory(double category);
}
}

View File

@@ -18,6 +18,13 @@ namespace Radzen.Blazor
/// </summary>
IEnumerable<double> ValuesForCategory(double category);
/// <summary>
/// Gets the items for category.
/// </summary>
/// <param name="category"></param>
/// <returns></returns>
IEnumerable<object> ItemsForCategory(double category);
/// <summary>
/// Gets the value at the specified index.
/// </summary>

View File

@@ -32,9 +32,15 @@
var itemValue = Value(data);
var radius = Chart.BarOptions.Radius;
if (radius > height / 2 || barIndex < barSeries.Count - 1)
if (radius > 0)
{
radius = 0;
var items = barSeries.SelectMany(series => series.ItemsForCategory(category(data))).ToList();
var index = items.IndexOf(data);
if (radius > height / 2 || index < items.Count - 1)
{
radius = 0;
}
}
var x0 = GetBarLeft(data, barIndex, category, barSeries);

View File

@@ -216,6 +216,18 @@ namespace Radzen.Blazor
return Items.Where(item => category(item) == value).Select(Value);
}
IEnumerable<object> IChartStackedBarSeries.ItemsForCategory(double value)
{
if (Items == null)
{
return Enumerable.Empty<object>();
}
var category = ComposeCategory(Chart.ValueScale);
return Items.Where(item => category(item) == value).Cast<object>();
}
/// <inheritdoc />
public override bool Contains(double x, double y, double tolerance)
{

View File

@@ -28,9 +28,14 @@
var itemValue = Value(data);
var radius = Chart.ColumnOptions.Radius;
if (radius > width / 2 || columnIndex < stackedColumnSeries.Count - 1)
if (radius > 0)
{
radius = 0;
var items = stackedColumnSeries.SelectMany(series => series.ItemsForCategory(category(data))).ToList();
var index = items.IndexOf(data);
if (radius > width / 2 || index < items.Count - 1)
{
radius = 0;
}
}
var y0 = GetColumnBottom(data, columnIndex, category, stackedColumnSeries);

View File

@@ -102,6 +102,18 @@ namespace Radzen.Blazor
return Items.Where(item => category(item) == value).Select(Value);
}
IEnumerable<object> IChartStackedColumnSeries.ItemsForCategory(double value)
{
if (Items == null)
{
return Enumerable.Empty<object>();
}
var category = ComposeCategory(Chart.CategoryScale);
return Items.Where(item => category(item) == value).Cast<object>();
}
double IChartStackedColumnSeries.ValueAt(int index)
{
if (Items == null || index < 0 || index >= Items.Count)