Wijmo 5 - AngularJS directives
by Ross Dederer
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.input.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.20161.138/controls/wijmo.grid.filter.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/interop/angular/wijmo.angular.min.js"></script>
<!-- mark this as an Angular application and give it a controller -->
<div ng-app="app" ng-controller="appCtrl">
<div ng-hide="hidden">
<wj-flex-grid items-source="data" item-formatter="itemFormatter" style="height: 400px;margin-top:10px" control="flex">
<wj-flex-grid-filter></wj-flex-grid-filter>
<wj-flex-grid-column header="Country" binding="country" width="*"></wj-flex-grid-column>
<wj-flex-grid-column header="Expenses" binding="expenses" format="c" width="*"></wj-flex-grid-column>
<wj-flex-grid-column header="Sales" name="Sales" binding="sales" format="c" width="*">
<span style="color:green" ng-if="$item.sales > 5000">{{ $item.sales | currency}}</span>
<span style="color:red" ng-if="$item.sales < 5000">{{ $item.sales | currency}}</span>
</wj-flex-grid-column>
<wj-flex-grid-column header="Date" binding="date" format="dd/MM/yyyy"></wj-flex-grid-column>
</wj-flex-grid>
</div>
<p>And this is a <b>FlexChart</b> control showing the same data: </p>
<wj-flex-chart style="height:300px" items-source="data" binding-x="country" selection-mode="Point">
<wj-flex-chart-axis wj-property="axisY" major-unit="2000" Position="Left"...
JavaScript
// define app, include Wijmo 5 directives
var app = angular.module('app', ['wj']);
// controller
app.controller('appCtrl', function ($scope) {
// $scope.itemFormatter = itemFormatter;
// create some random data
var countries = 'Australia,New Zealand,United States,Germany,Mexico,Canada,Japan,Greece'.split(','),
data = [];
for (var i = 0; i < countries.length; i++) {
data.push({
country: countries[i],
downloads: Math.round(Math.random() * 20000),
sales: Math.random() * 10000,
expenses: Math.random() * 5000,
date: new Date(2016, i % 12, (i + 10) % 25),
});
}
// expose data as a CollectionView to get events
$scope.data = new wijmo.collections.CollectionView(data);
/** function itemFormatter(panel, r, c, cell) {
if (panel.cellType == wijmo.grid.CellType.Cell) {
var col = panel.columns[c];
switch (col.name) {
case 'Sales':
cell.innerHTML = "Hello";
alert("Hi");
break;
}
}
} */
});