我有问题将数据正确绑定到WPF图表。当我设置ItemsSource时,我收到错误:
不能使用指定的从属轴。数据可能无法在提供的轴上呈现,或者系列可能要求它们的轴具有原点。
oc = new ObservableCollection<Pair>();
heartBeats.ItemsSource = oc;
配对我正在保存int和long
XAML:
...
xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit" >
<charting:Chart x:Name="ApplicatioChart">
<charting:Chart.Series>
<charting:ColumnSeries x:Name="heartBeats" Title="Working Set"
DependentValueBinding="{Binding First}" IndependentValueBinding="{Binding Second}" >
<charting:ColumnSeries.IndependentAxis>
<charting:CategoryAxis Orientation="X" />
</charting:ColumnSeries.IndependentAxis>
<charting:ColumnSeries.DependentRangeAxis>
<charting:LinearAxis Orientation="Y" />
</charting:ColumnSeries.DependentRangeAxis>
</charting:ColumnSeries>
</charting:Chart.Series>
</charting:Chart>
请帮助.. :(
答案 0 :(得分:2)
<charting:Chart Title="Engine Performance" x:Name="ApplicationChart">
<!-- Power curve -->
<charting:LineSeries x:Name="heartBeats"
Title="ManagedHeapSize"
IndependentValueBinding="{Binding EventTime}"
DependentValueBinding="{Binding ManagedHeapSize}">
<!-- Vertical axis -->
<charting:LineSeries.DependentRangeAxis>
<charting:LinearAxis
Orientation="Y"
Title="ManagedHeapSize"
Interval="10000000" Focusable="True"
ShowGridLines="True"/>
</charting:LineSeries.DependentRangeAxis>
</charting:LineSeries>
<charting:Chart.Axes>
<!-- Shared horizontal axis -->
<charting:LinearAxis
Orientation="X"
Title="EventTime"
Interval="100"
ShowGridLines="True"/>
</charting:Chart.Axes>
</charting:Chart>
答案 1 :(得分:0)
看不到标记有什么问题(除了相同的属性被绑定为依赖值和独立值)。
它似乎在Silverlight版本中运行良好,我没有WPF版本可以使用。
尝试删除DependentRangeAxis的定义,以查看它是否适用于默认值。