I'm implementing a table for a customer. On the x axis are date entries (e.g. 07-sep-19). However this looks quite crowded when there are many entries. Therefore we would like to adjust the scale of the x axis to months. So the x-axis values would become jan, feb, mrt, apr, etc. Would that be possible?
What you see is the default behavior of charts engine, but if you need some custom solution you can check in our documentation about wpDataCharts callbacks.
Every chart exposes several options that customize its look and feel. Charts usually support custom options appropriate to that visualization. wpDataChart callbacks allow adding options that are available in Google Charts API, Highcharts API and Chart.js API.
All necessary resources are available in charts engines API (depends on which one you use). Every engine has a different approach to chart settings. In wpDataChart callbacks you have to adopt those settings to the wpDataChart object (you can take a look at examples for each engine in our documentation, and also in Support help center). Huge number of examples for any area of programming can be found on stackoverflow.com (typing your problem in google and at the end add "site: stackoverflow.com" and google will search only that website). Also, a lot of examples of charts, chart settings and customization can be found on jsffidle.net (typing in google for example "line chart highcharts jsffidle")
Please note that using hooks or wpdatatable and wpDataChart callbacks requires certain level of programming skills and included support refers only to advice.
Thanks for your reply. Unfortunately I'm not able to find what I'm looking for to scale the x-axis (I want the scale to be months). Could you please point me to some example or where I can find the setting to do this? I guess I might just be overlooking it or searching with the wrong keywords combination.
It does not look like Highcharts callback because I choose Chart.js as the render engine. And yes of course I did search stackoverflow. However I would also expect a $59,- dollar plugin for rendering a chart to have some options or at least clear documentation about how to format the scale of the axis.
So please if you can point me out a bit on how to get a month-year scale on the x-axis using Chart.js as the render engine would be very much appreciated.
Sorry, I thought you were using Highcharts as the render engine.
wpDataTables provides you with the possibility to create charts using built-in options that come with the free libraries of chart engines. You're trying to change the date format on a chart, and since that is not included in the built-in options of the plugin, the only thing you can do is to customize the chart using callbacks.
I have already mentioned that using hooks or wpdatatable and wpDataChart callbacks requires certain level of programming skills and included support refers only to advice.
There is no documentation about this, only a few examples, exactly because of this. We cannot provide tutorials on how callbacks for each chart engine work.
If you can provide me with wp-admin credentials for your site, along with table and chart IDs, I can remote in and take a look. If I'm able to find a quick solution for you, I will. But, if it turns out to be more complicated, there's simply nothing much I can do with the included support of the plugin. We are offering customization services on paid basis for situations like this, but unfortunately we're extremely busy with priority tasks, so I cannot even offer that.
We do not interfere with any data or anything else except for the plugin (in case that’s a production version of the site), and of course we do not provide login data to third party. You can write credentials here just check Private Reply so nobody can see them except us.
However, the chart doesn't even show the labels on axes with the classic editor. Try removing the script, and take a look at the chart in front end. I see it shows normally on your homepage, but not when I try to modify the chart itself or when using callbacks.
So, I may have even guessed the callback, but simply cannot see it. How were you able to show the axes labels on your homepage?
Thanks for the tip about the placement of the script. I must have misunderstood the entry for custom css and js.
The reason you couldn't see the axis text is because I had put the font color on white. It's under the tab 'Formatting and preview' and then under 'chart' the last option.
On the test page you created I now placed a div around the chart shortcode and put the background on grey to make the labels visible.
However I see that it's showing dd/mm/yyyy. The same as I have.
This makes me wondering is the object obj from the callback actually the chart object. Or at an other level. Because when I make a call like obj.update() I get an unchaught TypeError that update is not a function.
Another thing I'm wondering about is how data is mapped from the table to the chart. I see that x axis data ends up in the object as: render_data.options.data.labels: ["01/01/2019", "04/01/2019", "10/01/2019", etc. Might it be that it just refuses to use the given settings for the x-axis because it can't handle the data format?
I'm gonna have to experiment with this a bit before I provide a solid response.
If the data format is supported by Charts.js engine, it should override whatever you set up in wpDataTables, we only need to find the correct callback. I'll be digging into this a bit more, and I'll let you know if I'm able to find anything.
I did try looking for a simple solution to your problem, but as it turns out it'd take a significant amount of time to find the exact callback that'd suit your needs. From what I saw in Charts.js documentation you need to load the moments.js and configure it in a proper way.
Unfortunately, I cannot find a callback that'd work for you.
Thank you for your time. I think I'll try to set up the chart manually, so I don't have to do a callback. Maybe that's the easiest solution. Then I only need some call to fill the 'data' with the data from the table. Do you know which call I should make to get the data from the table?
Sorry, but I've never created charts manually. I would need to do it myself a few times, then get into Charts.js documentation to be able to help you out with even a hint.
We don't have any new info about this, but hopefully Michel, here, will see your comment and explain what needs to be done to get around callbacks.
Anything that's not included in the built-in chart options generated by their API is considered as custom solution, so it's not included in provided support for the plugin.
Hi,
I'm implementing a table for a customer. On the x axis are date entries (e.g. 07-sep-19). However this looks quite crowded when there are many entries. Therefore we would like to adjust the scale of the x axis to months. So the x-axis values would become jan, feb, mrt, apr, etc. Would that be possible?
Thanks,
Michel ter Stege
Hello Michel
Thank you for your purchase.
What you see is the default behavior of charts engine, but if you need some custom solution you can check in our documentation about wpDataCharts callbacks.
Best regards.
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 Aleksander,
Thanks for your reply. Unfortunately I'm not able to find what I'm looking for to scale the x-axis (I want the scale to be months). Could you please point me to some example or where I can find the setting to do this? I guess I might just be overlooking it or searching with the wrong keywords combination.
Kind regards,
Michel
Hello Michel.
Please take a look at this. Maybe it can help you out.
You can see on jsFiddle how you can change what X-axis displays here. Also try exploring Stack Overflow. I've run into some good advice there.
Best regards.
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 Aleksandar,
Thanks again. I'm making progress, but not quite getting there. I'm using this as a reference.
My data comes from an Excel and is formatted like: dd-mm-yyyy.
In the "Custom wpDataTables JS" I added the folling code:
jQuery(window).load(function(){ if( typeof wpDataChartsCallbacks == 'undefined' ){ wpDataChartsCallbacks = {}; } wpDataChartsCallbacks[1] = function(obj){ obj.options.options.scales.xAxes.type = 'time'; obj.options.options.scales.xAxes.time = { unit: 'month', displayFormats: { month: 'MMM YYYY' } } } });which I think should format the x-axis scale as months. However the output on the chart is as in the attachment.
Not sure what I'm missing here.
Hi again Michel.
This doesn't look like Highcharts callback. Try something like this
I'm only guessing, though. Have you tried searching on Stack Overflow?
Best regards.
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 Aleksander,
It does not look like Highcharts callback because I choose Chart.js as the render engine. And yes of course I did search stackoverflow. However I would also expect a $59,- dollar plugin for rendering a chart to have some options or at least clear documentation about how to format the scale of the axis.
So please if you can point me out a bit on how to get a month-year scale on the x-axis using Chart.js as the render engine would be very much appreciated.
Kind regards,
Michel ter Stege
Hello again Michel.
Sorry, I thought you were using Highcharts as the render engine.
wpDataTables provides you with the possibility to create charts using built-in options that come with the free libraries of chart engines. You're trying to change the date format on a chart, and since that is not included in the built-in options of the plugin, the only thing you can do is to customize the chart using callbacks.
I have already mentioned that using hooks or wpdatatable and wpDataChart callbacks requires certain level of programming skills and included support refers only to advice.
There is no documentation about this, only a few examples, exactly because of this. We cannot provide tutorials on how callbacks for each chart engine work.
If you can provide me with wp-admin credentials for your site, along with table and chart IDs, I can remote in and take a look. If I'm able to find a quick solution for you, I will. But, if it turns out to be more complicated, there's simply nothing much I can do with the included support of the plugin. We are offering customization services on paid basis for situations like this, but unfortunately we're extremely busy with priority tasks, so I cannot even offer that.
We do not interfere with any data or anything else except for the plugin (in case that’s a production version of the site), and of course we do not provide login data to third party. You can write credentials here just check Private Reply so nobody can see them except us.
Kind regards.
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 again Michel.
First thing is - you can't add the script in Custom JS - it will not work like that.
You need to place it in between the <script> ... </script> tags above the shortcode, like I did in the new page I created for testing: https://blockchaintraders.nl/?page_id=1103&preview=true
However, the chart doesn't even show the labels on axes with the classic editor. Try removing the script, and take a look at the chart in front end. I see it shows normally on your homepage, but not when I try to modify the chart itself or when using callbacks.
So, I may have even guessed the callback, but simply cannot see it. How were you able to show the axes labels on your homepage?
Best regards.
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 Aleksander,
Thanks for the tip about the placement of the script. I must have misunderstood the entry for custom css and js.
The reason you couldn't see the axis text is because I had put the font color on white. It's under the tab 'Formatting and preview' and then under 'chart' the last option.
On the test page you created I now placed a div around the chart shortcode and put the background on grey to make the labels visible.
However I see that it's showing dd/mm/yyyy. The same as I have.
Kind regards,
Michel ter Stege
Hi Aleksander,
Okay I'm also experimenting a bit further and found something interesting I don't quite get:
Looking here there is an example about updating a chart. A chart object is passed into the function. It's used like this:
However using the wpDataChartsCallback like:
Is doing things like this I see in other examples:
This makes me wondering is the object obj from the callback actually the chart object. Or at an other level. Because when I make a call like obj.update() I get an unchaught TypeError that update is not a function.
Another thing I'm wondering about is how data is mapped from the table to the chart. I see that x axis data ends up in the object as: render_data.options.data.labels: ["01/01/2019", "04/01/2019", "10/01/2019", etc. Might it be that it just refuses to use the given settings for the x-axis because it can't handle the data format?
Kind regards,
Michel ter Stege
Hi again Michel.
I'm gonna have to experiment with this a bit before I provide a solid response.
If the data format is supported by Charts.js engine, it should override whatever you set up in wpDataTables, we only need to find the correct callback. I'll be digging into this a bit more, and I'll let you know if I'm able to find anything.
Best regards.
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 again Michel.
I did try looking for a simple solution to your problem, but as it turns out it'd take a significant amount of time to find the exact callback that'd suit your needs. From what I saw in Charts.js documentation you need to load the moments.js and configure it in a proper way.
Unfortunately, I cannot find a callback that'd work for you.
Best regards.
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 Aleksander,
Thank you for your time. I think I'll try to set up the chart manually, so I don't have to do a callback. Maybe that's the easiest solution. Then I only need some call to fill the 'data' with the data from the table. Do you know which call I should make to get the data from the table?
Kind regards,
Michel
Hello Michel.
Sorry, but I've never created charts manually. I would need to do it myself a few times, then get into Charts.js documentation to be able to help you out with even a hint.
Best regards.
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,
Did you ever find a solution to this? I am running into the same problem with Highcharts. Very annoying.
Is there even a way that we can query the content of the table with a REST api directly?
Hi Tibor
We don't have any new info about this, but hopefully Michel, here, will see your comment and explain what needs to be done to get around callbacks.
Anything that's not included in the built-in chart options generated by their API is considered as custom solution, so it's not included in provided support for the plugin.
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 Tibor,
Below is what I eventually ended up with. Hope this helps.
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js">
jQuery(window).load(function(){
if( typeof wpDataChartsCallbacks == 'undefined' ){ wpDataChartsCallbacks = {}; }
wpDataChartsCallbacks[2] = function(obj){
obj.options.options.scales.xAxes[0].type = 'time';
obj.options.options.scales.xAxes[0].time = {
unit: 'month',
displayFormats: {
quarter: 'MMM YYYY',
month : 'MMM YYYY',
day: 'MMM YYYY'
}
};
}
});
</script>
<p style="text-align: center;">[wpdatachart id=2]</p>