您好,登錄后才能下訂單哦!
小編給大家分享一下vue中怎么使用hightchats,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
vue中使用hightchats
1、安裝highcharts
npm install highcharts --save
2、在main.js中
import Highcharts from 'highcharts/highstock'; import HighchartsMore from 'highcharts/highcharts-more'; import HighchartsDrilldown from 'highcharts/modules/drilldown'; import Highcharts3D from 'highcharts/highcharts-3d'; import Highmaps from 'highcharts/modules/map'; HighchartsMore(Highcharts) HighchartsDrilldown(Highcharts); Highcharts3D(Highcharts); Highmaps(Highcharts); new Vue({ el: '#app', router, axios, components: { App }, template: '<App/>', methods:{ moreChart() { var options = this.getMoreOptions(this.type); if (this.chart) { this.chart.destroy(); }; // 初始化 Highcharts 圖表 this.chart = new Highcharts.Chart('highcharts-more', options); } } })
3、創(chuàng)建chart組件
<template> <p class="chart"> <p :id="id" :option="option"></p> </p> </template> <script> import HighCharts from 'highcharts' export default { // 驗(yàn)證類(lèi)型 props: { id: { type: String }, option: { type: Object } }, mounted() { HighCharts.chart(this.id, this.option) } } </script> <style scoped> </style>
4、其他組件引用圖表
<Chart :id="id" :option="option"></Chart> import Chart from "./Chart"; export default { name: "HelloWorld", components: { Chart }, data() { return { msg: "Welcome to Your Vue.js App", id: "test", option: { credits: { enabled: false }, chart: { type: "line" }, title: { text: "月平均氣溫" //表頭文字 }, subtitle: { text: "數(shù)據(jù)來(lái)源: WorldClimate.com" //表頭下文字 }, xAxis: { //x軸顯示的內(nèi)容 categories: [ "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月" ], plotbands: [ { //可以顯示一個(gè)方塊,如果需要的話(huà)可以更改透明度和顏色 from: 4.5, to: 6.5, color: "rgba(68,170,213,0)" //透明度和顏色 } ] }, yAxis: { //y軸顯示的內(nèi)容 title: { text: "氣溫 (°C)" } }, plotOptions: { line: { dataLabels: { enabled: false // 開(kāi)啟數(shù)據(jù)標(biāo)簽 }, enableMouseTracking: false // 關(guān)閉鼠標(biāo)跟蹤,對(duì)應(yīng)的提示框、點(diǎn)擊事件會(huì)失效 } }, series: [ { //兩條數(shù)據(jù) name: "東京", data: [ 7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6 ] }, { name: "倫敦", data: [ 3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8 ] } ] } } }
以上是“vue中怎么使用hightchats”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。