如何使用WPFToolKit Chart

private void button1_Click(object sender, EventArgs e)
{
var s = new Series();
s.ChartType = SeriesChartType.Line; var d = new DateTime(2013, 04, 01); s.Points.AddXY(d, 3);
s.Points.AddXY(d.AddMonths(-1), 2);
s.Points.AddXY(d.AddMonths(-2), 1);
s.Points.AddXY(d.AddMonths(-3), 4); chart1.Series.Clear();
chart1.Series.Add(s); chart1.Series[0].XValueType = ChartValueType.DateTime;
chart1.ChartAreas[0].AxisX.LabelStyle.Format = "yyyy-MM-dd";
chart1.ChartAreas[0].AxisX.Interval = 1;
chart1.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Months;
chart1.ChartAreas[0].AxisX.IntervalOffset = 1; chart1.Series[0].XValueType = ChartValueType.DateTime;
DateTime minDate = new DateTime(2013, 01, 01).AddSeconds(-1);
DateTime maxDate = new DateTime(2013, 05, 01); // or DateTime.Now;
chart1.ChartAreas[0].AxisX.Minimum = minDate.ToOADate();
chart1.ChartAreas[0].AxisX.Maximum = maxDate.ToOADate();
}

 

或者

<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>
<!-- See more at: http://mitchelsellers.com/blogs/2011/04/20/wpf-chart-styling-explained.aspx#sthash.EdMcBh2I.dpuf-->

 

隐藏Legend

隐藏Chart的Legend

<chartingToolkit:Chart.LegendStyle>
<Style TargetType="Control">
<Setter Property="Width" Value="0" />
<Setter Property="Height" Value="0" />
</Style>
</chartingToolkit:Chart.LegendStyle>

 

隐藏具体Item的legend

<charting:LineSeries.LegendItemStyle >
<Style TargetType="{x:Type charting:LegendItem}">
<Setter Property="Visibility" Value="Collapsed"/>
</Style>
</charting:LineSeries.LegendItemStyle>

 

显示定义横纵坐标

<Grid Height="800">
<chartingToolkit:Chart Name="lineChart" Title="Pressure over Time"
VerticalAlignment="Top" Margin="20,50,20,0" Height="500">
<chartingToolkit:Chart.Axes>
<chartingToolkit:LinearAxis Title="Pressure" Orientation="Y" Interval="100" />
<chartingToolkit:LinearAxis Title="Time" Orientation="X" Interval="100" />
</chartingToolkit:Chart.Axes>
<chartingToolkit:LineSeries DependentValuePath="Value" IndependentValuePath="Key" ItemsSource="{Binding}" Name="Test"
IsSelectionEnabled="True" ClipToBounds="False">
</chartingToolkit:LineSeries> </chartingToolkit:Chart>
<Button Width="100" Height="24" Margin="20,556,1058,220" Content="More" Name="Button1" />
</Grid>

 

修改横纵坐标

 

坐标值倒序排列

 

 

public class InverterConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is int)
{
return -(int)value;
}
throw new NotImplementedException();
} public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
 
<charting:Chart
FontSize="9">
<charting:LineSeries
ItemsSource="{Binding}"
DependentValueBinding="{Binding Place, Converter={StaticResource InverterConverter}}"
IndependentValuePath="Date"
Title="Book">
<charting:LineSeries.DataPointStyle>
<Style TargetType="charting:LineDataPoint">
<Setter Property="Background" Value="Maroon"/>
<Setter Property="DependentValueStringFormat" Value="{}{0:0.#;0.#}"/>
</Style>
</charting:LineSeries.DataPointStyle>
<charting:LineSeries.DependentRangeAxis>
<charting:LinearAxis
Orientation="Y"
Minimum="-10.5"
Maximum="-0.5"
Interval="1"
ShowGridLines="True">
<charting:LinearAxis.AxisLabelStyle>
<Style TargetType="charting:AxisLabel">
<Setter Property="StringFormat" Value="{}{0:0.#;0.#}"/>
</Style>
</charting:LinearAxis.AxisLabelStyle>
</charting:LinearAxis>
</charting:LineSeries.DependentRangeAxis>
</charting:LineSeries>
</charting:Chart>

参考 http://dlaa.me/blog/post/9607895

 

修改ToolTips

<ToolTipService.ToolTip>
<StackPanel>
<ContentControl
Content="Custom ToolTip"
FontWeight="Bold"/>
<ContentControl
Content="{TemplateBinding FormattedDependentValue}"/>
</StackPanel>
</ToolTipService.ToolTip>

http://dlaa.me/blog/post/9631686

 

参考

My new home page, extended [Updated collection of great Silverlight and WPF Charting resources!]

WPFTookit Chart 入门的更多相关文章

  1. WPFTookit Chart 高级进阶

    数据源增加SeriesSource 使用方式 <Charting:Chart x:Name="chart" Helper:ChartHelper.DependentValue ...

  2. c# Winform Chart入门

    额外参考链接:http://www.cnblogs.com/greenerycn/archive/2008/10/27/microsoft-chart.html winform 仪表盘相关下载链接:/ ...

  3. [转帖]从入门到实践:创作一个自己的 Helm Chart

    从入门到实践:创作一个自己的 Helm Chart https://www.cnblogs.com/alisystemsoftware/p/11436469.html 自己已经搭建好了 helm 和t ...

  4. Winform & Devexpress Chart使用入门

    一.Chart(Winform) 使用图表控件(chart)首先要理解图表区域(ChartArea).XY轴(AxisX.AxisY).数据点(Series).标题(Title).图例(Legend) ...

  5. [转]Chart.js入门教程

    Chart.js是一个简单.面向对象.为设计者和开发者准备的图表绘制工具库. 相信大部分人都一样,看到一大筐用文本或者表格形式呈现的数据就头疼.因为这种呈现方式也太无聊了吧...而且这对于我们处理原始 ...

  6. Chart.js入门教程

    Chart.js是一个简单.面向对象.为设计者和开发者准备的图表绘制工具库. 相信大部分人都一样,看到一大筐用文本或者表格形式呈现的数据就头疼.因为这种呈现方式也太无聊了吧...而且这对于我们处理原始 ...

  7. 从入门到实践:创作一个自己的 Helm Chart

    前言 我们平时在日常生活中会经常在不同的平台上与各种各样的应用打交道,比如从苹果的 App Store 里下载的淘宝.高德.支付宝等应用,或者是在 PC 端安装的 Word.Photoshop.Ste ...

  8. 可能是史上最强大的js图表库——ECharts带你入门

    PS:之前的那篇博客Highcharts——让你的网页上图表画的飞起 ,评论中,花儿笑弯了腰 和 StanZhai 两位仁兄让我试试 ECharts ,去主页看到<Why ECharts ?&g ...

  9. 给深度学习入门者的Python快速教程 - numpy和Matplotlib篇

    始终无法有效把word排版好的粘贴过来,排版更佳版本请见知乎文章: https://zhuanlan.zhihu.com/p/24309547 实在搞不定博客园的排版,排版更佳的版本在: 给深度学习入 ...

随机推荐

  1. 【C#公共帮助类】给大家分享一些加密算法 (DES、HashCode、RSA、AES等)

    AES 高级加密标准(英语:Advanced Encryption Standard,缩写:AES),在密码学中又称Rijndael加密法,是美国联邦政府采用的一种区块加密标准.这个标准用来替代原先的 ...

  2. 在IIS启用MP4

    在Windows 2008 R2 Server中,网站无法播放MP4视频.我们需要在IIS的MIME type: 如果我们不想在IIS管理介面更改与设置,或是我们没有更多权限,这样我们可以项目的Web ...

  3. 背水一战 Windows 10 (27) - 控件(文本类): TextBlock

    [源码下载] 背水一战 Windows 10 (27) - 控件(文本类): TextBlock 作者:webabcd 介绍背水一战 Windows 10 之 控件(文本类) TextBlock 示例 ...

  4. 在window下配置laravel开发环境

    1.由于有一点php基础,所以非常想更进一步,就选择据说在国外最流行的php框架来学习了,laravel框架,官网上介绍是为艺术而生,从知乎和一些论坛上看到,laravel学起来并不简单,首先配置问题 ...

  5. Lind.DDD.Utils.HttpHelper里静态对象引出的Http超时问题

    回到目录 Lind.DDD.Utils.HttpHelper组件主要实现了对HTTP的各种操作,如Get,Post,Put和Delete,它属于最纯粹的操作,大叔把它封装的目的主要为了实现与API安全 ...

  6. GJM:Unity导入百度地图SDK [转载]

    感谢您的阅读.喜欢的.有用的就请大哥大嫂们高抬贵手"推荐一下"吧!你的精神支持是博主强大的写作动力以及转载收藏动力.欢迎转载! 版权声明:本文原创发表于 [请点击连接前往] ,未经 ...

  7. DevExpress TreeList使用心得

    来自:http://www.cnblogs.com/sndnnlfhvk/archive/2011/05/15/2046920.html 最近做项目新增光纤线路清查功能模块,思路和算法已经想好了,些代 ...

  8. User Get 'Access Denied' with Excel Service WebPart

    用户可以访问网站,并且具有相应的访问权限. 用户尝试了其他浏览器和IE的其他版本. 解决: 将用户添加到 ‘Excel Services Views’ 这个SharePoint组就OK了.

  9. include的用法例子,以及include+merge的用法例子

    [include+LinearLayout]的使用例子 AndroidIncludeLayout.java package com.AndroidIncludeLayout; import andro ...

  10. iOS 开发中的争议(一)

    序言 打算分享一些有争议的话题,并且表达一下我的看法.这是该系列的第一篇,我想讨论的是:类的成员变量应该如何定义? 在 Objective-C 的语言的早期,类的私有成员变量是只能定义在 .h 的头文 ...