Chart.js is a free, open-source JavaScript chart library that wpDataTables uses as one of its chart rendering engines.
Chart.js is an Open Source JavaScript graph library, which renders simple and flexible charts that work on all platforms.
The wpDataTables plugin allows inserting Chart.js in WordPress posts or pages with a simple step-by-step wizard.
The steps needed to create any chart or JavaScript graph and insert it into a WordPress post or page are explained in the guide on creating charts with the chart creation wizard (they are the same for any rendering engine – Google Charts, Highcharts or Chart.js). Here we will cover Chart.js types and chart examples which are supported by the wpDataTables plugin, along with the data charts features. For an overview of everything you can build, see the WordPress charts and graphs feature page.
Which Chart.js version does wpDataTables use?
wpDataTables uses Chart.js v4.x, so callbacks written for older versions may need to be checked.
Please note: The Chart.js library has been updated to v4.x, so if you used wpDataChart callbacks, please verify that they still work as they should because the object packing structure has been changed. You can review how callbacks work in the wpDataCharts callbacks documentation.
The Chart.js 3.x migration guide can be found on the Chart.js website.
The Chart.js 4.x migration guide can be found on the Chart.js website.
Chart.js included most changes in 3.x, so make sure to check out both guides, as they are not the same.
Which Chart.js chart types does wpDataTables support?
wpDataTables supports Chart.js line, area, stacked area, column, stacked column, bar, stacked bar, radar, polar, pie, doughnut and bubble charts. Each type and its data requirements are described below.
How does a Chart.js line chart work?
A Chart.js line chart plots data points on a line and needs one string or date column plus at least one numerical column.
A line chart is a way of plotting data points on a line. Often, it is used to show trend data, and a comparison of two data sets:
- One string or date column supported (it will be used as the horizontal axis)
- Other columns should have numerical values.
- A minimum of 2 columns is required.