[英]Kendo UI Pie Chart Color in Asp.net mvc
Please I have the following code 请给我以下代码
@model System.Collections.Generic.IEnumerable<CellMinistry.CampusMinistry.Models.Domain.Charting_Models.MemberDistributionModel>
@{
var memberCount = ViewBag.MemberCount is int ? (int) ViewBag.MemberCount : 0;
}
@(Html.Kendo().Chart(Model)
.Name("chart")
.Legend(legend => legend
.Position(ChartLegendPosition.Bottom)
)
.Series(series => series.Pie(
model => model.Value,
model => model.Name,
null,
null // Color expression is omitted
).Labels(c => c.Visible(true).Template("#= kendo.format('{0:P}', percentage)#"))).Title(String.Format("Total Members: {0}", memberCount))
.Tooltip(tooltip => tooltip.Visible(true).Format("{0:N0}")
))
where Model data is from database and dynamically generated. 模型数据来自数据库并动态生成。
Anyways, The colors of the generated sections are somewhat alike and I cant find any docmentation as to how to customize them. 无论如何,生成的部分的颜色有点相似,我无法找到任何关于如何自定义它们的文档。
I dont want to include the colors in Model 我不想在模型中包含颜色
Kind regards 亲切的问候
Try and use the seriesColors property. 尝试并使用seriesColors属性。
@model System.Collections.Generic.IEnumerable<CellMinistry.CampusMinistry.Models.Domain.Charting_Models.MemberDistributionModel>
@{
var memberCount = ViewBag.MemberCount is int ? (int) ViewBag.MemberCount : 0;
}
@(Html.Kendo().Chart(Model)
.Name("chart")
.Legend(legend => legend
.Position(ChartLegendPosition.Bottom)
)
.Series(series => series.Pie(
model => model.Value,
model => model.Name,
null,
null // Color expression is omitted
).Labels(c => c.Visible(true).Template("#= kendo.format('{0:P}', percentage)#"))).Title(String.Format("Total Members: {0}", memberCount))
.SeriesColors("red", "blue", "yellow", "#006634", "#c72e15")
.Tooltip(tooltip => tooltip.Visible(true).Format("{0:N0}")
))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.