简体   繁体   English

系列之间的C#图表空间

[英]C# Chart space between series

I tried to create Bar chart to represent my data with more series data. 我试图创建条形图以用更多系列数据表示我的数据。 It seem to be good,but when i run my application the bar in each data series is too closed, so i want to modified my chart to space bar from each data series, but I can not solve this problem. 看起来不错,但是当我运行我的应用程序时,每个数据系列中的条形太封闭,因此我想将图表修改为每个数据系列中的空格,但是我无法解决此问题。

And this is my code to add 3 data Series to chart and 这是我的代码,将3个数据系列添加到图表并

chart1.Series["S1"].Points.AddXY(1, 5);
chart1.Series["S1"].Points.AddXY(2, 6);
chart1.Series["S1"].Points.AddXY(3, 7);
chart1.Series["S1"].Points.AddXY(4, 2);
chart1.Series["S1"].Points.AddXY(5, 8);

chart1.Series["S2"].Points.AddXY(1, 5);
chart1.Series["S2"].Points.AddXY(2, 6);
chart1.Series["S2"].Points.AddXY(3, 7);
chart1.Series["S2"].Points.AddXY(4, 2);
chart1.Series["S2"].Points.AddXY(5, 8);

chart1.Series["S3"].Points.AddXY(1, 5);
chart1.Series["S3"].Points.AddXY(2, 6);
chart1.Series["S3"].Points.AddXY(3, 7);
chart1.Series["S3"].Points.AddXY(4, 2);
chart1.Series["S3"].Points.AddXY(5, 8);

and this is my chart https://www.img.in.th/image/TCy 这是我的图表https://www.img.in.th/image/TCy

Try reducing the value of the custom property PointWidth for each series as follows: 尝试减少每个系列的自定义属性PointWidth的值,如下所示:

chart1.Series["S1"]["PointWidth"] = "0.5";
chart1.Series["S2"]["PointWidth"] = "0.5";
chart1.Series["S3"]["PointWidth"] = "0.5";

The default value for this property is 0.8. 此属性的默认值为0.8。 Lower values will make the bars narrower, which will result in more space between them. 较低的值会使条形变窄,这将导致它们之间有更多的空间。 The maximum value of 1 will result in no space between each bar. 最大值1将导致每个条之间没有空格。

After binding the Data to the Chart Control, finally you can put the below code 将数据绑定到图表控件之后,最后可以将以下代码放入

chart1.AlignDataPointsByAxisLabel();

if you want to reduce the bar width you can use 如果您想减小钢筋宽度,可以使用

chart1.Series[0]["PointWidth"]="0.3";
chart1.Series[1]["PointWidth"]="0.3";
chart1.Series[2]["PointWidth"]="0.3";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM