我有一个条形图,其中数据源连接到一个操作方法。 用户可以通过表单过滤数据。问题是结果的最大值取决于过滤器的设置,它在100到100000之间变化。
我想要实现的是,如果我得到最大值100,则应将轴设置为110等。
我还可以尝试计算控制器中的值,并通过ViewModel将其发送到视图。但有没有办法自动执行此操作?
这是我的代码:
@(Html.Kendo().Chart<Heartbeat.Models.User.UsersPerformance>()
.Name("chart")
.HtmlAttributes(new { style = "width:auto;height:800px" })
.Title("Geleistete Arbeitszeit pro Mitarbeiter in Minuten.")
.DataSource(dataSource => dataSource.Read(read => read.Action("Series", "UserPerformance", new { category = Model.Category,
company = Model.CustomerName,
startDate = Model.StartDate,
endDate = Model.EndDate
}))
)
.Legend(legend => legend
.Visible(false)
)
.ChartArea(chartArea => chartArea
.Background("transparent")
)
.Series(series =>
{
series.Bar(v => v.TimeInMinutes).Name("Total Time");
})
.CategoryAxis(axis => axis
.Categories(v => v.Username)
.MajorGridLines(lines => lines.Visible(false))
)
.ValueAxis(axis => axis
.Numeric()
.Max(100000)
.Line(line => line.Visible(false))
.MajorGridLines(lines => lines.Visible(true))
)
.Tooltip(tooltip => tooltip
.Visible(true)
.Template("#= series.name #: #= value #")
)
)