- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在我的项目中使用 recharts(参见示例),有时在我使用 recahrts 组件的所有页面上出现错误(参见错误),我的应用程序崩溃,然后我重新安装节点模块并开始工作。我使用的是 recharts@1.7.1 版本。我不明白为什么会出现此错误以及如何解决它。将不胜感激。
{dataWithoutNullValue.length > 0 && windowWidth &&
<PieChart width={windowWidth < 500 ? 300 : 500} height={windowWidth < 400 ? 350 : 400} >
<Pie
data={dataWithoutNullValue}
innerRadius={90}
outerRadius={125}
paddingAngle={5}
dataKey="value"
isAnimationActive={false}
label={windowWidth > 500 && renderCustomizedLabel}
>
{
dataWithoutNullValue.map((entry, index) => <Cell key={`cell-${index}`} fill={COLORS[index % COLORS.length]} />)
}
</Pie>
{windowWidth < 500 && <Legend dataKey="value" />}
</PieChart>}
Error
ChartUtils.js:133 Uncaught TypeError: validateData.map is not a function
at getDomainOfDataByKey (ChartUtils.js:133)
at generateCategoricalChart.js:1019
at Array.reduce (<anonymous>)
at CategoricalChartWrapper.getAxisMapByAxes (generateCategoricalChart.js:995)
at CategoricalChartWrapper.getAxisMapByAxes (react-hot-loader.development.js:724)
at CategoricalChartWrapper.getAxisMap (generateCategoricalChart.js:942)
at CategoricalChartWrapper.getAxisMap (react-hot-loader.development.js:724)
at generateCategoricalChart.js:1598
at Array.reduce (<anonymous>)
at CategoricalChartWrapper.updateStateOfAxisMapsOffsetAndStackGroups (generateCategoricalChart.js:1596)
at CategoricalChartWrapper.updateStateOfAxisMapsOffsetAndStackGroups (react-hot-loader.development.js:724)
at new BarChart (generateCategoricalChart.js:830)
at new BarChart (eval at ES6ProxyComponentFactory (react-hot-loader.development.js:337), <anonymous>:14:7)
at constructClassInstance (react-dom.development.js:12923)
at updateClassComponent (react-dom.development.js:17060)
at beginWork (react-dom.development.js:18538)
at HTMLUnknownElement.callCallback (react-dom.development.js:189)
at Object.invokeGuardedCallbackDev (react-dom.development.js:238)
at invokeGuardedCallback (react-dom.development.js:291)
at beginWork$1 (react-dom.development.js:23078)
at performUnitOfWork (react-dom.development.js:22042)
at workLoopSync (react-dom.development.js:22018)
at performSyncWorkOnRoot (react-dom.development.js:21636)
at react-dom.development.js:11148
at unstable_runWithPriority (scheduler.development.js:659)
at runWithPriority$1 (react-dom.development.js:11094)
at flushSyncCallbackQueueImpl (react-dom.development.js:11143)
at flushSyncCallbackQueue (react-dom.development.js:11131)
at scheduleUpdateOnFiber (react-dom.development.js:21079)
at Object.enqueueSetState (react-dom.development.js:12693)
at Connect.push../node_modules/react/cjs/react.development.js.Component.setState (react.development.js:464)
at Connect.onStateChange (connectAdvanced.js:205)
at Connect.onStateChange (react-hot-loader.development.js:724)
at Object.notify (Subscription.js:23)
at Subscription.notifyNestedSubs (Subscription.js:60)
at Connect.onStateChange (connectAdvanced.js:202)
at Connect.onStateChange (react-hot-loader.development.js:724)
at Object.notify (Subscription.js:23)
at Subscription.notifyNestedSubs (Subscription.js:60)
at Connect.onStateChange (connectAdvanced.js:202)
at Connect.onStateChange (react-hot-loader.development.js:724)
at Object.dispatch (redux.js:222)
at e (<anonymous>:1:40553)
at index.js:11
at middleware.js:13
at middleware.js:72
at dispatch (redux.js:640)
at index.js:196
最佳答案
我也有同样的问题,我使用了 lodash-webpack-plugin 并且它导致了错误。在 lodash-wepback-plugin 文档中,扁平化功能会自动删除,这会导致错误。在 webpack 配置文件中,您可以启用展平功能:
new LodashModuleReplacementPlugin({
'flattening': true,
});
对我有用
关于reactjs - 为什么app crush with recharts components?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61268885/
我想使用 Recharts 绘制图表。 我目前正在查看他们网站上的文档中给出的示例。 将他们的代码复制到我的应用程序中后,我遇到以下错误: 'recharts' does not contain an
假设我正在使用 Recharts 创建条形图,我将如何为以下每个 Recharts 组件创建自定义组件: XAxis、YAxis、Tooltip、Legend、CartesianGrid、Cell 和
我正在尝试在 Recharts 图表的右下角添加一段静态文本(与显示的数据无关)。 我可以将一些 CSS 和 HTML 组合在一起,以从相邻的 DOM 元素获取文本,但我宁愿使用 recharts A
正如您在屏幕截图中看到的那样,在底部中心(x 轴),标签 Quiz/Exam 被裁剪了。我增加了折线图的高度,但它只会增加图表的大小。 最佳答案 我遇到了同样的问题并通过添加 margin 修复了它到
我有一个包含 14 个数据点的 Recharts LineChart(尽管将来这可能会有所不同,所以理想情况下我不想对它进行硬编码)。我想在 X 轴上显示 2 个刻度值 - 第一个和最后一个。 所以,
我的图表组件有一个非常简单的数据数组: {name: '12.1.2011', series1: 4000, series2: 2400, series3: 2400}, {name: '12.2.2
我的条形图中有三个不同的条形。 我希望条形图中的每个条形都有一个工具提示,而不仅仅是三个。 import React from 'react'; import { BarChart, Bar,
我对 React 和 Recharts 都很陌生,而且我有点进退两难。我做了很多阅读,但似乎找不到我要找的东西,所以我希望能在这里得到一些帮助。 我有一个数据集,其中包含具有已完成、失败和进行中状态的
我正在使用 recharts饼图库。 我想始终为两个值加载饼图。图表正在水平加载,如您所见 here从 Angular 0 开始。 但我希望它从 Angular 90 开始,如下所示。 PS:尝试更改
Recharts 文档描述了如何在悬停期间格式化数据点的样式以及工具提示。 然而,在悬停期间,文档中似乎没有描述出现的垂直实线(除非我遗漏了它)。 是否有允许格式化该行的 Prop ? (如果你不知道
我正在尝试在重新图表雷达图表上获取自定义标签工作。我已经尝试根据文档做多件事,所以我想我会把它扔给狼群。希望你们中的一个能指出我正确的方向。
我正在使用 Rechart 的散点图 数据显示正常,但我想工具提示显示一个额外的弹出窗口(项目的名称),就像它在条形图上一样。我发现我可以完全自定义工具提示,但我想知道是否有更简单的方法?就像一个我不
我正在使用双轴折线图,并试图弄清楚如何使用格式化程序功能来格式化工具提示的内容。 我想要的是让我的输出阅读: 2019-01-13 Price: $17.99 Sales Rank: 326,518
我创建了一个折线图,并尝试在其顶部放置 2 个标签,但没有成功。我在开头和结尾使用了 2 条引用线,以及它们上面的标签。我正在努力实现以下目标: L1 L2 | |_______ 代码:
是否可以在工具提示上为大数字添加逗号? 例如57,574 而不是 57574 谢谢! 最佳答案 是的,您可以使用 formatter 属性将任何格式化程序函数传递给工具提示组件,例如 new
我正在尝试学习如何使用 Rechart。该文档说您可以在图表元素上放置标签,并给出了如何使用“名称”作为标签数据键来执行此操作的示例。 我尝试在图表中执行此操作,但没有成功。 如果我从字段中删除“标签
我正在使用 Recharts 库创建 StackBarChart 示例,但当其位置设置为“右”时我无法看到标签 code> 虽然我可以显示其他标签位置。 ...
有没有办法关闭 Recharts 中条形图悬停时出现的灰色背景? ? 使用版本 1.4.1。代码(简化)如下所示: import React from "react" // Recharts impo
我想创建一个包含多行的 ReChart 组件。 到目前为止,我有这个虚拟代码。 Cyber assesment 数据是一个数组,有两个值对象
我正在尝试使用 reChart 呈现条形图以 100% 适合其容器: http://recharts.org/#/en-US/api/ResponsiveContainer
我是一名优秀的程序员,十分优秀!