Skip to content

Commit

Permalink
cleaning code
Browse files Browse the repository at this point in the history
  • Loading branch information
Madhuka committed Jun 24, 2015
1 parent b2a5a3e commit 330580f
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 50 deletions.
4 changes: 2 additions & 2 deletions app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ angular
.module('apacheZeppelinGsocApp', [
'ngResource',
'ngRoute',
'googlechart',
'googlechart',
'highcharts-ng',
'nvd3'
])
Expand All @@ -26,7 +26,7 @@ angular
templateUrl: 'views/milestone01.html',
controller:'ChartCtrl'
})
.when('/contact', {
.when('/contact', {
templateUrl: 'views/contact.html'
})
.when('/', {
Expand Down
17 changes: 8 additions & 9 deletions app/scripts/chart-factory/google-chart-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ angular.module('apacheZeppelinGsocApp').factory('GoogleChartFactory', function(
cssStyle: 'height:400px; width:500px;',
data: {
'cols': [{
id: 'pizza',
label: 'Pizza',
type: 'string'
}, {
id: 'populartiy',
label: 'Populartiy',
type: 'number'
}
],
id: 'pizza',
label: 'Pizza',
type: 'string'
}, {
id: 'populartiy',
label: 'Populartiy',
type: 'number'
}],
'rows': [{
c: [{
v: 'Pepperoni'
Expand Down
1 change: 0 additions & 1 deletion app/scripts/chart-factory/high-chart-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ angular.module('apacheZeppelinGsocApp').factory('HighChartFactory', function(
}

function loadYAxisLabel(fileName) {
console.log(fileName)
highAxisLabels = d3.csv(fileName).row(highYaxisModel).get(getHighYaxis);
}
return HighChartFactory;
Expand Down
3 changes: 1 addition & 2 deletions app/scripts/chart-factory/nvd3-chart-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ angular.module('apacheZeppelinGsocApp').factory('NVD3ChartFactory', function(
right: 20,
bottom: 20,
left: 20
},
},
x: function(d) {
return d.valuex;
},
Expand Down Expand Up @@ -65,7 +65,6 @@ angular.module('apacheZeppelinGsocApp').factory('NVD3ChartFactory', function(
function setChartTypeView(chartType) {
NVD3ChartFactory.viewModel.options.chart.type = ChartList[chartType];
}

var NVD3Chart = {
model: nvd3Model,
get: getNVD3
Expand Down
2 changes: 0 additions & 2 deletions app/scripts/config/chart-config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';

/**
* @ngdoc function
* @name apacheZeppelinGsocApp.configure
Expand All @@ -8,7 +7,6 @@
*
* @author madhuka udantha
*/

angular.module('apacheZeppelinGsocApp')
.constant('chartConfig', {
'libraryName': [{
Expand Down
5 changes: 2 additions & 3 deletions app/scripts/controllers/chart-controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
angular.module('apacheZeppelinGsocApp').controller('ChartCtrl', function($scope,
ChartFactory, GoogleChartFactory, HighChartFactory, NVD3ChartFactory,
ChartService, ChartMetaService, chartConfig) {
var vm = this,
varmyChart = {};
var vm = this;
//loading from chart config file.
var libraryName = chartConfig.libraryName;
var files = chartConfig.dataFiles;
Expand Down Expand Up @@ -41,7 +40,7 @@ angular.module('apacheZeppelinGsocApp').controller('ChartCtrl', function($scope,
drawChart(data);
}

function getChartTemplateURL(libraryIndex) {
function getChartTemplateURL() {
return ChartMetaService.getChartTemplateURL();
}

Expand Down
46 changes: 15 additions & 31 deletions app/scripts/services/chart-meta-service.js
Original file line number Diff line number Diff line change
@@ -1,73 +1,57 @@
'use strict';

/**
* @ngdoc function
* @name apacheZeppelinGsocApp.ChartMetaService
* @description
* # ChartMetaService will be using Handle Basic Chart Meta Details.
*
*/


angular.module('apacheZeppelinGsocApp').service('ChartMetaService', function() {

/*Chart Meta Data Service*/
var MetaModel = {
ChartLib:null,
ChartTemplateURL:null,
ChartType:null,
ChartDataSetName:null,
ChartDataSetPath:null,
ChartLib: null,
ChartTemplateURL: null,
ChartType: null,
ChartDataSetName: null,
ChartDataSetPath: null,
ChartData: null
};

//getters
this.getChartLib = function() {
return MetaModel.ChartLib ;
return MetaModel.ChartLib;
};

this.getChartType = function() {
return MetaModel.ChartType ;
return MetaModel.ChartType;
};

this.getChartTemplateURL = function() {
return MetaModel.ChartTemplateURL ;
return MetaModel.ChartTemplateURL;
};

this.getChartDataSetName = function() {
return MetaModel.ChartDataSetName ;
return MetaModel.ChartDataSetName;
};

this.getChartDataSetPath = function() {
return MetaModel.ChartDataSetPath ;
return MetaModel.ChartDataSetPath;
};

this.getChartData = function() {
return MetaModel.ChartData ;
return MetaModel.ChartData;
};

//setters
this.setChartLib = function(ChartLib) {
MetaModel.ChartLib = ChartLib ;
MetaModel.ChartLib = ChartLib;
};

this.setChartType = function(ChartType) {
MetaModel.ChartType = ChartType ;
MetaModel.ChartType = ChartType;
};

this.setChartTemplateURL = function(ChartTemplateURL) {
MetaModel.ChartTemplateURL = ChartTemplateURL;
};

this.setChartDataSetName = function(ChartDataSetName) {
MetaModel.ChartDataSetName = ChartDataSetName ;
MetaModel.ChartDataSetName = ChartDataSetName;
MetaModel.ChartDataSetPath = 'data/' + ChartDataSetName + '.csv';
MetaModel.ChartData = d3.csv(MetaModel.ChartDataSetPath);
};

//looking for UI model logic
this.isMetaCompleted = function() {
return MetaModel.ChartType !== null ;
return MetaModel.ChartType !== null;
};

});
4 changes: 4 additions & 0 deletions test/spec/controllers/chart-controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,9 @@ describe('Controller: ChartCtrl', function() {
expect(ChartCtrl.isButtonActive('dataButton','car')).toBe(false);
});

it('Get ChartTemplate URL testing', function() {
expect(ChartCtrl.getChartTemplateURL).toBeDefined();
expect(ChartCtrl.getChartTemplateURL instanceof Function).toBe(true);
});
});

0 comments on commit 330580f

Please sign in to comment.