<template>
<div class="highcharts-container" id="container" ref="leida" style="min-width: 400px; max-width: 660px; height: 400px; margin: 0 auto" />
</template>
<script>
import Highcharts from 'highcharts';
import highcharts3d from 'highcharts/highcharts-3d.js';
import highchartsMore from 'highcharts/highcharts-more.js';//扩展图表类型
highcharts3d(Highcharts);
highchartsMore(Highcharts);
export default {
name: "Highcharts",
props: {},
data: () => ({
chart: null,
options: {},
cColor: ['#5c08ef', '#ff000', '#21b100', '#f56c6c', '#d99c40', '#409eff', '#d4ff40']
}),
watch: {},
mounted() {
this.renderChart();
},
methods: {
renderChart() {
let that = this;
if(this.chart || !this.options) return;
this.options = {
chart: {
polar: true,
type: 'area',
},
title: {
text: '水果售卖比例',
x: -80
},
colors: this.cColor,
pane: {
size: '60%', // 图形大小
},
xAxis: {
categories: ['苹果', '香橙', '樱桃', '雪梨','冬枣', '葡萄'],
tickmarkPlacement: 'on',
lineWidth: 0
},
yAxis: {
gridLineInterpolation: 'polygon',
lineWidth: 0,
tickInterval: 20, // 刻度间隔
min: 0
},
tooltip: {
shared: true,
shape: 'rect',
borderRadius: 50,
borderWidth: 1,
followPointer: true,
borderColor: '#ededed',
backgroundColor: '#ffffff',
padding: 16,
formatter: function () {
var s = '';
$.each(this.points, function (i, item) {
item.color = that.cColor[item.point.index];
s += '<span style="display: inline-block; color: '+that.cColor[item.point.index]+'; background-color:'+item.color+';">' + item.key + ': ' +
item.y + '%'+'</span>';
});
return s;
}
},
legend: {
enabled: false,
align: 'right',
verticalAlign: 'top',
y: 70,
layout: 'vertical'
},
plotOptions: {
series: {
fillOpacity: 0.2,
cursor: 'pointer',
point: {
events: {
click: function(e) {
console.log('>>>>', e.point, this.category);
}
}
}
}
},
series: [
{
name: '苹果',
data: [{
className: 'yellow',
name: '哈哈哈哈',
y: 54.4,
}, 89, 60, 35, 57, 100],
pointPlacement: 'on'
}]
}
this.chart = new Highcharts.Chart(this.$refs.leida, this.options);
}
},
beforeDestroy() {
if(this.chart !== null) {
this.chart.destroy();
}
}
};
</script>
<style>
/* 设置画布右下角水印 */
.highcharts-credits{
display: none;
}
.yellow{
color:aquamarine;
}
</style>
原文地址:http://www.cnblogs.com/min77/p/16801494.html
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,请务用于商业用途!
3. 如果你也有好源码或者教程,可以到用户中心发布,分享有积分奖励和额外收入!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 如遇到加密压缩包,默认解压密码为"gltf",如遇到无法解压的请联系管理员!
8. 因为资源和程序源码均为可复制品,所以不支持任何理由的退款兑现,请斟酌后支付下载
声明:如果标题没有注明"已测试"或者"测试可用"等字样的资源源码均未经过站长测试.特别注意没有标注的源码不保证任何可用性