目前我有这个并且效果很好..我需要的是CategoryAxis中的类别是动态的而不是静态的.Categories(" 1"," 2", " 3"," 4"," 5")..
我已经拥有了我希望从我的模型中获取的值,即@ item.SurveyLinearCounts.FirstOrDefault()。最小值为最小值,@ item.SurveyLinearCounts.FirstOrDefault()。最大值为最大值
我该怎么做??
@(Html.Kendo().Chart<AnalyzeResponseViewModel>()
.Name(@item.SurveyQuestionID.ToString())
.Legend(legend => legend
.Position(ChartLegendPosition.Top)
.Visible(true)
)
.ChartArea(chartArea => chartArea
.Background("transparent")
)
.Series(series =>
{
series.Column(model => model.ResponseCount).Name("Count").Tooltip(tooltip => tooltip.Visible(true).Template("#= series.name #: #= value #"));
})
.CategoryAxis(axis => axis
.Categories("1", "2", "3", "4", "5")
.MajorGridLines(lines => lines.Visible(false))
)
.
)
.ValueAxis(axis => axis
.Numeric()
.Line(line => line.Visible(false))
.MajorGridLines(lines => lines.Visible(true))
)
.DataSource(ds => ds
.Read(read => read.Action("GetSurveyResponseChart", "DataSource", new { item.SurveyQuestionID })))
.Tooltip(tooltip => tooltip.Visible(true).Template("#= series.name #: #= value #")))
答案 0 :(得分:0)
假设您想要的值在item.SurveyLinearCounts
属性中,您应该可以执行以下操作:
.CategoryAxis(axis => axis
.Categories(item.SurveyLinearCounts)
.MajorGridLines(lines => lines.Visible(false))
)
如果您有其他属性,您可以执行以下操作:
.Categories(item.SurveyLinearCounts.Select(x => x.MyProp))