Estoy usando amcharts v4.10.20. Estoy tratando de sincronizar el movimiento del cursor y hacer zoom en varios gráficos. Usando ejemplos de la documentación, logré que la sincronización del zoom funcionara, pero no tuve suerte con los cursores.
function syncDateAxes(syncWithAxis) { for (let i = 0; i < props.chartsRef?.current.length; i += 1) { const chart = props.chartsRef?.current[i]; const dateAxis = chart.xAxes.getIndex(0); if (dateAxis && dateAxis !== syncWithAxis) { try { dateAxis.events.disableType("selectionextremeschanged"); dateAxis.start = syncWithAxis.start; dateAxis.end = syncWithAxis.end; dateAxis.events.enableType("selectionextremeschanged"); } catch (error) { console.log(error); } } } } chart.cursor.adapter.add("cursorPoint", function cursorPoint(point) { if ( props.chartsRef?.current[0]?.scrollbarX && props.chartsRef?.current[0]?.scrollbarX.isBusy ) { point.y = -1000; } else if (!chart.cursor.fitsToBounds(point)) { point.y = 0; chart.cursor.lineY.visible = false; const _cursor = chart.yAxes.getIndex(0); if (_cursor) { _cursor.cursorTooltipEnabled = false; } } else { chart.cursor.lineY.visible = true; const _cursor = chart.yAxes.getIndex(0); if (_cursor) { _cursor.cursorTooltipEnabled = true; } } return point; }); xAxis.events.on( "selectionextremeschanged", function selectionextremeschanged(event) { syncDateAxes(event.target); } );Tengo una demostración de trabajo que puedes bifurcar. DEMO DE TRABAJO
Piense en una solución diferente que podría estar usando estos.
https://www.amcharts.com/docs/v4/tutorials/tracking-cursors-position-via-api/
https://www.amcharts.com/docs/v4/tutorials/positioning-xy-cursor-via-api/#Moving_cursor_to_point
ACTUALIZACIÓN: así que hice algunos progresos y creé una bifurcación con cambios. FORKED_DEMO
Funciona, pero a veces falla con
TypeError: no se pueden leer las propiedades de null (leyendo 'push')