My charts have dates on the X-axis, and the data points get populated continuously every day. I wish for the X-axis to be fixed so that the chart will start from the left at a fixed point.
Currently, the chart self aligns itself to the center, meaning every time a new data point comes in the chart zooms itself out - which is not what I want.
As you can see the date goes from 15.05 to 01.06 as of right now. I would like to have the X-axis fixed to a period from 15.05 to 15.08 even though there will be no data points for any future dates.
Unless the table has data for those dates, you won't be able to plot them on the chart. We're using free chart libraries and they come with some limitations.
Maybe you could use some wpDataCharts callbacks to plot them manually but we can't guarantee that will work as we've never done anything similar in the past.
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.
Thank you for your answer. I think there is a solution here then.
Is there a way to make datapoint which are at 0 to be invisible/colorless on the chart? In this way the X axis could be fixed without showing any datapoints.
New versions of wpDataTables should not include zeros and NULL values but if they are still plotted on the chart, you can access 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.
Dear TMS.
My charts have dates on the X-axis, and the data points get populated continuously every day. I wish for the X-axis to be fixed so that the chart will start from the left at a fixed point.
Currently, the chart self aligns itself to the center, meaning every time a new data point comes in the chart zooms itself out - which is not what I want.
Is there any way to change this? :-)
Best regards, Kim.
Hi, Kim
Thanks for reaching out to us
- It seems that I've understood what you need, but i would like to be certain.
Is it possible for you to maybe record a video to show how it is currently looking, just to make sure we fully understand what you need,
and we will assist?
If not, perhaps a screenshot would be good , as well.
And a link to a page where you have the chart would be great.
If there is any sensitive data, you can mark response as PRIVATE, so that only we will see it.
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
Dear Milos.
I attached a pic of the chart currently.
As you can see the date goes from 15.05 to 01.06 as of right now. I would like to have the X-axis fixed to a period from 15.05 to 15.08 even though there will be no data points for any future dates.
Is this possible?
Best regards, Kim.
Dear Milos.
I'm still looking for a solution to this. Do you know how to implement the fixed X axis?
Best regards, Kim.
Hello Kim.
Unless the table has data for those dates, you won't be able to plot them on the chart. We're using free chart libraries and they come with some limitations.
Maybe you could use some wpDataCharts callbacks to plot them manually but we can't guarantee that will work as we've never done anything similar in the past.
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
Dear Aleksandar.
Thank you for your answer. I think there is a solution here then.
Is there a way to make datapoint which are at 0 to be invisible/colorless on the chart? In this way the X axis could be fixed without showing any datapoints.
Best regards, Kim
Hello again Kim
New versions of wpDataTables should not include zeros and NULL values but if they are still plotted on the chart, you can access 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.
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
Dear Aleksandar.
I already have the newest version of Wpdatatables, do I have to create the charts again for it to update with the new features?
Best regards, Kim.
Hi, Kim
Sorry for the delay.
As my senior colleague explained, if you can still see 0 values plotted on the charts;
you don't have to make new charts, this code is going to be applied to all the charts,
the existing ones and new ones.
Please edit the functions.php file of your theme or child theme, with any text/code editor, and add the code as Aleksandar suggested.
Let us know if that works, and if you still have any questions, we will be happy to help and to answer.
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