Skip to content

silianpan/p-charts

Repository files navigation

p-charts

Chart components based on AntV G2

doc gitee Travis status antv-g2-deps antv-l7-deps NPM version

GitHub stars GitHub commit activity GitHub top language GitHub license

p-charts支持Vue3.x版本,查看分支vue3

Document

Blog

Examples

Gitee

Getting Started

installation

npm install -S p-charts
# or
yarn add p-charts

Usage

// main.js
import PCharts from 'p-charts'
Vue.use(PCharts)

p-pie

<template>
  <p-pie
    :data="PieJson"
    :options="options"
    ref="pieRef"
    @pie-title-click="handleTitleClick"
    @pie-label-click="handleLabelClick"
  />
</template>

<script>
import PieJson from './data/pie1.json'
export default {
  data() {
    return {
      PieJson,
      options: {
        fieldMap: {
          time: 'year',
          name: 'budgetSubject',
          // 统计指标,可以更换
          value: 'budgetNum'
        },
        title: `总收入和总支出占比情况-预算数(单位:万元)`,
        colorList: ['#1890ff', '#37c661']
      }
    }
  },
  methods: {
    updateData() {
      this.$refs.pieRef.initData()
    },
    handleTitleClick() {
      console.log('title-click')
    },
    handleLabelClick(data) {
      console.log('label-click', data)
    }
  }
}
</script>

Development

# install dependencies
npm install
# or
yarn

# serve with hot reload at localhost:8080
npm run dev
# or
yarn dev

# build for production with minification
npm run build
# or
yarn build