I am building charts that plot values vs dates. Several of the date values simply don't have a value (blank, etc) but I can't figure out how to hide blank values in the charts. They shouldn't be reporting as zero because it just makes the chart look too crowded. Can we hide blank values in charts?
My wpDataTables is pulling from GoogleSheets. Any blank cell is coded with a using quotation marks value ("")
Below you can see that I set the wpDataTables to float instead of int, and that hides the values within wpDataTables. That information is fed to the chart in the attachment but you can see that all blank values are coded as zeros.
I've tried using several chart formats (Highcharts vs others etc)
Hello, We have a custom workaround to achieve this. Please note that this workaround only works for HighCharts Engine.
For other Chart Engines we don't currently have a workaround to skip NULL and/or zero values.
If you wish to try it, 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 );
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.
Will this be a development goal in the future? I'm having difficulty editing functions.php because my theme is symlinked and I can't access within FileZilla
I am honestly not 100% sure if we will be able to add a native/'out of the box' option for the charts to 'skip zeroes' and/or NULL values - but you can make a development suggestion, and we will do our best to work on it in the future.
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.
For the time being, it is only possible as this custom solution, as we sent it - and only for the HighCharts engine.
In regards to these difficulties of editing your functions.php file, I am sorry to hear that, but our Support is not able to cover that part. There are various tutorials/guides online and there must be other users who had the same issue, so I hope you will find a way to work around that specific issue to add a custom function/hook like this or there might be another way, perhaps not strictly by adding it via the Theme, etc.
I am building charts that plot values vs dates. Several of the date values simply don't have a value (blank, etc) but I can't figure out how to hide blank values in the charts. They shouldn't be reporting as zero because it just makes the chart look too crowded. Can we hide blank values in charts?
My wpDataTables is pulling from GoogleSheets. Any blank cell is coded with a using quotation marks value ("")
Below you can see that I set the wpDataTables to float instead of int, and that hides the values within wpDataTables. That information is fed to the chart in the attachment but you can see that all blank values are coded as zeros.
I've tried using several chart formats (Highcharts vs others etc)
Attached files: Ragweed test.png
Hello,
We have a custom workaround to achieve this.
Please note that this workaround only works for HighCharts Engine.
For other Chart Engines we don't currently have a workaround to skip NULL and/or zero values.
If you wish to try it, please 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.
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
Will this be a development goal in the future? I'm having difficulty editing functions.php because my theme is symlinked and I can't access within FileZilla
Hi Amer,
I am honestly not 100% sure if we will be able to add a native/'out of the box' option for the charts to 'skip zeroes' and/or NULL values - but you can make a development suggestion, and we will do our best to work on it in the future.
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.
For the time being, it is only possible as this custom solution, as we sent it - and only for the HighCharts engine.
In regards to these difficulties of editing your functions.php file, I am sorry to hear that, but our Support is not able to cover that part.
There are various tutorials/guides online and there must be other users who had the same issue, so I hope you will find a way to work around that specific issue to add a custom function/hook like this or there might be another way, perhaps not strictly by adding it via the Theme, etc.
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