It would be nice to create a generic version of the ChartSeries where you can pass the ChartType as a parameter (even if this means you miss out on some chart specific parameters)
Example:
<RadzenChartSeries ChartType=@ChartTypes.Bar Data=@Data ValueProperty=@ValueProperty CategoryProperty=@ CategoryProperty>
Currently to do this I have a long conditional which is painful and even worse if I decide to add RadzenMarkers or RadzenSeriesDataLabels to it as I would need to add it to each case.
But in case anyone else needs this, here's quick boilerplate to handle letting the user pick the ChartType and IsStacked realtime.
<RadzenChart>
@foreach (var series in SeriesGraphData) //Area , Bar , Column , Donut , Line , and Pie (Area, Bar, and Column are stackable)
{
@if (Config.ChartType == "Area")
{
@if (Config.IsStacked)
{
<RadzenStackedAreaSeries Data="@series.Value" CategoryProperty="Category" ValueProperty="Value" Title="@series.Key" />
}
else
{
<RadzenAreaSeries Data="@series.Value" CategoryProperty="Category" ValueProperty="Value" Title="@series.Key" />
}
}
else if (Config.ChartType == "Bar")
{
@if (Config.IsStacked)
{
<RadzenStackedBarSeries Data="@series.Value" CategoryProperty="Category" ValueProperty="Value" Title="@series.Key" />
}
else
{
<RadzenBarSeries Data="@series.Value" CategoryProperty="Category" ValueProperty="Value" Title="@series.Key" />
}
}
else if (Config.ChartType == "Column")
{
@if (Config.IsStacked)
{
<RadzenStackedColumnSeries Data="@series.Value" CategoryProperty="Category" ValueProperty="Value" Title="@series.Key" />
}
else
{
<RadzenBarSeries Data="@series.Value" CategoryProperty="Category" ValueProperty="Value" Title="@series.Key" />
}
}
else if (Config.ChartType == "Donut")
{
<RadzenDonutSeries Data="@series.Value" CategoryProperty="Category" ValueProperty="Value" Title="@series.Key" />
}
else if (Config.ChartType == "Line")
{
<RadzenLineSeries Data="@series.Value" CategoryProperty="Category" ValueProperty="Value" Title="@series.Key" />
}
else if (Config.ChartType == "Pie")
{
<RadzenPieSeries Data="@series.Value" CategoryProperty="Category" ValueProperty="Value" Title="@series.Key" />
}
}
<RadzenValueAxis>
<RadzenGridLines Visible="@Config.ShowGridLinesForValues" />
<RadzenAxisTitle Text="@Config.ValueProperty" />
</RadzenValueAxis>
<RadzenCategoryAxis>
<RadzenGridLines Visible="@Config.ShowGridLinesForCategories" />
<RadzenAxisTitle Text="@Config.CategoryProperty" />
</RadzenCategoryAxis>
<RadzenLegend Visible="@Config.ShowLegend" />
</RadzenChart>