I need to be able to edit the dates on the x-axis. It looks rather weird now. Google per standard use the first letter of some months...Apex is just...crowded!
As far as I have been able to read I need to use callbacks. No idea what it is but it involves inserting some code somewhere.
Can you tell me:
Where do I insert this code (I use Elementor for building the site)
What does the callback code look like for Google and ApexCharts? You don't have to write the entire code, but please get me started, then I can fiddle with it myself.
On this page you will find, our developers made one custom callback example for each Chart Engine,
and you will then need to modify that example to edit the option of the chart you need.
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 the Support help center). A 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 a certain level of programming skills and included support refers only to advice.
-
When it comes to inserting this custom callback code,
you can either insert it in our main plugin settings/Custom JS and CSS/Custom JS,
or it is better to insert it directly on your WordPress Page where you have the Chart, as Custom HTML, wrapped inside a HTML "script" tag, like this
I got a bit further. I'm using Google Charts and have used the callback function to remove the padding Google adds to the chart as standard (which makes the chart fill out only 50% of the container) and made the tooltip include both graphs.
As I have no coding background I'm pretty satisfied with myself so far :-) You can see the chart here. The code looks like this:
But...I have not been able to solve the issue with the horizontal axis. I want to be able to control which dates goes in the horizontal axis. I have been looking in the Google API documentation and found the object I need (hAxis.ticks) but I just can't make it work. No matter what I do, It has zero impact on the dates shown.
This is the code I'm working with now:
<script type="text/javascript"> jQuery(window).on('load',function(){ if( typeof wpDataChartsCallbacks == 'undefined' ){ wpDataChartsCallbacks = {}; } wpDataChartsCallbacks[4] = function(obj){ obj.options.hAxis.ticks = hAxis: { ticks: [new Date(2020,1,1), new Date(2021,1,1), new Date(2022,1,1), new Date(2023,1,1)]
Only thing that remains now is how I get each year to center under each of the vertical gridlines? Right now the year/text starts at the gridline - if it makes sense.
Hi,
Please take a look at the test site/URL https://aialphalab.com/fund-interest-gammel/. I have inserted line charts using Google and ApexCharts.
I need to be able to edit the dates on the x-axis. It looks rather weird now. Google per standard use the first letter of some months...Apex is just...crowded!
As far as I have been able to read I need to use callbacks. No idea what it is but it involves inserting some code somewhere.
Can you tell me:
Best,
Morten
Hi Morten,
You are correct.
Every chart engine has its own layout and its settings.
We use free libraries for chart engines, and they are limited as to what we can change from our end within the plugin's built-in User Interface.
You can check out all the available chart engines and examples of wpDataCharts documentation here .
If the options you need are not in the chart creation wizard, you can try to find a custom solution using chart callbacks.
You can check our documentation about wpDataCharts callbacks.
On this page you will find, our developers made one custom callback example for each Chart Engine,
and you will then need to modify that example to edit the option of the chart you need.
-
When it comes to inserting this custom callback code,
you can either insert it in our main plugin settings/Custom JS and CSS/Custom JS,
or it is better to insert it directly on your WordPress Page where you have the Chart, as Custom HTML, wrapped inside a HTML "script" tag, like this
"<script>...your code...</script>".
I hope that 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
Hi Milos,
I got a bit further. I'm using Google Charts and have used the callback function to remove the padding Google adds to the chart as standard (which makes the chart fill out only 50% of the container) and made the tooltip include both graphs.
As I have no coding background I'm pretty satisfied with myself so far :-) You can see the chart here. The code looks like this:
<script type="text/javascript">
jQuery(window).on('load',function(){
if( typeof wpDataChartsCallbacks == 'undefined' ){ wpDataChartsCallbacks = {}; }
wpDataChartsCallbacks[4] = function(obj){
obj.options.chartArea = {left:135,top:30,width:'100%',height:'75%'};
obj.options.focusTarget = ['category'];
}
});
</script>
But...I have not been able to solve the issue with the horizontal axis. I want to be able to control which dates goes in the horizontal axis. I have been looking in the Google API documentation and found the object I need (hAxis.ticks) but I just can't make it work. No matter what I do, It has zero impact on the dates shown.
This is the code I'm working with now:
<script type="text/javascript">
jQuery(window).on('load',function(){
if( typeof wpDataChartsCallbacks == 'undefined' ){ wpDataChartsCallbacks = {}; }
wpDataChartsCallbacks[4] = function(obj){
obj.options.hAxis.ticks = hAxis: {
ticks: [new Date(2020,1,1), new Date(2021,1,1), new Date(2022,1,1), new Date(2023,1,1)]
}
});
</script>
Can you help me?
Best,
Morten
Hi again,
Managed to solve the question below. This code works:
<script type="text/javascript">
jQuery(window).on('load',function(){
if( typeof wpDataChartsCallbacks == 'undefined' ){ wpDataChartsCallbacks = {}; }
wpDataChartsCallbacks[4] = function(obj){
obj.options.chartArea = {left:135,top:30,width:'100%',height:'75%'};
obj.options.focusTarget = ['category'];
obj.options.hAxis.ticks = [{v: new Date(2020, 1, 1), f: '2020'}, {v: new Date(2021, 1, 1), f: '2021'}, {v: new Date(2022, 1, 1), f: '2022'}, {v: new Date(2023, 1, 1), f: '2023'}];
}
});
</script>
Only thing that remains now is how I get each year to center under each of the vertical gridlines? Right now the year/text starts at the gridline - if it makes sense.
Do you know?
Hi Morten,
i am glad to see that you found a solution for the previous question,
we will make note of this, and will do our best to add more custom examples of Chart callbacks on our Documentation in the future.
2. In regards to getting each year to center under each of the vertical gridlines;
I am sorry, but at the moment we do not have any working example to for something like this.
You can check out our examples for wpDataCharts callbacks.
On that page our developers made one custom example for each Chart Engine;
so you will have to search on the Chart Engine's API documentation which options you need to change to achieve your goal,
and you need to modify one of our examples to your use case.
Of course, you can also research online on places such as Stack Overflow and similar, if any other user has managed to change the option(s) you need.
I hope that 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
Alright, I will try Stackoverflow. They also helped me with the code below :-)
Let's close this ticket.
Best,
Morten
Hi Morten,
no problem, i hope that it helps.
Please don't hesitate to open new tickets if anything new comes up.
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