React에서 상위 차트에 주석을 동적으로 추가하려고합니다. 내 앱에서 호버 이벤트가 발생했지만 주석이 렌더링되지 않을 때마다 addAnnotation
함수를 사용하여 새 주석을 추가합니다. 디버거를 코드에 추가했는데 chart.annotations
을 호출하면 현재 주석 배열이 있음을 알 수 있지만 렌더링되지 않습니다. 심지어이 함수에서 addPlotLine
에 전화를 걸었고 plotline이 차트에 렌더링되었습니다. 내 설정 파일이하이 차트 주석이 렌더링되지 않습니다.
chart: {
annotations: [{
labelOptions: {
backgroundColor: 'rgba(0, 0, 0, 0.5)',
verticalAlign: 'top',
align: 'right',
}
}],
annotationsOptions: {
},
.... some lots more config options
}
모양과 내가 찾은
if(isNumber(value))
//this renders a plotline
chart.xAxis[0].addPlotLine(baseChartHandle.generateInteractivePlotLine(value));
// this doesn't render my annotation however
chart.addAnnotation({
linkedTo: value,
title: {
text: "It works!"
}
});
}
주석 라이브러리 ('modules/annotations.js')를 포함 시켰습니까? – wergeld
파일에'require ('highcharts/modules/annotations') (ReactHighcharts.Highcharts);가 포함되어 있습니다. – Jstuff
다른 아이디어가 있습니까? 왜 작동하지 않는지 잘 모르겠다. – Jstuff