Wijmo 5 - FlexGrid and FlexChart
HTML
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="http://cdn.wijmo.com/5.latest/styles/wijmo.min.css">
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.grid.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.chart.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.input.min.js"></script>
<button ID=BTN>GET DATA</button>
<h1>FlexSheet with dataMap - Pure JS</h1>
<div id="flex1" style="height: 500px"></div>
CSS
.wj-flexgrid {
margin: 12px;
}
.wj-flexchart {
height: 300px;
margin: 12px;
}
body {
margin-bottom: 24pt;
}
JavaScript
var countries = 'US,Germany,UK,Japan,Italy,Greece,Greece'.split(','),
data = [];
window.onload = function () {
// create some data
for (var i = 0; i < 10; i++) {
data.push({
country: countries[i % countries.length],
downloads: Math.round(Math.random() * 20000),
date: new Date(2014, i % 12, i % 28),
sales: Math.random() * 10000
});
}
data.push({
country: 70,
downloads: 20000,
date: new Date(2014, 12, 28),
sales: 10000
});
// initialize grid
var host= document.createElement('div');
var flex1 = new wijmo.grid.FlexGrid("#flex1", {
autoGenerateColumns: false,
columns: [
{ binding: 'country', header: 'Country', width: 150 },
{ binding: 'downloads', header: 'Downloads', format: 'n0', width: 150 },
{ binding: 'sales', header: 'Sales', format: 'n2', width: 150 },
{ binding: 'date', header: 'Date', width: 150 },
],
itemsSource: data
});
flex1.columns.getColumn("country").dataMap= new wijmo.grid.DataMap(countries);
flex1.itemFormatter=function(panel,r,c,cell){
if(panel.cellType=wijmo.grid.CellType.Cell&&panel.columns[c].dataMap){
var data=panel.getCellData(r,c,false);
var key=panel.columns[c].dataMap.getKeyValue(data);
if(!key){
cell.childNodes[0].textContent="";
}
}
}
flex1.hostElement.addEventListener("keydown",function(e){
if(e.keyCode==40 && flex1.editRange){ ...