I am trying to build a sankey using google charts. Here is the Link.
function convertFormat(data) {
if (data.length === 0) return [];
let new_data = [];
let key_data = [];
Object.keys(data[0]).map((key) => {
if (key !== "id") key_data.push(key);
});
new_data.push(key_data);
data.map((item) => {
let new_item = [];
Object.values(item).map((value, index) => {
if (index !== 0) new_item.push(value);
});
new_data.push(new_item);
});
return new_data;
}
I was trying the above code to convert my data into the below format so that i can provide it into google charts (sankey chart).
const data = [
["Word", "Target", "Weight"],
["AN", "Female", 0],
["Aaron", "Male", 0],
["Abbey","Female", 0],
];
But i am getting this error when i tried it. Error: <text> attribute y: Expected length, "NaN".
