<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>
<body>
<input type="button" value="Build JSON data onclick" onclick="buildJSONData();">
</body>
</html>
// Code goes here
function buildJSONData(){
var data = [
{
"ric": "ADAG.DE",
"sedol": "5653487",
"quantity": 107479,
"activityQuantity": null,
"businessDate": 20141023
},
{
"ric": "ADAG.DE",
"sedol": "BBJPFY1",
"quantity": 2758,
"activityQuantity": null,
"businessDate": 20141023
},
{
"ric": "ADAG.DE",
"sedol": "5653487",
"quantity": 107479,
"activityQuantity": null,
"businessDate": 20141023
},
{
"ric": "BDAG.DE",
"sedol": "5653487",
"quantity": 107479,
"activityQuantity": null,
"businessDate": 20141023
},
{
"ric": "BDAG.DE",
"sedol": "5653487",
"quantity": 107479,
"activityQuantity": null,
"businessDate": 20141023
}
];
var tempmap = {};
var jsonData = [];
var selectedRic = "ADAG.DE";
for ( var j = 0; j < data.length; j ++ )
{
if (!(data[j].ric in tempmap))
{
jsonData.push (
{
key: data[j].ric,
values: []
}
);
tempmap[data[j].ric] = jsonData.length - 1;
}
jsonData[tempmap[data[j].ric]].values.push (data[j]);
}
document.write(JSON.stringify(jsonData));
}
/* Styles go here */