Winform Chart
Chart图表解释说明:
第一步:使用VS创建Winform项目;
第二步:工具箱中拖入Chart控件;
第三步:所有控件拖入其他控件如下图所示:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting; namespace ZB.PISS.StatisticsSys
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{
List<int> x = new List<int> { , , , , }; List<int> a = new List<int> { , , , , };
List<int> b = new List<int> { , , , , };
List<int> c = new List<int> { , , , , };
var dd = chartDemo.Series; this.chartDemo.Series["name1"].Points.DataBindXY(x, a);
this.chartDemo.Series["name2"].Points.DataBindXY(x, b);
this.chartDemo.Series["name3"].Points.DataBindXY(x, c);
Winfrom chart DataBindXY X内容显示不全解决方法如下:
chartImage.ChartAreas["ChartArea1"].AxisX.LabelAutoFitStyle = LabelAutoFitStyles.None;
chartImage.ChartAreas["ChartArea1"].AxisX.LabelStyle.Interval = 1;
chartImage.ChartAreas["ChartArea1"].AxisX.LabelStyle.IsStaggered = false;
//Chart Title
this.chartDemo.Titles.Add("人员信息统计").Alignment = ContentAlignment.MiddleCenter;
Color[] arr = chartDemo.PaletteCustomColors;
this.cmbPattern.DataSource = PatternList();
this.cmbType.DataSource = SeriesTypeList(); //Axis Title
this.chartDemo.ChartAreas[].AxisX.Title = "月份信息";
this.chartDemo.ChartAreas[].AxisY.Title = "数量信息"; //Lable
// #VALX 显示当前图例的X轴的对应文本(或数据)
//#VAL, #VALY, 显示当前图例的Y轴的对应文本(或数据)
//#VALY2, #VALY3, 显示当前图例的辅助Y轴的对应文本(或数据)
//#SER: 显示当前图例的名称
//#LABEL 显示当前图例的标签文本
//#INDEX 显示当前图例的索引
//#PERCENT 显示当前图例的所占的百分比
//#TOTAL 总数量
//#LEGENDTEXT 图例文本
this.chartDemo.Series[].Label = "#VAL";
this.chartDemo.Series[].Label = "#VAL";
this.chartDemo.Series[].Label = "#VAL"; //Marker
this.chartDemo.Series[].MarkerSize = ;
this.chartDemo.Series[].MarkerSize = ;
this.chartDemo.Series[].MarkerSize = ;
this.chartDemo.Series[].MarkerStyle = MarkerStyle.Circle;
this.chartDemo.Series[].MarkerStyle = MarkerStyle.Square;
this.chartDemo.Series[].MarkerStyle = MarkerStyle.Diamond; } #region ChartType
public List<string> SeriesTypeList()
{
List<string> list = new List<string>();
foreach (string item in Enum.GetNames(typeof(SeriesChartType)))
{
list.Add(item);
}
return list;
} private void cmbType_SelectedValueChanged(object sender, EventArgs e)
{
try
{
SeriesChartType type = (SeriesChartType)Enum.Parse(typeof(SeriesChartType),
this.cmbType.Text); this.chartDemo.Series["name1"].ChartType = type;
this.chartDemo.Series["name2"].ChartType = type;
this.chartDemo.Series["name3"].ChartType = type;
}
catch
{
return;
}
} #endregion #region Pattern
public List<string> PatternList()
{
List<string> list = new List<string>();
foreach (string item in Enum.GetNames(typeof(ChartColorPalette)))
{
list.Add(item);
}
return list;
} private void cmbPattern_SelectedValueChanged(object sender, EventArgs e)
{
ChartColorPalette palette = (ChartColorPalette)Enum.Parse(typeof(ChartColorPalette),
this.cmbPattern.Text);
this.chartDemo.Palette = palette;
} #endregion }
}
运行效果如下:
资源源码下载地址:http://download.csdn.net/my Winfrom Chart
补充:
一:实现3D效果
private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
{
if (this.comboBox1.Text.Equals("3D"))
{
//this.chartDemo.ChartAreas[0].Area3DStyle.Enable3D = true;
//开启三维模式的原因是为了避免标签重叠
this.chartDemo.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;//开启三维模式;PointDepth:厚度BorderWidth:边框宽
this.chartDemo.ChartAreas["ChartArea1"].Area3DStyle.Rotation = ;//起始角度
this.chartDemo.ChartAreas["ChartArea1"].Area3DStyle.Inclination = ;//倾斜度(0~90)
this.chartDemo.ChartAreas["ChartArea1"].Area3DStyle.LightStyle = LightStyle.Realistic;//表面光泽度
this.chartDemo.ChartAreas["ChartArea1"].AxisX.Interval = ; //决定x轴显示文本的间隔,1为强制每个柱状体都显示,3则间隔3个显示
this.chartDemo.ChartAreas["ChartArea1"].AxisX.LabelStyle.Font = new Font("宋体", , FontStyle.Regular);
this.chartDemo.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;
}
else
{
this.chartDemo.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = false;
}
}
Winform Chart的更多相关文章
- c# winform Chart Pie 中若X轴数据为字符串时,#VALX取值为0
https://q.cnblogs.com/q/83848/ 在winform程序中用自带的Chart进行画图表时,若画饼图,其中X轴数据为字符串,这时候如果想设置Label值的格式为#VALX:#V ...
- c# Winform Chart入门
额外参考链接:http://www.cnblogs.com/greenerycn/archive/2008/10/27/microsoft-chart.html winform 仪表盘相关下载链接:/ ...
- winform Chart控件 获取鼠标处坐标值方法
Chart控件本身功能强大,应用广泛,因此其属性.方法也很多.此处介绍在很多应用中需要查看鼠标位置处坐标值的一些方法 1,调用Chart事件 GetToolTip 利用ToolTipEventArg ...
- WPF 使用WinForm Chart控件
第一步: 页面 首先引用命名空间 xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFor ...
- 使用WinForm Chart控件 制作饼装,柱状,折线图
http://blog.csdn.net/dream2050csdn/article/details/53510340 chart控件的属性很多,主要用到Chart控件图表区域的属性有五个属性 1.A ...
- 【207】WinForm Chart类
目录: 在工具箱中找到 Chart 控件并使用 设置 Chart 属性 代码中设置属性 属性中设置属性 Chart 类说明 ChartAreas ChartAreaCollection 类 Chart ...
- Winform Chart 控件读取datatable后显示图表
private void Button2_Click(object sender, EventArgs e) { DataTable table = new DataTable(); this.cha ...
- C# chart,有关如何在鼠标移动到Series上时显示节点及数据 (有待继续更新)
一.效果与思路 效果: 解决方案1 用chart的mousemove时间,实时跟踪鼠标最近的X轴的位置,然后把cursorX设置到那个位置上,让用户知道我是选的那一个X的值,同时用tooltip显示该 ...
- Winform & Devexpress Chart使用入门
一.Chart(Winform) 使用图表控件(chart)首先要理解图表区域(ChartArea).XY轴(AxisX.AxisY).数据点(Series).标题(Title).图例(Legend) ...
随机推荐
- django配置Ueditor富文本编辑器
1.https://github.com/twz915/DjangoUeditor3下载包,进入包文件夹,找到DjangoUeditor包拷贝到项目下,和xadmin同级目录 2.找到项目的setti ...
- Scrum_Sprint
1.计划会议过程 经过一天的讨论研究,我们对该项目进行了需求分析,确定了这周所要实现的各个功能 并做好了任务看板,并将项目的各个功能分成一个个任务,进行了初步的分工 2.backlog BACKLOG ...
- pytorch基础教程2
1. 四部曲 1)forward; 2) 计算误差 :3)backward; 4) 更新 eg: 1)outputs = net(inputs) 2)loss = criterion(outputs, ...
- Java 构造器Constructor 继承
Java默认构造方法 构造方法作用:初始化所定义的类的对象和属性. 构造方法没有返回类型. 2 继承中的构造器 子类是不继承父类的构造器(构造方法或者构造函数)的,它只是调用(隐式或显式). 如果父类 ...
- arch/arm/Makefile:382: recipe for target 'kernel.img' failed
/********************************************************************** * arch/arm/Makefile:382: rec ...
- 【机器学习基础】SVM实现分类识别及参数调优(二)
前言 实现分类可以使用SVM方法,但是需要人工调参,具体过程请参考here,这个比较麻烦,小鹅不喜欢麻烦,正好看到SVM可以自动调优,甚好! 注意 1.reshape的使用: https://docs ...
- c# 移动鼠标到指定位置
/// <summary> /// 引用user32.dll动态链接库(windows api), /// 使用库中定义 API:SetCursorPos /// </summary ...
- 2018.10.25 CCSP马拉松摸铜归来
24号体测跑50+1000米. 50米抢跑被罚重跑???然后老年人就只能吊着一口仙气跑第二次50米.然后跑1000米,然后再到宿舍收拾行李赶往地铁站,然后再冲到火车站...(卒) 宾馆,三人挤入二人房 ...
- 第六课cnn和迁移学习-七月在线-cv
ppt 参数共享终于把拿一点想清楚啦,一定要知道w是矩阵! 在传统BP中,w前后连接时是all的,辣么多w使得你给我多少图片我就能记住多少信息-->导致过拟合-->cnn当中权值共享 激励 ...
- 2019寒假算法基础集训营1 - B 小a与"204"
题目: 小a非常喜欢这个数字,因为. 现在他有一个长度为的序列,其中只含有这三种数字 设为序列中第个数,你需要重新排列这个数列,使得最大(公式的含义是:每个数与前一个数差的平方的和) 注意:我们默认 ...