I'm importing data from a MYSQL database to populate a graph. I'm using a line graph, and I do not wish for the graph to draw a line whenever the value is 0.
You'll need to modify some files since we somehow forgot to pass the chart ID in there. Please go to wp-content/plugins/wpdatatables/source/class.wpdatachart.php and on line 1634 you will find this:
This adds the chart ID in the parameters. You'll only have to do this one time, as it will be included in our next update.
Then, 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.
We'll include the fix in the next update, so you won't need to change the code after the plugin updates, but you will need to keep this code in functions.php.
Dear TMS.
I'm importing data from a MYSQL database to populate a graph. I'm using a line graph, and I do not wish for the graph to draw a line whenever the value is 0.
Is this possible?
Regards, Kim.
Hi Kim
Thank you for reaching out to us.
You have to make some changes in code in file :
/wp-content/plugins/wpdatatables/source/class.wpdatachart.php around line 1584
and replace with this
With this changes you will get charts like on the screenshot (Selection_016.jpg).
If you want to make charts like on screenshot (Selection_015.jpg) you have to use wpdatachart callbacks and insert that on page where is your chart.
One more thing you have to change in this callback number 39 in (wpDataChartsCallbacks[39]) to id of the chart that you use on page.
This will be overwritten on next update so you have to come back here and do it again.
Hey Blaženka,
This fix worked for me until current update; now when I change the code at affects no change. Can you shed any light?
Many thanks,
Matt.
Hi Matt,
thank you for contacting back
I will escalate this matter to our senior colleague so that he would give a more experienced advice; he will contact you as soon as possible.
I wish you a lovely day in the meantime.
Hey Matt
You'll need to modify some files since we somehow forgot to pass the chart ID in there. Please go to wp-content/plugins/wpdatatables/source/class.wpdatachart.php and on line 1634 you will find this:
Replace it with this:
In the same file, on line 1642 you will find this:
And you need to replace it with this:
Again, in the same file, on line 1725 you will find this:
Replace it with this:
Then go to line 1733 of the same file, and find this:
Replace it with this:
This adds the chart ID in the parameters. You'll only have to do this one time, as it will be included in our next update.
Then, 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.
We'll include the fix in the next update, so you won't need to change the code after the plugin updates, but you will need to keep this code in functions.php.
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
Thanks for your reply Aleksandar,
Unfortunately this appears to filter every value on all of my charts, not just null/0! :(
Thank you for your feedback, Matt, I forwarded the ticket to our developers for review, and as soon as I hear from them, 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
Hey Matt
I just saw that this was actually resolved in another ticket.
If you have any further questions or issues, please feel free to open a new ticket, and we'll gladly help.
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