Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data loading fix #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions app/scripts/chart-factory/google-chart-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions app/scripts/chart-factory/high-chart-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions app/scripts/chart-factory/nvd3-chart-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 = {};

Expand Down
10 changes: 9 additions & 1 deletion app/scripts/controllers/chart-controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,29 @@ angular.module('apacheZeppelinGsocApp').controller('ChartCtrl', function($scope,
switch (ChartMetaService.getChartLib()) {
case 'NVD3Chart':
//set data for NVD3
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);
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) {
renderChart(myNewChart.model, data);
//renderChart(myNewChart.model, data);
}
//NVD3 axis update
}
Expand Down
17 changes: 16 additions & 1 deletion app/scripts/services/chart-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@
*/


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) {
var myChart = HighChartFactory;
myChart.dataTransform();
myChart.setChartType(chartType);
myChart.setChartAxis(ChartMetaService.getChartDataSetPath());
return myChart;
};

this.getGoogleChart = function(chartType) {
var myChart = GoogleChartFactory;
updateGoogleData();
myChart.setChartType(chartType);
return myChart;
};
Expand All @@ -32,4 +34,17 @@ angular.module('apacheZeppelinGsocApp').service('ChartService', function(HighCha
return myChart;
};

this.updateData = function() {
var myChart = NVD3ChartFactory;
myChart.setChartAxis(ChartMetaService.getChartDataSetPath());
myChart.dataTransform();
return myChart;
};

function updateGoogleData () {
var myChart = GoogleChartFactory;
myChart.dataTransform();
return myChart;
};

});