javascript - HighCharts error #18: Requested Axis Does not exist -


i new highcharts , trying display 2 graphs on same x-axis) axis shown here: http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/demo/combo-multi-axes/.

however, error message: error happens when set series' xaxis or yaxis property point axis not exist.

the error occurs in "chart1"

the html , javascript code follows:

$(function updat() {    var url = "https://xpm4zyor39.execute-api.us-west-2.amazonaws.com/prod/entries";    var humid = [],      date = [],      high=[],      day=[],      chanceofrain=[],      humid_final = [],      day_final=[],      high_final=[],      chanceofrain_final=[]      $.getjson(url, function (json) {        $(json['items']).each(function(i, data) {        //store indicator name                // fill date array        humid.push(data.humidity);        // fill string data array         date.push(data.date);          high.push(data.high);        day.push(data.day);        chanceofrain.push(data.chanceofrain);        });        console.log(date);      // query send string need convert numbers      (var = 0; < humid.length; i++) {        if (humid[i] != null) {          humid_final.push(parsefloat(humid[i]));          high_final.push(parsefloat(high[i]));          day_final.push(parsefloat(day[i]));          chanceofrain_final.push(parsefloat(chanceofrain[i]));        } else {         humid_final.push(null)        };      }        console.log("day_final", day_final);          var chart = new highcharts.chart({        chart: {          type: 'spline',          renderto: 'light',          marginbottom: 200        },        title: {          text: 'indicatorname'        },        tooltip: {          valuedecimals: 2,          pointformat: '<span style="color:{point.color}">\u25cf</span> {series.name}: <b>{point.y}%</b><br/>'        },        plotoptions: {          series: {            marker: {              enabled: false            }          }        },        subtitle: {          text: 'ambient light level'        },        xaxis: {          categories: day_final //.reverse() have min year on left         },        series: [{          name: 'light level',          data: high_final //        }]      });       var chart1= highcharts.chart('temp&humid',{        chart: {          zoomtype:'xy'        },        title:{          text:'humidity , temperature'        },          xaxis:{          categories: [1,2,3],          crosshair: true        },          yaxis: [{          labels:{            format: '{value}°c',            style: {              color: highcharts.getoptions().colors[2]            }          },          title:{            text: 'temperature',            style:{              color: highcharts.getoptions().colors[2]            }          },          opposite: true        },        { //secondary y axis          gridlinewidth: 0,          title:{            text: 'humidity',            style:{               color: highcharts.getoptions().colors[0]            }          },          labels:{            format: '{value}%',            style:{              color:highcharts.getoptions().colors[0]            }          }        }]        ,          tooltip:{shared:true},          legend:{        layout: 'vertical',        align:'left',        x:80,        verticalalign: 'top',        y: 55,        floating:true,        backgroundcolor: (highcharts.theme && highcharts.theme.legendbackgroundcolor) || '#ffffff'        },          series:[{          name:'humidity',          type: 'column',          yaxis:1,          data:[12,3],          tooltip:{valuesuffix: ' %'}        },        {          name:'temperature',          type:'spline',          yaxis:2,          data: [1,2,3],          tooltip:{valuesuffix: ' °c'}        }]        });      }); //getjson method    settimeout(updat, 3000);  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>  <script src="https://code.highcharts.com/highcharts.js"></script>  <script src="https://code.highcharts.com/modules/exporting.js"></script>  <script src= "ag.js"></script>  <div id="light" style="min-width: 310px; height: 400px; left:10px"></div>  <div id="temp&humid" style="min-width: 310px; height: 400px; left:10px"></div>

you doing following:

series:[{     yaxis:1,    },   {     yaxis:2,   }] 

the problem axes start indexing @ 0. index set temperature axis 2 not work because there no axis 2. in demo there 3 axes, why works these definitions.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -