I am trying to construct a pie chart with flot, and getting the json data from server as below
[
{"transactions": 7, "products__name": "mark"},
{"transactions": 12, "products__name": "vicky"},
{"transactions": 30, "products__name": "daniel"},
{"transactions": 6, "products__name": "hurray "}]
So i need to format the above list of dictionaries in to below format so that i can use that to directly insert to flot pie chat placeholder
data = [
{ label: "mark", data: 7, color: "#4572A7"},
{ label: "vicky", data: 12, color: "#80699B"},
{ label: "daniel", data: 30, color: "#3D96AE"},
{ label: "hurray", data: 6, color: "#89A54E"},
];
Actually i just want to do this with jquery, by using foreach or something else..