Highcharts导出为PDF - 结果"无法显示网页"使用IE9

时间:2016-04-20 09:21:11

标签: javascript internet-explorer pdf highcharts

尝试使用IE9将Highcharts导出为PDF。我尝试了以下代码,导致" IE页面无法显示"错误。任何人都可以指导我修复错误吗?非常感谢您的时间和帮助。

我的代码:

      function getData() {
              var myChart;
              var options = {
                    chart : {
                        renderTo : 'container',
                        type : 'area',
                    },
                   xAxis : {
                        categories : []
                    },
                   exporting: {
                        enabled : true,
                         type: 'application/pdf'
                   },
                   series : []
              };

        $.get(url, function(xml) {
            var $xml = $(xml);
            $xml.find('categories month').each(
                    function(i, category) {
                        options.xAxis.categories.push($(category).text());
                    });
            $xml.find('Type Series').each(
                            function(i,series){
                                var seriesOptions = {
                                    name : $(series).find('name').text(),
                                    data : [],
                                };
                              $(series).find('data point').each(
                                    function(i,point){
                                        seriesOptions.data.push(parseInt($(point).text()));
                                });
                              options.series.push(seriesOptions);
                            });
                    myChart = new Highcharts.Chart(options);
        });

        Highcharts.getSVG = function(charts) {
                var svgArr = [],
                    top = 0,
                    width = 0;

                $.each(charts, function(i, chart) {
                    var svg = chart.getSVG();
                    svg = svg.replace('<svg', '<g transform="translate(0,' + top + ')" ');
                    svg = svg.replace('</svg>', '</g>');

                    top += chart.chartHeight;
                    width = Math.max(width, chart.chartWidth);

                    svgArr.push(svg);
                });

                return '<svg height="'+ top +'" width="' + width + '" version="1.1" xmlns="http://www.w3.org/2000/svg">' + svgArr.join('') + '</svg>';
            };

            Highcharts.exportCharts = function(charts, options) {
                // Merge the options

                options = Highcharts.merge(Highcharts.getOptions().exporting, options);

                // Post to export server
                Highcharts.post(options.url, {
                    filename: options.filename || 'chart',
                    type: options.type,
                    width: options.width,
                    svg: Highcharts.getSVG(charts)
                });
            };
            $('#export').click(function() {
                Highcharts.exportCharts([myChart]);
            });
        }



<body>
<button id="export">Export all</button>
<div id="container" class="myChart" style="width: 100%; height: 500px; margin: 0 auto"></div>
</body>

0 个答案:

没有答案