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

Combining pie charts with line and column charts


In Chapter 3, Line and Spline Charts, we combined the line and the column chart. In the following example, we will take a look at how to combine a pie chart with a column and line chart to present data via three different chart types for greater data visualization.

Consider the example of fuel consumption by the United States, China, and the European Union in the year 2012 by fuel type. First, the data for the first two countries will be plotted by the column graph whereas the data for the EU will be visualized by the line chart. We will then plot the total fuel consumption by type using a pie chart that will appear along with the main chart.

The following is the code for the line and column chart combination:

(function() {
  $( '#chart_container' ).highcharts({
    title: {
      text: 'Fuel Consumption by Type for the Year 2012'
    },
    subtitle: {
      text: 'Source: <a href="http://bp.com">BP</a>',
      useHTML: true
   ...