国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

在vue項目中引入highcharts圖表的方法(詳解)

2019-11-19 14:14:09
字體:
供稿:網(wǎng)友

npm進行highchars的導入,導入完成后就可以進行highchars的可視化組件開發(fā)了

npm install highcharts --save

1、components目錄下新建一個chart.vue組件

<template> <div class="x-bar"> <div :id="id" :option="option"></div> </div></template><script>import HighCharts from 'highcharts'export default { // 驗證類型 props: { id: { type: String }, option: { type: Object } }, mounted() { HighCharts.chart(this.id,this.option) }}</script>

2、chart組件建好后,開始創(chuàng)建chart-options目錄,里面創(chuàng)建一個options.js用來存放模擬的chart數(shù)據(jù),如下圖目錄

如下圖我寫的一個柱狀圖的數(shù)據(jù)

module.exports = { bar: { chart: { type:'column'//指定圖表的類型,默認是折線圖(line) }, credits: { enabled:false },//去掉地址 title: { text: '我的第一個圖表' //指定圖表標題 }, colors: ['#058DC7', '#50B432', '#ED561B', '#DDDF00',  '#24CBE5' ], xAxis: {  categories: ['1號', '2號', '3號','3號','3號'] //指定x軸分組 }, yAxis: {  title: {  text: '最近七天', //指定y軸的標題 }, }, plotOptions: {  column: {  colorByPoint:true  },  }, series: [{ //指定數(shù)據(jù)列  name: '小明',  data: [{  y:1000,  color:"red"}, 5000, 4000,5000,2000] //數(shù)據(jù) }] }}

3、引用chart組件

<template> <div id="app"> <x-chart :id="id" :option="option"></x-chart> </div></template><script>// 導入chart組件import XChart from 'components/chart.vue'// 導入chart組件模擬數(shù)據(jù)import options from './chart-options/options'export default { name: 'app', data() { let option = options.bar return { id: 'test', option: option } }, components: { XChart }}</script><style>#test { width: 400px; height: 400px; margin: 40px auto;}</style>

效果如下圖所示

以上這篇在vue項目中引入highcharts圖表的方法(詳解)就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持武林網(wǎng)。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 江阴市| 阳东县| 天长市| 出国| 读书| 宝坻区| 鞍山市| 长顺县| 裕民县| 镇平县| 太保市| 涿州市| 河南省| 泽州县| 永新县| 广东省| 韶山市| 洪湖市| 永泰县| 正定县| 民权县| 麻栗坡县| 佛山市| 石楼县| 广丰县| 聂拉木县| 梧州市| 乐业县| 益阳市| 阜阳市| 板桥市| 玛多县| 大埔区| 嘉黎县| 根河市| 汉中市| 昔阳县| 永康市| 嘉祥县| 临汾市| 昌邑市|