Skip to content

Commit

Permalink
Removing switch
Browse files Browse the repository at this point in the history
  • Loading branch information
Madhuka committed Jun 29, 2015
1 parent 15abb03 commit c979e1a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
3 changes: 3 additions & 0 deletions app/scripts/config/chart-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ angular.module('apacheZeppelinGsocApp')
.constant('chartConfig', {
'libraryName': [{
'library': 'highChart',
'service': 'getHighChart',
'template': 'views/charts/highchart.html'
}, {
'library': 'NVD3Chart',
'service': 'getNVD3Chart',
'template': 'views/charts/nvd3chart.html'
}, {
'library': 'googleChart',
'service': 'getGoogleChart',
'template': 'views/charts/googlechart.html'
}],
'dataFiles': ['car', 'bike'],
Expand Down
27 changes: 8 additions & 19 deletions app/scripts/controllers/chart-controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ angular.module('apacheZeppelinGsocApp').controller('ChartCtrl', function($scope,
setButtonActive('chartLibraryButton', libraryName[libraryIndex].library);
ChartMetaService.setChartLib(libraryName[libraryIndex].library);
ChartMetaService.setChartTemplateURL(libraryName[libraryIndex].template);
ChartMetaService.setChartService(libraryName[libraryIndex].service);
if (ChartMetaService.getChartType() === null) {
//setting default chart type
ChartMetaService.setChartType('Bar');
Expand All @@ -55,26 +56,14 @@ angular.module('apacheZeppelinGsocApp').controller('ChartCtrl', function($scope,
//Checking chart requirement is completed
var myNewChart = {};
var myChartType = ChartMetaService.getChartType();
console.log(myChartType);
switch (ChartMetaService.getChartLib()) {
case 'NVD3Chart':
//set data for NVD3
myNewChart = ChartService.getNVD3Chart(myChartType);
vm.chart = myNewChart.viewModel;
break;
case 'highChart':
myNewChart = ChartService.getHighChart(myChartType);
vm.chart = myNewChart.viewModel;
break;
case 'googleChart':
myNewChart = ChartService.getGoogleChart(myChartType);
vm.chart = myNewChart.viewModel;
break;
var chartService = ChartMetaService.getChartService();
if (chartService !== null) {
myNewChart = ChartService[chartService](myChartType);
vm.chart = myNewChart.viewModel;
if (myNewChart.model) {
renderChart(myNewChart.model, data);
}
}
if (myNewChart.model) {
renderChart(myNewChart.model, data);
}
//NVD3 axis update
}

function getData(fileName) {
Expand Down
7 changes: 7 additions & 0 deletions app/scripts/services/chart-meta-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ angular.module('apacheZeppelinGsocApp').service('ChartMetaService', function() {
var MetaModel = {
ChartLib: null,
ChartTemplateURL: null,
ChartService: null,
ChartType: null,
ChartDataSetName: null,
ChartDataSetPath: null,
Expand All @@ -26,6 +27,9 @@ angular.module('apacheZeppelinGsocApp').service('ChartMetaService', function() {
this.getChartTemplateURL = function() {
return MetaModel.ChartTemplateURL;
};
this.getChartService = function() {
return MetaModel.ChartService;
};
this.getChartDataSetName = function() {
return MetaModel.ChartDataSetName;
};
Expand All @@ -45,6 +49,9 @@ angular.module('apacheZeppelinGsocApp').service('ChartMetaService', function() {
this.setChartTemplateURL = function(ChartTemplateURL) {
MetaModel.ChartTemplateURL = ChartTemplateURL;
};
this.setChartService = function(ChartService) {
MetaModel.ChartService = ChartService;
};
this.setChartDataSetName = function(ChartDataSetName) {
MetaModel.ChartDataSetName = ChartDataSetName;
MetaModel.ChartDataSetPath = 'data/' + ChartDataSetName + '.csv';
Expand Down

0 comments on commit c979e1a

Please sign in to comment.