I have an Web Service that generates different kinds of charts. The charts are generated programatically using System.Windows.Forms.DataVisualization.Charting
and they are saved to .png files. But whatever I do, the charts have the dimension 300x300 pixels.
On the internet I have found many solutions on changing the size of the chart, but they only apply to situations where the chart is put into a WinForm and then saved to a file.
How can I change the size of the chart if I don't have WinForms in my application?
This is a dummy example of what I do in my code
int[] yVal = { 1, 1, 1, 1, 1, 1, 1 };
string[] xName = { "a", "b", "b", "b", "b", "b", "b" };
System.Windows.Forms.DataVisualization.Charting.Chart Chart1 = new Chart();
Chart1.Titles.Add("Title");
Chart1.Series.Add(new Series());
Chart1.Series[0].XValueType = ChartValueType.String;
Chart1.Series[0].YValueType = ChartValueType.Int32;
Chart1.Series[0].Points.DataBindXY(xName, yVal);
Chart1.Palette = ChartColorPalette.EarthTones;
Chart1.Legends.Add(new Legend());
Chart1.Legends[0].Enabled = false;
ChartArea chartArea = new ChartArea();
chartArea.AxisX.Title = "X";
chartArea.AxisY.Title = "Y";
Chart1.ChartAreas.Add(chartArea);
Chart1.SaveImage("chart.png", ChartImageFormat.Png);
要获得1000px x 1000px的大图像,请在图表初始化后添加以下行:
Chart1.Size = new Size(1000, 1000);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.