How to set chart bar's width?

2019-03-25 14:43发布

问题:

I'm using Visual Studio 2010 to write a Winforms application in C#. I'm using the chart control from the regular toolbox to view data from my SQL database. As you see, the bar is very wide. Is there some property or way to make it smaller, and fixed?

回答1:

I did a small example binding three values and set the PixelPointWidth of dataPointCustomProperties.

int[] liste = new int[] { 1, 2, 3 };//, 4, 5, 6, 7 };
chart1.Series["Series1"].Points.DataBind(liste, "sampleData", "count", "Tooltip=count");
// dataPointCustomProperties
chart1.Series["Series1"]["PixelPointWidth"] = "1";

will result in this chart



回答2:

You can use the following Code :

Chart1.Series["Series1"]["PixelPointWidth"] = "15";

Thank you.



回答3:

You can also set the PixelPointWidth in the report designer as below.

  1. Click on the chart series, press F4 to show the properties.
  2. Change the PixelPointWidth in CustomAttributes node.