Crosshair is rendered on top of tooltips
CreativeCoders opened this issue · 5 comments
CreativeCoders commented
jclusso commented
Has anyone resolved this?
CreativeCoders commented
Not to my knowledge @jclusso
jclusso commented
@CreativeCoders actually this guys version adds an option drawUnderChart
that fixes this.
shi-314 commented
Here's is a very simple workaround, if you have the plugin globally registered in ChartJS:
// Fix for crosshair plugin drawing over the chart and tooltip
let crosshairPlugin = Chart.registry.plugins.get("crosshair");
const afterDraw = crosshairPlugin.afterDraw.bind(crosshairPlugin);
crosshairPlugin.afterDraw = function (chart, args, options) {};
crosshairPlugin.afterDatasetDraw = function (chart, args, options) {
afterDraw(chart, args, options);
};
This plugin is rendering the crosshair during the afterDraw
state which is triggered after the tooltip has been rendered. This workaround moves the rendering logic to the afterDatasetDraw
function instead.