I'm trying to dynamically enable and disable plugins rendered a react-chartjs-2 component.
The plugins that should be rendered are passed to the component like this:
import { useRef, useEffect } from 'react';
import { my_plugin_t} from '../types/all_types'
import { Chart as ChartJS, ChartType, registerables, ChartOptions } from 'chart.js';
import { Line } from 'react-chartjs-2';
const MyPlot = ({signals, plugin_list}: { signals: signal_t[], plugin_list: any[]}) => {
ChartJS.register(...registerables);
// ... chart setup of data and options...
return(
<>
<Line ref={chartRef} data={data} options={options} plugins={plugin_list} />
</>
)
}
When the plugin_list includes the plugins that need to be drawn in the first rendering of the component it shows up fine. When I leave it empty, it does not show up.
However, changing plugin_list does not toggle whether the plugin is enabled or disabled.
Is there a way to dynamically add or remove plugins to the Line component?