【发布时间】:2020-05-25 07:35:28
【问题描述】:
我正在使用 react-chartjs-2(2.9.0) 和 chart.js(2.9.3) 在我的 react 应用程序中创建图表。图表在除 Microsoft Edge 44.18362.449.0 之外的所有浏览器中都能正常工作。
代码:
import React, { Component } from 'react';
import { Pie } from 'react-chartjs-2';
import { ReportSettings } from './ReportSettings';
import 'chartjs-plugin-labels';
class PIEChart extends Component {
render() {
const { reportData } = this.props;
let dataArr = [
reportData.Last360DaysCount,
reportData.Last180DaysCount,
reportData.Last90DaysCount,
reportData.Last30DaysCount,
];
let labels = ['Last 360 days', 'Last 180 days', 'Last 90 days', 'Last 30 days'];
const data = {
labels: labels,
datasets: [
{
backgroundColor: ['#6264A7', '#ddd', '#929191', '#BDBDE6', '#333', 'Purple'],
data: dataArr,
fill: true,
borderColor: '#fff',
hoverBackgroundColor: ['#6264A7', '#ddd', '#929191', '#BDBDE6', '#333', 'Purple'],
},
],
};
return (
<div className="Report">
<article className="canvas-container">
<div className="teamsummary">
<Pie data={data} width={400} height={400} />
</div>
</article>
</div>
);
}
}
export default PIEChart;
问题详情:
描述:“无效参数。” 消息:“无效参数。” 号码:-2147024809 堆栈:“错误:无效的参数。在适合 (http://localhost:3000/static/js/bundle.js:30571:3) 在更新 (http://localhost:3000/static/js/bundle.js:30474:3) 在 fitBoxes (http://localhost:3000/static/js/bundle.js:22325:3) 在 core_layouts.update (http://localhost:3000/static/js/bundle.js:22539:3) 在 updateLayout (http://localhost:3000/static/js/bundle.js:24878:3) 在更新 (@987654326 @) 在构造 (http://localhost:3000/static/js/bundle.js:24555:3) 在图表 (http://localhost:3000/static/js/bundle.js:24492:2) 在 renderChart (http://localhost:3000/static/js/bundle.js:113285:5) 在 componentDidMount (http://localhost:3000/static/js/bundle.js:113090:5) 在 commitLifeCycles (http://localhost:3000/static/js/bundle.js:140426:13) 在 commitLayoutEffects (http://localhost:3000/static/js/bundle.js:143660:7) 在 callCallback (http://localhost:3000/static/js/bundle.js:118694:9) )"
【问题讨论】:
-
我已经用一些测试数据(如this)测试了你的代码,看来代码在我这边运行良好(screenshot),请尝试清除浏览器数据并重新检查它。此外,在我的 react 应用程序中,我已经安装了 react-app-polyfill,你可以尝试安装它。如果仍然不能解决问题,可能问题与另一部分代码有关,您能否发布足够的代码(或创建Codepen)来重现问题。
-
该问题在旧边缘 44.18362.449.0 中可重现。当我在新的铬边上尝试这个时,这是不可重现的。你能告诉我你试过哪个版本的edge吗?同时我将在 codepen 上工作
-
我也在使用 Microsoft Edge 44.18362.449.0 版本。
标签: charts chart.js microsoft-edge react-chartjs