从 10.2.1 升级到 10.3.1 时,highcharts 条形图消失

问题描述 投票:0回答:1

我目前正在尝试将 highcharts 升级到最新版本,但遇到了麻烦。

我有一个具有以下配置的条形图:

{
            chart: {
                type: 'bar',
                height: 70,
                pointPadding: 0,
            },
            title: {
                text: null,
            },
            credits: {
                enabled: false,
            },
            xAxis: {
                type: 'datetime',
                visible: false,
            },
            yAxis: {
                type: 'datetime',
                min: startTime,
                max: endTime,
                visible: true,
                opposite: false,
                endOnTick: true,
                ordinal: false,
                minPadding: 0,
                maxPadding: 0,
                tickInterval: tickIntervalMs,
                minTickInterval: tickIntervalMs,
                reversedStacks: false,
                title: {
                    text: null,
                },
                labels: {
                    style: {
                        color: mfTheme.colorPalette.n500,
                    },
                    // This makes sure that the times are displayed in the correct timezone
                    formatter() {
                        return moment((this as any).value)
                            .tz(institutionTimezone)
                            .format('LT');
                    },
                },
            },
            time: {
                timezone: institutionTimezone,
                moment,
            },
            legend: {
                enabled: false,
            },
            tooltip: {
                borderWidth: 0,
                borderRadius: 24,
                backgroundColor: '#FFFFFF',
            },
            plotOptions: {
                series: {
                    stacking: 'normal',
                    pointWidth: 50,
                    groupPadding: 0,
                    pointPadding: 0,
                    borderWidth: 0,
                },
            },
            series,
        }
}

并且在版本 10.2.1 之前都呈现完美的效果

bar graph on highcharts 10.2.1

但是,当更新到 Highcharts 10.3.1 时,该栏就消失了,什么也不显示。 (不需要截图,只是全白)

研究图表,结果发现所有元素的高度和宽度均为 0。

我正在使用 highcharts-react-official 运行此程序。

我什至研究了更新说明中的 PR 更改,但找不到任何 PR 可以为我提供有关新版本实际出现问题的任何线索。

如何让图表重新出现?

codesandbox 可重现:

https://codesandbox.io/p/sandbox/highcharts-react-demo-forked-s82pdf?file=%2Fdemo.jsx

javascript typescript highcharts bar-chart
1个回答
0
投票

根据 API,

yAxis.min
应该是一个数字。我不确定为什么这在以前的版本中有效;也许这是一个打字缺陷,后来已经被修复了。例如,提供最小
yAxis
值的正确方法是时间戳,就像
yAxis.max
的情况一样。

演示: https://codesandbox.io/p/sandbox/highcharts-react-demo-forked-5623sy?file=%2Fdemo.jsx%3A31%2C1

API 参考: https://api.highcharts.com/highcharts/yAxis.min

© www.soinside.com 2019 - 2024. All rights reserved.