From c80814a35642cfc6c7255ac24c5f4c53a7e32754 Mon Sep 17 00:00:00 2001 From: madhuka Date: Wed, 24 Jun 2015 21:29:13 +0530 Subject: [PATCH 1/3] adding data tranform services --- app/scripts/chart-factory/nvd3-chart-factory.js | 6 ++++-- app/scripts/controllers/chart-controllers.js | 1 + app/scripts/services/chart-service.js | 9 ++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/scripts/chart-factory/nvd3-chart-factory.js b/app/scripts/chart-factory/nvd3-chart-factory.js index 0454e92..7561927 100644 --- a/app/scripts/chart-factory/nvd3-chart-factory.js +++ b/app/scripts/chart-factory/nvd3-chart-factory.js @@ -6,8 +6,7 @@ * # Extending Gobal Chart Factory for NVD3 Chart Model * */ -angular.module('apacheZeppelinGsocApp').factory('NVD3ChartFactory', function( - ChartFactory) { +angular.module('apacheZeppelinGsocApp').factory('NVD3ChartFactory', function(ChartMetaService, ChartFactory) { var ChartList = { 'Bar': 'discreteBarChart', 'Line': 'lineChart' @@ -79,6 +78,9 @@ angular.module('apacheZeppelinGsocApp').factory('NVD3ChartFactory', function( NVD3ChartFactory.setChartAxis = function(data) { loadYAxisLabel(data); }; + NVD3ChartFactory.dataTransform = function() { + ChartMetaService.getChartData().row(NVD3Chart.model).get(NVD3Chart.get); + }; // define a new internal private method for this chart object var nvd3AxisLabels = {}; diff --git a/app/scripts/controllers/chart-controllers.js b/app/scripts/controllers/chart-controllers.js index 1a7d0a8..2589c17 100644 --- a/app/scripts/controllers/chart-controllers.js +++ b/app/scripts/controllers/chart-controllers.js @@ -60,6 +60,7 @@ angular.module('apacheZeppelinGsocApp').controller('ChartCtrl', function($scope, case 'NVD3Chart': //set data for NVD3 myNewChart = ChartService.getNVD3Chart(myChartType); + ChartService.updateData(); vm.data = myNewChart.viewModel.data; vm.options = myNewChart.viewModel.options; break; diff --git a/app/scripts/services/chart-service.js b/app/scripts/services/chart-service.js index 163c757..0758eae 100644 --- a/app/scripts/services/chart-service.js +++ b/app/scripts/services/chart-service.js @@ -9,7 +9,7 @@ */ -angular.module('apacheZeppelinGsocApp').service('ChartService', function(HighChartFactory, GoogleChartFactory, NVD3ChartFactory,ChartMetaService) { +angular.module('apacheZeppelinGsocApp').service('ChartService', function($q, HighChartFactory, GoogleChartFactory, NVD3ChartFactory,ChartMetaService) { /*using chart facotry*/ this.getHighChart = function(chartType) { @@ -32,4 +32,11 @@ angular.module('apacheZeppelinGsocApp').service('ChartService', function(HighCha return myChart; }; + this.updateData = function() { + var myChart = NVD3ChartFactory; + myChart.setChartAxis(ChartMetaService.getChartDataSetPath()); + myChart.dataTransform(); + return myChart; + }; + }); \ No newline at end of file From 5bccaab21da30336891328bcdb8348da7748011d Mon Sep 17 00:00:00 2001 From: madhuka Date: Wed, 24 Jun 2015 22:44:47 +0530 Subject: [PATCH 2/3] finding issue of library --- app/scripts/controllers/chart-controllers.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/scripts/controllers/chart-controllers.js b/app/scripts/controllers/chart-controllers.js index 2589c17..f693416 100644 --- a/app/scripts/controllers/chart-controllers.js +++ b/app/scripts/controllers/chart-controllers.js @@ -59,10 +59,14 @@ angular.module('apacheZeppelinGsocApp').controller('ChartCtrl', function($scope, switch (ChartMetaService.getChartLib()) { case 'NVD3Chart': //set data for NVD3 - myNewChart = ChartService.getNVD3Chart(myChartType); ChartService.updateData(); + myNewChart = ChartService.getNVD3Chart(myChartType); + //only for nvd3 for fixing the bug vm.data = myNewChart.viewModel.data; vm.options = myNewChart.viewModel.options; + console.log('VM Level'); + console.log(vm.data); + console.log(myNewChart.viewModel.data); break; case 'highChart': myNewChart = ChartService.getHighChart(myChartType); @@ -74,7 +78,7 @@ angular.module('apacheZeppelinGsocApp').controller('ChartCtrl', function($scope, break; } if (myNewChart.model) { - renderChart(myNewChart.model, data); + //renderChart(myNewChart.model, data); } //NVD3 axis update } From 6cbb8a26f52408d0f8390a63ad9d0e1d1fa2d5a9 Mon Sep 17 00:00:00 2001 From: madhuka Date: Wed, 24 Jun 2015 23:14:53 +0530 Subject: [PATCH 3/3] Fixing google chart and Old model for High chart for Demo/show) --- app/scripts/chart-factory/google-chart-factory.js | 13 ++++++++----- app/scripts/chart-factory/high-chart-factory.js | 6 ++++-- app/scripts/controllers/chart-controllers.js | 3 +++ app/scripts/services/chart-service.js | 10 +++++++++- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/app/scripts/chart-factory/google-chart-factory.js b/app/scripts/chart-factory/google-chart-factory.js index d3347a6..ce0399e 100644 --- a/app/scripts/chart-factory/google-chart-factory.js +++ b/app/scripts/chart-factory/google-chart-factory.js @@ -6,21 +6,21 @@ * # Extending Gobal Chart Factory for Google Chart Model * */ -angular.module('apacheZeppelinGsocApp').factory('GoogleChartFactory', function( - ChartFactory) { +angular.module('apacheZeppelinGsocApp').factory('GoogleChartFactory', function(ChartMetaService, ChartFactory) { var ChartList = { 'Bar': 'BarChart', 'Line': 'LineChart' }; //googleChart model (sample chart data model) - //TO-DO Sample Data will remove after model set. + //TO-DO Sample Data will remove after model set + //Question tobe ask, As data model from CSV is not support data types so need cols var GoogelChartChartModel = { type: 'BarChart', cssStyle: 'height:400px; width:500px;', data: { 'cols': [{ - id: 'pizza', - label: 'Pizza', + id: 'mtot', + label: 'motor', type: 'string' }, { id: 'populartiy', @@ -80,6 +80,9 @@ angular.module('apacheZeppelinGsocApp').factory('GoogleChartFactory', function( GoogleChartFactory.type = chartType; setChartTypeView(chartType); }; + GoogleChartFactory.dataTransform = function() { + ChartMetaService.getChartData().row(googlexChart.model).get(googlexChart.get); + }; // define a new internal private method for this chart object function setChartAxis() {} return GoogleChartFactory; diff --git a/app/scripts/chart-factory/high-chart-factory.js b/app/scripts/chart-factory/high-chart-factory.js index 8d59daf..3c94543 100644 --- a/app/scripts/chart-factory/high-chart-factory.js +++ b/app/scripts/chart-factory/high-chart-factory.js @@ -6,8 +6,7 @@ * # Extending Gobal Chart Factory for High Chart Model * */ -angular.module('apacheZeppelinGsocApp').factory('HighChartFactory', function( - ChartFactory) { +angular.module('apacheZeppelinGsocApp').factory('HighChartFactory', function(ChartMetaService, ChartFactory) { var ChartList = { 'Bar': 'bar', 'Line': 'line' @@ -63,6 +62,9 @@ angular.module('apacheZeppelinGsocApp').factory('HighChartFactory', function( HighChartFactory.setChartAxis = function(data) { loadYAxisLabel(data); }; + HighChartFactory.dataTransform = function() { + ChartMetaService.getChartData().row(highxChart.model).get(highxChart.get); + }; var highAxisLabels = {}; function getHighYaxis(error, rows) { diff --git a/app/scripts/controllers/chart-controllers.js b/app/scripts/controllers/chart-controllers.js index f693416..6eb2329 100644 --- a/app/scripts/controllers/chart-controllers.js +++ b/app/scripts/controllers/chart-controllers.js @@ -73,8 +73,11 @@ angular.module('apacheZeppelinGsocApp').controller('ChartCtrl', function($scope, vm.chartConfig = myNewChart.viewModel; break; case 'googleChart': + //ChartService.updateGoogleData(); myNewChart = ChartService.getGoogleChart(myChartType); vm.chart = myNewChart.viewModel; + console.log('VM Level'); + console.log(vm.chart.data.rows); break; } if (myNewChart.model) { diff --git a/app/scripts/services/chart-service.js b/app/scripts/services/chart-service.js index 0758eae..f20bfe4 100644 --- a/app/scripts/services/chart-service.js +++ b/app/scripts/services/chart-service.js @@ -14,6 +14,7 @@ angular.module('apacheZeppelinGsocApp').service('ChartService', function($q, Hig /*using chart facotry*/ this.getHighChart = function(chartType) { var myChart = HighChartFactory; + myChart.dataTransform(); myChart.setChartType(chartType); myChart.setChartAxis(ChartMetaService.getChartDataSetPath()); return myChart; @@ -21,6 +22,7 @@ angular.module('apacheZeppelinGsocApp').service('ChartService', function($q, Hig this.getGoogleChart = function(chartType) { var myChart = GoogleChartFactory; + updateGoogleData(); myChart.setChartType(chartType); return myChart; }; @@ -32,11 +34,17 @@ angular.module('apacheZeppelinGsocApp').service('ChartService', function($q, Hig return myChart; }; - this.updateData = function() { + this.updateData = function() { var myChart = NVD3ChartFactory; myChart.setChartAxis(ChartMetaService.getChartDataSetPath()); myChart.dataTransform(); return myChart; }; + function updateGoogleData () { + var myChart = GoogleChartFactory; + myChart.dataTransform(); + return myChart; + }; + }); \ No newline at end of file