How to export a specific RadHTMLChart to PDF

1 Answer 127 Views
Chart (HTML5)
kieran
Top achievements
Rank 2
kieran asked on 09 Jul 2021, 05:33 AM

Hi there,

              I have used your example code to be able to export a chart to PDF

<script>
     function exportChartToPDF() {
         var $ = $telerik.$;
         $get('<%=RadClientExportManager1.ClientID%>').exportPDF($(".RadHtmlChart"));
     }
     function exportChartToImage() {
         var $ = $telerik.$;
         $find('<%=RadClientExportManager1.ClientID%>').exportImage($(".RadHtmlChart"));
     }
</script>

I have this triggered by a button and it is working, but I need to be able to export a specific RadHTMLchart.

I have limited knowledge of this in page scripting.

 

the supplied function finds the first instance of the type requested, is there a way to find a specific control?

Please excuse my lack of understanding, I am finding my feet with this stuff.

Thanks.

1 Answer, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 09 Jul 2021, 01:18 PM

Hi kieran,

You can add a custom CSS class to the HtmlChart you want to export, and use this class after that when passing chart element to the ClientExportManager's exportPDF() function.

For example:

            <telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" CssClass="ChartToExport" Width="800px" Height="500px">
                <PlotArea>
                    <XAxis Type="Log">
                        <TitleAppearance Text="Frequency (Hz)"></TitleAppearance>
                    </XAxis>
                    <Series>
                        <telerik:ScatterLineSeries DataFieldY="SoundPressureLevel" DataFieldX="Frequency" Name="20 phon">
                            <LineAppearance LineStyle="Smooth" />
                            <LabelsAppearance Visible="false"></LabelsAppearance>
                            <MarkersAppearance Size="4" />
                        </telerik:ScatterLineSeries>
                    </Series>
                    <YAxis>
                        <TitleAppearance Text="Sound Pressure Level (dB)"></TitleAppearance>
                    </YAxis>
                </PlotArea>
                <ChartTitle Text="Equal-Loudness Contour">
                </ChartTitle>
            </telerik:RadHtmlChart>
        </div>
        <script>
            var $ = $telerik.$;

            function exportRadHtmlChart() {
                $find('<%=RadClientExportManager1.ClientID%>').exportPDF($(".ChartToExport"));
            }
        </script>

 

Regards,
Vessy
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

kieran
Top achievements
Rank 2
commented on 11 Jul 2021, 04:32 PM

Thankyou! That did the trick nicely.
Vessy
Telerik team
commented on 12 Jul 2021, 05:58 AM

You are welcome, kieran! :)
Tags
Chart (HTML5)
Asked by
kieran
Top achievements
Rank 2
Answers by
Vessy
Telerik team
Share this question
or