问题描述
我正在开发 React 应用程序,其中我使用了 React 谷歌图表来显示带注释的折线图。但是我遇到了折线图中列的角色属性问题,已经在工作组件中导入了 react-google-charts。下面是我的代码:
Home.tsx > 组件
import * as React from 'react';
import { Chart } from 'react-google-charts';
import GoogleDataTableColumnRoleType from 'react-google-charts/dist/types';
export class Home extends React.Component<IChildComponentProps,AddDataState> {
constructor(props) {
super(props);
public render() {
<div id="chart_div2">
<Chart
width={400}
height={'300px'}
chartType="LineChart"
loader={<div>Loading Chart</div>}
rows={this.state.o3TargetChart}
columns={[
{
type: "string",label: "Week"
},{
type: "number",label: "O3Done"
},{
type: "string",role: GoogleDataTableColumnRoleType.annotation // getting error here
},label: "Target"
}
]}
options={{
title: '',hAxis: {
title: 'Week',titleTextStyle: {
},baselineColor: '#cccccc'
},vAxis: {
title: 'O3 Coverage ( in %)',minValue: 0,maxValue: 100,baselineColor: '#cccccc',},pointsVisible: true,chartArea: {
left: 100
},height: 400,width: 1000,}}
/>
</div>
}
}
虽然我可以在 node_modules 目录下找到 type 模块如下:
node_modules\react-google-charts\dist\types.d.ts
已经按照其他人的建议在 webpack.config.js 文件中添加了以下代码:
resolve: {
extensions: ['','.js','.jsx']
},
我仍然收到找不到模块的错误。请建议..
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)