Hello.
I am using both ChartContorl and WebChartControl, in the ChartContorl there is the ability to export the chart into pdf format or html format and other formats.
I couldn't find how to do it in the WebChartControl.
How can i do it ?
Thanks,
Koby.
p.s. i am also using PivotGrid and ASPxPivotGrid and on both i have the ability to export.
We have closed this ticket because another page addresses its subject:
Web - Capability to print and export a WebChartControl on the client sideExport from WebChartControl
Answers approved by DevExpress Support
Hello Koby,
First, about the problem with exporting a chart to PDF and XLS. I must say that this problem isn't specific to Web charts only - you may observe the same behavior when resizing a Windows Forms chart. The current behavior presumes that the diagram is hidden when there isn't enough space for it on a chart (for example, when a legend occupies too much space). And, when you export a chart to PDF in your example, it turns out that the chart is resized to fit the page width (which is used in the resulting PDF file), and its size in PDF is smaller than its size on the Web page. That is why the diagram is visible on a Web page, but is hidden in PDF and XLS.
To avoid this problem I suggest you to do one of the following:
- Set winChart.OptionsPrint.SizeMode = DevExpress.XtraCharts.Printing.PrintSizeMode.None and then manually set the chart size.
or - Set the Legend.AlignmentHorizontal property to Center, AlignmentVertical to TopOutside and Direction to LeftToRight.
This should help.
As for exporting a report to HTML, it seems to be impossible to export a chart in such a way. The reason is that the stream can contain only one file, and this is the HTML file in your case. A chart image can't be saved anywhere, and so that is why the HTML output is empty. Could you please explain, why do you need to export a chart to HTML and MHT from a Web Page?
Best regards, Alan.
R&D, .NET Team.
Hi,
I did everything you said in order to export the WebChartControl but the PDF file shows an empty Chart container. By the way the WebChartControl is created dinamically at runtime in C#. What am I doing wrong? Any help would be appreciated.
Cheers, Patricia
PS. please find attached the PDF file
Hi Patricia,
Please check to see that your runtime chart initialization routine is executed on every round trip to the server (i.e., via the Page_Load event). If this does not help, create a separate ticket and provide a small sample project to illustrate the issue. We will be glad to help you.
Hello Koby,
Sorry, this task can't be easily solved with the WebChartControl. So, we suggest that you use the following code:
protected void Button1_Click(object sender, EventArgs e) { ChartControl winChart = new ChartControl(); (((IChartContainer)winChart).Chart).Assign(((IChartContainer)this.WebChartControl1).Chart); winChart.ExportToPdf("chart.pdf"); }
Please see the attached project, which illustrates how this can be done.
Also, if you wish this behavior to be improved in the future, please track the corresponding suggestion (Web - Capability to print and export a WebChartControl on the client side), and you'll be notified when it's implemented.
Best regards, Alan.
R&D, .NET Team.
Thank for your answer Alan.
Well, i get it to work now, but i got a big problem about the size of the of the image on the pdf.
As you can see on the project I attached, the size of the chart is too big for my data.
How can i make the image on the pdf to fit one and fill one pdf page ?
I simply wants to show the chart as bigger as possible one one pdf page.
Thanks,
Koby.
Hello Koby,
For this, please try to set the winChart.OptionsPrint.SizeMode property to either Zoom or Stretch.
For example:
(((IChartContainer)winChart).Chart).Assign(((IChartContainer)this.WebChartControl1).Chart); winChart.OptionsPrint.SizeMode = DevExpress.XtraCharts.Printing.PrintSizeMode.Zoom; winChart.ExportToPdf(stream);
Does this help you?
Best regards, Alan.
R&D, .NET Team.
Thanks for you answer Alan.
It took me some time to answer because i upgraded to version 3.8.1.
Your solution worked great for exporting the chart into PDF format, but i still got problems exporting to other methods.
I attached sample web site which is basically what i need, please look at the method Export.
I am trying to export to each method, and except the PDF format nothing works like i expected.
Please try all the buttons and look at the results.
What am i doing wrong ?
Please help.
Thanks,
Koby.
Hello Koby,
I've tested your application (in Windows Vista with Internet Explorer 7.0) and have got the following results:
winChart.Size = new Size(1000, 600);
Unfortunately, I can't give you the immediate answer why the chart is exported incorrectly to HTML and MHT. Please wait, and I'll come back to you when we get any results.
Could you please confirm that exporting to XLS works fine for you, and exporting to image works fine after setting the chart's size?
Best regards, Alan.
R&D, .NET Team.
Thanks for your answer Alan.
Thanks,
Koby.
p.s. I have attached the project with the data in which the PDF and XSL will not work fine.
Hello Koby,
I've investigated your test project and confirm that I see the problem with exporting a chart to PDF and XLS. Again, this is caused by the chart size, which is too small to display a diagram and a legend. You need to either make the chart's size bigger, or hide a legend. To make a chart bigger, please try to make axis labels smaller - in any case, they are unreadable now. Does this help you with the PDF and XLS output?
Alan.
R&D, .net Team.
Hey Alan.
Well it will be very hard for me to resize the chart every time i what to export it.
I don't understand why it works on the Win forms application and not on the Web Application.
Is it going to be implemented soon ?
Thanks,
Koby.