carl.xie87
carl.xie87

Reputation: 113

How to set chart bar's width?

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?

http://priv.hiphotos.baidu.com/album/s%3D308%3Bq%3D90/sign=131a1ec68bd4b31cf43c92bbbfed5642/d4628535e5dde711c9184673a7efce1b9c166168.jpg?psign=de6394777d1ed21b3ae15fd4ad4712a551da81cb3bdb1fb1

Upvotes: 11

Views: 35724

Answers (4)

Kauno Medis
Kauno Medis

Reputation: 93

VB.NET version of same problem:

Dim EL As New Series
EL.ChartType = SeriesChartType.Column
EL.Name = "Series name"
EL.SetCustomProperty("PixelPointWidth", "1")
EL.Points.AddXY(x, y)
Chart1.Series.Add(EL)

This custom property is not accessible using chart properties. If this property is uninitialized, width of the chart bar is random!.

Upvotes: 1

jeyaramg
jeyaramg

Reputation: 11

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.

Settting PixelPointWidth

Upvotes: 1

Guest
Guest

Reputation: 71

You can use the following Code :

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

Thank you.

Upvotes: 7

Pilgerstorfer Franz
Pilgerstorfer Franz

Reputation: 8359

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

Chart bar width 1px

Upvotes: 18

Related Questions