zoukankan      html  css  js  c++  java
  • C# 中使用MSChart组件

     这两天在研究怎样在 C# 中使用MSChart组件来绘制柱状、饼状图形,由于以前没有接触过MSChart组件,关于这方面的资料也没有;于是就到网上狂搜一把,找到了一些相关的资料,但资料都写的不完整; 现在将自己摸索的心得整理一下:

    1、将MSChart control的引用添加到工具栏。

       选择“工具->选择工具箱项”, 然后切换到“COM 组件”页,选择“Microsoft Chart Control 6.0 (OLEBD)”,点击确定后就可以成功加载控件了。

    2、添加引用,using MSChart20Lib;

    3、定义图表样式

              

    //图表标题        

    MSChartBar.TitleText = "年度统计图表";

               

    //页底说明          

    MSChartBar.Footnote.Text = "说明:年度柱状统计图表";

               

    //设置图例          

    MSChartBar.ShowLegend = true;
               

    MSChartBar.Legend.Location.LocationType = VtChLocationType.VtChLocationTypeRight;

             
               

    //设置Plot的Shadow          

    MSChartBar.Plot.Backdrop.Shadow.Style = VtShadowStyle.VtShadowStyleDrop;
             
               

    //设置Shadow的大小          

    MSChartBar.Plot.Backdrop.Shadow.Offset.Set(60, 60);
             
               

    //设置Plot的边框          

    MSChartBar.Plot.Backdrop.Frame.Style = VtFrameStyle.VtFrameStyleSingleLine;
                      

    //关闭选择          

    MSChartBar.AllowSelections = false;

    4、显示数据           

    MSChartBar.RowCount = 12;            

    MSChartBar.ColumnLabel = "温度";

                        

    // Y轴名称             

    MSChartBar.Plot.get_Axis(VtChAxisId.VtChAxisIdY, 0).AxisTitle.Text = "温度";
                           

    // X轴名称    

    MSChartBar.Plot.get_Axis(VtChAxisId.VtChAxisIdX, 0).AxisTitle.Text = "月份";
                 

    for(int row = 1; row <= 12; ++row)          

    {               

        MSChartBar.Row = (short)row;                 

        MSChartBar.RowLabel = Convert.ToString(row);                 

        MSChartBar.DataGrid.SetData((short)row, 1, 12*row, 0);                            

     }

                


    MSChartBar.Refresh();

        基本可以满足一般需求了,需要完善的有-显示百分比数值。

  • 相关阅读:
    aidl 详解
    为什么我选择用 flutter
    hunting
    Dynamic programming
    android 微信开发交流群
    hash function 字符串哈希函数
    函数也可以看成是空间的变换
    语法树
    生活中的物理随处可见
    about coroutine
  • 原文地址:https://www.cnblogs.com/lzjsky/p/2007898.html
Copyright © 2011-2022 走看看