C# 如何设置图表栏的宽度?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12525997/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 23:34:00  来源:igfitidea点击:

How to set chart bar's width?

c#winformscharts

提问by carl.xie87

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?

我正在使用 Visual Studio 2010 在 C# 中编写 Winforms 应用程序。我正在使用常规工具箱中的图表控件来查看我的 SQL 数据库中的数据。如您所见,酒吧很宽。是否有一些属性或方法可以使它更小并固定?

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

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

采纳答案by Pilgerstorfer Franz

I did a small example binding three valuesand set the PixelPointWidthof dataPointCustomProperties.

我做了一个小例子结合三个值和设定PixelPointWidthdataPointCustomProperties

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

Chart bar width 1px

回答by Guest

You can use the following Code :

您可以使用以下代码:

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

Thank you.

谢谢你。

回答by jeyaramg

You can also set the PixelPointWidthin the report designer as below.

您还可以PixelPointWidth在报表设计器中进行如下设置。

  1. Click on the chart series, press F4to show the properties.
  2. Change the PixelPointWidthin CustomAttributesnode.
  1. 单击图表系列,按F4显示属性。
  2. 更改PixelPointWidthinCustomAttributes节点。

Settting PixelPointWidth

Settting PixelPointWidth