diff --git a/Gruntfile.js b/Gruntfile.js index 0bc2c8b..133bcb0 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -44,7 +44,7 @@ module.exports = function(grunt) { livereload: true }, taskName: { - files: ['src/*.js', 'example/*.html'], + files: ['src/*.js', 'example/*.*'], tasks: ['default'] } }, diff --git a/example/index.html b/example/index.html index 68c8b79..37c3a0c 100644 --- a/example/index.html +++ b/example/index.html @@ -19,88 +19,7 @@ type="text/javascript" src="../dist/angular-fusioncharts.js" > - +
diff --git a/example/index.js b/example/index.js new file mode 100644 index 0000000..da6b591 --- /dev/null +++ b/example/index.js @@ -0,0 +1,65 @@ +var jsonify = res => res.json(); +var dataFetch = fetch( + 'https://raw.githubusercontent.com/fusioncharts/dev_centre_docs/fusiontime-beta-release/charts-resources/fusiontime/online-sales-single-series/data.json' +).then(jsonify); +var schemaFetch = fetch( + 'https://raw.githubusercontent.com/fusioncharts/dev_centre_docs/fusiontime-beta-release/charts-resources/fusiontime/online-sales-single-series/schema.json' +).then(jsonify); + +var app = angular.module('myApp', ['ng-fusioncharts']); + +app.controller('MyController', function($scope) { + $scope.timeSeriesDS = { + caption: { text: 'Online Sales of a SuperStore in the US' }, + data: null, + yAxis: [ + { + plot: [ + { + value: 'Sales ($)' + } + ] + } + ] + }; + + $scope.columnDS = { + chart: { + caption: 'Countries With Most Oil Reserves [2017-18]', + subCaption: 'In MMbbl = One Million barrels', + xAxisName: 'Country', + yAxisName: 'Reserves (MMbbl)', + numberSuffix: 'K', + theme: 'fusion' + }, + data: [ + { label: 'Venezuela', value: '290' }, + { label: 'Saudi', value: '260' }, + { label: 'Canada', value: '180' }, + { label: 'Iran', value: '140' }, + { label: 'Russia', value: '115' }, + { label: 'UAE', value: '100' }, + { label: 'US', value: '30' }, + { label: 'China', value: '30' } + ] + }; + + $scope.update = function() { + $scope.timeSeriesDS.caption.text = 'Something Else'; + $scope.columnDS.chart.caption = 'Something Else'; + }; + + Promise.all([dataFetch, schemaFetch]).then(res => { + const data = res[0]; + const schema = res[1]; + const fusionTable = new FusionCharts.DataStore().createDataTable( + data, + schema + ); + $scope.$apply(function() { + $scope.timeSeriesDS.data = fusionTable; + }); + }); +}); + +// getData();