Can you advise on how to plot empty values so that they are not rendered in the chart? right now we have zeros for empty values and they show up as horizontal line - which should NOT be rendered let me show the chart
If you have zeros in your table, that is an issue we've been dealing with, because integer and float columns cannot have anything other than numbers in them, the plugin is treating an empty cell as "0"
I can try and help you out, but you have to make some changes in code in file :
/wp-content/plugins/wpdatatables/source/class.wpdatachart.php around line 1631:
case 'int': $return_data_row[] = (float)$row[$columnKey]; break; case 'float': if ($decimalPlaces != -1){ $return_data_row[] = (float)number_format( (float)($row[$columnKey]), $decimalPlaces, '.', $thousandsSeparator ? '' : '.'); }else { $return_data_row[] = (float)$row[$columnKey]; } break;
and replace it with this
case 'int':
if (is_null($row[$columnKey])){ $return_data_row[]= null; }else{ $return_data_row[] = (float)$row[$columnKey]; } break; case 'float': if ($decimalPlaces != -1) { if (is_null($row[$columnKey])) { $return_data_row[] = null; }else { $return_data_row[] = (float)number_format( (float)($row[$columnKey]), $decimalPlaces, '.', $thousandsSeparator ? '' : '.'); } } else { if (is_null($row[$columnKey])) { $return_data_row[] = null; }else { $return_data_row[] = (float)$row[$columnKey]; } } break;
With these changes you will get charts like on the first screenshot below.
If you want to make charts like on screenshot #2 you have to use wpdatachart callbacks and insert that on page where your chart is.
thank you Aleksandar - is there a way to make spline charts more smooth? currently they are not different from simple line charts as you cane see in the attached image below the lines are not very smooth - is there a special parameter in hicharts that I can change to make spline charts more smooth?
Did this callback work for you before? I know I've tested it in the past, and it used to work, but I can't get it to work on my local environment either.
I forwarded the callback to one of our developers, so he can take a look at it, and as soon as I hear from him I will let you know. Please note, though, that using callbacks requires some coding knowledge, and included support refers only to advice, so I can't guarantee anything.
I'm pretty confident that we'll be able to get to the bottom of this, as this is a simple placeholder, and it used to work. As soon as I hear from our developer, I will let you know.
Can you advise on how to plot empty values so that they are not rendered in the chart?
So, I assumed you were referring to NULL values, not zeros, even though you commented that they are saved as zeros right below that. Sorry about the misunderstanding. Empty (NULL) values, are different from zeros ( 0 ), and the code that I sent you works when the data in the columns is saved as NULL in the database. Since you have them saved as zeros, this code won't work.
To use this callback for tables with zeros, you need to change the code in file /wp-content/plugins/wpdatatables/source/class.wpdatachart.php around line 1631 from:
case 'int':
$return_data_row[] = (float)$row[$columnKey];
break;
case 'float':
if ($decimalPlaces != -1){
$return_data_row[] = (float)number_format(
(float)($row[$columnKey]),
$decimalPlaces,
'.',
$thousandsSeparator ? '' : '.');
}else {
$return_data_row[] = (float)$row[$columnKey];
}
break;
MUCH BETTER - LAST POINTS DO NOT SHOW ANY ABRUPT DECLINE TO ZERO....now I need to remove those markers - can your callback be easily modified to remove them?
Can you please show me how the table looks like, what chart you used, and which callback exactly, and I'll add it to our FAQ section (when I have time).
image used is Spline Chart. Zeroes used to show future chart values. The charts will be used to show intraday waves - will be constantly updated through the day - therefore needed the last values to NOT connect to zero.
I am trying to set the same behavior for my charts, but the plugin code changed, and I don't know which of its part to replace to stop plotting the empty values (line chart - chart.js).
If you need a workaround for charts to "skill NULL and 0 values",
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){ $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.
Could you please open a new ticket from your account,
then we can ask you for WP-Admin remote access, if thats'OK, so we can inspect how you added this on your site and why it is not working.
When we try the same method, it is working to "skip NULL /blank" values on our charts on all our testing sites,
and so far for all other users that requested it, it also works for them.
So, it might be due to something with the Shortcoder plugin, but not sure.
Did you try to add the said function directly in your functions.php file of the Theme?
In either case, we can certainly check this out remotely and try to debut the issue on your site - but if you can make a new ticket, so that we can privately exchange the access URL + Admin credentials in Private messages, for safety reasons.
Hello,
Can you advise on how to plot empty values so that they are not rendered in the chart? right now we have zeros for empty values and they show up as horizontal line - which should NOT be rendered let me show the chart
Pasteboard - Uploaded Image
also these are called spline charts - but they do not smooth the data - is there a way to make them more curvy?
Hello Dave
If you have zeros in your table, that is an issue we've been dealing with, because integer and float columns cannot have anything other than numbers in them, the plugin is treating an empty cell as "0"
I can try and help you out, but you have to make some changes in code in file :
/wp-content/plugins/wpdatatables/source/class.wpdatachart.php around line 1631:
and replace it with this
With these changes you will get charts like on the first screenshot below.
If you want to make charts like on screenshot #2 you have to use wpdatachart callbacks and insert that on page where your chart is.
One more thing you have to change in this callback number 39 in (wpDataChartsCallbacks[39]) to id of the chart that you use on the page.
This will be overwritten on next update so you have to come back here and do it again.
I hope this helps.
Kind Regards,
Aleksandar Vuković
[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
thank you Aleksandar - is there a way to make spline charts more smooth? currently they are not different from simple line charts as you cane see in the attached image below the lines are not very smooth - is there a special parameter in hicharts that I can change to make spline charts more smooth?
Hello again Dave
Spline charts have smooth lines by default.
In this example, the green is a spline line, and the blue one behind it is a line, so you can see that spline is rather smooth, and line is sharp.
Kind Regards,
Aleksandar Vuković
[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
I am suing the code below and the spline chart still connects to the zeros from the last points on the charts...
here is how this looks:
I changed 39 to 16 as the callback id to chart id
Hello Dave.
Did this callback work for you before? I know I've tested it in the past, and it used to work, but I can't get it to work on my local environment either.
I forwarded the callback to one of our developers, so he can take a look at it, and as soon as I hear from him I will let you know. Please note, though, that using callbacks requires some coding knowledge, and included support refers only to advice, so I can't guarantee anything.
I'm pretty confident that we'll be able to get to the bottom of this, as this is a simple placeholder, and it used to work. As soon as I hear from our developer, I will let you know.
Kind Regards,
Aleksandar Vuković
[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
Fantastic - I will wait to hear from you! I will note that it did not work before
Hi again Dave
I need to watch out for terminology in the future
Your initial comment on this ticket was this:
Can you advise on how to plot empty values so that they are not rendered in the chart?
So, I assumed you were referring to NULL values, not zeros, even though you commented that they are saved as zeros right below that. Sorry about the misunderstanding. Empty (NULL) values, are different from zeros ( 0 ), and the code that I sent you works when the data in the columns is saved as NULL in the database. Since you have them saved as zeros, this code won't work.
To use this callback for tables with zeros, you need to change the code in file /wp-content/plugins/wpdatatables/source/class.wpdatachart.php around line 1631 from:
To this:
The difference between this, and what I previously sent is this:
This is used when data in the database (in your table) is saved with empty values (NULL):
And the code that I just posted above is used when the data is saved with zeros:
When you apply the code above, and use the same callback I provided in my initial response, it will work. I just tested it locally, and it works fine.
Kind Regards,
Aleksandar Vuković
[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
Superb! it works - thanks a lot! LET ME SHOW YOU
MUCH BETTER - LAST POINTS DO NOT SHOW ANY ABRUPT DECLINE TO ZERO....now I need to remove those markers - can your callback be easily modified to remove them?
I added this line and it worked! no markers found!!!!
obj.options.plotOptions.series.marker = { enabled: false };
Great news, Dave
Thank you for letting me know.
Can you please show me how the table looks like, what chart you used, and which callback exactly, and I'll add it to our FAQ section (when I have time).
Kind Regards,
Aleksandar Vuković
[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
Sure - here is the callback that I use:
image used is Spline Chart. Zeroes used to show future chart values. The charts will be used to show intraday waves - will be constantly updated through the day - therefore needed the last values to NOT connect to zero.
here is the snapshot:
Awesome, Dave, thanks!
Just a screenshot of the table, please, and I'll leave you to your work
Kind Regards,
Aleksandar Vuković
[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
Hi,
I am trying to set the same behavior for my charts, but the plugin code changed, and I don't know which of its part to replace to stop plotting the empty values (line chart - chart.js).
Aleks, could you help me out, please?
Hi, Petr
If you need a workaround for charts to "skill NULL and 0 values",
Please go to the functions.php file of your theme or child theme, and add this:
If you want to apply it just for NULL 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.
Let us know if that works for your use-case. Thanks
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
Hi Miloš,
I've just tested it, and it doesn't work.
I also tried the callback, which also didn't affect the chart.
By the way, I've added the functions to my theme using the Shortcoder plugin.
Hi, Petr.
Could you please open a new ticket from your account,
then we can ask you for WP-Admin remote access, if thats'OK, so we can inspect how you added this on your site and why it is not working.
When we try the same method, it is working to "skip NULL /blank" values on our charts on all our testing sites,
and so far for all other users that requested it, it also works for them.
So, it might be due to something with the Shortcoder plugin, but not sure.
Did you try to add the said function directly in your functions.php file of the Theme?
In either case, we can certainly check this out remotely and try to debut the issue on your site - but if you can make a new ticket, so that we can privately exchange the access URL + Admin credentials in Private messages, for safety reasons.
Thank you.
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