效果图如下:

1、拖chart控件在新建的窗口,命名chart1

2、源代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;namespace Chartyiet应用
{public partial class Form1 : Form{public Form1(){InitializeComponent();}private void Form1_Load(object sender, EventArgs e){string[] x = new string[] { "成都大队", "广东大队", "广西大队", "云南大队", "上海大队", "苏州大队", "深圳大队", "北京大队", "湖北大队", "湖南大队", "重庆大队" ,"辽宁大队" };double[] y = new double[] { 589, 598, 445, 654, 884, 457, 941, 574, 745, 854, 684, 257 };string[] z = new string[] { "", "", "", "", "", "", "", "", "", "", "", "" };string[] a = new string[] { "成都大队", "广东大队", "广西大队", "云南大队", "上海大队" };double[] b = new double[] { 541, 574, 345, 854, 257 };#region 柱状图//标题chart1.Titles.Add("柱状图数据分析");chart1.Titles[0].ForeColor = Color.Blue;chart1.Titles[0].Font = new Font("微软雅黑", 12f, FontStyle.Regular);chart1.Titles[0].Alignment = ContentAlignment.TopCenter;chart1.Titles.Add("合计:25414 宗");chart1.Titles[1].ForeColor = Color.Blue;chart1.Titles[1].Font = new Font("微软雅黑", 8f, FontStyle.Regular);chart1.Titles[1].Alignment = ContentAlignment.TopRight;//控件背景chart1.BackColor = Color.Transparent;//图表区背景chart1.ChartAreas[0].BackColor = Color.Transparent;chart1.ChartAreas[0].BorderColor = Color.Transparent;//X轴标签间距chart1.ChartAreas[0].AxisX.Interval = 1;chart1.ChartAreas[0].AxisX.LabelStyle.IsStaggered = true;chart1.ChartAreas[0].AxisX.LabelStyle.Angle = -45;chart1.ChartAreas[0].AxisX.TitleFont = new Font("微软雅黑", 14f, FontStyle.Regular);chart1.ChartAreas[0].AxisX.TitleForeColor = Color.White;//X坐标轴颜色chart1.ChartAreas[0].AxisX.LineColor = ColorTranslator.FromHtml("#38587a"); ;chart1.ChartAreas[0].AxisX.LabelStyle.ForeColor = Color.Blue;chart1.ChartAreas[0].AxisX.LabelStyle.Font = new Font("微软雅黑", 10f, FontStyle.Regular);//X坐标轴标题chart1.ChartAreas[0].AxisX.Title = "数量(宗)";chart1.ChartAreas[0].AxisX.TitleFont = new Font("微软雅黑", 10f, FontStyle.Regular);chart1.ChartAreas[0].AxisX.TitleForeColor = Color.Blue;chart1.ChartAreas[0].AxisX.TextOrientation = TextOrientation.Horizontal;chart1.ChartAreas[0].AxisX.ToolTip = "数量(宗)";//X轴网络线条chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = true;chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = ColorTranslator.FromHtml("#2c4c6d");//Y坐标轴颜色chart1.ChartAreas[0].AxisY.LineColor = ColorTranslator.FromHtml("#38587a");chart1.ChartAreas[0].AxisY.LabelStyle.ForeColor = Color.Blue;chart1.ChartAreas[0].AxisY.LabelStyle.Font = new Font("微软雅黑", 10f, FontStyle.Regular);//Y坐标轴标题chart1.ChartAreas[0].AxisY.Title = "数量(宗)";chart1.ChartAreas[0].AxisY.TitleFont = new Font("微软雅黑", 10f, FontStyle.Regular);chart1.ChartAreas[0].AxisY.TitleForeColor = Color.Blue;chart1.ChartAreas[0].AxisY.TextOrientation = TextOrientation.Rotated270;chart1.ChartAreas[0].AxisY.ToolTip = "数量(宗)";//Y轴网格线条chart1.ChartAreas[0].AxisY.MajorGrid.Enabled = true;chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = ColorTranslator.FromHtml("#2c4c6d");chart1.ChartAreas[0].AxisY2.LineColor = Color.Transparent;chart1.ChartAreas[0].BackGradientStyle = GradientStyle.TopBottom;Legend legend = new Legend("legend");legend.Title = "legendTitle";chart1.Series[0].XValueType = ChartValueType.String;  //设置X轴上的值类型chart1.Series[0].Label = "#VAL";                //设置显示X Y的值    chart1.Series[0].LabelForeColor = Color.Blue;chart1.Series[0].ToolTip = "#VALX:#VAL";     //鼠标移动到对应点显示数值chart1.Series[0].ChartType = SeriesChartType.Column;    //图类型(折线)chart1.Series[0].Color = Color.Lime;chart1.Series[0].LegendText = legend.Name;chart1.Series[0].IsValueShownAsLabel = true;chart1.Series[0].LabelForeColor = Color.Blue;chart1.Series[0].CustomProperties = "DrawingStyle = Cylinder";chart1.Legends.Add(legend);chart1.Legends[0].Position.Auto = false;//绑定数据chart1.Series[0].Points.DataBindXY(x, y);chart1.Series[0].Points[0].Color = Color.Blue;chart1.Series[0].Palette = ChartColorPalette.Bright;#endregion}}
}

C# Winform Chart控件用法3 柱状图相关推荐

  1. C# Winform Chart控件用法1

    1.Chart控件五大核心" 图表属性 "--它们均是" 集合 " ChartAreas属性 Series属性 Legends属性 Titles 属性 Anno ...

  2. C# Winform Chart控件用法6之雷达图

    1.ChartAreas属性 ChartAreas属性指绘图区,一个控件可以有多个绘图区,比如我要在同一个控件内显示饼图和柱状图,肯定不能放在同一个ChartAreas区域内,应该在同一个Chart控 ...

  3. C# Winform Chart控件用法5之Bar图

    1.ChartAreas属性 ChartAreas属性指绘图区,一个控件可以有多个绘图区,比如我要在同一个控件内显示饼图和柱状图,肯定不能放在同一个ChartAreas区域内,应该在同一个Chart控 ...

  4. C# Winform Chart控件用法4之饼状图

    1.拖chart控件在新建的窗口,命名chart1 2.源代码 using System; using System.Collections.Generic; using System.Compone ...

  5. winform chart控件设置

    winform chart控件设置//seriesX.MarkerColor = Color.Green;//设置点的大小//seriesX.MarkerSize = 5;//seriesX.Mark ...

  6. C#chart控件绘制折线图、柱状图、饼图、雷达图

    转载来源:https://blog.csdn.net/u011854789/article/details/82946553 参考链接: http://www.cnblogs.com/winshe/a ...

  7. 一个WinForm记事本程序(包含主/下拉/弹出菜单/打开文件/保存文件/打印/页面设置/字体/颜色对话框/剪切版操作等等控件用法以及记事本菜单事件/按键事件的具体代码)...

    (一).说明 功能类似Windows 操作系统自带的记事本.  一个WinForm记事本程序(包含主/下拉/弹出 菜单/打开保存对话框等控件用法以及记事本菜单事件的具体代码) (二).图片示例 (三) ...

  8. C# WinForm开发系列之c# 通过.net自带的chart控件绘制饼图,柱形图和折线图的基础使用和扩展

    一.需要实现的目标是: 1.将数据绑定到pie的后台数据中,自动生成饼图. 2.生成的饼图有详细文字的说明. 1.设置chart1的属性Legends中默认的Legend1的Enable为false: ...

  9. 基于Winform的Chart控件的简单使用(Chart控件中的条形统计图、折线统计图、扇形统计图的简单使用)

    Chart控件集成了颇多的统计图模型,拿来即用的理念大大节省了开发的时间.下面演示最常见的三种统计图模型的使用. 效果展示: C#代码: using System; using System.Coll ...

最新文章

  1. 你不知道的JavaScript之词法作用域
  2. centos输入正确的账号和密码登陆不进去
  3. realme怎么互传_realme真我X7 Pro首发体验:非常轻快,颜值不赖
  4. 计算两个日期相差几年几个月
  5. 如何通过本地化事件正确实现微服务内部强一致性,事件总线跨微服务间最终一致性...
  6. DB2 存储过程中执行动态SQL的两种写法
  7. 基于mycat高可用方案——数据库负载
  8. 变相裁员?人人车发奇葩通知:未离职员工每天打卡三次 只抄规则
  9. 风格化图像_CVPR2019:基于神经网络纹理转换的图像超分辨率
  10. 服务器运行程序 网络错误怎么办,网站出现:ldquo;/rdquo;应用程序中的服务器错误。该如何解决?_已解决 - 阿里巴巴生意经...
  11. Python之数据分析(案例:净额成交量、矢量化、数据曲线平滑)
  12. 使用Visual C#制作可伸缩个性化窗体
  13. CI生成查询记录集result(),row(),row_array().....
  14. springboot中的controller注解没有生效
  15. 保密工作中非密计算机工具检查,【保密知识】别在保密工作面前耍“小聪明”哦~...
  16. java基于springboot高校后勤报修管理系统
  17. java生成pdf文档
  18. freeradius mysql web_CentOS7部署FreeRadius3.0及WEB管理界面DaloRadius
  19. Hadoop Web 控制台安全认证
  20. 求解tsw30浊度传感器

热门文章

  1. iptables简单使用
  2. NDS9435快速开关MOS管的使用
  3. 20170515_建立排序二叉树BST
  4. 游戏分析之引擎的基本概念及常见的游戏引擎介绍
  5. 傻子都能看懂的——详解AdaBoost原理
  6. 我是名黑客我想黑掉淘宝有可能吗?
  7. 使用ThinkPHP创建留言板项目
  8. 简易两位二进制乘法器设计
  9. 安卓炫酷的抽屉菜单——JPSpringMenu
  10. 如何保障消息100%投递成功、消息幂等性?