jQuery UI Widgets Forums Chart Looking to learn more about: Chart.

This topic contains 1 reply, has 2 voices, and was last updated by  admin 6 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Looking to learn more about: Chart. #136182

    jovanovic
    Participant

    Is there a built-in method to export a jqxChart as a PNG image using jQuery?

    Looking to learn more about: Chart. #136193

    admin
    Keymaster

    Hi,

    Yes, there is such method.

    <div id="chart"></div>
    <button id="exportBtn">Export to PNG</button>
    
    <script type="text/javascript">
    $(document).ready(function () {
        let sampleData = [
            { Day: 'Monday', Sales: 30 },
            { Day: 'Tuesday', Sales: 25 },
            { Day: 'Wednesday', Sales: 55 },
            { Day: 'Thursday', Sales: 45 }
        ];
    
        $('#chart').jqxChart({
            title: "Sales per Day",
            description: "Export Example",
            source: sampleData,
            xAxis: { dataField: 'Day' },
            seriesGroups: [{
                type: 'column',
                series: [{ dataField: 'Sales', displayText: 'Sales' }]
            }]
        });
    
        // Export button handler
        $("#exportBtn").on("click", function () {
            $("#chart").jqxChart('saveAsPNG', 'my-chart.png');
        });
    });
    </script>

    Best regards,
    Peter Stoev

    jQWidgets Team
    https://www.jqwidgets.com/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.