WPF Tookit Chart
如何使用Chart
实例:
Binding数据源中是一个KeyValuePair对象。可以是Dictionary.
<charting:Chart x:Name="chtSummary" Width="770" Height="400" Title="My Chart Title"> <charting:Chart.TitleStyle> <Style TargetType="datavis:Title"> <Setter Property="FontSize" Value="28" /> <Setter Property="FontFamily" Value="Arial" /> <Setter Property="Margin" Value="5, 10, 5, 15" /> </Style> </charting:Chart.TitleStyle> <charting:Chart.LegendStyle> <Style TargetType="datavis:Legend"> <Setter Property="Width" Value="0" /> </Style> </charting:Chart.LegendStyle> <charting:Chart.Series> <charting:BarSeries ItemsSource="{Binding}" DependentValuePath="Value" IndependentValuePath="Key" IsSelectionEnabled="True" > <charting:BarSeries.IndependentAxis> <charting:CategoryAxis Orientation="Y" AxisLabelStyle="{StaticResource SummaryChartAxisStyle}" /> </charting:BarSeries.IndependentAxis> </charting:BarSeries> </charting:Chart.Series> </charting:Chart>
如何添加第二个Y坐标
secondary y axis on WPF toolkit chart
实例:
On the first serie (ColumnSerie on my example), add this
<DVC:ColumnSeries.DependentRangeAxis > <DVC:LinearAxis Location="Left" Orientation="Y" /> </DVC:ColumnSeries.DependentRangeAxis>
On the second serie (LineSeries), add this
<DVC:LineSeries.DependentRangeAxis > <DVC:LinearAxis Location="Right" Orientation="Y" /> </DVC:LineSeries.DependentRangeAxis>
如何修改图列的名称
实例:
LineSeries Title=" Monthly Count" is responsible for display the legend text
<wpft:Chart Canvas.Top="80" Canvas.Left="10" Name="mcChart" Width="400" Height="250" Background="LightSteelBlue"> <wpft:Chart.Series> <wpft:LineSeries Title=" Monthly Count" IndependentValueBinding="{Binding Path=Key}" DependentValueBinding="{Binding Path=Value}"> </wpft:LineSeries> </wpft:Chart.Series> </wpft:Chart>
改变DataPointStyle
实例:
<chartingToolkit:Chart Margin="0,12,12,12" Name="chart1"> <chartingToolkit:Chart.Series> <chartingToolkit:ColumnSeries DependentValuePath="value"> <chartingToolkit:ColumnSeries.DataPointStyle> <Style TargetType="chartingToolkit:ColumnDataPoint"> <Setter Property="DependentValueStringFormat" Value="{}{0:C0}"/> </Style> </chartingToolkit:ColumnSeries.DataPointStyle> </chartingToolkit:ColumnSeries> </chartingToolkit:Chart.Series> <chartingToolkit:Chart.Axes> <chartingToolkit:LinearAxis Orientation="Y" ShowGridLines="False" HorizontalAlignment="Left"> <chartingToolkit:LinearAxis.AxisLabelStyle> <Style TargetType="chartingToolkit:AxisLabel"> <Setter Property="StringFormat" Value="{}{0:C0}"/> </Style> </chartingToolkit:LinearAxis.AxisLabelStyle> </chartingToolkit:LinearAxis> </chartingToolkit:Chart.Axes> </chartingToolkit:Chart>
作者:旭东
出处:http://www.cnblogs.com/HQFZ
关于作者:专注于微软平台项目架构、管理和企业解决方案。现主要从事WinForm、ASP.NET、WPF、WCF、等方面的项目开发、架构、管理。如有问题或建议,请不吝指教!
本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。如有问题,可以联系我,非常感谢。
如果您该文觉得不错或者对你有帮助,请点下推荐,让更多的朋友看到,谢谢!