首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Vue Echarts中创建饼图?

如何在Vue Echarts中创建饼图?
EN

Stack Overflow用户
提问于 2020-09-25 14:47:14
回答 1查看 1.1K关注 0票数 0

我正在开发VueJS和Vue Echarts库,用于创建数据可视化。

以下是Vue Echarts的Polar chart演示:

官方网站:https://ecomfe.github.io/vue-echarts/demo/ GitHub页面:https://github.com/ecomfe/vue-echarts

代码语言:javascript
复制
<template>
<v-chart :options="polar"/>
</template>

<style>
/**
 * The default size is 600px×400px, for responsive charts
 * you may need to set percentage values as follows (also
 * don't forget to provide a size for the container).
 */
.echarts {
  width: 100%;
  height: 100%;
}
</style>

<script>
import ECharts from 'vue-echarts'
import 'echarts/lib/chart/line'
import 'echarts/lib/component/polar'

export default {
  components: {
    'v-chart': ECharts
  },
  data () {
    let data = []

    for (let i = 0; i <= 360; i++) {
        let t = i / 180 * Math.PI
        let r = Math.sin(2 * t) * Math.cos(2 * t)
        data.push([r, i])
    }

    return {
      polar: {
        title: {
          text: '极坐标双数值轴'
        },
        legend: {
          data: ['line']
        },
        polar: {
          center: ['50%', '54%']
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross'
          }
        },
        angleAxis: {
          type: 'value',
          startAngle: 0
        },
        radiusAxis: {
          min: 0
        },
        series: [
          {
            coordinateSystem: 'polar',
            name: 'line',
            type: 'line',
            showSymbol: false,
            data: data
          }
        ],
        animationDuration: 2000
      }
    }
  }
}
</script>

结果:Polar Chart Looks Like

我想创建饼图,而不是极点。我查看了几个网站,但没有找到我的结果。

我需要的是:this pie chart

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-12-09 23:12:01

查看https://github.com/ecomfe/vue-echarts/blob/master/src/demo/Demo.vue

您需要导入饼库,如下所示:

导入'echarts/lib/chart/pie‘

代码沙盒示例位于:https://codesandbox.io/s/vue-echarts-pie-xu9wl?file=/src/components/Pie.vue

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64059177

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档