资源简介
VS中提供的MSChart控件功能强大,但是最多只支持2个Y轴。在实际运用中,有的时候需呀Chart有多个Y轴,本Demo实现了MSChart的多Y轴实现,给大家分享。

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms.DataVisualization.Charting;
namespace WindowsFormsApplication9
{
class ChartController
{
private Chart chart;
private ChartArea drawArea; // 画图区域
private ChartArea newYAxisArea; //为了添加Y轴而创建的区域
private float positionX = 3; //最左边画图区域X坐标
private float positionY = 3; //最左边画图区域Y坐标
private Color seriesColor = Color.Red;
public ChartController(Chart chart)
{
this.chart = chart;
positionX = chart.ChartAreas[0].Position.X;
positionY = chart.ChartAreas[0].Position.Y;
}
public void AddYAxis(ChartArea area Series series float axisOffset)
{
drawArea = area;
createYAxis(series axisOffset);
chart.Update();
drawGraph(series);
}
///
/// 创建Y轴
///
/// 指定画图区域
/// 序列
/// Y轴间距
private void createYAxis(Series series float axisOffset)
{
newYAxisArea = chart.ChartAreas.Add(“AxisY_“ + series.Name);
newYAxisArea.Position.Auto = false;
newYAxisArea.Position.Y = positionY;
newYAxisArea.Position.X = positionX;
newYAxisArea.Position.Height = drawArea.Position.Height;
newYAxisArea.Position.Width = drawArea.Position.Width;
moveArea(chart.ChartAreas newYAxisArea axisOffset);
//网格线不可见
newYAxisArea.AxisX.MajorGrid.Enabled = false;
newYAxisArea.AxisX.MajorTickMark.Enabled = false;
newYAxisArea.AxisY.MajorGrid.Enabled = false;
// X轴线、刻度透明
newYAxisArea.AxisX.Labelstyle.ForeColor = Color.Transparent;
newYAxisArea.AxisX.LineColor = Color.Transparent;
//背景透明
newYAxisArea.BackColor = Color.Transparent;
//图例不可见
seriesColor = series.Color;
series.IsVisibleInLegend = false;
series.Color = Color.Transparent;
series.ChartArea = newYAxisArea.Name;
}
///
/// 移动画图区域
///
/// 画图区域集合
/// 不移动的画图区
/// 偏移量
private void moveArea(ChartAreaCollection areas ChartArea unMovedArea float axisOffset)
{
foreach (ChartArea area in areas)
{
if (area != unMovedArea)
{
area.Position.X += axisOffset;
}
}
}
private v
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 187 2014-10-09 11:05 WindowsFormsApplication9\WindowsFormsApplication9\App.config
文件 13824 2014-10-09 17:22 WindowsFormsApplication9\WindowsFormsApplication9\bin\Debug\WindowsFormsApplication9.exe
文件 187 2014-10-09 11:05 WindowsFormsApplication9\WindowsFormsApplication9\bin\Debug\WindowsFormsApplication9.exe.config
文件 30208 2014-10-09 17:22 WindowsFormsApplication9\WindowsFormsApplication9\bin\Debug\WindowsFormsApplication9.pdb
文件 24224 2014-10-10 09:38 WindowsFormsApplication9\WindowsFormsApplication9\bin\Debug\WindowsFormsApplication9.vshost.exe
文件 187 2014-10-09 11:05 WindowsFormsApplication9\WindowsFormsApplication9\bin\Debug\WindowsFormsApplication9.vshost.exe.config
文件 490 2010-03-17 22:39 WindowsFormsApplication9\WindowsFormsApplication9\bin\Debug\WindowsFormsApplication9.vshost.exe.manifest
文件 4148 2014-10-09 15:45 WindowsFormsApplication9\WindowsFormsApplication9\ChartController.cs
文件 2275 2014-10-09 15:32 WindowsFormsApplication9\WindowsFormsApplication9\Form1.cs
文件 4575 2014-10-09 15:31 WindowsFormsApplication9\WindowsFormsApplication9\Form1.Designer.cs
文件 5817 2014-10-09 15:31 WindowsFormsApplication9\WindowsFormsApplication9\Form1.resx
文件 1626 2014-10-10 09:38 WindowsFormsApplication9\WindowsFormsApplication9\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 7178 2014-10-09 13:57 WindowsFormsApplication9\WindowsFormsApplication9\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 0 2014-10-09 11:05 WindowsFormsApplication9\WindowsFormsApplication9\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
文件 0 2014-10-09 11:05 WindowsFormsApplication9\WindowsFormsApplication9\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
文件 0 2014-10-09 11:05 WindowsFormsApplication9\WindowsFormsApplication9\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
文件 1014 2014-10-10 09:38 WindowsFormsApplication9\WindowsFormsApplication9\obj\Debug\WindowsFormsApplication9.csproj.FileListAbsolute.txt
文件 977 2014-10-09 15:31 WindowsFormsApplication9\WindowsFormsApplication9\obj\Debug\WindowsFormsApplication9.csproj.GenerateResource.Cache
文件 2384 2014-10-09 13:59 WindowsFormsApplication9\WindowsFormsApplication9\obj\Debug\WindowsFormsApplication9.csprojResolveAssemblyReference.cache
文件 13824 2014-10-09 17:22 WindowsFormsApplication9\WindowsFormsApplication9\obj\Debug\WindowsFormsApplication9.exe
文件 180 2014-10-09 15:31 WindowsFormsApplication9\WindowsFormsApplication9\obj\Debug\WindowsFormsApplication9.Form1.resources
文件 30208 2014-10-09 17:22 WindowsFormsApplication9\WindowsFormsApplication9\obj\Debug\WindowsFormsApplication9.pdb
文件 180 2014-10-09 13:59 WindowsFormsApplication9\WindowsFormsApplication9\obj\Debug\WindowsFormsApplication9.Properties.Resources.resources
文件 536 2014-10-09 11:05 WindowsFormsApplication9\WindowsFormsApplication9\Program.cs
文件 1390 2014-10-09 11:05 WindowsFormsApplication9\WindowsFormsApplication9\Properties\AssemblyInfo.cs
文件 2900 2014-10-09 11:05 WindowsFormsApplication9\WindowsFormsApplication9\Properties\Resources.Designer.cs
文件 5612 2014-10-09 11:05 WindowsFormsApplication9\WindowsFormsApplication9\Properties\Resources.resx
文件 1111 2014-10-09 11:05 WindowsFormsApplication9\WindowsFormsApplication9\Properties\Settings.Designer.cs
文件 249 2014-10-09 11:05 WindowsFormsApplication9\WindowsFormsApplication9\Properties\Settings.settings
文件 3942 2014-10-09 13:59 WindowsFormsApplication9\WindowsFormsApplication9\WindowsFormsApplication9.csproj
............此处省略13个文件信息
相关资源
- WPF USB 网络 串口 通信软件
- B/S 网上订餐系统
- 教室管理系统.rar
- 小鸡快跑游戏.
-
分别适用于.NET fr
amework 2.0和4.0的E - 汽车租赁系统............................
- 德卡D8读写器关于读写感应卡的一些代
- halcon 测量助手
- 图片存储到数据库保存二进制文件并
- 用Socket写的简易FTP服务器和客户端
- 企业销售管理信息系统(全套)
- 串口操作类(justinio)
- 基于Petri网的工作流(完整的原创源代
- 选择题自动考试系统
- 多线程实例:桌面智能弹球小游戏
- 土地信息管理系统
- ServiceStack V3.9 全部dll
- PDF pdfview.ocx 无水印
- MSChart使用手册
- 无需共享打印机实现远程打印功能小
- 真正的破解版PDFView4NET
- 网页调用ActiveX控件获取串口数据
- Luence的与盘古分词的使用软件
- Emgu.CV 打开视频与人脸检测
- 麦克纳姆轮程序.rar
- Unity3D 实战视频教程 保卫萝卜 2D 游戏
- net微信支付
- lucene.net+盘古分词多条件全文检索并匹
- 闪电猫-电商下图助手5.0.zip
- FastReport.Net V2014.4.8 For .Net2.0
评论
共有 条评论