编程语言
首页 > 编程语言> > C#中统计图控件的使用(ZedGraph)

C#中统计图控件的使用(ZedGraph)

作者:互联网

本篇内容来自https://www.cnblogs.com/gaizai/archive/2010/02/22/1671154.html

 

开源的统计图控件中基本常用的是OpenFlashChar和ZedGraph,今天就先来讲讲ZedGraph的使用。

ZedGraph资源

 

ZedGraph的特点:

 

ZedGraph的缺点:

 

注意事宜

 

一个简单的入门例子

一些经验

myPane.XAxis.Scale.FontSpec.Size = 30;//设置x轴的文字大小.
myPane.YAxis.Scale.FontSpec.Size = 30;//设置y轴的文字大小.
myPane.YAxis.MajorGrid.IsVisible = true;//设置虚线.
myPane.Chart.Border.IsVisible = false;//图表区域的边框设置.
myPane.Legend.IsVisible = false;//图表的注释标签显示设置项目.
        /// <summary>
        /// 曲线图.
        /// </summary>
        public void CreateLineChart(GraphPane myPane, IDictionary<int, int> dic, string title, string xField, string yFields, string format)
        {
            myPane.XAxis.Scale.FontSpec.Size = 30;//设置x轴的文字大小.
            myPane.YAxis.Scale.FontSpec.Size = 30;//设置y轴的文字大小.
            myPane.YAxis.MajorGrid.IsVisible = true;//设置虚线.
            myPane.Chart.Border.IsVisible = false;//图表区域的边框设置.
            myPane.Legend.IsVisible = false;//图表的注释标签显示设置项目.

            int rows = dic.Count;
            double[] arrY = new double[rows];
            double[] arrX = new double[rows];
            string[] labels = new string[rows];

            int i = 0;
            foreach (KeyValuePair<int, int> kvp in dic)
            {
                arrX[i] = Convert.ToDouble(kvp.Key);
                arrY[i] = Convert.ToDouble(kvp.Value);
                labels[i] = kvp.Key.ToString();
                i++;
            }

            LineItem myCurve = myPane.AddCurve(title, arrX, arrY, Color.Red, SymbolType.Square);
            myCurve.Symbol.Fill = new Fill(Color.Blue, Color.White, Color.Blue);//填充这个蓝条,让这蓝条看起来有3D的效果
            myCurve.Line.Width = 2;

            myPane.XAxis.Scale.TextLabels = labels; //X轴的说明文字
            myPane.XAxis.Type = AxisType.Text;
        }

 

            myPane.XAxis.Scale.FontSpec.Size = 30;//设置x轴的文字大小.
            myPane.YAxis.Scale.FontSpec.Size = 30;//设置y轴的文字大小.
            myPane.YAxis.MajorGrid.IsVisible = true;//设置虚线.
            myPane.Chart.Border.IsVisible = false;//图表区域的边框设置.
            myPane.Legend.IsVisible = false;//图表的注释标签显示设置项目.
            myPane.YAxis.Scale.Min = 0;//设置只显示正半轴.
            myPane.YAxis.Scale.MajorStep = 1;//设置刻度为1;

 

 

 

相关资料

    1. http://weblogs.asp.net/scottgu/archive/2008/11/24/new-asp-net-charting-control-lt-asp-chart-runat-quot-server-quot-gt.aspx
    2. http://zedgraph.org/wiki/index.php?title=Sample_Graphs
    3. 波浪线图:http://zedgraph.org/wiki/index.php?title=Dual-Y_Demo
    4. RenderMode.ImageTag例子:http://zedgraph.org/wiki/index.php?title=Use_RenderMode.ImageTag_in_a_web_page
      RenderMode.RawImage例子:http://zedgraph.org/wiki/index.php?title=Use_RenderMode.RawImage_in_a_web_page
    5. ZedGraph webform 初学小例子 (代码有详细解释)

      ZedGraph属性

      一个简单例子
    6. 开源图表控件ZedGraph控件的研究(1)
    7. ZedGraph属性\方法介绍

标签:控件,Scale,ZedGraph,C#,统计图,YAxis,设置,IsVisible,myPane
来源: https://www.cnblogs.com/wzhk009/p/14200519.html