Book Image

Highcharts Essentials

By : Bilal Shahid
Book Image

Highcharts Essentials

By: Bilal Shahid

Overview of this book

Table of Contents (16 chapters)
Highcharts Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Adding series and points


We can dynamically add axes, series, and points to any chart after it has been initialized. In the following examples, we will first initialize a chart and then add points and series to it upon different actions.

Adding a point dynamically

Consider the following code for a chart representing energy consumption by leading continents in 2013:

(function() {
  $( '#energy_consumption' ).highcharts({
    title: {
      text: 'Energy Consumption in 2013'
    },
    xAxis: {
      type: 'category',
      title: {
        text: 'Continents'
      }
    },
    yAxis: {
      title: {
        text: 'Million Metric Tons of Oil Equivalent'
      }
    },
    series: [{
      name: 'Energy Consumption',
      type: 'column',
      data:  [{
        id: 'north-america',
        name: 'North America',
        y: 2786.7
      }, {
        id: 'asia',
        name: 'Asia',
        y: 5594
      }]
    }]
  });
})();

This chart will have two data points for two continents showing their...