GithubHelp home page GithubHelp logo

hhy5277 / qcharts-vue Goto Github PK

View Code? Open in Web Editor NEW

This project forked from qcharts/qcharts-vue

0.0 1.0 0.0 1.54 MB

qcharts-vue 是一个基于 spritejs , QCharts 封装的图表库,可以让用户以组件的形式组合出各种图表。

License: MIT License

JavaScript 88.27% Vue 11.73%

qcharts-vue's Introduction

快速开始

特点

qcharts-vue 是一个基于 spritejs , QCharts 封装的 Vue 图表库,可以让用户以组件的形式组合出各种图表。 → 详细文档

如何使用

1.通过 npm 获取 CatChartsVue,我们提供了 CatChartsVue npm 包,通过下面的命令即可完成安装,Demo:Quickstart

npm install qcharts-vue --save
// 通过模块引入的方式使用CatCharts
import * as QchartsVue from 'qcharts-vue'
Vue.use(QchartsVue)

2.通过 cdn 获取 QchartsVue,通过下面的标签引入 QchartsVue,因为 QchartsVue 依赖 Vue 与 spritejs,所以需要先引入这两个,Demo:Quickstart

<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://unpkg.com/spritejs@3/dist/spritejs.min.js"></script>
<script src="https://unpkg.com/@qcharts/core@1/dist/index.js"></script>
<script src="https://unpkg.com/qcharts-vue/lib/index.js"></script>
// 通过cdn的方式使用CatCharts
Vue.use(QchartsVue)

开始绘制图表

完成一个 QchartsVue 的组件或者页面

<template>
  <div class="chart">
    <s-chart :data="lineData" :data-fields="dataFields" :size="[700,600]">
      <s-line :attrs="attrs" />
      <s-axis :attrs="{orient:'left'}" />
      <s-axis :attrs="{orient:'bottom'}" />
      <s-tooltip :attrs="tooltipAttrs" />
    </s-chart>
  </div>
</template>
<script>
  export default {
    data: function() {
      return {
        attrs: {
          pos: ['10%', '10%'],
          size: ['80%', '80%']
        },
        lineData: [
          { date: '05-01', catgory: '图例一', sales: 15.2 },
          { date: '05-02', catgory: '图例一', sales: 39.2 },
          { date: '05-03', catgory: '图例一', sales: 31.2 },
          { date: '05-04', catgory: '图例一', sales: 65.2 },
          { date: '05-05', catgory: '图例一', sales: 55.2 },
          { date: '05-06', catgory: '图例一', sales: 75.2 },
          { date: '05-07', catgory: '图例一', sales: 95.2 },
          { date: '05-08', catgory: '图例一', sales: 65.2 }
        ],
        tooltipAttrs: {
          formatter: data => `${data.date}-${data.catgory}-${data.sales}`
        },
        dataFields: {
          row: 'catgory',
          value: 'sales',
          text: 'date'
        }
      }
    }
  }
</script>
<style>
  .chart {
    height: 600px;
  }
</style>

一张折线图就绘制成功

qcharts-vue's People

Contributors

yaotaiyang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.