Highcharts: collecting all charts on a page second time produces error -



Highcharts: collecting all charts on a page second time produces error -

i have puzzling situation.

i have page few column charts. on page, there link, clicking on builds form , sends info server, sends pdf document:

$('#my-link").click(function(ev) { var svgarray=[]; $(highcharts.charts).each(function(i, chart){ svgarray.push(chart.getsvg()); <!--show error "typeerror: chart undefined" in firefox when clicking on sec time without refreshing page --> }); var svgjson = json.stringify(svgarray); var form = $('#my-form'); var ele = $('<input name="chartsvgarray" style="display: none" value="' + $.base64('encode', svgjson) + '">'); form.append(ele); form.submit(); ev.preventdefault(); });

the browser able pdf document (with charts in it) server , prompts me opening or saving it. in above uses 2 javascript tools. json , .base64 http://www.jqueryscript.net/text/base64-decode-encode-plugin-base64-js.html.

here have problem. without refreshing page, click link again, error in line:

svgarray.push(chart.getsvg()); <!--show error "typeerror: chart undefined" in firefox when clicking on sec time without refreshing page -->

if refresh (reload) page, there no problem producing document each time.

can show me how prepare this?

thanks , regards.

the problem in highcharts.chart array have charts created , destroyed. when phone call getsvg() new chart (duplicate) created , available in array. now, 1 time chart removed, it's replaced undefined, result after exporting first time may be:

highcharts.charts[] = [ chart1, chart2, undefined, undefined ];

solution simple, check if chart variable exists:

$(highcharts.charts).each(function(i, chart){ if(chart) svgarray.push(chart.getsvg()); });

highcharts

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -