我正在使用 react-highcharts 為一些工作數(shù)據(jù)繪制一個相對簡單的柱形圖。老板們希望將其設(shè)置為隱藏圖例中的項(xiàng)目將調(diào)整比例,即使該元素位于圖表中間。我按照highcharts 論壇上的這個小提琴來使我的數(shù)據(jù)消失并重新出現(xiàn)。太好了,一切正常!但是我有一個我無法在我的代碼中確定的錯誤。每當(dāng)我刪除并返回最右邊的可見元素時,右數(shù)第二個元素就會丟失其數(shù)據(jù)標(biāo)簽。我相當(dāng)確定問題出在我的 HighCharts 選項(xiàng)對象上。下面是: 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 選項(xiàng)是:immutable: true 和 allowChartUpdate: true如果有人認(rèn)為其他事情是相關(guān)的,我很樂意提供更多信息,我只需要稍微清理一下就可以繼續(xù)了。
在 Highcharts 中,當(dāng)重新啟用圖表最右邊的元素時,我的數(shù)據(jù)標(biāo)簽消失了
慕碼人2483693
2023-04-27 10:24:08