0

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

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

Goldarrow
  • 43
  • 1
  • 8
  • 2
    which chart control you are using? – Joseph Jun 25 '15 at 10:57
  • In actualy, I want to use Box Plot Type – Goldarrow Jun 25 '15 at 11:59
  • 1
    As far as I can tell there is no easy option for that, see: http://stackoverflow.com/questions/2137157/force-a-gap-between-points-on-the-x-axis-ms-net-chart-controls-column-chart – Stefan Orie Jun 25 '15 at 14:48
  • You are talking about the distance between the Columns of the various Series, not the distance between DataPoints, right? The above link tried to solve the latter problem; I doubt there is a good solution for either, amazingly.. I have tried to insert dummy Series as spacers but they always tended to be too large. – - See [here](http://stackoverflow.com/questions/29451045/how-can-i-manipulate-winforms-chart/29459902?s=40|1.1882#29459902) for the solution I posted then.. – TaW Jun 25 '15 at 17:50

2 Answers2

1

Try reducing the value of the custom property PointWidth for each series as follows:

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. 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.

Brett Wolfington
  • 6,587
  • 4
  • 32
  • 51
  • I tried with you suggestion already, but it not work. and this link https://www.img.in.th/image/TCy is the picture of my chart. i want to space on the position that i mark Red Arrow on this picture. Help me please. – Goldarrow Jun 25 '15 at 13:58
  • This only results in more space between the datapoints not between the series. – TaW Jun 25 '15 at 18:09
0

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";
Thiru
  • 1
  • 1