我需要创建一个堆叠柱形图如图片所示。 X轴:组件名称 Y轴:错误数 堆栈:对于每个组件,我需要创建堆叠图告诉我: --->对于每个组件类别(音频/视频),我需要说我有x个高,中,低,SHOWSTOPPER错误。创建堆积条形图柱形图与后面的代码
我有格式的数据: 类别名称|| 错误类型:数字 错误类型:数字 错误类型:数字 错误类型:数字
示例数据: AUDIO :: => 高:30 介质:17 低:1个 VIDEO :: = > 高:1 PERIPHERAL :: => 介质:15 高:14 低:1 搅局:1个 SENSOR :: => 介质:2
上面显示的这些数据是用一些LINQ查询创建的。所以它不在字典中。创建上述数据的代码:
var dbQuery = from bug in RawListData
group bug by new { bug.category, bug.customer_priority } into grouped
select new {
Category = grouped.Key.category,
Priority = grouped.Key.customer_priority,
Count = grouped.Count()
};
var query = dbQuery.ToLookup(result => result.Category,
result => new { result.Priority, result.Count });
foreach (var result in query)
{
//Console.WriteLine("{0}: ", result.Key);
System.Diagnostics.Debug.WriteLine(" : ", result.Key);
foreach (var subresult in result)
{
//Console.WriteLine(" {0}: {1}", subresult.Priority, subresult.Count);
System.Diagnostics.Debug.WriteLine(" {0}: {1}", subresult.Priority, subresult.Count);
}
}
请注意,某些类别没有每个错误类型的值。
我知道如何在XAML做到这一点。我想在“后面的代码”中这样做。任何指针在这将不胜感激。我起诉创建图形的代码是普通的XAML:
<asp:Chart ID="Chart2" runat="server" ImageLocation="~/FolderLocation/Chart_#SEQ(1000,0)" ImageStorageMode="UseImageLocation" ImageType="Png" IsSoftShadows="true">
<series>
<asp:Series Name="Championships" YValueType="Int32" ChartType="StackedColumn" >
<Points>
<asp:DataPoint AxisLabel="Audio" YValues="17" />
<asp:DataPoint AxisLabel="Video" YValues="15" />
<asp:DataPoint AxisLabel="Peripheral" YValues="6" />
</Points>
</asp:Series>
<asp:Series Name="Championships2" YValueType="Int32" ChartType="StackedColumn" >
<Points>
<asp:DataPoint AxisLabel="Audio" YValues="2" />
<asp:DataPoint AxisLabel="Video" YValues="5" />
<asp:DataPoint AxisLabel="Peripheral" YValues="16" />
</Points>
</asp:Series>
<asp:Series Name="Championships3" YValueType="Int32" ChartType="StackedColumn" >
<Points>
<asp:DataPoint AxisLabel="Audio" YValues="10" />
<asp:DataPoint AxisLabel="Video" YValues="3" />
<asp:DataPoint AxisLabel="Peripheral" YValues="16" />
</Points>
</asp:Series>
<asp:Series Name="Championships4" YValueType="Int32" ChartType="StackedColumn" >
<Points>
<asp:DataPoint AxisLabel="Audio" YValues="10" />
<asp:DataPoint AxisLabel="Video" YValues="3" />
<asp:DataPoint AxisLabel="Peripheral" YValues="16" />
</Points>
</asp:Series>
</series>
<chartareas>
<asp:ChartArea Name="ChartArea1">
<Area3DStyle Enable3D="True" />
</asp:ChartArea>
</chartareas>
</asp:Chart>
我还想显示每个堆栈组件上的错误数。
如何创建通过编写代码,而不是在XAML此堆积图?