javascript - Different type of series in highstock with json data -


in example below, how have:

  • serie 'msft' in type line
  • serie 'aapl' in type column
  • serie 'goog' in type spline

$.each(names, function (i, name) {      $.getjson('https://www.highcharts.com/samples/data/jsonp.php?filename=' + name.tolowercase() + '-c.json&callback=?',    function (data) {          seriesoptions[i] = {             name: name,             data: data         };          // we're loading data asynchronously, don't know order arrive.         // keep counter , create chart when data loaded.         seriescounter += 1;          if (seriescounter === names.length) {             createchart();         }     }); }); 

http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/stock/demo/compare/

simply create types array , use in loop function: http://jsfiddle.net/epaltjre/

var seriesoptions = [],     seriescounter = 0,     names = ['msft', 'aapl', 'goog'],     types = ['line', 'column', 'spline']; // add types 

and later:

        seriesoptions[i] = {             name: name,             data: data,             type: types[i] // apply type series         }; 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -