Skip to content

spritejs/cat-charts-react

Folders and files

NameName
Last commit message
Last commit date

Latest commit

053e81a · Dec 26, 2019

History

54 Commits
Jul 16, 2019
Dec 26, 2019
Jul 16, 2019
Dec 26, 2019
Jul 16, 2019
Jun 13, 2019
Jun 13, 2019
Jun 13, 2019
Dec 2, 2019
Jun 13, 2019
Jun 13, 2019
Jun 17, 2019
Jun 13, 2019
Jun 17, 2019
Nov 5, 2019
Nov 4, 2019
Nov 4, 2019

Repository files navigation

cat-charts-react

基于 QCharts 封装的 React 图表组件库。使用上基本与 QCharts 一致。 → 详细文档

安装

npm

npm i spritejs @qcharts/core cat-charts-react

CDN

在 HTML 文件依次引入 spritejs@qcharts/corecat-charts-react

<script src="https://unpkg.com/spritejs/dist/spritejs.min.js"></script>
<script src="https://unpkg.com/@qcharts/core/lib/index.js"></script>
<script src="https://unpkg.com/cat-charts-react/lib/index.js"></script>

绘制

import React from 'react'
import ReactDOM from 'react-dom'
import { Chart, Bar, Axis } from 'cat-charts-react'

function App() {
  const data = [
    { value: 6100, label: 'TOP1' },
    { value: 5200, label: 'TOP2' },
    { value: 4400, label: 'TOP3' },
    { value: 3700, label: 'TOP4' },
    { value: 2800, label: 'TOP5' },
    { value: 2000, label: 'TOP6' },
    { value: 1300, label: 'TOP7' },
    { value: 400, label: 'TOP8' }
  ]
  const dataFields = {
    row: '*',
    value: 'value',
    text: 'label'
  }

  return (
    <Chart data={data} dataFields={dataFields} forceFit={true}>
      <Bar />
      <Axis />
      <Axis orient={'left'} />
    </Chart>
  )
}

ReactDOM.render(<App />, document.querySelector('#app'))

Demo:Quickstart