WPF Tookit Chart
如何使用Chart
实例:
Binding数据源中是一个KeyValuePair对象。可以是Dictionary.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | < 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
1 2 3 | < DVC:ColumnSeries.DependentRangeAxis > < DVC:LinearAxis Location="Left" Orientation="Y" /> </ DVC:ColumnSeries.DependentRangeAxis > |
On the second serie (LineSeries), add this
1 2 3 | < DVC:LineSeries.DependentRangeAxis > < DVC:LinearAxis Location="Right" Orientation="Y" /> </ DVC:LineSeries.DependentRangeAxis > |
如何修改图列的名称
实例:
LineSeries Title=" Monthly Count" is responsible for display the legend text
1 2 3 4 5 6 7 8 9 10 | < 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
实例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | < 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、等方面的项目开发、架构、管理。如有问题或建议,请不吝指教!
本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。如有问题,可以联系我,非常感谢。
如果您该文觉得不错或者对你有帮助,请点下推荐,让更多的朋友看到,谢谢!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?