https://jshare.com.cn/demos/hhhhiG
点击对应的文件可打开,复制代码到(创建一个同名文件)里面;放到项目对应目录下
两种引入 highcharts.js 方法皆可用;注意 highcharts-3d 引入方式
- import Highcharts from './static/js/highcharts.js'
- // const Highcharts = require('./static/js/highcharts.js')
- require('./static/js/highcharts-3d')(Highcharts)
在vue中使用
- new Vue({
- el: '#app',
- data() {
- return {}
- },
-
- mounted() {
- this.$nextTick(() => {
- this.renderHighcharts()
- })
- },
-
- methods: {
- renderHighcharts() {
- var chart = Highcharts.chart('container', {
- chart: {
- type: 'pie',
- backgroundColor: 'rgba(0,0,0,0)',
- options3d: {
- enabled: true,
- alpha: 45,
- beta: 0
- }
- },
- title: {
- text: '访问量占比',
- style: {
- color: 'white',
- fontWeight: 'bold'
- }
- },
- credits: {
- enabled: false //去除图表右下角版权信息
- },
- tooltip: {
- pointFormat: '{series.name}: {point.percentage:.1f}%'
- },
- plotOptions: {
- pie: {
- allowPointSelect: true,
- cursor: 'pointer',
- depth: 35,
- dataLabels: {
- enabled: true,
- format: '{point.name}({point.y})'
- }
- }
- },
- series: [
- {
- type: 'pie',
- name: '占比',
- style: {
- color: 'white'
- },
- data: [
- ['Firefox', 45.0],
- ['IE', 26.8],
- ['Safari', 8.5]
- ]
- }
- ]
- })
- }
- }
- })