[WordPress] Story of resolving the issue where graphs such as M Chart or Visualizer were not displayed
![[WordPress] Story of resolving the issue where graphs such as M Chart or Visualizer were not displayed](img/ogp.png)
A note on how to fix the issue where graphs were not displayed in a WordPress plugin that allows you to insert graphs.
Well-known ones like 「M Chart」や 「Visualizer」、 「WP Charts & Graphs」 and many others, I tried various plugins, but
They all behaved similarly: HTML was output, but the graphs were not displayed, likely due to JS errors.

The cause was deleting the default jQuery
The cause was deleting WordPress's jQuery, which is loaded by wp_head().
The functions.php code that caused the issue
// Delete default jQuery
function delete_jquery() {
if (!is_admin()) {
wp_deregister_script('jquery');
}
}
add_action('init', 'delete_jquery');
In the case of "M Chart", the following JS files need to be loaded:
- /wp-content/plugins/m-chart/components/js/m-chart-chartjs-helpers.min.js
- /wp-content/plugins/m-chart/components/external/chartjs/chart.js
- /wp-content/plugins/m-chart/components/external/chartjs/chartjs-plugin-datalabels.js
It seems that deleting the default jQuery also removes these.
So, first, try commenting out this description and see if the graph is displayed.
If it's displayed
If it's displayed, review the functions.php description.
If you are loading jQuery independently, WordPress's jQuery is indeed unnecessary,
Change the functions.php description as follows. (In the case of M Chart)
// Delete default jQuery
function delete_jquery() {
if (!is_admin()) {
wp_deregister_script('jquery');
// Load M Chart's JS
wp_enqueue_script('m-chart', plugins_url() . '/m-chart/components/js/m-chart-chartjs-helpers.min.js', array(), NULL, true);
wp_enqueue_script('chart-js', plugins_url() . '/m-chart/components/external/chartjs/chart.js', array(), NULL, true);
wp_enqueue_script('datalabels', plugins_url() . '/m-chart/components/external/chartjs/chartjs-plugin-datalabels.js', array(), NULL, true);
}
}
add_action('init', 'delete_jquery');
With this, WordPress's jQuery will be deleted, but the JS files required for "M Chart" will be loaded.
In the case of "Visualizer", it seems that JS files are dynamically generated in the upload folder and JS is written inline, so this approach might not be possible.
In that case, just delete the functions.php description.
Even with other plugins, observe what JS is loaded after deleting the functions.php description and try to address it.




If this was helpful, we appreciate your support!
Your support will be used for childcare.
Or support by buying something from the buttons below
(You don't have to buy the linked product.)
Amazon
楽天市場
Yahoo!ショッピング
PR