Table of Contents
How to create ApexCharts charts in WordPress with wpDataTables
Say you run an online course platform and want a modern dashboard page: a gradient donut of students per course, a 100% stacked column chart of completion rates and line charts that highlight the same week when visitors hover over any of them. ApexCharts is an open-source library for modern, interactive charts, and wpDataTables builds them from your table data without any code.
What is ApexCharts?
ApexCharts is an open-source, modern chart library for interactive data visualizations, and one of the engines in wpDataTables Premium. It adds options the other engines don’t have, such as gradients, monochrome color schemes, a toolbar with zoom and downloads, and drop shadows.
How do I create a ApexCharts chart in the chart wizard?
Go to wpDataTables → Create a Chart, name the chart, choose ApexCharts as the engine and click a chart type, then follow the wizard. ApexCharts offers 18 chart types. The steps after the engine are the same for every engine: the data source, the data range, the formatting with a live preview and Save chart, as described in how to create a chart in the chart wizard.
Which ApexCharts chart types does wpDataTables support?
wpDataTables supports 18 ApexCharts chart types. Each needs one text or date column for the labels and number columns for the values:
| Chart type | Data it needs | Notes |
|---|---|---|
| Line | 1 text or date column + 1 or more number columns | Can be combined with other series types |
| Spline | 1 text or date column + 1 or more number columns | Can be combined with other series types |
| Stepline | 1 text or date column + 1 or more number columns | Can be combined with other series types |
| Column | 1 text or date column + 1 or more number columns | Can be combined with other series types |
| Stacked column | 1 text or date column + 1 or more number columns | |
| 100% stacked column | 1 text or date column + 1 or more number columns | |
| Bar | 1 text or date column + 1 or more number columns | |
| Stacked bar | 1 text or date column + 1 or more number columns | |
| 100% stacked bar | 1 text or date column + 1 or more number columns | |
| Area | 1 text or date column + 1 or more number columns | Can be combined with other series types |
| Spline area | 1 text or date column + 1 or more number columns | Can be combined with other series types |
| Stepline area | 1 text or date column + 1 or more number columns | Can be combined with other series types |
| Pie | 1 text or date column + exactly 1 number column | |
| Pie gradient | 1 text or date column + exactly 1 number column | |
| Donut | 1 text or date column + exactly 1 number column | |
| Donut with gradient | 1 text or date column + exactly 1 number column | |
| Radar | 1 text or date column + 1 or more number columns | |
| Radial bar | 1 text or date column + exactly 1 number column |
How do I combine chart types?
Change the type of a series and set several vertical axes in the Series group of the Formatting and preview step. It works for line, spline, stepline, basic area, spline area, stepline area and basic column charts.
How do I make several charts react together?
Create the charts separately with the same horizontal axis, add them to one page, and add a wpDataCharts callback that gives each chart a unique ID and the same group. When visitors hover over one chart, all charts in the group show the values for the same point. For four charts with the IDs 1 to 4, add this script to the page:
<script type="text/javascript">
jQuery(window).on('load', function(){
if( typeof wpDataChartsCallbacks == 'undefined' ){ wpDataChartsCallbacks = {}; }
wpDataChartsCallbacks[1] = function(obj){
obj.options.chart.id = 'line-1',
obj.options.chart.group = 'sync'
}
wpDataChartsCallbacks[2] = function(obj){
obj.options.chart.id = 'line-2',
obj.options.chart.group = 'sync'
}
wpDataChartsCallbacks[3] = function(obj){
obj.options.chart.id = 'area-1',
obj.options.chart.group = 'sync'
}
wpDataChartsCallbacks[4] = function(obj){
obj.options.chart.id = 'area-2',
obj.options.chart.group = 'sync'
}
});
</script>
Replace the numbers in wpDataChartsCallbacks[1] with your chart IDs. The id must be different for each chart, and the group, here sync, must be the same. Set the same height for all charts in the wizard, for example 160 px, so they line up.
What should I remember about ApexCharts?
ApexCharts is the Premium engine for modern charts with gradients, toolbars and zoom. Choose ApexCharts in Create a Chart, pick a type whose data needs match your table, combine series types in the Series group, and sync several charts with a callback.
Where can I read more?
These pages cover creating charts and the other engines: