JavaScript Events
Available since version 2.0. These are native CustomEvent events dispatched on the chart's <canvas> element on the front end.
m_chart.render_done
Fired on the canvas element after the chart has finished rendering. Includes a reference to the Chart.js chart instance.
document.querySelectorAll( 'canvas.m-chart' ).forEach( ( canvas ) => {
canvas.addEventListener( 'm_chart.render_done', ( event ) => {
const { post_id, instance } = event.detail;
console.log( 'Chart', post_id, 'instance', instance, 'rendered' );
} );
} );
event.detail properties:
post_id(int) — The chart post IDinstance(int) — The instance number
Fires on its own canvas since 2.4
Before 2.4 each chart dispatched the event on every canvas.m-chart on the page, each carrying its own post_id. Since 2.4 it fires only on the canvas that rendered. Listeners on individual canvases get exactly one event per chart.
Highcharts
The Highcharts Library plugin dispatches its own m_chart.render_done event with the Highcharts chart instance included in event.detail, and an additional render_start event before rendering begins. The core Chart.js dispatch does not expose the chart instance on the event — see Highcharts JavaScript Events for the Highcharts-specific event shapes.
Same name as the admin wp.hooks action
The front-end CustomEvent m_chart.render_done and the admin-side wp.hooks action m_chart.render_done are intentionally identically named — same semantic event ("the chart has finished rendering") exposed through two different mechanisms (a DOM CustomEvent on the front end, a wp.hooks action in the admin React app). Listen via canvas.addEventListener( 'm_chart.render_done', ... ) on the front end and wp.hooks.addAction( 'm_chart.render_done', ..., callback ) in the admin.
M Chart Pro tables
On a chart using M Chart Pro's Display as Table, m_chart.render_done and the deprecated render_done fire on the <table class="m-chart-pro-table"> element instead of a canvas, with the same event.detail shape. The events bubble, but a canvas.m-chart selector will not find them; listen on the chart container or on document.
Deprecated event name: render_done
Prior to v2.1, the event was named just render_done (no namespace). That name is still dispatched for backward compatibility but is deprecated and will be removed in v3. Update any listeners to use m_chart.render_done instead.
Migrating from v1
In v1.x these events were jQuery custom events (.on('render_done', ...)). In v2.0+ they are native CustomEvent events dispatched on the canvas element. Event data is accessed via event.detail rather than the jQuery handler arguments. See Migrating to v2.
MChartHelper helpers
window.MChartHelper is the Chart.js plugin M Chart registers on every chart. Since 2.4 it also exposes two functions for front end code.
MChartHelper.formatValue( chart, value, affixes )
Format a value the way M Chart's tooltips and data labels do. Pass a parsed data point from a dataset's rawData ({ value, prefix, suffix, text }) or a plain number with optional { prefix, suffix }. The chart's options.locale drives the number formatting.
canvas.addEventListener( 'm_chart.render_done', ( event ) => {
const chart = Chart.getChart( event.target );
const raw = chart.data.datasets[ 0 ].rawData[ 0 ];
console.log( MChartHelper.formatValue( chart, raw ) ); // "$1,234.5"
console.log( MChartHelper.formatValue( chart, 7, { suffix: '%' } ) ); // "7%"
} );
MChartHelper.dispatchRenderDone( el, detail )
Dispatch m_chart.render_done and the deprecated render_done on one element, bubbling, with the given event.detail. Plugins that render a chart's data some other way can fire the same events core does.
MChartHelper.dispatchRenderDone( tableElement, { post_id: 12, instance: 1 } );
MChartHelper is only loaded when the chart is drawn by Chart.js, see m_chart_render_uses_chartjs.
Internal Events
These events are dispatched by the admin UI for its own coordination. They are not part of the public API — names, payload shapes, and the fact that they exist at all are subject to change without notice. Extensions should not depend on them.
m-chart-tab-nav— Bubbled from individual sheet tab elements to coordinate cross-tab keyboard navigation (Arrow keys, Home, End) in the multi-sheet tab bar.