Wijmo 5 - AngularJS directives
by Joel Parks
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.grapecity.com/wijmo/5.latest/styles/wijmo.min.css">
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.grid.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.chart.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/interop/angular/wijmo.angular.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.input.min.js"></script>
<!-- mark this as an Angular application and give it a controller -->
<div ng-app="app" ng-controller="appCtrl" class="container">
<h1>Hello Wijmo 5 and AngularJS!</h1>
<p><b>ComboBox</b> w/ API call to retrieve data:</p>
<wj-combo-box items-source="data"></wj-combo-box>
<p>This is a <b>FlexGrid</b> control:</p>
<wj-flex-grid items-source="data">
<wj-flex-grid-column header="Country" binding="country"></wj-flex-grid-column>
<wj-flex-grid-column header="Sales" binding="sales"></wj-flex-grid-column>
<wj-flex-grid-column header="Expenses" binding="expenses"></wj-flex-grid-column>
</wj-flex-grid>
<p>And this is a <b>FlexChart</b> control showing the same data:</p>
<wj-flex-chart items-source="data" binding-x="country">
<wj-flex-chart-axis wj-property="axisY" major-unit="5000"></wj-flex-chart-axis>
<wj-flex-chart-series binding="sales" name="Sales"></wj-flex-chart-series>
<wj-flex-chart-series binding="expenses" name="Expenses"></wj-flex-chart-series>
<wj-flex-chart-legend position="Bottom"></wj-flex-chart-legend>
</wj-flex-chart>
</div>
CSS
.wj-flexgrid {
height: 150px;
margin-top:10px;
}
.wj-flexchart {
height: 300px;
}
JavaScript
// define app, include Wijmo 5 directives
var app = angular.module('app', ['wj']);
// controller
app.controller('appCtrl', function($scope, $http) {
var apiData = [];
// Retrieve data from the API
$http.get("https://mocki.io/v1/1b128feb-d87d-4078-acba-a82372033779").then(function(response) {
$scope.data = new wijmo.collections.CollectionView(response.data);
});
// create some random data
var countries = 'US,Germany,UK,Japan,Italy,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
});
}
// expose data as a CollectionView to get events
//$scope.data = new wijmo.collections.CollectionView(apiData);
});