score:6

Accepted answer

here is an alternative solution that does the printing directly. it's based on the chart.print() function, but it works on multiple charts.

see the demo here: http://jsfiddle.net/jim31415/q5rzu/150/

        //--------------------------------------------------------------------
        $("#print").click(function () {
            printcharts([chart1, chart2, chart3]);
        });


        //--------------------------------------------------------------------
        function printcharts(charts) {

            var origdisplay = [],
                origparent = [],
                body = document.body,
                childnodes = body.childnodes;

            // hide all body content
            highcharts.each(childnodes, function (node, i) {
                if (node.nodetype === 1) {
                    origdisplay[i] = node.style.display;
                    node.style.display = "none";
                }
            });

            // put the charts back in
            $.each(charts, function (i, chart) {
                origparent[i] = chart.container.parentnode;
                body.appendchild(chart.container);
            });

            // print
            window.print();

            // allow the browser to prepare before reverting
            settimeout(function () {
                // put the charts back in
                $.each(charts, function (i, chart) {
                    origparent[i].appendchild(chart.container);
                });

                // restore all body content
                highcharts.each(childnodes, function (node, i) {
                    if (node.nodetype === 1) {
                        node.style.display = origdisplay[i];
                    }
                });
            }, 500);
        }
    });

score:8

the exportchart method accepts parameters so you can send it more than one chart. however, the print method does not accept any parameters. so, to print you have to specify each chart separately like chart1.print(); and chart2.print(); which prints them each separately.

there are two workarounds:

  1. printing the whole page without using highcharts printing. here is an example.

  2. you could export both of the charts to a pdf file and then print form there. here is an example on how to export multiple charts to one pdf.


Related Query