WPF Toolkit Chart


<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:toolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
Title="MainWindow" Height="350" Width="525" xmlns:my="clr-namespace:PV;assembly=PV" Loaded="Window_Loaded">
<Grid>
<!--<my:PVStage Margin="0,211,303,0" Height="100" VerticalAlignment="Top" />-->
<toolkit:Chart x:Name="mChart">
<toolkit:Chart.Series>
<toolkit:ColumnSeries Title="Column" IndependentValueBinding="{Binding Key}" DependentValueBinding="{Binding Value}"/>
<toolkit:LineSeries Title="Line" IndependentValueBinding="{Binding Key}" DependentValueBinding="{Binding Value}"/>
</toolkit:Chart.Series>
</toolkit:Chart>
<Button VerticalAlignment="Bottom" Click="Button_Click"> 增加</Button>
</Grid>
</Window>


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls.DataVisualization.Charting;
using System.Collections.ObjectModel;

namespace WpfApplication1
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}

private void Window_Loaded(object sender, RoutedEventArgs e)
{
ObservableCollection<KeyValuePair<int, int>> list = new ObservableCollection<KeyValuePair<int, int>>()
{
new KeyValuePair<int,int>(1,10),
new KeyValuePair<int,int>(2,20),
new KeyValuePair<int,int>(3,30),
new KeyValuePair<int,int>(4,40)
};

ColumnSeries cs = (ColumnSeries)mChart.Series[0];
cs.ItemsSource = list;

LineSeries ls = (LineSeries)mChart.Series[1];
ls.ItemsSource = list;
}

int count = 4;
private void Button_Click(object sender, RoutedEventArgs e)
{
count++;
LineSeries ls = (LineSeries)mChart.Series[1];
ObservableCollection<KeyValuePair<int, int>> list = (ObservableCollection<KeyValuePair<int, int>>)ls.ItemsSource;
list.Add(new KeyValuePair<int, int>(count, count * 10));
}
}

}

点增加按钮后曲线增加

对X轴,Y轴进行操作

<charting:Chart.Axes>
<toolkit:LinearAxis Orientation="X" Title="Time" Interval="20" ShowGridLines="False"/>
<toolkit:LinearAxis Title="Number of Waiting Tasks" Orientation="Y" Interval="5" ShowGridLines="False"/>
</charting:Chart.Axes>

时间: 2024-11-05 06:26:06

WPF Toolkit Chart的相关文章

WPF Toolkit Chart--多Y轴显示

效果: <Window x:Class="Chart.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width=&quo

WPF Toolkit Chart--动态换列

效果: <Window x:Class="切换显示曲线.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width=&qu

WPF ToolKit Chart 自定义样式

1.引用:WPFToolkit.dll, System.Windows.Controls.DataVisualization.Toolkit.dll 2. 页面代码参考如下: <UserControl x:Class="GDNXFD.Alert.IFIXControls.StationPieChart" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="

安装Extended WPF Toolkit

Extended WPF Toolkit 可以说是WPF Toolkit 的一个补充,也包含了许多WPF 控件供开发者使用.本篇将介绍Extended WPF Toolkit 1.4.0 中新增的一些控件. 安装Extended WPF Toolkit Extended WPF Toolkit 安装其实很简单,利用nuget 可以快速将控件库添加到项目中.右键References 选择“Add Library Package Reference...” 在搜索框中输入"Extended WPF

WPF toolkit AutoCompleteBox

checked http://www.broculos.net/2014/04/wpf-autocompletebox-autocomplete-text.html#.WGNnq4N95aQ. 1.Search Wpf toolkit in Nuget and install; View: <Window x:Class="WpfApplication28.MainWindow" xmlns="http://schemas.microsoft.com/winfx/200

WPF Toolkit AutoCompleteBox 实体类绑定 关键字自定义关联搜索匹配

原文:WPF Toolkit AutoCompleteBox 实体类绑定 关键字自定义关联搜索匹配 网上的例子都是零散的   翻阅了 很多篇文章后 再根据 自己项目的实际需求  整理出一个完整的 应用例子 汉字首字母全文匹配 提取绑定实体类相应的ID值 XAML <Window x:Class="WpfApp3.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation&quo

WPF DevExpress Chart控件多Y轴,指定数据参考的Y轴

当Chart中有两个及以上的Y轴时,我们就要指明图表中的柱子或折线对应的是哪个Y轴了,这时候需要指明柱子或者折线的dxc:XYDiagram2D.SeriesAxisY属性,来设置对应的Y轴(dxc:XYDiagram2D.SeriesAxisY="{Binding ElementName=y2}"),其中Binding的ElementName就是需要对应的Y轴的Name(即这里的y2),界面代码如下: <dxc:ChartControl DataSource="{Bi

WPF工具开发: 第三库选择

PropertyGrid Winforms's PropertyGrid 非WPF原生支持, 需要借助WinFormHost 风格不可定制 PropertyInspectorView 算是"官方"库, 风格不可定制 WPF Property Grid 开源 功能还不够完善 可以定制风格 PropertyEditor for WPF 开源 功能比较实用, 有自己的特色 Actipro PropertyGrid 商业控件 Mindscape WPF Property Grid 商业控件 D

Wpf开源收集

1,到底有哪些开源MVVM框架? 前面介绍了WPF的基本概念和一些相关知识,我们了解到开发WPF应用程序可以使用现成的框架和模式,最为合适的莫过于时下正热的MVVM模式,所以这里我们也列出针对MVVM模式的已有开源框架: 图3 上面除了WPFToolKit和MEF之外都是一些常用的MVVM框架,连带自己开发的一共是八个,所以自己也取了一个响亮的名字——MVVM 八大框架!圣殿骑士本人实际项目中只用到了三个框架,之前WPF使用过MVVM Helpers,在Silverlight项目当中用过MVVM