AI编程助手
AI免费问答

C# 使用zedgraph绘制 柱状图的详解

黄舟   2017-03-02 11:55   4738浏览 原创

1.下载zedgraph控件:http://download.csdn.net/detail/allisnew/322251

2.添加引用 zedGraph.dll

3.在工具箱的最后面添加常规控件--浏览--选择zedgraph.dll

4.编写如下初始化代码(也可以直接拖一个控件):

private ZedGraphControl zedGraphControl1 = new ZedGraphControl();

 this.zedGraphControl1.Location = new System.Drawing.Point(36, 48);
            this.zedGraphControl1.Name = "zedGraphControl1";
            this.zedGraphControl1.ScrollGrace = 0;
            this.zedGraphControl1.ScrollMaxX = 0;
            this.zedGraphControl1.ScrollMaxY = 0;
            this.zedGraphControl1.ScrollMaxY2 = 0;
            this.zedGraphControl1.ScrollMinX = 0;
            this.zedGraphControl1.ScrollMinY = 0;
            this.zedGraphControl1.ScrollMinY2 = 0;
            this.zedGraphControl1.Size = new System.Drawing.Size(427, 247);
            this.zedGraphControl1.TabIndex = 0;
            this.Controls.Add(zedGraphControl1);

5.编写绘图代码:

 private void ShowChart()
        {
            zedGraphControl1.GraphPane.CurveList.Clear();
            zedGraphControl1.GraphPane.GraphObjList.Clear();
            // clearing not teste


            GraphPane myPane = zedGraphControl1.GraphPane;


            myPane.Title.Text = "消费者学历统计";  //设计图表的标题
            myPane.XAxis.Title.Text = "学历类型"; //X轴标题
            myPane.YAxis.Title.Text = "人数"; //Y轴标题
            //      myPane.XAxis.Type = ZedGraph.AxisType.Date;
            // Date wont work in our case


            PointPairList PPLa = new PointPairList();
            PointPairList PPLb = new PointPairList();
            PointPairList PPLc = new PointPairList();
            PointPairList PPLd = new PointPairList();


            for (int i = 1; i <p>如需要横坐标显示文字:</p><pre class="brush:c#;toolbar:false;"> private void ShowChart()
        {
            zedGraphControl1.GraphPane.CurveList.Clear();
            zedGraphControl1.GraphPane.GraphObjList.Clear();
            // clearing not teste


            GraphPane myPane = zedGraphControl1.GraphPane;
            // 画图面版标题
            myPane.Title.Text = "收入统计";
            // 画图面版X标题
            myPane.XAxis.Title.Text = "区域";


            myPane.XAxis.Scale.Min = 0;
            //初始化数据
            PointPairList list = new PointPairList();
            PointPairList list2 = new PointPairList();
            PointPairList list3 = new PointPairList();


            for (int i = 0; i <p> 以上就是C#  使用zedgraph绘制 柱状图的详解的内容,更多相关内容请关注PHP中文网(www.php.cn)!<br></p>
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。