I want to make the array suitable for Highchart data returned from SQL.
This array should be made available to Highchart.
Can you help me on this topic ?
From SQL returned json value :
{
"FuelConsumption": [{
"Unit": "Computing",
"UnitID": 9,
"DateofPurchase": "18.04.2016",
"Liter": 2
}, {
"Unit": "Transportation",
"UnitID": 10,
"DateofPurchase": "18.04.2016",
"Liter": 3453
}, {
"Unit": "GeneralManager",
"UnitID": 7,
"DateofPurchase": "20.04.2016",
"Liter": 5
}, {
"Unit": "Boss",
"UnitID": 8,
"DateofPurchase": "20.04.2016",
"Liter": 4564
}, {
"Unit": "Computing",
"UnitID": 9,
"DateofPurchase": "20.04.2016",
"Liter": 579
}, {
"Unit": "Transportation",
"UnitID": 10,
"DateofPurchase": "20.04.2016",
"Liter": 337
}, {
"Unit": "Boss",
"UnitID": 8,
"DateofPurchase": "21.04.2016",
"Liter": 3
}, {
"Unit": "Transportation",
"UnitID": 10,
"DateofPurchase": "21.04.2016",
"Liter": 22
}]
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
I want to get results this way :
{
name: 'Transportation',
data: [3453, 337, 22]
}, {
name: 'Computing',
data: [2, 5, 579]
}, {
name: 'Boss',
data: [4564, 3]
}