Asp.net 根据Kendo DataViz堆叠图建模POCO
我在创建POCO类以使用Kendo DataViz时遇到了一个问题 我们希望使用MVC包装器创建堆叠图,在剑道示例中,它显示了一些静态值,如Asp.net 根据Kendo DataViz堆叠图建模POCO,asp.net,asp.net-mvc,asp.net-mvc-4,c#-4.0,kendo-dataviz,Asp.net,Asp.net Mvc,Asp.net Mvc 4,C# 4.0,Kendo Dataviz,我在创建POCO类以使用Kendo DataViz时遇到了一个问题 我们希望使用MVC包装器创建堆叠图,在剑道示例中,它显示了一些静态值,如 .Column(new int[] { 1100941, 1139797, 1172929, 1184435, 1184654 }).Stack(true) .Column(new int[] { 810169, 883051, 942151, 1001395, 1184654 }).Stack(true) 现在,这将创建5个条形图
.Column(new int[] { 1100941, 1139797, 1172929, 1184435, 1184654 }).Stack(true)
.Column(new int[] { 810169, 883051, 942151, 1001395, 1184654 }).Stack(true)
现在,这将创建5个条形图,每个条形图堆叠一个以上的数据和每个值
int数组对应不同的条,所有数组中的每个索引对应相同的条
i、 e:1100941和810169对应于第一个条bar1
因此,如何将这些静态数据建模到POCO类中并填充数据
我创建了POCO,如下所示
public class TroubleFound
{
//Service center Name for which trouble is found
public string ServiceCenterName { get; set; }
//Which type of trouble is found
public string TroubleFoundName { get; set; }
//total count of trouble found
public List<int> TroubleFoundCount { get; set; }
}
那么如何创建POCO并根据Kendo Dataviz填充它呢
请参考我实际想要开发的内容。我最近不得不做一些非常类似的事情,但有专栏。我相信您可以在不做任何其他更改的情况下将系列类型从列切换到条。 以下是我们使用的模型:
public class KendoStackedColumnChartModel
{
public string Title { get; set; }
public IEnumerable<KendoStackedColumnModel> StackedColumns { get; set; }
public class KendoStackedColumnModel
{
public string StackName { get; set; }
public string Colour { get; set; }
public IEnumerable<KendoColumnModel> Columns { get; set; }
public class KendoColumnModel
{
public decimal Value { get; set; }
public string Category { get; set; }
}
}
}
希望这能帮助其他人节省一些时间……信息有点不连贯,好像
.Column()
内容和base.Bar()部分之间缺少一块逻辑。从你的问题中确定任何东西都是不可能的,即使你想说try.Column(data.TroubleFoundCount).Stack(true)
。试着展示这一切是如何结合在一起的,我相信答案会很快出现
public class KendoStackedColumnChartModel
{
public string Title { get; set; }
public IEnumerable<KendoStackedColumnModel> StackedColumns { get; set; }
public class KendoStackedColumnModel
{
public string StackName { get; set; }
public string Colour { get; set; }
public IEnumerable<KendoColumnModel> Columns { get; set; }
public class KendoColumnModel
{
public decimal Value { get; set; }
public string Category { get; set; }
}
}
}
.Series(series =>
{
foreach (WebUI.Models.KendoStackedColumnChartModel.KendoStackedColumnModel stacked in Model.StackedColumns)
{
series.Column(stacked.Columns).CategoryField("CategoryLabel").Field("Value").Name(stacked.StackName).Color(stacked.Colour);
}
}
)
.SeriesColors(new string[] { "#20BDFF", "#84DAFF", "#FFCD8A", "#FE9915", "#FF6633" })