【问题标题】:JSON data into Chart in ReactJSON 数据到 React 中的图表
【发布时间】:2021-01-24 06:52:57
【问题描述】:

我正在尝试在图形中显示 JSON 数据,但出现问题并引发一堆错误,有人可以解释一下吗? 我应该改变什么?谢谢! JSON很简单

import * as React from 'react';
import Paper from '@material-ui/core/Paper';
import {
  Chart,
  PieSeries,
} from '@devexpress/dx-react-chart-material-ui';

import info from './data.json'

const data = {
    information: info.users
}


export default class Demo extends React.PureComponent {
  constructor(props) {
    super(props);

    this.state = {
      data,
    };
  }

  render() {
    // const { data: chartData } = this.state;
    return (
    
      <Paper>
        <Chart
          data={data}
        >
          <PieSeries
            valueField="area"
            argumentField="country"
          />
        </Chart>
      </Paper>
    );
  }
}

【问题讨论】:

    标签: node.js json reactjs material-ui


    【解决方案1】:
    1. 检查数据是否存在,

    2. 换行 常量 { 数据:chartData } = this.state; 到 常量 { 数据 } = this.state; 它是对象简洁属性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-30
      • 1970-01-01
      • 1970-01-01
      • 2021-02-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多