<template>
<div id="container" style="width:400px;height:400px"></div>
</template>
<script>
var Highcharts = require('highcharts');
// 在 Highcharts 加載之后加載功能模塊
require('highcharts/modules/exporting')(Highcharts);
export default {
name: 'Chart',
data () {
return {
}
},
created(){
Highcharts.chart('container', {
//圖表類型,
type:'bar',
// 反轉,x和y軸
inverted:false,
// 動畫
animation:true,
//圖表,可以配置圖表樣式
chart: {
// 樣式,或者使用className:string也行
style: {
fontFamily: "",
fontSize: '12px',
fontWeight: 'bold',
color: '#006cee'
}
},
// 標題,以及副標題subtitle,配置基本上就是樣式的設置
// 可以動態獲取及設置標題: chart.title.textStr,chart.setTitle(titleObj,subTitleObj);
// 或update標題:chart.title.update(titleObj),hart.subtitle.update(titleObj);
title:{
text: '我是標題'
},
//事件
events: {
click:function(){
}
},
// loading 加載時的一些配置
loading:{
},
xAxis:{
title:{
text:'x軸標題',
align:"middle",//'low','high' 即底部,中間,和頂部
margin:10,//偏移量。相當于字外圍。和offset(字內圍)互斥。x,y相對于自身再偏移。即相對定位
rotation:0,//旋轉角度
style:{}
}
},
yAxis:{
title:{
text:'y軸標題',
align:"middle"
}
},
// 坐標軸刻度
Labels:{
enabled:true,//false, 默認有刻度
Formatter:function(){
return this.value;//this.value表示原先的刻度值,可以對原先刻度值格式化,返回新的值
},
Step:1,//顯示值的跨度為1。如果為2則相當于第一個刻度沒有值顯示,第二個才有。第三個沒有,第四個有。多列好像沒用?
},
// 數據列
series:[
{
data:[2,4,6,3,8,11],
// 其它如列類型,線條樣式,dataLabels(數據標簽:節點處顯示值) 貌似在這里配置沒用?
}
]
}
</script>
<style scoped>
</style>