简体   繁体   English

不使用WinForms更改DataVisualization.Chart大小

[英]Changing DataVisualization.Chart size without using WinForms

I have an Web Service that generates different kinds of charts. 我有一个Web服务,可以生成各种图表。 The charts are generated programatically using System.Windows.Forms.DataVisualization.Charting and they are saved to .png files. 这些图表是使用System.Windows.Forms.DataVisualization.Charting以编程方式生成的,并将它们保存到.png文件中。 But whatever I do, the charts have the dimension 300x300 pixels. 但是无论我做什么,图表的尺寸都是300x300像素。

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. 在Internet上,我发现了许多更改图表大小的解决方案,但是它们仅适用于将图表放入WinForm然后保存到文件的情况。

How can I change the size of the chart if I don't have WinForms in my application? 如果我的应用程序中没有WinForms,如何更改图表的大小?

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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 DataVisualization.Chart的样式化图形和工具提示 - Stylizing graphs and tooltip of DataVisualization.Chart DataVisualization.Chart,如何使X轴间隔更大? - DataVisualization.Chart, how can I make the X-axis interval larger? 使用System.Web.UI.DataVisualization.Charting命名空间更改饼图上的标签颜色 - Changing the label color on a Pie Chart using System.Web.UI.DataVisualization.Charting namespace 如何使用Web.UI.DataVisualization.Charting绘制图表? - How to chart using Web.UI.DataVisualization.Charting? C#:System.Windows.Forms.DataVisualization.Charting.Chart设置行大小 - C#: System.Windows.Forms.DataVisualization.Charting.Chart Set Line Size 数据可视化图表轴动态位置 - Datavisualization Chart Axes dynamic location 更改winforms应用程序的字体系列和大小 - Changing the font family and size for a winforms app 如何在不写入文件的情况下将DataVisualization.Charting.Chart的图像获取到iTextSharp.text.Image? - How may I get the image of DataVisualization.Charting.Chart to iTextSharp.text.Image without writing to a file? 有没有一种方法可以使用System.Web.UI.DataVisualization.Charting旋转烛台图表以水平显示,而不是垂直显示? - Is there a way using System.Web.UI.DataVisualization.Charting to rotate a Candlestick chart to display horizontally instead of vertically? 不使用WinForms旋转光标 - Rotating cursor without using WinForms
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM