Profile Picture

Chart Export Resolution

Posted By Patrick R 15 Years Ago
Author
Message
Patrick R
Posted 15 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 4, Visits: 1
Is it possible to export charts at a resolution higher than 72dpi?

I need my chart to be 300dpi for good print quality. I am importing my chart image into an Adobe InDesign document for PDF generation.

Thanks!

bob milanov
Posted 15 Years Ago
View Quick Profile
Supreme Being

Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)

Group: Forum Members
Last Active: 6 Months Ago
Posts: 153, Visits: 11

Hello Patrick,

 

Yes you can export chart images with different size and resolution. Here is a sample code:

 

nChartControl1.ImageExporter.SaveToFile("c:\\temp\\chart.png", new NSize(400, 400), new NResolution(300, 300), new NPngImageFormat());

 

You can also check the image exporter from the Chart examples.

 

Hope this helps – let me know if you have any questions or comments.

 

Best regards.

Bob



Patrick R
Posted 15 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 4, Visits: 1
Thanks Bob.

I have tried this. When I add "new NResolution(300, 300)" to the parameter list for ImageExporter.SaveToFile() the export image of the chart is mostly black with my chart shrunk down and cruched into the top left corner. I have attached two images exported from the code below. Any ideas?

Thanks!

Patrick



NChartControl nChartCtrl = new NChartControl();

nChartCtrl.Settings.ShapeRenderingMode = ShapeRenderingMode.AntiAlias;

nChartCtrl.BackgroundStyle.FrameStyle.Visible = false;
nChartCtrl.Width = 600;
nChartCtrl.Height = 500;

NChart nChart = nChartCtrl.Charts[0];
nChart.Dock = System.Windows.Forms.DockStyle.Fill;

nChart.DockMargins = new NMarginsL(20, 0, 20, 0);

Random rand = new Random(DateTime.Now.Millisecond);

NLineSeries line = (NLineSeries)nChart.Series.Add(SeriesType.Line);
line.Values.FillRandom(rand, 10);

NPngImageFormat pngFormat = new NPngImageFormat();
pngFormat.PixelFormat = System.Drawing.Imaging.PixelFormat.Format24bppRgb;

NResolution resolution = new NResolution(300, 300);

nChartCtrl.ImageExporter.SaveToFile("C:\\Test\\chart300.png", new NSize((int)nChartCtrl.Width, (int)nChartCtrl.Height), resolution, pngFormat);

nChartCtrl.ImageExporter.SaveToFile("C:\\Test\\chart72.png", new NSize((int)nChartCtrl.Width, (int)nChartCtrl.Height), NResolution.ScreenResolution, pngFormat);


Attachments
chart300.png (43 views, 10.00 KB)
chart72.png (51 views, 16.00 KB)
Patrick R
Posted 15 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 4, Visits: 1
I actually just noticed that if I remove the line:

pngFormat.PixelFormat = System.Drawing.Imaging.PixelFormat.Format24bppRgb;

The black space disappears and the chart fills the entire image. However, all the contents of the chart remain crammed together.

How can I preserve the intended look of the chart (72dpi) when I export to 300dpi?

I have attached a recent version.


Thanks!

Patrick

Attachments
chart300.png (43 views, 23.00 KB)
bob milanov
Posted 15 Years Ago
View Quick Profile
Supreme Being

Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)

Group: Forum Members
Last Active: 6 Months Ago
Posts: 153, Visits: 11

Hi Patrick,

 

Regarding the black image - I was not able to reproduce it with the current version of the control, even if I change the pixel format.

 

NChartControl nChartCtrl = new NChartControl();

nChartCtrl.Settings.ShapeRenderingMode = ShapeRenderingMode.AntiAlias;

nChartCtrl.BackgroundStyle.FrameStyle.Visible = false;

nChartCtrl.Width = 600;

nChartCtrl.Height = 500;

 

NChart nChart = nChartCtrl.Charts[0];

nChart.Dock = System.Windows.Forms.DockStyle.Fill;

 

Random rand = new Random(DateTime.Now.Millisecond);

 

NLineSeries line = (NLineSeries)nChart.Series.Add(SeriesType.Line);

line.Values.FillRandom(rand, 10);

 

NPngImageFormat pngFormat = new NPngImageFormat();

pngFormat.PixelFormat = System.Drawing.Imaging.PixelFormat.Format24bppRgb;

 

NResolution resolution = new NResolution(300, 300);

 

float xScale = resolution.DpiX / NResolution.ScreenResolution.DpiX;

float yScale = resolution.DpiX / NResolution.ScreenResolution.DpiY;

 

nChartCtrl.ImageExporter.SaveToFile("C:\\temp\\chart300.png", new NSize((int)(xScale * nChartCtrl.Width), (int)(yScale * nChartCtrl.Height)), resolution, pngFormat);

 

nChartCtrl.ImageExporter.SaveToFile("C:\\temp\\chart72.png", new NSize((int)nChartCtrl.Width, (int)nChartCtrl.Height), NResolution.ScreenResolution, pngFormat);

 

I used the above code - in general you also need to scale the chart dimensions - the resolution setting will generally change the size of 2D objects like texts as well as everything else that uses absolute measurement units.

 

Hope this helps - let me know if you have any questions or meet any problems.

 

Best regards,
Bob





Similar Topics


Reading This Topic