vue-schart : vue.js 的圖表組件


原文地址:http://blog.gdfengshuo.com/article/16/

介紹

vue-schart 是使用vue.js封裝了sChart.js圖表庫的一個小組件。支持vue.js 1.x & 2.x

sChart.js 作為一個小型簡單的圖表庫,沒有過多的圖表類型,只包含了柱狀圖、折線圖、餅狀圖和環形圖四種基本的圖表。麻雀雖小,五臟俱全。sChart.js 基本可以滿足這四種圖表的需求。而它的小,體現在它的體積上,代碼只有 8kb,如果經過服務器的Gzip壓縮,那就更小了,因此不用擔心造成項目代碼冗余。

該庫使用 canvas 實現,兼容 IE9 以上瀏覽器。

效果

demo

使用指南

安裝:

npm install vue-schart -S

在vue組件中使用:

<template>
    <div id="app">
        <schart :canvasId="canvasId"
            :type="type"
            :width="width"
            :height="height"
            :data="data"
            :options="options"
        ></schart>
    </div>
</template>
<script>
import Schart from 'vue-schart';
export default {
    data() {
        return {
            canvasId: 'myCanvas',
            type: 'bar',
            width: 500,
            height: 400,
            data: [
                {name: '2014', value: 1342},
                {name: '2015', value: 2123},
                {name: '2016', value: 1654},
                {name: '2017', value: 1795},
            ],
            options: {
                title: 'Total sales of stores in recent years'
            }
        }
    },
    components:{
        Schart
    }
}
</script>

應用

vue-manage-system 后台框架中應用了 vue-schart 組件,體積小,加載快。

演示地址:http://blog.gdfengshuo.com/example/work/#/basecharts

更多文章:lin-xin/blog


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM