This:
var requestOptions = [
{
id: 1
},
{
id: 2
}];
console.log(requestOptions);
Is returning me this:
0: Object
id: 2
1: Object
id: 2
Why so? Looks like they are being merged and I don't want it to.
**** The full code is below *** As I mentioned in the comments, the simplified version above, runs fine (sorry). But, the below isn't.
setDataTable function, uses the same variable name to merge and validate, then sending an Ajax call.
google.charts.setOnLoadCallback(function() {
// Set datasources
var requestOptions = [
{
id: 1,
fields: 'cidade_uf, uf, data as Data, SUM(demanda) AS Demanda, SUM(mercado) AS Mercado',
formats: '[{"type":"string"}, {"type":"string"}, {"type":"date", "options": {"format":"M Y"}},{"type":"decimal","options":{"cases":2}},{"type":"money","options":{"sign":"R$"}}]',
groupby: 'cidade_uf, uf, data',
s: '<?=$source1?>'
},
{
id: 2,
fields: 'data as Data, SUM(demanda)/SUM(mercado) as `Mkt Share (%)`',
formats: '[{"type":"date", "options": {"format": "M Y"}}, {"type":"percent", "options":{"cases": 0}}]',
groupby: 'data',
s: '<?=$source1?>'
}];
console.log(requestOptions);
setDataTable(requestOptions,dataCallback);
});