3
這裏是我的目標:綁定集合WPF工具包圖表
- 使用WPF工具包,創建具有線性Y軸和一個DateTime範圍X軸的簡單柱形圖。
- 將一組對象綁定到圖表。每個對象都有一個DateTime(X軸數據點)和Int32(Y軸數據點)屬性。
下面是我目前的XAML。下面的XAML有我想然而,圖表將不提供任何數據軸:
<chartingToolkit:Chart Grid.Column="1" Grid.Row="1" Grid.RowSpan="2" Name="ColumnChart" Title="Records Loaded By Date"
VerticalAlignment="Top" Height="262">
<chartingToolkit:Chart.Axes>
<chartingToolkit:DateTimeAxis Interval="1" IntervalType="Days" x:Name="myDateTimeAxis"
Orientation="X" Title="Date">
<chartingToolkit:DateTimeAxis.AxisLabelStyle>
<Style TargetType="chartingToolkit:DateTimeAxisLabel">
<Setter Property="StringFormat" Value="{}{0:MM/dd}"/>
</Style>
</chartingToolkit:DateTimeAxis.AxisLabelStyle>
</chartingToolkit:DateTimeAxis>
<chartingToolkit:LinearAxis Orientation="Y" ShowGridLines="True" x:Name="myYAxis"
Title="Transactions Loaded"/>
</chartingToolkit:Chart.Axes>
<chartingToolkit:Chart.Series>
<chartingToolkit:ColumnSeries DependentValuePath="TransactionLoadCount"
IndependentValuePath="Date" ItemsSource="{Binding Path=LoadStats}"
IsSelectionEnabled="True">
</chartingToolkit:ColumnSeries>
</chartingToolkit:Chart.Series>
</chartingToolkit:Chart>
注:當我刪除XML部分<chartingToolkit:Chart.Axes>...</chartingToolkit:Chart.Axes>
數據會出現但不是我喜歡的格式。
爲什麼圖表不顯示我的收集數據?
http://stackoverflow.com/questions/4762455/wpf-toolkit-february-2010-release-chart-with-column-series-empty-when-itemssou 圖表似乎只有在有多個集合中的項目。我正在測試一個元素的集合。 – Josh 2012-02-06 18:05:20
我從來沒有使用WPF的圖表控件,但我最終可能會最終。請讓我知道這個問題是怎麼回事。 – 2012-02-06 18:16:51
@jberger - 我遇到的是工具包中的一個錯誤。錯誤是:如果我的集合中存在1個元素,那麼圖表將不會呈現任何數據。 當我的集合包含> 1個元素時,則按預期控制渲染。所以我想解決方法是確保你的集合有多個元素。祝你好運! – Josh 2012-02-06 19:32:02