I am trying to create a Google chart with two stacked bars. One bar is last year's data, while the other bar is this year's data.
As the data comes from two different databases, I have two JSON objects that look as below. I'm not sure how I could combine the two upstream, as one is a MS SQL DB and the other a MySql. Combining it into one SQL does not seem obvious.
[["","Others","Restaurant","Retail"],["2022",3362,810,2110],["2023",0,0,0]]
[["","Event","Hotel","Other","Restaurant"],["2022",0,0,0,0],["2023",3802.5,2642,10955.44,7256]]
The categories are not complete, there could be some more.
I am trying to merge the two objects with $.merge(json1, json2);
however that creates the following object:
[["","Restaurant","Retail","Supermarket"],["2022",8667,1067,1549.6],["2023",0,0,0],["","Event","Hotel","Restaurant"],["2022",0,0,0,"2023",34580,0,6839.42]]
However, I would like to have an object in this format:
[["","Event","Hotel","Restaurant","Retail","Supermarket"],["2022",0,0,8667,1067,1549.6],["2023",34580,0,6839.42,0,0]]
Is that something I have to solve with a custom loop? Or is there some helpful existing function for this kind of combination?
I checked a possible duplicate question, however these all work with single dimension and same length dimensions. I tried var jsongraph = json1.map((e, i) => json2[i]);
yet that doesn't combine the two objects as desired.