如何在Vue Echarts中制作饼图?
How to create a pie chart in Vue Echarts?
我正在研究用于创建数据可视化的 VueJS 和 Vue Echarts 库。
下面是 Vue Echarts 的 Polar 图表演示:
官网:https://ecomfe.github.io/vue-echarts/demo/
GitHub 页数:https://github.com/ecomfe/vue-echarts
<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
查看 https://github.com/ecomfe/vue-echarts/blob/master/src/demo/Demo.vue
需要导入pie lib,如下:
进口'echarts/lib/chart/pie'
代码沙箱示例位于:https://codesandbox.io/s/vue-echarts-pie-xu9wl?file=/src/components/Pie.vue
我正在研究用于创建数据可视化的 VueJS 和 Vue Echarts 库。
下面是 Vue Echarts 的 Polar 图表演示:
官网:https://ecomfe.github.io/vue-echarts/demo/ GitHub 页数:https://github.com/ecomfe/vue-echarts
<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
查看 https://github.com/ecomfe/vue-echarts/blob/master/src/demo/Demo.vue
需要导入pie lib,如下:
进口'echarts/lib/chart/pie'
代码沙箱示例位于:https://codesandbox.io/s/vue-echarts-pie-xu9wl?file=/src/components/Pie.vue