[英]WPF Pie chart doesn't slice up
I am using PieChart
control to display the two values from my database as (USED and AVAILABLE). 我正在使用
PieChart
控件将数据库中的两个值显示为(USED和AVAILABLE)。 but I get output without slicing as seen in the image below, 但是我得到的输出没有切片,如下图所示,
How to slice up the Pie Chart? 如何切饼图?
my KeyValue pair is of type . 我的KeyValue对类型为。 I am getting the values for my KeyValuePair from a datasource & i am retrieving using Linq to sql queries.
我从数据源获取KeyValuePair的值,并且正在使用Linq到sql查询进行检索。
XAML for my Pie chart: 我的饼图的XAML:
<Window.Resources>
<CollectionViewSource x:Key="ramView" Source="{Binding Path=UsageRAMs, Source={StaticResource serverView}}"/>
</Window.Resources>
<dvc:Chart x:Name="Ram" Background="White" Foreground="Black" Margin="950,0,92,485" Grid.Column="1" Grid.Row="1">
<dvc:Chart.Series>
<dvc:PieSeries ItemsSource="{Binding}"
DependentValuePath="Available" IndependentValuePath="Used" >
</dvc:PieSeries>
</dvc:Chart.Series>
</dvc:Chart>
code behind 背后的代码
private CollectionViewSource serversUsageRAMsViewSource;
private void Window_Loaded(object sender, RoutedEventArgs e)
{
var ramList = (from c in db.UsageRAMs
orderby c.UsageRamID descending, c.Used,c.Available,c.Total
select c).Take(1);
this.serversUsageRAMsViewSource = (CollectionViewSource)this.FindResource("ramView");
serversUsageRAMsViewSource.Source = ramList;
}
Well I guess you should have two series. 好吧,我想您应该有两个系列。
<dvc:Chart ...>
<dvc:Chart.Series>
<dvc:PieSeries ItemsSource="{Binding}" DependentValuePath="Available" />
<dvc:PieSeries ItemsSource="{Binding}" DependentValuePath="Used" />
</dvc:Chart.Series>
</dvc:Chart>
Disclaimer - I didn't test it, but that's what I would try. 免责声明-我没有测试过,但这就是我会尝试的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.