I have a line chart that I am grouping the data by a "type" field. The data set is by type, year, and amount. Most of the time, the data is in only one type. The problem is if there are multiple types available across multiple years, the chart wants to put the data on the 1st year even if it should not belong there.
In the example attached, there are 3 types. The data is for 2020 - 2023 (fiscal years). The 2nd and 3rd types are only for 2023 while the 1st type has data for 2020-2022. The chart does not show 2023 and added the 2nd and 3rd types to the 2020 category.
Is what I am doing possible with a line chart? I did try to make a scatter line work however I have not been able to make display with the data.
HTML:
@(Html.Kendo().Chart<Model>()
.Name("chart")
.Legend(legend => legend.Visible(true).Position(ChartLegendPosition.Bottom))
.SeriesColors("#FF9900", "#005757", "#95B9C7")
.Series(series =>
{
series.Line(v => v.Amount).Labels(l => l.Visible(true).Format("{0:n0}"))
.Tooltip(tooltip => tooltip.Visible(true).Template("#= dataItem.Label #: #= kendo.format('{0:n0}', dataItem.Amount) #"));
})
.CategoryAxis(axis => axis.Categories(m => m.FiscalYearCode).Labels(l => l.Visible(true)))
.ValueAxis(va => va.Labels(l => l.Format("{0:c0}")))
.DataSource(ds =>
{
ds.Read(read => read.Action("Get", "Home"))
.Group(g => g.Add(a => a.AmountType));
})
)
Model:
public class Model
{
public string FiscalYearCode { get; set; }
public int Amount { get; set; }
public string Label { get; set; }
public string ObjectDescription { get; set; }
public string AmountType { get; set; }
}