-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhigh-chart-factory.js
84 lines (78 loc) · 2.04 KB
/
high-chart-factory.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
'use strict';
/**
* @ngdoc function
* @name apacheZeppelinGsocApp.HighChartFactory
* @description
* # Extending Gobal Chart Factory for High Chart Model
*
*/
angular.module('apacheZeppelinGsocApp').factory('HighChartFactory', function(ChartMetaService, ChartFactory) {
var ChartList = {
'Bar': 'bar',
'Line': 'line'
};
//highChart model
var HighChartChartModel = {
options: {
chart: {
type: 'bar'
}
},
xAxis: {
categories: []
},
series: [{
data: []
}],
size: {
width: 500,
height: 300
},
loading: false
};
//high chart
// define a new internal private method for this chart object
function highChartModel(d) {
return +d.Length;
}
function getHighChart(error, rows) {
console.log('loading for view');
console.log(rows);
HighChartChartModel.series[0].data = rows;
}
function setChartTypeView(chartType) {
HighChartFactory.viewModel.options.chart.type = ChartList[chartType];
}
function setChartAxis() {}
var highxChart = {
model: highChartModel,
get: getHighChart
};
//setting up the highchart and chart view model for this chart
var HighChartFactory = new ChartFactory('highxChart', highxChart);
HighChartChartModel.series[0].data = null;
HighChartFactory.viewModel = HighChartChartModel;
HighChartFactory.setChartType = function(chartType) {
HighChartFactory.type = chartType;
setChartTypeView(chartType);
};
HighChartFactory.setChartAxis = function(data) {
loadYAxisLabel(data);
};
HighChartFactory.dataTransform = function() {
ChartMetaService.getChartData().row(highxChart.model).get(highxChart.get);
};
var highAxisLabels = {};
function getHighYaxis(error, rows) {
console.log(rows);
highAxisLabels = rows;
HighChartFactory.viewModel.xAxis.categories = highAxisLabels;
}
function highYaxisModel(d) {
return d.Make;
}
function loadYAxisLabel(fileName) {
highAxisLabels = d3.csv(fileName).row(highYaxisModel).get(getHighYaxis);
}
return HighChartFactory;
});