Highcharts 3D Pie Chart

To create a 3D pie chart using Highcharts, you can follow these steps:

  • Include the Highcharts library in your HTML file. You can either download it from the Highcharts website or include it from a CDN like this:
<script src="https://code.highcharts.com/highcharts.js"></script>
  • Create a container element for the chart in your HTML file, like this:
<div id="chart-container"></div>
  • In your JavaScript code, define the data for the chart in an array. Each data point should have a name and a value, like this:
var data = [
  { name: 'Apples', value: 5 },
  { name: 'Oranges', value: 3 },
  { name: 'Bananas', value: 2 },
  { name: 'Pears', value: 7 }
];
  • Create a Highcharts chart object and configure it with the data and chart options. In this case, we want a 3D pie chart, so we'll set the chart type to 'pie' and enable the 'options3d' and 'depth' features, like this:
Highcharts.chart('chart-container', {
  chart: {
    type: 'pie',
    options3d: {
      enabled: true,
      alpha: 45,
      beta: 0
    }
  },
  title: {
    text: 'Fruit Sales'
  },
  plotOptions: {
    pie: {
      innerSize: '50%',
      depth: 45
    }
  },
  series: [{
    name: 'Sales',
    data: data.map(item => [item.name, item.value])
  }]
});
  • Finally, add some CSS to style the chart container and make it responsive, like this:
#chart-container {
  width: 100%;
  height: 500px;
  max-width: 800px;
  margin: 0 auto;
}

This will create a 3D pie chart with the specified data and options, and render it in the 'chart-container' element on your web page. You can customize the chart further by adjusting the options and adding additional features, like tooltips, legends, and labels.

  1. Customizing Highcharts 3D Pie Chart appearance:

    • Customize the appearance of the 3D Pie Chart by setting properties in the chart object, such as options3d for 3D effects.
    Highcharts.chart('container', {
        chart: {
            type: 'pie',
            options3d: {
                enabled: true,
                alpha: 45
            }
        },
        series: [{
            type: 'pie',
            data: [5, 10, 15, 20]
        }],
        // Other configuration options...
    });
    
  2. Adding data to Highcharts 3D Pie Chart:

    • Populate the chart with data by providing an array of values in the data property of the series.
    Highcharts.chart('container', {
        chart: {
            type: 'pie',
            options3d: {
                enabled: true,
                alpha: 45
            }
        },
        series: [{
            type: 'pie',
            data: [{
                name: 'Category 1',
                y: 5
            }, {
                name: 'Category 2',
                y: 10
            }, {
                name: 'Category 3',
                y: 15
            }, {
                name: 'Category 4',
                y: 20
            }]
        }],
        // Other configuration options...
    });
    
  3. Nested 3D Pie Chart in Highcharts:

    • Create a nested 3D Pie Chart by incorporating multiple series with hierarchical data.
    Highcharts.chart('container', {
        chart: {
            type: 'pie',
            options3d: {
                enabled: true,
                alpha: 45
            }
        },
        series: [{
            type: 'pie',
            innerSize: '50%',
            data: [{
                name: 'Category 1',
                y: 5
            }, {
                name: 'Category 2',
                y: 10
            }]
        }, {
            type: 'pie',
            data: [{
                name: 'Category 3',
                y: 15
            }, {
                name: 'Category 4',
                y: 20
            }]
        }],
        // Other configuration options...
    });
    
  4. Exploded 3D Pie Chart using Highcharts:

    • Separate slices in the Pie Chart by exploding specific segments.
    Highcharts.chart('container', {
        chart: {
            type: 'pie',
            options3d: {
                enabled: true,
                alpha: 45
            }
        },
        plotOptions: {
            pie: {
                innerSize: '50%',
                depth: 45
            }
        },
        series: [{
            type: 'pie',
            data: [{
                y: 5,
                sliced: true,
                selected: true
            }, {
                y: 10
            }, {
                y: 15
            }, {
                y: 20
            }]
        }],
        // Other configuration options...
    });
    
  5. Interactive features in Highcharts 3D Pie Chart:

    • Enable interactive features like tooltips, data labels, and events for a richer user experience.
    Highcharts.chart('container', {
        chart: {
            type: 'pie',
            options3d: {
                enabled: true,
                alpha: 45
            }
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    format: '<b>{point.name}</b>: {point.y}'
                }
            }
        },
        series: [{
            type: 'pie',
            data: [{
                name: 'Category 1',
                y: 5
            }, {
                name: 'Category 2',
                y: 10
            }, {
                name: 'Category 3',
                y: 15
            }, {
                name: 'Category 4',
                y: 20
            }]
        }],
        // Other configuration options...
    });