vue中v-charts的使用【移動(dòng)端可以上下左右滑動(dòng)】

vue中v-charts的使用

官方文檔:https://v-charts.js.org/#/

在使用 echarts 生成圖表時(shí),經(jīng)常需要做繁瑣的數(shù)據(jù)類型轉(zhuǎn)化、修改復(fù)雜的配置項(xiàng),v-charts 的出現(xiàn)正是為了解決這個(gè)痛點(diǎn)?;?Vue2.0 和 echarts 封裝的 v-charts 圖表組件,只需要統(tǒng)一提供一種對(duì)前后端都友好的數(shù)據(jù)格式設(shè)置簡單的配置項(xiàng),便可輕松生成常見的圖表。

1:在初次安裝的時(shí)候,用的是官方推薦

npm i v-charts echarts -S

? ? 但是在引入的時(shí)候總是報(bào)錯(cuò),換了下面這個(gè)指令就可以了,

npm install v-echarts echarts --save

2:可以按需引入或者全局引入

? ? 全局引入:

// main.js

import Vue from 'vue'

import VCharts from 'v-charts'

import App from './App.vue'

Vue.use(VCharts)

new Vue({

? el: '#app',

? render: h => h(App)

})

用法:柱狀圖

<div style="overflow-x:auto">

<div class="box">

? <ve-histogram :width="widthpx" :extend="extend"></ve-histogram>

</div>

</div>

//折線圖

<div? style="overflow-y:auto;height:100vh">

? ? <div class="box" style="width:100vw;overflow-x:auto;">

? ? ? <div class="line" v-bind:style="'width:'+imglength+'px'">

? ? ? ? <ve-line :data="chartData" :extend="extend" v-if='hackReset'></ve-line>

? ? ? </div>?

? ? </div>?

</div>

【列】按需引入:

import Vue from 'vue'

import VeLine from 'v-charts/lib/line'

import App from './App.vue'

Vue.component(VeLine.name, VeLine)

new Vue({

? el: '#app',

? render: h => h(App)

})

二。另外一個(gè)移動(dòng)端組件

教程:https://www.yuque.com/antv/f2/getting-started

demo:https://antv.alipay.com/zh-cn/f2/3.x/demo/index.html

安裝

npm install @antv/f2 --save

成功安裝完成之后,即可使用 import 或 require 進(jìn)行引用。

const F2 = require('@antv/f2');

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容