如何使用 Highcharts 在 Vue.js 中制作堆叠甜甜圈(饼图)图表?
P粉980815259
P粉980815259 2024-03-19 19:17:54
0
1
443

我想使用 Highcharts 制作圆环图,但我无法将此图表转换为堆叠形式。 Vue.js代码如下:

<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>

我创建的图表如下所示:

我正在尝试在 Elasticsearch 中提供堆叠圆环图。这是一个例子:

尝试在“name”和“y”之后添加发音,但没有成功。另外,我是否需要在已安装(或任何方法)中添加子类别?如果您对此有任何想法,我等待您的帮助。

P粉980815259
P粉980815259

全部回复(1)
P粉068486220

要在 Highcharts 中创建此类图表,您可以使用旭日系列类型:

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

实例: https://jsfiddle.net/BlackLabel/2Ldpvogr/

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


或者两个具有指定大小innerSize的饼图系列:

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

实例: https://jsfiddle.net/BlackLabel/uogq3waf/

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

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!