zoukankan      html  css  js  c++  java
  • 【原创】web环境使用.NETCHARTING图表

    .netcharting插件,让我们可以方便的将数据转化为图表。图表的形式也很多,有线性,图饼,柱型,3D等等。

    官网下载地址:http://www.dotnetcharting.com/download.aspx

    首先下载donetcharting.dll保存到本地文件夹

    打开vs,工具箱右击 chooseitems ,浏览找到刚才下载的dll,确定。

    确认后在工具箱中会多出如上图,然后把Chart拖到页面上即可。

    接下来就可以根据自己的喜好对控件进行样式设置(cs文件中、控件上右击属性)。

    个人偏爱好写C#代码进行设置:

    Chart.Title = "Title";
    Background cabg = new Background();
    cabg.Color = Color.Transparent;
    Chart.ChartArea.Background = cabg;
    //Chart.Depth = 15;
    //Chart.Use3D = true;//如果要显示3D效果,设置True即可
    Chart.XAxis.ClusterColumns = false;
    Chart.DefaultSeries.DefaultElement.Transparency = 20;
    Chart.DefaultSeries.Line.Width = 3;
    Chart.YAxis.Scale = Scale.Normal;
    Chart.XAxis.Label.Text = "时间";
    Chart.XAxis.Label.Font = new Font("宋体", 12F, FontStyle.Bold);
    Chart.YAxis.Label.Text = "百分率";
    Chart.YAxis.Label.Font = new Font("宋体", 12F, FontStyle.Bold);
    Chart.TempDirectory = "temp";//一定要保证有该文件夹,否则会提示警告
    Chart.Width = 780;
    Chart.Height = 400;
    Chart.YAxis.NumberPrecision = 2;//很多朋友在使用的时候发现不能显示小数,同事帮忙解决。
    Chart.YAxis.Maximum = 110;
    Chart.YAxis.Percent = true;//启用百分比
    Chart.SeriesCollection.Add(GetChartData()); 

    public SeriesCollection GetChartData()
    {
    SeriesCollection SC = new SeriesCollection();
    Series s = new Series();
    for(int i=0;i<10;i++)
    {

    Element elt = new Element();
    elt.Name = DateTime.Now.ToString("yyyyMMdd");//x轴数值
    Random r =new Random();
    elt.YValue = Convert.ToDouble(r.next(100));//y轴数值
    elt.ShowValue = true;//开启显示Y数值
    s.AddElements(elt);

    }
    SC.Add(s);
    SC[0].DefaultElement.Color = Color.FromArgb(52, 122, 170);
    SC[0].Type = SeriesType.Line;//设置 图表样式
    return SC;
    }

    运行代码,最后效果图:

  • 相关阅读:
    动态规划----背包问题
    动态规划----最长公共子序列
    贪心算法---codeforce680D Bear and Tower of Cubes
    贪心算法----Fence Repair(POJ 3253)
    线段树拓展----HDU 6315 Naive Operations
    Saruman`s Army(POJ 3069)
    字典序最小问题 Best Cow Line (POJ 3617)
    RMQ
    牛客2018年第二次acm暑期培训----H-Diff-prime Pairs
    牛客2018年第二次多校培训----A-run
  • 原文地址:https://www.cnblogs.com/zhxhdean/p/2383894.html
Copyright © 2011-2022 走看看