Export Multiple highcharts with custom text into pdf

别等时光非礼了梦想. 提交于 2019-12-13 09:46:20

问题


I want to export multiple charts with textareas in PDF i

How will I implement in the following above code? pLease guide me


回答1:


You can use my previous idea from similar topic: Export highchart with free text entered as pdf

You can iterate over all of your charts and add them to your exported svg with texts related to these charts:

Highcharts.getSVG = function(charts, texts) {
    var svgArr = [],
        top = 0,
        width = 0,
        txt;
    Highcharts.each(charts, function(chart, i) {
        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);
        txt = texts[i];
        txt = '<text x= "' + 0 + '" y = "' + (top + 20) + '" styles = "' + txt.attributes.style.value + '">' + $(txt).val() + '</text>';
        top += 60;
        svgArr.push(txt);
    });
    return '<svg height="' + top + '" width="' + width + '" version="1.1" xmlns="http://www.w3.org/2000/svg">' + svgArr.join('') + '</svg>';
  };

Here you can find an example how it can work: http://jsfiddle.net/6m2rneL8/32/



来源:https://stackoverflow.com/questions/39171077/export-multiple-highcharts-with-custom-text-into-pdf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!