How to make stacked donut(pie) chart in Vue.js by using Highcharts?

Viewed 32

I wanted to make a donut chart using Highcharts, but I'm having trouble converting this chart to stacked form. Vue.js codes are below:

<template>
  <div>
    <b-col md="12" style="margin-top: 40px">
      <highcharts :options="pieChartOptions"></highcharts>

    </b-col>

  </div>

</template>

<script>
import axios from 'axios'
import {mapActions} from "vuex";
import Highcharts from "highcharts";
import {Chart} from 'highcharts-vue'
import DashboardTable from "../../components/DashboardTable/DashboardTable";
import Widget from '@/components/Widget/Widget';

export default {
  name:"TestChart",
  components: {
    DashboardTable, Widget,
    highcharts: Chart
  },
  data(){
    return{
      pieChartOptions:{
        colors: ['#01BAF2', '#71BF45', '#FAA74B', '#B37CD2'],
        chart: {
          type: 'pie'
        },
        accessibility: {
          point: {
            valueSuffix: '%'
          }
        },
        title: {
          text: 'Coffee'
        },
        tooltip: {
          pointFormat: '{series.name}: <b>{point.percentage:.0f}%</b>'
        },
        plotOptions: {
          pie: {
            allowPointSelect: true,
            cursor: 'pointer',
            dataLabels: {
              enabled: true,
              format: '{point.name}: {y} %'
            },
            showInLegend: true
          }
        },
        series: [{
          name: 'Types',
          colorByPoint: true,
          innerSize: '75%',
          data: [{
            name: 'Filtre',
            y: 68.1,
          }, {
            name: 'Türk',
            y: 11.0
          }, {
            name: 'Latte',
            y: 11.2
          }, {
            name: 'Espresso',
            y: 9.7
          }]
        }]
      }
    }
  },
}

</script>

<style>

</style>

Oluşturduğum chart şu şekilde görünmektedir:enter image description here

Elasticsearch de bulunan stacked donut chart yapmaya çalışıyorum. İşte bir örnek:enter image description here

Trying to add sounding after "name" and "y" but that didn't work. Also, do I need to add subcategories in mounted (or any method)? If you have any ideas about this, I am waiting for your help.

1 Answers

To create such chart in Highcharts, you can use sunburst series type:

    series: [{
        type: 'sunburst',
        ...
    }]

Live example: https://jsfiddle.net/BlackLabel/2Ldpvogr/

Docs: https://www.highcharts.com/docs/chart-and-series-types/pie-chart


Or two pie series with specified size and innerSize:

    chart: {
        type: 'pie'
    },
    series: [{
        size: '60%',
        ...
    }, {
        size: '80%',
        innerSize: '60%',
        ...
    }]

Live example: https://jsfiddle.net/BlackLabel/uogq3waf/

Docs: https://www.highcharts.com/docs/chart-and-series-types/sunburst-series

Related