标签: react-charts

将 react-charts 功能组件示例转换为类组件

嘿,我在尝试将这个示例实现到我的 React 项目时遇到了很多麻烦。该示例与我的设置方式不同,我无法将其从他们的方式转换为我的方式。我有一个图表,但我真的希望包含渐变颜色。这就是我所得到的......

import React from 'react'
import { Chart } from 'react-charts'

class GraphClub extends React.Component {
  constructor(props) {
    super(props)

    this.state = {
      chartData: [
        {
          label: 'Won',
          data: [
            [0, 0],
          ],
        },
      ],
    }
  }


  componentDidMount() {
      //Get chartData
  }

  render() {
    return (
      <>
        <Chart
          data={this.state.chartData}
          axes={[
            {
              primary: true,
              type: 'linear',
              position: 'bottom',
              show: this.props.axis,
            },
            {
              type: 'linear',
              position: 'left',
              show: this.props.axis,
            },
          ]}
          series={{ type: 'line', showPoints: false }}
          tooltip
        /> …
Run Code Online (Sandbox Code Playgroud)

class reactjs react-charts

6
推荐指数
2
解决办法
154
查看次数

标签 统计

class ×1

react-charts ×1

reactjs ×1