I'm trying to figure out how to handle a line series chart by adding code dynamically.
I got part of the answer from: Adding/Removing RadzenLineSeries to RadzenChart from code-behind?
<RadzenChart>
@foreach(var myDataItem in myData)
{
<RadzenLineSeries Data=@myDataItem.Data
CategoryProperty=@myDataItem.Category
ValueProperty=@myDataItem.Value />
}
</RadzenChart>
However, I'm having trouble figuring out what the types should be. I have a DataItem class that includes the month and expenditure amount. Then I have a series of about 26 budget categories but that can change. Essentially, I need a line on the chart for each category. Here's what I've tried:
@foreach(List<DataItem> line in dataLines)
{
<RadzenLineSeries Smooth="@smooth" Data="@line" CategoryProperty="@line.Month" Title="Name" ValueProperty="@line.Amount">
<RadzenMarkers Visible="@showMarkers" MarkerType="MarkerType.Circle"/>
<RadzenSeriesDataLabels Visible="@showDataLabels"/>
</RadzenLineSeries>
}
List<DataItem> categoryLine = new();
List<List<DataItem>> budgetLines= new();
class DataItem
{
public int Month { get; set; }
public decimal Amount { get; set; }
}
I know I'm not grasping this whole concept correctly. I know one line series is a list of DataItem. So am I correct in thinking the chart will be a list of a list of DataItems?
In the first example, I think my disconnect is I'm not sure what types myDataItem and myData are and how they're related.
I'd appreciate it if someone could point me in the right direction.