The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
When I send the Chart to an image, how can I control the resolution that the picture is saved as?
I am currently creating the Chart control within an ActiveReports file. To display the chart correctly, I must send the chart to an image, then load that image into the Picture1 control within the ActiveReport. What is happening now is that the chart displays great within the Report, but when sent to a file or the printer (via the reporting tool) the reduction of pixels is significant. I suspect this is because I am not sending the chart image with a large enough resolution.
ChartSeries Series = cc.Model.NewSeries("Title", ChartSeriesType.Pie);
// Load Data
// Specify Chart Properties
Size sizePix = new Size((int)(this.Picture1.Size.Width*96), this.Picture1.Size.Height*96));
Image img = new Bitmap(sizePix.Width, sizePix.Height);
cc.Draw(img);
this.Picture1.Image = img;
Have you dealt with this behaviour at all? I know it isn''t directly related because I am using ActiveReports, but if you do have any information I would greatly appreciate it.
*note - I already talked to ActiveReports and they mentioned it is likely an image resolution specification within the Chart control.
Thanks, Kevin
Just thought I would mention, that I am using the method described in the example:
http://www.syncfusion.com/support/user/Uploads/EssentialChartActiveReports_2860.zip
specified in the forum link:
http://www.syncfusion.com/Support/forums/message.aspx?MessageID=15523
Thanks,
DJDavis Jebaraj Syncfusion Team June 24, 2004 12:23 PM UTC
Hi Kevin,
The resolution of the image printed by the printer is lower because the sizing of the image is intended for on screen display (We used a factor of 96 for the screen''s PPI Pixels Per Inch).
You could change the 96 to be 300 or 600 to reflect the Dots Per Inch DPI of the printer. This will change the size of the image on the screen. We can set the Picture control property''s SizeMode property to accomodate this change. Also, the font sizes for the Title and axes will have to be increased for higher resolutions. Please see the code below:
private void Detail_Format(object sender, System.EventArgs eArgs)
{
Syncfusion.Windows.Forms.Chart.ChartControl cc = new Syncfusion.Windows.Forms.Chart.ChartControl();
cc.Model.ColorModel.Palette = ChartColorPalette.Pastel;
cc.PrimaryXAxis.Title = "Resource Labor Costs";
cc.PrimaryYAxis.Title = "Hours Worked";
ChartSeries Series = cc.Model.NewSeries ( "Resource Costs ", ChartSeriesType.Column );
for ( int j = 0; j < 20; j++ )
{
Series.Points.Add ( Convert.ToDouble ( j ), Convert.ToDouble ( j + 1 ) );
}
Series.Style.DisplayText = false;
Series.Style.DisplayShadow = true;
Series.Style.Symbol.Shape = ChartSymbolShape.Square;
Series.Style.Symbol.Size = new Size ( 15, 15 );
Series.Style.Symbol.Color = Color.Blue;
Series.Style.Border.Color = Color.FromArgb(100, Color.BlueViolet);
Series.Style.Border.DashStyle = DashStyle.DashDotDot;
cc.Series.Add(Series);
cc.LegendPosition = ChartLegendPosition.Top;
cc.PrimaryXAxis.DrawGrid = false;
cc.PrimaryYAxis.DrawGrid = false;
cc.Legend.Visible = false;
//Higher Resolution Image Begin
this.arPictureControl.SizeMode = SizeModes.Stretch;
cc.Font = new Font(cc.Font.Name , 72);
cc.PrimaryXAxis.Font = new Font(cc.PrimaryXAxis.Font.Name , 48);
cc.PrimaryYAxis.Font = new Font(cc.PrimaryYAxis.Font.Name , 48);
// Convert ActiveReports'' Inches
System.Drawing.Size sizePix = new System.Drawing.Size(
(int)(this.arPictureControl.Size.Width*600),
(int)(this.arPictureControl.Size.Height*600));
// Higher Resolution Image End
// Lower Resolution Image Begin
/*System.Drawing.Size sizePix = new System.Drawing.Size(
(int)(this.arPictureControl.Size.Width*96),
(int)(this.arPictureControl.Size.Height*96));
*/
// Lower Resolution Image End
Image img = new Bitmap(sizePix.Width,sizePix.Height);
cc.Draw(img);
this.arPictureControl.Image = img;
}
Regards,
Davis