wpf做如何做可以上下拖动Y轴坐标的折线图 用WPFVisifire.Charts做的不能拖动

一下是我写的代码 但是不能上下拖动Y轴坐标,数据使用txt文件来读取 急用 各位大神帮帮忙 谢谢

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
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 Visifire.Charts;

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

    #region 公共属性
    Visifire.Charts.Chart chart = new Visifire.Charts.Chart();
    DataSeries dataSeries;
    string[] subLines = { "" };
    Visifire.Charts.DataPoint dataPoint;
    #endregion

    /// <summary>
    /// 创建折线图
    /// </summary>
    /// <param name="path"></param>
    private void zhexian(string path)
    {
        using (Stream resourceStream = new FileStream(path, FileMode.Open))
        {
            using (StreamReader reader = new StreamReader(resourceStream, Encoding.GetEncoding("GB2312")))
            {
                chart.Width = 980;
                chart.Height = 580;
                chart.Margin = new Thickness(100, 5, 10, 5);
                ArrayList mydata;
                dataPoint = new Visifire.Charts.DataPoint();
                #region 创建折线图1
                //解析所有行数据
                var strings = reader.ReadToEnd().Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
                mydata = new ArrayList();
                ArrayList madata2 = new ArrayList();
                for (int i = 0; i < strings.Length; i++)
                {
                    sj j = new sj();
                    string[] stringArr = Regex.Split(strings[i], " ");
                    j.number = new double[stringArr.Length];
                    for (int h = 0; h < stringArr.Length; h++)
                    {
                        j.number[h] = Double.Parse(stringArr[h]);
                    }
                    madata2.Add(j);
                }
                //整理后的列数据
                string[] strArr = Regex.Split(strings[0], " ");
                for (int i = 0; i < strArr.Length; i++)
                {
                    sj sj = new sj();
                    sj.number = new double[madata2.Count];
                    int h = 0;
                    foreach (sj item in madata2)
                    {
                        if (i < item.number.Length)
                        {
                            sj.number[h] = item.number[i];
                            h++;
                        }
                    }
                    mydata.Add(sj);
                }
                //开始划线
                foreach (sj item in mydata)
                {
                    double num1 = 1;
                    // 创建一个新的数据线。               
                    dataSeries = new DataSeries();
                    // 设置数据线的格式。               
                    dataSeries.LegendText = "樱桃";
                    dataSeries.RenderAs = RenderAs.Line;//折线图
                    for (int i = 0; i < item.number.Length; i++)
                    {
                        // 创建一个数据点的实例。    
                        dataPoint = new Visifire.Charts.DataPoint();
                        // 设置X轴点
                        dataPoint.XValue = num1;
                        //设置Y轴点
                        string num = item.number[i].ToString();
                        dataPoint.YValue = Double.Parse(num);
                        dataPoint.MarkerSize = 8;
                        num1++;
                        //添加数据点                   
                        dataSeries.DataPoints.Add(dataPoint);
                    }
                    // 添加数据线到数据序列。  
                    chart.Series.Add(dataSeries);
                }
                #endregion
            }
        }

        //将数据绑定到Grid面板上
        System.Windows.Controls.Grid gr = new System.Windows.Controls.Grid();
        gr.Children.Add(chart);
        Simon.Children.Add(gr);
    }


    /// <summary>
    /// 窗体加载
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        string path = @"C:\Users\AllDream\Desktop\新建文件夹 (2)\ZheXian\zhexian\shuju.txt";
        zhexian(path);
        huoqu();
    }
    //创建一个double类型的数组类用于存储重新组合之后的数据
    public class sj
    {
        public double[] number = null;
    }
    public void huoqu()
    {
        Point zuobiao = new Point();
        object xzou = dataPoint.XValue;
        double oo = (double)xzou;
        zuobiao.X = oo;
        zuobiao.Y = dataPoint.YValue;
    }

}

}

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问