javascript - 如何在 react-jsx-highstock (Highcharts)中动态查找 x 轴 plotband 宽度的宽度?
问题描述
我正在使用https://www.npmjs.com/package/react-jsx-highstock库来绘制数据。我想动态地知道绘图带的宽度,当我检查 Highcharts 时,有事件重绘和加载,我们可以通过这些事件找到绘图带的宽度(http://jsfiddle.net/hfrntt/fdTEx/4661/)。现在我想知道它在react-jsx-highstock库中是如何工作的。由于这个库提供了 react 组件,所以不知道在哪里添加这些事件。
import { Chart, HighchartsStockChart, PlotBand, Series, useChart, XAxis, YAxis } from 'react-jsx-highstock'
<HighchartsStockChart plotOptions={plotOptions}>
<Chart {...chartOptions} />
<GenericOptions {...genericOptions} />
<XAxis {...xAxis}>
{(dayBands || []).map((plotBand) => (
<PlotBand key={`{plotBand.label?.text}`} {...plotBand} />
))}
</XAxis>
<YAxis {...yAxis}>
{(seriesData || []).map((series, index) => (
<Series key={index} id={index} {...series} />
))}
</YAxis>
</HighchartsStockChart>
解决方案
我鼓励您使用完全支持的 highcharts-react-official 包装器。
https://github.com/highcharts/highcharts-react
https://www.npmjs.com/package/highcharts-react-official
稍后,请使用示例数据在在线编辑器上重现您的问题,您可以从这个演示开始:https ://codesandbox.io/s/highcharts-react-demo-gnev1?file=/demo.jsx
推荐阅读
- json - 使用 cookie 从 JSON 获取对象
- sqlite - .net Core/Standard 的 SQLite 库:MS EF 还是 sqlite.org?
- wiremock - 在存根的 json 文件中生成当前日期
- c++ - 如何将这些 OpenGL 着色器转换为适用于 android NDK 的 GLES3 的 OpenGL ES 着色器?
- php - Laravel Eloquent 中的控制器方法问题
- c# - 从手机到 PC C# Xamarin.Forms 的蓝牙连接
- java - 当方向改变时保持价值
- ios - 如何为不同的屏幕设置自动大小文本
- python - 如何在没有实例的情况下引用父类的类变量
- javascript - 使用 jquery 更改单击的 div 内的锚标记的 css