0

我正在研究 Highchart,它工作正常,但现在页面加载时。我希望自动下载 png(图像文件)。我怎样才能做到这一点?

<?php 
$xcat = array('0-4', '5-9', '10-14', '15-19',
            '20-24', '25-29', '30-34', '35-39', '40-44',
            '45-49', '50-54', '55-59', '60-64', '65-69',
            '70-74', '75-79', '80-84', '85-89', '90-94',
            '95-99', '100 +');
$unit = "age";
$data1 = array("0"=>array("Seriesname"=>"Male","data"=>array("-1746181", "-1884428", "-2089758", "-2222362", "-2537431", "-2507081", "-2443179",
                    "-2664537", "-3556505", "-3680231", "-3143062", "-2721122", "-2229181", "-2227768",
                    "-2176300", "-1329968", "-836804", "-354784", "-90569", "28367", "-3878")),
"1"=>array("Seriesname"=>"Female","data"=>array("1656154", "1787564", "1981671", "2108575", "2403438", "2366003", "2301402", "2519874",
                    "3360596", "3493473", "3050775", "2759560", "2304444", "2426504", "2568938", "1785638",
                    "1447162", "1005011", "330870", "130632", "21208"))
);
echo NegativeBarChart("container2","Testing","Test",$xcat,$unit,$data1);
?>

<div id="container2" style="min-width: 400px; max-width: 800px; height: 400px; margin: 0 auto"></div>
4

1 回答 1

1

我建议熟悉导出选项:http ://api.highcharts.com/highcharts#exporting.buttons.contextButton.onclick和示例http://jsfiddle.net/72E6v/,其中介绍了如何自动下载图表。

exporting: {
        buttons: {
            contextButton: {
                menuItems: null,
                onclick: function() {
                    this.exportChart();
                }
            }
        }

编辑:自动下载http://jsfiddle.net/8uDdb/1/

chart: {
        events: {
            load: function () {
                var ch = this;
                setTimeout(function(){
                    ch.exportChart();
                },1);
            }
        }
    },
于 2013-06-07T14:10:50.130 回答