We have updated WebDataRocks EULA, effective as of April 18, 2024. Learn more about what's changed.

Pre-set report

Resolved

I’m getting my data from a php mysql query, and for that reason i don’t want to simply load a report that a made before. My data changes almost every time i load the table, but i don’t want to have to re-build my layout every time…..
 
Any ideias for it?

3 answers

WebDataRocks Team WebDataRocks March 11, 2019

Hi Joao!

If your data have the same fields you can just save the report and set the path to your PHP script. It will return different data every time but you still have the same layout.

Does it work?

joao March 12, 2019

this is my current code:
 
it works fine for this table, but a i can’t make it start with the right units, 2 decimals, and custom filters (like just the last 2 years…)…

 

var dados_chart = [ <?php echo $my_chart;?> ];
var pivot = new WebDataRocks({
    
    container: “#wdr-component”,
    toolbar: true,
    height: “900”,
    report: {

 
        dataSource: {
            data: dados_chart
        },

        //PARA PRE_SET DA TABELA
        slice: {
     “rows”: [
     {
     “uniqueName”: “Local”
     },
     {
     “uniqueName”: “Tipo”
},
{
     “uniqueName”: “Fracção”
     },
     {
     “uniqueName”: “Inquilino”
     }
     ],
     “columns”: [
     {
     “uniqueName”: “Mes.Year”
     },
     {
     “uniqueName”: “Mes.Month”
     },
    
     {
     “uniqueName”: “Measures”
     }
     ],
     “measures”: [
     {
     “uniqueName”: “Total”,
     “aggregation”: “sum”
     }
            ],

            
    
},
    }
});

WebDataRocks Team WebDataRocks March 15, 2019

Hi Joao!
 
Thank you for the code example.
As I understood, you want to apply 2 decimals places format by default.
For this, please add the following format to your report:

"formats": [{
"name": "",
"decimalPlaces": 2
}]

As for the custom filters for the last 2 years, you can also do this via report configuration with some dynamic PHP code:

"columns": [
{
"uniqueName": "Mes.Year",
"filter": {
"members": [
"Mes.Year.<?php echo date('Y'); ?>",
"Mes.Year.<?php echo date('Y', strtotime('-1 year')); ?>"
]
}
},
...
]

Please let us know if it works fine for you.
 
Regards,
WebDataRocks Team