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

Getting values with the Chart.get() method


The Chart.get() method can be used to get an axis, series, or a point by its ID. It returns an object of an axis, series, or a point containing various properties. This method is useful due to faster access to the mentioned components, as we don't have to manually navigate through the object hierarchy of a chart.

Note

Note that this method is only available in the top-level chart object.

Consider the following example from Chapter 7, Theming with Highcharts, modified to include an ID for the Windows 7 data point:

$( '#chart_container' ).highcharts({
  chart: {
    type: 'pie'
  },
  title: {
    ...
  },
  tooltip: {
    ...
  },aotOptions: {
    ...
  },
  series: [{
    name: 'Windows versions',
    data: [
      {
        name: 'Win 7',
        id: 'win7',
        y: 55.03
      },
      ...
    ]
  }]
}

While being on the top-level chart object, we can call the get() method in the callback function to get the object of the win7 data point:

var win7Point...