From 3ef98e976a37446d75c54aa03d39068e05bbd782 Mon Sep 17 00:00:00 2001 From: Rohan Dey Date: Fri, 4 Jan 2019 16:01:29 +0530 Subject: [PATCH 1/4] Refactored example code --- example/index.html | 83 +--------------------------------------------- example/index.js | 77 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 82 deletions(-) create mode 100644 example/index.js 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..028447c --- /dev/null +++ b/example/index.js @@ -0,0 +1,77 @@ +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']); + +function getData() { + Promise.all([dataFetch, schemaFetch]).then(res => { + const data = res[0]; + const schema = res[1]; + fusionTable = new FusionCharts.DataStore().createDataTable(data, schema); + console.log('Done'); + app.controller('MyController', function($scope) { + $scope.timeSeriesDS.data = fusionTable; + $scope.$apply(); + }); + }); +} + +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.timeSeriesDS.data = fusionTable; + $scope.$apply(); + }); +}); + +// getData(); From 8d90d8e27ac6c72378ee9182d79720aa0aa7706a Mon Sep 17 00:00:00 2001 From: Rohan Dey Date: Fri, 4 Jan 2019 16:13:15 +0530 Subject: [PATCH 2/4] Fixed gruntfile and example --- Gruntfile.js | 2 +- example/index.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 0bc2c8b..331a95f 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/*.html', 'example/*.js'], tasks: ['default'] } }, diff --git a/example/index.js b/example/index.js index 028447c..2aec5c1 100644 --- a/example/index.js +++ b/example/index.js @@ -69,8 +69,9 @@ app.controller('MyController', function($scope) { data, schema ); - $scope.timeSeriesDS.data = fusionTable; - $scope.$apply(); + $scope.$apply(function() { + $scope.timeSeriesDS.data = fusionTable; + }); }); }); From c48defc3d459ddd16cd5b8bfac23748d8cb6f0b1 Mon Sep 17 00:00:00 2001 From: Rohan Dey Date: Fri, 4 Jan 2019 16:16:11 +0530 Subject: [PATCH 3/4] Fixed grunt config --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 331a95f..133bcb0 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -44,7 +44,7 @@ module.exports = function(grunt) { livereload: true }, taskName: { - files: ['src/*.js', 'example/*.html', 'example/*.js'], + files: ['src/*.js', 'example/*.*'], tasks: ['default'] } }, From 12076798f3c954075d7335352a0fa029c060796f Mon Sep 17 00:00:00 2001 From: Rohan Dey Date: Fri, 4 Jan 2019 16:19:11 +0530 Subject: [PATCH 4/4] Removed unnecessary code --- example/index.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/example/index.js b/example/index.js index 2aec5c1..da6b591 100644 --- a/example/index.js +++ b/example/index.js @@ -8,19 +8,6 @@ var schemaFetch = fetch( var app = angular.module('myApp', ['ng-fusioncharts']); -function getData() { - Promise.all([dataFetch, schemaFetch]).then(res => { - const data = res[0]; - const schema = res[1]; - fusionTable = new FusionCharts.DataStore().createDataTable(data, schema); - console.log('Done'); - app.controller('MyController', function($scope) { - $scope.timeSeriesDS.data = fusionTable; - $scope.$apply(); - }); - }); -} - app.controller('MyController', function($scope) { $scope.timeSeriesDS = { caption: { text: 'Online Sales of a SuperStore in the US' },