WebDataRock TypeError:无法读取 nul 的属性“元素”和 WebDataRocks:无法绘制枢轴。
问候。
我尝试在我的 react-app 项目中实现 WebDataRocks,我可以实现 WebDataRock.Pivot 组件,但由于开始渲染组件,控制台打印此消息
webdatarocks.js:180 Uncaught TypeError: Cannot read property 'element' of null at new e (webdatarocks.js:180) at b.setControls (webdatarocks.js:1006) at webdatarocks.js:992
几秒钟后,控制台打印:
index.js:1 WebDataRocks:无法绘制枢轴。
import React from "react";
import ReactDOM from "react-dom";
import WebDataRocks from "webdatarocks";
export class Pivot extends React.Component<WebDataRocks.Params, any> {
webdatarocks: WebDataRocks.Pivot;
componentDidMount() {
const tempProps : any = this.props;
const pivotData = tempProps.pivotData;
const columnsData : any[] = tempProps.columnsData;
const tempColums = [];
const tempKeys = [];
columnsData.forEach(cd => {
const tempLabelColumn = cd.title;
tempColums.push(tempLabelColumn);
tempKeys.push(cd.key);
});
this.webdatarocks = new WebDataRocks({
toolbar: true,
report: {
dataSource: {
data: pivotData
},
slice: {
rows: tempKeys,
expands: {
expandAll: true
},
measures: [{
"uniqueName": "Price",
"aggregation": "sum",
"format": "currency"
}, {
"uniqueName": "Discount",
"aggregation": "sum",
"format": "currency"
}],
columns: tempColums,
},
options: {
"grid": {
"type": "flat"
},
},
formats: [{
"name": "",
"thousandsSeparator": " ",
"decimalSeparator": ".",
"decimalPlaces": 2,
"maxSymbols": 20,
"currencySymbol": "",
"currencySymbolAlign": "left",
"nullValue": " ",
"infinityValue": "Infinity",
"divideByZeroValue": "Infinity"
}]
},
container: ReactDOM.findDOMNode(this)
});
}
componentWillUnmount() {
// console.log('componentWillUnmount this.webdatarocks', this.webdatarocks.dispose);
if (this.webdatarocks.dispose) {
// this code break the system
// this.webdatarocks.dispose();
}
}
shouldComponentUpdate() {
return false;
}
render() {`enter code here`
return <div>Pivot</div>;
}
}
export default Pivot;
有人可以帮我解决这个问题吗?
谢谢,我很感激任何帮助。