在Windows窗体应用程序中,我想为每列设置自定义宽度。例如,从x = 1到x = 3,y = 1。
这就是我所做的
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;
chart1.Series[0].XValueMember = "Time";
chart1.Series[0].YValueMembers = "Busy";
chart1.ChartAreas[0].AxisX.IntervalOffsetType = DateTimeIntervalType.Number;
this.chart1.Series["ServerBusyTime"].Points.AddXY(2, 10);
this.chart1.Series["ServerBusyTime"].Points.AddXY(1, 5);
this.chart1.Series["ServerBusyTime"].Points.AddXY(3, 5);
this.chart1.Series["ServerBusyTime"].Points.AddXY(4, 5);
结果如下:
这就是我想要的:
答案 0 :(得分:0)
您必须添加一个
[..].AddXY(x,1)
对于要添加到图表的每个x值
for (var i1 = 2; i < 6; i++)
this.chart1.Series["ServerBusyTime"].Points.AddXY(i1, 1);
for (var i2 = 10; i < 20; i++)
this.chart1.Series["ServerBusyTime"].Points.AddXY(i2, 1);