【发布时间】:2019-01-03 06:09:03
【问题描述】:
我已经安装了 react 图表组件并将其导入到我的项目中。但是导入后出现如下错误:
对这个问题有任何帮助吗? 我有以下代码:
import PropTypes from "prop-types";
import { connect } from "react-redux";
import React, { Component } from "react";
// import LineChart from 'react-chartjs';
// import { Sparklines, SparklinesBars } from 'react-sparklines';
import Chart from "react-google-charts";
class AnalyticsPage extends Component {
render() {
const data = [
["Year", "Visitations", { role: "style" }],
["2010", 10, "color: gray"],
["2020", 14, "color: #76A7FA"],
["2030", 16, "color: blue"],
[
"2040",
22,
"stroke-color: #703593; stroke-width: 4; fill-color: #C5A5CF"
],
[
"2050",
28,
"stroke-color: #871B47; stroke-opacity: 0.6; stroke-width: 8; fill-color: #BC5679; fill-opacity: 0.2"
]
];
return (
<div>
Analytics
<div>
<Chart chartType="BarChart" width="100%" height="400px" data={data} />
</div>
</div>
);
}
}
const AnalyticsPageWithRedux = connect()(AnalyticsPage);
export default AnalyticsPageWithRedux;
【问题讨论】:
-
你试过这样吗:import {Chart} from "react-google-charts";
-
是的 @RohanVeer 刚刚尝试过,仍然遇到同样的问题。
标签: javascript reactjs react-redux react-component