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="525"         
        xmlns:tk="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit" Loaded="Window_Loaded">
    <Grid>
        <tk:Chart Name="chart1" Title="Chart Title" >
            <tk:Chart.Axes>
                <tk:LinearAxis Orientation="X" Interval="1" Title="次数"></tk:LinearAxis>
            </tk:Chart.Axes>
            <tk:LineSeries x:Name="line1" DependentValuePath="Value" IndependentValuePath="Key">
                <tk:LineSeries.DependentRangeAxis>
                    <tk:LinearAxis Orientation="Y" Interval="10" Minimum="0" Maximum="100" Title="Series1"></tk:LinearAxis>
                </tk:LineSeries.DependentRangeAxis>
            </tk:LineSeries>
            <tk:LineSeries x:Name="line2" DependentValuePath="Value" IndependentValuePath="Key">
                <tk:LineSeries.DependentRangeAxis>
                    <tk:LinearAxis Orientation="Y" Interval="100" Title="Series2"></tk:LinearAxis>
                </tk:LineSeries.DependentRangeAxis>
            </tk:LineSeries>
            <tk:LineSeries x:Name="line3" DependentValuePath="Value" IndependentValuePath="Key">
                <tk:LineSeries.DependentRangeAxis>
                    <tk:LinearAxis Orientation="Y" Interval="1000" Title="Series3"></tk:LinearAxis>
                </tk:LineSeries.DependentRangeAxis>
            </tk:LineSeries>
        </tk:Chart>
    </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;

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

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Dictionary<int, int> d = new Dictionary<int, int>();
            d.Add(1, 50);
            d.Add(2, 40);
            d.Add(3, 50);
            d.Add(4, 40);
            d.Add(5, 50);

            line1.ItemsSource = d;

            Dictionary<int, int> d1 = new Dictionary<int, int>();
            d1.Add(1, 100);
            d1.Add(2, 200);
            d1.Add(3, 300);
            d1.Add(4, 400);
            d1.Add(5, 500);

            line2.ItemsSource = d1;

            Dictionary<int, int> d2 = new Dictionary<int, int>();
            d2.Add(1, 1000);
            d2.Add(2, 3000);
            d2.Add(3, 4000);
            d2.Add(4, 2000);
            d2.Add(5, 5000);

            line3.ItemsSource = d2;
        }


    }
}

 

转载于:https://www.cnblogs.com/amw2738/p/3728705.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
之前三此发的库http://download.csdn.net/detail/maiker/9621027可以作废,本次为最新的,其中测试了历史曲线的动态显示,这是对Microsoft WpfToolkit的更新和扩展: 1、将库版本升级到.NET 4.6.1,对命名控件进行了替换处理 2、实现了单数据Chart图的混合颜色显示,可通过修改资源字典调整和添加颜色 3、可控制各种Chart图形的数据值显示 4、坐标轴文本可倾斜显示 5、添加了StepLine图和圆环图,圆环半径比例系数可设定,同时添加了饼图的半径比系数,这样可以更好的控制饼图的标签显示,避免重叠 6、Legend可位于区域四侧,对齐方式也可以设定,以及是否显示, 可控制Chart Title是否显示 7、柱状图缝隙间隔可调整 8、全方面的加入了各种加载动画效果,动画效果可屏蔽,同时原系统自带动画效果,可叠加,这是两种不同的效果,可以互补性的单个使用 9、设计了四种主题颜色,各人可以针对图形颜色和背景色进行更好的搭配,在用户项目中,可以自己添加新的主题。 10、扩展了时间轴的应用,在新的DateTimeChart中可以通过鼠标平移和缩放时间轴,并测试了两个例子用于动态显示历史曲线,一个是外部定时更新,一个是内部定时更新 11、对LineDataPoint样式进行了设计,现在可以选择线图的点样式(如空心圆、五角星、三角形,矩形等),同时这些不同的点样式可以体现在Legend上,从而实现颜色和图形的双重区分。 总而言之,微软的控件库做得很标准,还是很好修改的。 最后一直想在历史曲线中取消点动画(及默认的透明度动画),以便提高执行效率,但微软的那部分动画不熟,总是修改失败。 可以发邮件wuyang26@live.cn讨论。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值