如何使用Zedgraph放大Masterpane的图形?

时间:2015-04-15 19:34:16

标签: c# graph zedgraph

我想,如果我点击任何图表,以便所选图表增加或切换到新窗口。

我尝试将此answer的代码用于问题How to select and enlarge a Masterpane in Zedgraph

但是我收到了错误:

//Zedgraph control 
var zgc = Apprefs.Zedgraph;

错误1当前上下文中不存在名称“Apprefs”

More in FIG.

I used ZedGraph chart.

1 个答案:

答案 0 :(得分:0)

  1. 我创建了一个图表

    public void CreateChart(ZedGraphControl zg1)     {
            MasterPane master = zg1.MasterPane;         master.PaneList.Clear();

        //Title of graph
        master.Title.IsVisible = true;
        master.Title.Text = SPolohaE+"E----"+SPolohaN+"N";
        master.Margin.All = 10;
    
        /*Background collor*/
        master.Fill = new Fill(Color.Blue, Color.LightBlue, 45.0f);
    
        GraphPane pane1 = new GraphPane();
    
        /*New list for graph*/
        PointPairList list1 = new PointPairList();
    
        string date, time, y;
        double Y_axis, X_axis;
        /*load data row to row*/
        for (int rows = 0; rows < pocet_Radku-1; rows++)
        {
                /*load data from datagridview*/
                date = dataGridView1.Rows[rows].Cells[2].Value.ToString();
                time = dataGridView1.Rows[rows].Cells[1].Value.ToString();
                y = dataGridView1.Rows[rows].Cells[5].Value.ToString();
    
                Y_axis = double.Parse(y);
                string[] datum = date.Split(' ');
                DateTime dt = Convert.ToDateTime(datum[0]+" "+time);
                /*Create X axis*/
                X_axis = (double) new XDate(dt);
                /*add to list data*/
                list1.Add(X_axis, Y_axis);
        }
    
        /*Type of X axes*/
        pane1.XAxis.Type = AxisType.Date;
    
        pane1.Title.Text = "Teplota 1"; //Title of char
        LineItem Graf1 = pane1.AddCurve("", list1, Color.Black, SymbolType.Diamond);
    
        //Add graph
        master.Add(pane1);
    
        //Set graph
        using (Graphics g = this.CreateGraphics())
        {
            master.SetLayout(g, true, new int[] { 3, 3, 2 });   /
        }
    
        /*init axes*/
        zg1.AxisChange();
        zg1.Invalidate();
    

    }

  2. 如果我在这里写:

    public void CreateChart(ZedGraphControl zg1)
    {     
         var zg1 = Apprefs.Zedgraph;
    ..........
    

    所以我的Visual Studio单词&#39; Apprefs&#39;或不提供。