资源简介
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个文件信息
相关资源
- 基于.NET的酒店管理系统
- 设置RichTextBox的文本对齐方式
- ajax异步刷新,一般处理程序返回dat
- ArcEngine二次开发中AOI书签开发实现的
- 表白小程序,有源代码,不会写代码
- 使用treeview listview实现我的资源管理器
- GDI+绘图功能软件
- MODBUS-CSharp tcp测试正常
- HttpHelper 爬虫应用类库 苏飞万能框架
- HID USB设备通讯-源代码 UsbLibrary
- vs2008下编写带括号计算器
- C_#_TCP发送消息和传输文件
- 注册机获取CPU信息并使用MD5多重加密
- 算法 Point 是否在多边形内
- addFlowFor.net 画流程图的
-
nunit.fr
amework.dll很有用的 - DevComponents.DotnetBar控件
- 自己做的FEMTOCELL环境仿真
- BACnet协议源码
- kinect控制PPT翻页
- 地下停车场车辆管理系统
- O2S.Components.PDFRender4NET.dll 4.5.1无水印
- 自己动手改造TabControl--从山寨Safari开
- 用GDI+绘制极坐标图
- OA人员选择模块Js+JSON
- 航空管理系统
- 资源管理器
- 学生健康管理系统 软件工程大作业
- LitJson源码--cs文件
- redupload多文件上传控件 dll
评论
共有 条评论