I have line chart that works well... except when in one serie there is just one value. Then I get wrong values all over... When I add a dummy record it works.
Do I do something wrong or is this a feature or bug?
@(Html.Kendo().Chart<
SignalRDoc.ViewModels.HistoryTot
>()
.Name("linechartteam")
.Theme("Material")
.Title("Utfall i procent per månad (Team och konsult)")
.Legend(legend => legend
.Position(ChartLegendPosition.Bottom))
.DataSource(ds => ds.Read(read => read.Action("LineChartTeam", "Statistik"))
.Group(group => group.Add(model => model.Fnamn))
.Sort(sort => sort.Add(model => model.Period).Ascending())
)
.Series(series =>
{
series.Line(model => model.Procent, categoryExpression: model => model.Period).Name("#= group.value #");
})
.CategoryAxis(axis => axis
.Categories(model => model.Period)
.MajorGridLines(lines => lines.Visible(true))
.Labels(labels => labels.Format("MMM"))
)
.ValueAxis(axis => axis.Numeric()
.Labels(labels => labels.Format("{0:p1}"))
.Line(line => line.Visible(true))
)
.Tooltip(tooltip => tooltip.Visible(true).Shared(true).Format("{0:p1}")
)
)
</
div
>
And the Controller
public
ActionResult LineChartTeam(
int
? year,
string
team)
{
if
(year ==
null
)
{
DateTime dt = DateTime.Today;
year = dt.Year;
}
var data = (from p
in
db.History
where p.Period.Year == year
where p.Team == team
group p by
new
{ p.Fnamn, p.Period }
into areaGroup
select
new
HistoryTot()
{
Fnamn = areaGroup.Key.Fnamn,
Antal = areaGroup.Sum(p => p.Antal),
Budget = areaGroup.Sum(p => p.Budget),
Period = areaGroup.Key.Period
}).ToList();
return
Json(data);
}