When drawing graphs as e.g. "Line", "Spline" or "Point" graphs for a scientific application we are developing, we have found the data points appear to get rasterised, i.e. aligned with a relatively low-resolution grid.
The attached enlargement shows the effect: a "Point" graph is shown containing some 3000 data points evenly distributed along the X-axis. In the individual sections, the raw data should result in smooth curves (almost lines) being drawn.
Clearly the data points get "grouped" to discrete positions along the X-axis producing the visibly jagged effect ("steps"). The Y-axis also appears to be subject of the low resolution, though the effect is less visible on the attached picture.
We have unsuccessfully searched through the wizard and support forums… is there anything obvious we're missing?
If not, how can this issue be solved? For an application like the one we're developing the ability to plot precise and correct graphs is of utmost importance, so we are extremely thankful for any help provided.
Thanks a lot in advance!
ChartDiagram plot low precision / resolution issue
Answers approved by DevExpress Support
Hi Alan,
I want to reactivate this thread with additional details. I understand that this is a very long-lasting issue that needs to be resolved. Allow me to provide you with some background.
The XRChart control is an adapted version of the corresponding WinForms component - ChartControl. In other words, XRChart is a sort of container for the ChartControl, which makes it possible to use Charts in Reports. The ChartControl uses advanced drawing capabilities (OpenGL, GDI+), while our PDF export routine utilizes common native PDF commands to generate the PDF content. That is why we cannot use all the ChartControl possibilities on exporting to PDF. As a result, we are forced to convert the XRChart to an image in order to display it in the resulting document.
We discussed the possibility of implementing the mechanism for export vector images (and charts in a vector format) to PDF with our developers multiple times. After thorough research, we came to the distressing conclusion that it is almost impossible to embed this mechanism into our current export routines, and we would be looking at a complete rewrite of the PDF export mechanism. Again, I understand this limitation is fairly mature, but a highly demanded functionality. However, we still cannot promise or estimate anything regarding this feature right now. I suggest that you keep tracking the Export to PDF - Support exporting of vector EMF and WMF images in native PDF commands request to stay informed of our progress.
In the meantime, I can only suggest that you use a temporary solution offered by Peter Thorpe in the mentioned thread. When you export a report to PDF, export the content of XRCharts to images in EMF format in order to draw these images to high-resolution Bitmaps. After that, replace all XRCharts with XRPictureBoxes and pass the corresponding images to their Image property. In this case, charts will be exported with a higher quality. I have attached a sample project (dxSample.zip) to demonstrate this approach in action (for both direct export and from Print Preview).
We examined the possibility of embedding this temporary solution, so it is available out-of-the-box, like an option. However, increasing the image resolution may significantly increase memory consumption, decrease performance and rendering speed in the PDF Viewers (e.g., Adobe Reader), and it may cause more issues than benefits. We tend to think that this would not be a good step.
If you have any questions, let me know. I will be happy to help you resolve any difficulties.
Hi Kevin,
Thank you for the follow-up. It appears that the sample code snippet is related to the DXCharts Suite (WPF). If possible, create a separate ticket and provide your sample project to illustrate the difference with the built-in and custom export methods. We will check for a suitable solution for you.
Hi Daniel,
The vector image format (WMF, EMF) is supported by the ChartControl.ExportToImage method. This should make it possible to rescale and print the resulting chart image with best results. If you are referring to a different scenario, let us know. We will be happy to help you.
Hello Alan,
Thank you for the detailed information. Unfortunately, there is no good way to obtain a desired chart quality. Currently, you can try to use the approach shown in the Line Chart has distorted lines thread. Please try this solution and let us know about the results.
Thanks,
Alessandro.
Hi Alessandro!
Thank you for your prompt reply and the link to the related thread. Indeed, the problem experienced there is the same we are seeing. Likewise, the proposed workaround does not give the desired results. Even with the "smoothing" effect of BMP generation, the positions of the data points can be seen to be rasterised.
There appears to be an issue with the underlying drawing routines which round positions in order to align points to a grid which is altogether too rough for rendering precise data. In our case, the data is part of an engineering application and is safety-relevant as well as subject to scrutiny by regulatory bodies - so any workaround which modifies the output data will in all likelyhood not be acceptable to our customers.
Somewhere in the plotting routines, the size of the cells of the grid the data points are aligned to must be defined and can surely be adapted to provide a higher output resolution. I am convinced many users would benefit from a drawing engine which provides correct results down to the available printing resolution.
I am looking forward to hearing from you with a suggestion as to how we can proceed in this matter. To date we are highly satisfied with XtraReports and hope to expand its usage across multiple projects of ours; therefore we sincerely hope we can come to a satisfying solution in this matter.
Best regards and thanks in advance,
Alan
Hello Alan,
Most likely, you're referring to the behavior that is by design because the BMP is a pixel format. I've prepared a small sample, demonstrating the difference between chart images rendered into different formats. The best quality is achieved when the chart is rendered into a metafile format (XRChart.ImageType = ChartImageType.Metafile). Please review this sample and let me know whether this information was helpful.
Thanks,
Alessandro.