我正在使用 react-highcharts 為一些工作數據繪制一個相對簡單的柱形圖。老板們希望將其設置為隱藏圖例中的項目將調整比例,即使該元素位于圖表中間。我按照highcharts 論壇上的這個小提琴來使我的數據消失并重新出現。太好了,一切正常!但是我有一個我無法在我的代碼中確定的錯誤。每當我刪除并返回最右邊的可見元素時,右數第二個元素就會丟失其數據標簽。我相當確定問題出在我的 HighCharts 選項對象上。下面是: const highChartsOptionsObject= {chart: { type: "column", style: { fontFamily: "helvetica", }, height: 300,},title: { text: null,},xAxis: { allowDecimals: true, type: "category", crosshair: true,},yAxis: { min: 0, title: { text: getLabel(), }, labels: { formatter: getLabelString() }, },},credits: { enabled: false,},legend: { enabled: true,},tooltip: { formatter: function () { return ` <b>${this.point.name}</b><br /> ${ getTooltip(); } `; },},plotOptions: { column: { stacking: "normal", pointPadding: 0.3, borderWidth: 0, dataLabels: { enabled: true, crop: false, overflow: "none", formatter: function () { const labelString = "hard coded test"; return labelString; }, }, }, series: { cursor: "pointer", events: { legendItemClick: function () { if (this.visible) { this.setData([], false); } else { let elementData = getSeries()[this.index].data[0]; this.setData([{ ...elementData }], false); } }, }, },},series: getSeries(),};作為參考,我的其他 highcharts 選項是:immutable: true 和 allowChartUpdate: true如果有人認為其他事情是相關的,我很樂意提供更多信息,我只需要稍微清理一下就可以繼續了。
在 Highcharts 中,當重新啟用圖表最右邊的元素時,我的數據標簽消失了
慕碼人2483693
2023-04-27 10:24:08