Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WinForm chart control: Change size of chart when saving it to a file

is there a way to change size of chart when using method Chart.SaveImage() from the source code?

Right now the only way I found to set the size of chart, is resize the form on which chart control (System.Windows.Forms.DataVisualization.Charting.Chart) sits. Can I explicit set its width and height? Trying to change Chart.Size, Chart.Width or Chart.Size doesn't work.

like image 816
pascon Avatar asked Nov 01 '25 16:11

pascon


2 Answers

All right. The solution was so obvious that I couldn't found it thou 3 days - I had setted Chart.Dock = DockStyle.Fill, so changing Size property doesn't affect. After modified it to DockStyle.None I could change chart's size and (finally!) save it with appropriative width and height.

like image 115
pascon Avatar answered Nov 04 '25 08:11

pascon


You can define it by redefining the Size property of the chart :

var ch = new Chart();
ch.Size = new Size(600, 250);
like image 41
aceregid Avatar answered Nov 04 '25 08:11

aceregid



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!