I would like to have two or more category axes, where in this example, I would like all the months for each year to be displayed above the year. Both year and month should use the same value series "YAxis".
But I can't figure out how to get this result.
How it looks now:
How it should look:
Code:
<div style="height: 80vh;">
<TelerikChart Height="100%">
<ChartLegend Visible="false" />
<ChartTooltip Visible="true" Background="white" Color="black">
<Template>
<div>
<strong>@context.SeriesName:</strong> @string.Format("{0:N0}", Convert.ToDouble(context.FormattedValue.ToString().Replace('.', ',')))
</div>
</Template>
</ChartTooltip>
<ChartSeriesItems>
<ChartSeries Type="ChartSeriesType.Column" Data="Data" Field="Value" CategoryField="Month">
</ChartSeries>
<ChartSeries Visible="false" Data="Data" Field="Value" CategoryField="Year" CategoryAxis="secondAxis">
</ChartSeries>
</ChartSeriesItems>
<ChartValueAxes>
<ChartValueAxis Min="0">
<ChartValueAxisLabels Format="{0:N0}"></ChartValueAxisLabels>
<ChartValueAxisTitle Text="Value"></ChartValueAxisTitle>
</ChartValueAxis>
</ChartValueAxes>
<ChartCategoryAxes>
<ChartCategoryAxis></ChartCategoryAxis>
<ChartCategoryAxis Name="secondAxis"></ChartCategoryAxis>
</ChartCategoryAxes>
</TelerikChart>
</div>
@code {
public class ModelData
{
public int Year { get; set; }
public string Month { get; set; }
public int Value { get; set; }
}
public List<ModelData> Data = new List<ModelData>()
{
new ModelData() { Year = 2019, Month = "Jan", Value = 1000 },
new ModelData() { Year = 2019, Month = "Feb", Value = 2554 },
new ModelData() { Year = 2019, Month = "Mar", Value = 9000 },
new ModelData() { Year = 2020, Month = "Jan", Value = 5250 },
new ModelData() { Year = 2020, Month = "Feb", Value = 3400 },
new ModelData() { Year = 2020, Month = "Mar", Value = 7540 },
new ModelData() { Year = 2021, Month = "Jan", Value = 4570 },
new ModelData() { Year = 2021, Month = "Feb", Value = 7860 },
new ModelData() { Year = 2021, Month = "Mar", Value = 1670 },
};
}
NuGet might be missing when downloading the example.
Thanks
Regards,
Nikolas