I would like to inquire if wpDataTables charts offer the ability to exclude empty values from the chart. I am currently using Gravity Forms, and I have encountered a situation where certain questions have conditional logic, resulting in empty answers. Consequently, I would prefer not to include these empty values in the chart. I have tried other chart plugins, but unfortunately, they were unable to address this issue. Hence, I am curious if wpDataTables charts can provide a solution for this.
Yes, we have a workaround how you can skip NULL and/or zero values in our Charts.
Here is how we do that.
You would go to the functions.php file of your theme or child theme, and add this:
function filterNullValues ($value, $origHeader ,$chartID, $tableID){
// You can add conditions for specific org header, chart id or table id
// Here we only check if value is null and provide same value to the chart object
if (is_null($value) || $value == 0){
$value = null;
}
return $value;
}
add_filter( 'wpdatatables_filter_int_cell_data_in_charts', 'filterNullValues', 10, 4 );
add_filter( 'wpdatatables_filter_float_cell_data_in_charts', 'filterNullValues', 10, 4 );
This works for integer and float columns that have NULL values and "0" values.
If you want to apply it just for NULL values, you can use this code:
function filterNullValues ($value, $origHeader ,$chartID, $tableID){
// You can add conditions for specific org header, chart id or table id
// Here we only check if value is null and provide same value to the chart object
if (is_null($value)){
$value = null;
}
return $value;
}
add_filter( 'wpdatatables_filter_int_cell_data_in_charts', 'filterNullValues', 10, 4 );
add_filter( 'wpdatatables_filter_float_cell_data_in_charts', 'filterNullValues', 10, 4 );
And if you want to apply it just for "0" values, you can use this code:
function filterNullValues ($value, $origHeader ,$chartID, $tableID){
// You can add conditions for specific org header, chart id or table id
// Here we only check if value is null and provide same value to the chart object
if ($value == 0){
$value = null;
}
return $value;
}
add_filter( 'wpdatatables_filter_int_cell_data_in_charts', 'filterNullValues', 10, 4 );
add_filter( 'wpdatatables_filter_float_cell_data_in_charts', 'filterNullValues', 10, 4 );
You don't need to change the code after the plugin updates, but you will need to keep this code in functions.php.
I would like to inquire if wpDataTables charts offer the ability to exclude empty values from the chart. I am currently using Gravity Forms, and I have encountered a situation where certain questions have conditional logic, resulting in empty answers. Consequently, I would prefer not to include these empty values in the chart. I have tried other chart plugins, but unfortunately, they were unable to address this issue. Hence, I am curious if wpDataTables charts can provide a solution for this.
Hi, Fatlind.
Yes, we have a workaround how you can skip NULL and/or zero values in our Charts.
Here is how we do that.
You would go to the functions.php file of your theme or child theme, and add this:
This works for integer and float columns that have NULL values and "0" values.
If you want to apply it just for NULL values, you can use this code:
And if you want to apply it just for "0" values, you can use this code:
You don't need to change the code after the plugin updates, but you will need to keep this code in functions.php.
If you want to connect data with NULLs skipped, you can use this callback: https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-connectnulls-true/
Just make sure to replace [16] with the ID of your chart.
-
We also have an integration with Gravity Forms, so you can output the data from them in our tables,
if you get our premium add-on Integration With Gravity Forms.
Please check more about this add-on here.
Before purchase you can test all plugin and Add-on features on our sandbox site.
-
You can also check out all the available chart engines and examples of wpDataCharts documentation here .
Let us know if you have any additional questions.
Kind Regards,
Miloš Jovanović
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables