We have some charts that we need curves & lines to end so certain values are left blank intentionally. When those values are left blank, the chart system assumes they are a zero and thus charts the line accordingly. Is there a way to allow blank values in the charts?
I am not sure if this is what you wish to achieve, but there is a custom workaround you can do if you wish to simply 'skip zero' or skip 'NULL' values so that the Chart does not show them in the series.
You can certainly try these variants and i hope one of them can help.
Please note that this specific workaround only works for the HighCharts Engine.
For other Chart Engines we don't currently have a workaround to skip NULL and/or zero values.
We will do our best to add them for other Chart Engines soon, but i can't say an ETA.
If you wish to affect that development speed, you can make a suggestion.
to see if someone may be already suggested this feature. If you can't see it, feel free to add your suggestion there, and as more people vote, the feature will move higher on the priority list.
You can certainly follow our changeLog page if you'd like ( it is also available in the plugin dashboard), where we state any changes/new features/bug fixes during updates;
and our newsletter, so you're informed about new features, bug fixes, freebies, etc.
-
If you wish to try this HighChart custom workaround, please 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 || intval($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 );
That one one 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.
Hello,
We have some charts that we need curves & lines to end so certain values are left blank intentionally. When those values are left blank, the chart system assumes they are a zero and thus charts the line accordingly. Is there a way to allow blank values in the charts?
Thank you!
Hi Dylan,
I am not sure if this is what you wish to achieve, but there is a custom workaround you can do if you wish to simply 'skip zero' or skip 'NULL' values so that the Chart does not show them in the series.
You can certainly try these variants and i hope one of them can help.
Please note that this specific workaround only works for the HighCharts Engine.
For other Chart Engines we don't currently have a workaround to skip NULL and/or zero values.
We will do our best to add them for other Chart Engines soon, but i can't say an ETA.
If you wish to affect that development speed, you can make a suggestion.
Please feel free to search on our suggestions page,
to see if someone may be already suggested this feature. If you can't see it, feel free to add your suggestion there, and as more people vote, the feature will move higher on the priority list.
You can certainly follow our changeLog page if you'd like ( it is also available in the plugin dashboard), where we state any changes/new features/bug fixes during updates;
and our newsletter, so you're informed about new features, bug fixes, freebies, etc.
-
If you wish to try this HighChart custom workaround, please go to the functions.php file of your theme or child theme, and add this:
That one one 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.
And as mentioned earlier, this only works for the HighCharts Engine,
I hope it helps.
Kind Regards,
Miloš Jovanović
[email protected]
Rate my support
Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/
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