Highcharts-ng
A simple Angularjs directive for Highcharts.
AngularJs, Highcharts
by esantiagovieira
HTML
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<script src="http://code.angularjs.org/1.1.0/angular.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="https://rawgithub.com/pablojim/highcharts-ng/master/src/highcharts-ng.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div ng-app="myapp">
<div ng-controller="myctrl">
<div class="span12">
<button ng-click="svgExport()">SVG Please</button>
</div>
<div class="row">
<highchart id="chart1" config="chartConfig" class="span10"></highchart>
</div>
</div>
</div>
<h3><a href="https://github.com/pablojim/highcharts-ng">See Highcharts-ng on github</a></h3>
JavaScript
//See: https://github.com/pablojim/highcharts-ng
var myapp = angular.module('myapp', ["highcharts-ng"]);
myapp.controller('myctrl', function ($scope) {
$scope.chartConfig = {
options: {
chart: {
height: 300,
type: 'bar',
events: {
load: function () {
$scope.chartExport = $.proxy(this.exportChart, this);
}
}
}
},
series: [{
data: [10, 15, 12, 8, 7]
}],
title: {
text: 'Hello'
},
loading: false,
// func: function (chart) {
// $scope.chartExport = $.proxy(chart.exportChart, chart);
// }
}
$scope.svgExport = function() {
$scope.exportChart({type: 'image/svg+xml', filename: 'my-svg'}, {
chart: {events: {load: function () {} }},
subtitle: {text:''}});
}
});