Wijmo 5 (Angular) - FlexChart Grouping
by Joel Parks
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.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" class="container">
<h1>Wijmo 5 - FlexChart (Angular)</h1>
<p>This is a <b>FlexChart</b> control showing data:</p>
<wj-flex-chart items-source="data" binding-x="country" class="custom-flex-chart">
<wj-flex-chart-axis wj-property="axisY" major-unit="5000" title="Units"></wj-flex-chart-axis>
<wj-flex-chart-series binding="sales" name="Sales"></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;
}
/* custom chart theme */
/* changes the axis labels */
.custom-flex-chart.wj-flexchart .wj-axis-x .wj-label {
font-family: Courier New, Courier, monospace;
font-weight: bold;
stroke: #000000;
}
/* changes the legend labels */
.custom-flex-chart.wj-flexchart .wj-legend .wj-label {
font-family: Courier New, Courier, monospace;
font-weight: bold;
}
/* changes the legend background */
.custom-flex-chart.wj-flexchart .wj-legend > rect {
fill: #f8f8f8;
stroke: #c0c0c0;
}
/* changes the plot area */
.custom-flex-chart.wj-flexchart .wj-plot-area > rect {
fill: #f8f8f8;
stroke: #c0c0c0;
}
JavaScript
// define app, include Wijmo 5 directives
var app = angular.module('app', ['wj']);
// controller
app.controller('appCtrl', function($scope) {
// create some random data
var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(',');
data = [], data1 = [], data2 = [];
for (var i = 0; i < countries.length; i++) {
data1.push({
country: countries[i],
sales: Math.random() * 10000
});
data2.push({
country: countries[i],
sales: Math.random() * 10000
});
}
data = data1;
// expose data as a CollectionView to get events
$scope.data = new wijmo.collections.CollectionView(data);
});