Saturday 15 August 2015

javascript - HighCharts. Adding series to yAxis with id -



javascript - HighCharts. Adding series to yAxis with id -

im having problems adding series yaxis different id in highcharts.

i have made example:

$(function () { $('#graf').highcharts({ chart: { zoomtype: 'xy' }, title: { text: '' }, subtitle: { text: '' }, xaxis: [{type: 'datetime', title: { text: 'date' }}], yaxis: [], series : [] , tooltip: { shared: true }, legend: { enabled: true, align: 'left', backgroundcolor: '#ffffff', bordercolor: 'grey', borderwidth: 1, layout: 'vertical', verticalalign: 'top', y: 0, shadow: true } }); var chart = $('#graf').highcharts(); $('#add').click(function () { chart.addaxis({ // secondary yaxis id: "asd", title: { text: 'rainfall' }, linewidth: 2, linecolor: '#08f', opposite: true }); chart.addaxis({ // secondary yaxis id: "abc", title: { text: 'rainfall' }, linewidth: 2, linecolor: '#08f', opposite: true }); chart.addseries({ name: 'rainfall', type: 'column', color: '#08f', yaxis: "asd", data: [ [date.utc(1970, 9, 27), 0 ], [date.utc(1970, 10, 10), 0.6 ], [date.utc(1970, 10, 18), 0.7 ], [date.utc(1970, 11, 2), 0.8 ], [date.utc(1970, 11, 9), 0.6 ]] }); $(this).attr('disabled', true); $('#remove').attr('disabled', false); }); });

jsfiddle: http://jsfiddle.net/5f6b6mu9/

i have yaxis id "asd" , "abc". when trying add together series "asd" yaxis doesnt work. uncaught typeerror: cannot read property 'length' of undefined.

here cap of whats going on in webpage: http://i61.tinypic.com/8yx7cw.jpg

if alter both yaxis id same id, work, thats not point.

any suggestions? thanks

thats pretty simple.

add series corresponding yaxis after add together series.

chart.addaxis({ // secondary yaxis id: "asd", title: { text: 'rainfall' }, linewidth: 2, linecolor: '#08f', opposite: true },false); chart.addseries({ name: 'rainfall', type: 'column', color: '#08f', yaxis: "asd", data: [ [date.utc(1970, 9, 27), 0 ], [date.utc(1970, 10, 10), 0.6 ], [date.utc(1970, 10, 18), 0.7 ], [date.utc(1970, 11, 2), 0.8 ], [date.utc(1970, 11, 9), 0.6 ]] }); chart.addaxis({ // secondary yaxis id: "abc", title: { text: 'rainfall' }, linewidth: 2, linecolor: '#08f', opposite: true },false);

here i've updated fiddle

javascript highcharts

No comments:

Post a Comment