【发布时间】:2016-04-09 00:08:10
【问题描述】:
我创建了一个小的反应程序来显示散点谷歌图表。我总共有 3 个文件:- a) index.html b)main.js 渲染我的 scatterChart & c) ScatterChart.js 这是我的 main.js 渲染的反应组件 ScatterChart.js 看起来像:
export default class PieChart extends React.Component {
constructor(){
super();
var myOptions = {
title: 'Age vs. Weight comparison',
hAxis: {title: 'Age', minValue: 0, maxValue: 15},
vAxis: {title: 'Weight', minValue: 0, maxValue: 15},
legend: 'none'
};
var myData = [
['Age', 'Weight'],
[ 8, 12],
[ 4, 5.5],
[ 11, 14],
[ 4, 5],
[ 3, 3.5],
[ 6.5, 7]
];
this.state={
data : myData,
options : myOptions
};
}
render() {
return(
<Chart chartType = "ScatterChart" data = {this.state.data} options = {this.state.options} graph_id = "ScatterChart" width={"100%"} height={"400px"} legend_toggle={true} />
);
}}
这会返回以下错误:
未捕获的不变违规:元素类型无效:预期为字符串(对于内置组件)或类/函数(对于复合组件)但得到:对象。检查ScatterChart的渲染方法。
【问题讨论】:
标签: reactjs google-visualization