1.配置HighCharts环境
1.1安装HighCharts
npm install -S vue-highcharts
npm install -S highcharts
1.2 在main.js全局引入
import highcharts from 'highcharts'
import highcharts3d from 'highcharts/highcharts-3d'
highcharts3d(highcharts);
2.HighCharts的使用
<div class="charts">
<div :id="id" :option="option"></div>
</div>
import HighCharts from "highcharts";
<template>
<div class="app-container">
<div class="charts">
<div :id="id" :option="option"></div>
</div>
</div>
</template>
<script>
import HighCharts from "highcharts";
export default {
data() {
return {
id: "test",
option: {
chart: {
type: "pie",
backgroundColor: "rgb(242, 242, 242)",
options3d: {
enabled: true,
alpha: 60,
beta: 0,
},
},
credits: {
enabled: false,
},
title: {
text: "状态图",
},
subtitle: {
text: "",
},
tooltip: {
pointFormat: "{series.name}: {point.percentage:.2f}%",
style: {
color: "#000",
},
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: "pointer",
depth: 35,
dataLabels: {
enabled: true,
formatter: function () {
return (
'<span style="color:#000">' +
this.point.name +
"</span><br/><span>占比:" +
this.percentage.toFixed(2) +
"%</span><br/>" +
"</span>"
);
},
style: {
fontSize: 15,
color: "#000",
},
},
colors: [
"#714fe3",
"rgb(153, 153, 255)",
"rgb(153, 51, 102)",
"rgb(255, 255, 204)",
],
},
},
series: [
{
type: "pie",
name: "占比",
data: [
{ name: "二级单位", y: 10 },
{ name: "三级单位", y: 10 },
{ name: "四级单位", y: 10 },
],
},
],
},
};
},
created() {},
mounted() {
HighCharts.chart(this.id, this.option);
},
methods: {},
};
</script>