Skip to content

Commit

Permalink
refactored code
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwondercorn committed Apr 29, 2018
1 parent e6f82ed commit 2e731fa
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 80 deletions.
92 changes: 46 additions & 46 deletions tests/dummy/app/controllers/donut.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@ import Controller from '@ember/controller';

export default Controller.extend({

init: function() {
init() {
this._super(...arguments);
later(this, function() {
this.get('data.columns').push(
["setosa", 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2,
0.2, 0.1, 0.2, 0.2, 0.1, 0.1, 0.2, 0.4, 0.4, 0.3,
0.3, 0.3, 0.2, 0.4, 0.2, 0.5, 0.2, 0.2, 0.4, 0.2,
0.2, 0.2, 0.2, 0.4, 0.1, 0.2, 0.2, 0.2, 0.2, 0.1,
0.2, 0.2, 0.3, 0.3, 0.2, 0.6, 0.4, 0.3, 0.2, 0.2,
0.2, 0.2
]);
this.get('data.columns').push(
["versicolor", 1.4, 1.5, 1.5, 1.3, 1.5, 1.3, 1.6, 1.0,
1.3, 1.4, 1.0, 1.5, 1.0, 1.4, 1.3, 1.4, 1.5, 1.0,
1.5, 1.1, 1.8, 1.3, 1.5, 1.2, 1.3, 1.4, 1.4, 1.7,
1.5, 1.0, 1.1, 1.0, 1.2, 1.6, 1.5, 1.6, 1.5, 1.3,
1.3, 1.3, 1.2, 1.4, 1.2, 1.0, 1.3, 1.2, 1.3, 1.3,
1.1, 1.3
]);
this.get('data.columns').push(
["virginica", 2.5, 1.9, 2.1, 1.8, 2.2, 2.1, 1.7, 1.8,
1.8, 2.5, 2.0, 1.9, 2.1, 2.0, 2.4, 2.3, 1.8, 2.2,
2.3, 1.5, 2.3, 2.0, 2.0, 1.8, 2.1, 1.8, 1.8, 1.8,
2.1, 1.6, 1.9, 2.0, 2.2, 1.5, 1.4, 2.3, 2.4, 1.8,
1.8, 2.1, 2.4, 2.3, 1.9, 2.3, 2.5, 2.3, 1.9, 2.0,
2.3, 1.8
]);
this.notifyPropertyChange('data');
},

later(this, function () {
this.get('data.columns').push(
["setosa", 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2,
0.2, 0.1, 0.2, 0.2, 0.1, 0.1, 0.2, 0.4, 0.4, 0.3,
0.3, 0.3, 0.2, 0.4, 0.2, 0.5, 0.2, 0.2, 0.4, 0.2,
0.2, 0.2, 0.2, 0.4, 0.1, 0.2, 0.2, 0.2, 0.2, 0.1,
0.2, 0.2, 0.3, 0.3, 0.2, 0.6, 0.4, 0.3, 0.2, 0.2,
0.2, 0.2
]);
this.get('data.columns').push(
["versicolor", 1.4, 1.5, 1.5, 1.3, 1.5, 1.3, 1.6, 1.0,
1.3, 1.4, 1.0, 1.5, 1.0, 1.4, 1.3, 1.4, 1.5, 1.0,
1.5, 1.1, 1.8, 1.3, 1.5, 1.2, 1.3, 1.4, 1.4, 1.7,
1.5, 1.0, 1.1, 1.0, 1.2, 1.6, 1.5, 1.6, 1.5, 1.3,
1.3, 1.3, 1.2, 1.4, 1.2, 1.0, 1.3, 1.2, 1.3, 1.3,
1.1, 1.3
]);
this.get('data.columns').push(
["virginica", 2.5, 1.9, 2.1, 1.8, 2.2, 2.1, 1.7, 1.8,
1.8, 2.5, 2.0, 1.9, 2.1, 2.0, 2.4, 2.3, 1.8, 2.2,
2.3, 1.5, 2.3, 2.0, 2.0, 1.8, 2.1, 1.8, 1.8, 1.8,
2.1, 1.6, 1.9, 2.0, 2.2, 1.5, 1.4, 2.3, 2.4, 1.8,
1.8, 2.1, 2.4, 2.3, 1.9, 2.3, 2.5, 2.3, 1.9, 2.0,
2.3, 1.8
]);
this.notifyPropertyChange('data');
},
1500);

// FIXME: No way to unload yet
Expand All @@ -49,23 +49,23 @@ export default Controller.extend({
},

data: {
columns: [
['data1', 30],
['data2', 120],
],
type: 'donut',
onclick: function(d, i) {
console.log("onclick", d, i);
},
onmouseover: function(d, i) {
console.log("onmouseover", d, i);
columns: [
['data1', 30],
['data2', 120],
],
type: 'donut',
onclick: function (d, i) {
console.log("onclick", d, i);
},
onmouseover: function (d, i) {
console.log("onmouseover", d, i);
},
onmouseout: function (d, i) {
console.log("onmouseout", d, i);
}
},
onmouseout: function(d, i) {
console.log("onmouseout", d, i);
}
},
donut: {
title: "Iris Petal Width"
}

donut: { title: "Iris Petal Width" }


});
64 changes: 32 additions & 32 deletions tests/dummy/app/controllers/pie.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@ import Controller from '@ember/controller';

export default Controller.extend({

init: function() {
init() {
this._super(...arguments);

later(this, function() {
this.get('data.columns').push(
["setosa", 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2,
0.2, 0.1, 0.2, 0.2, 0.1, 0.1, 0.2, 0.4, 0.4, 0.3,
0.3, 0.3, 0.2, 0.4, 0.2, 0.5, 0.2, 0.2, 0.4, 0.2,
0.2, 0.2, 0.2, 0.4, 0.1, 0.2, 0.2, 0.2, 0.2, 0.1,
0.2, 0.2, 0.3, 0.3, 0.2, 0.6, 0.4, 0.3, 0.2, 0.2,
0.2, 0.2
]);
this.get('data.columns').push(
["versicolor", 1.4, 1.5, 1.5, 1.3, 1.5, 1.3, 1.6, 1.0,
1.3, 1.4, 1.0, 1.5, 1.0, 1.4, 1.3, 1.4, 1.5, 1.0,
1.5, 1.1, 1.8, 1.3, 1.5, 1.2, 1.3, 1.4, 1.4, 1.7,
1.5, 1.0, 1.1, 1.0, 1.2, 1.6, 1.5, 1.6, 1.5, 1.3,
1.3, 1.3, 1.2, 1.4, 1.2, 1.0, 1.3, 1.2, 1.3, 1.3,
1.1, 1.3
]);
this.get('data.columns').push(
["virginica", 2.5, 1.9, 2.1, 1.8, 2.2, 2.1, 1.7, 1.8,
1.8, 2.5, 2.0, 1.9, 2.1, 2.0, 2.4, 2.3, 1.8, 2.2,
2.3, 1.5, 2.3, 2.0, 2.0, 1.8, 2.1, 1.8, 1.8, 1.8,
2.1, 1.6, 1.9, 2.0, 2.2, 1.5, 1.4, 2.3, 2.4, 1.8,
1.8, 2.1, 2.4, 2.3, 1.9, 2.3, 2.5, 2.3, 1.9, 2.0,
2.3, 1.8
]);
this.notifyPropertyChange('data');
},
later(this, function () {
this.get('data.columns').push(
["setosa", 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2,
0.2, 0.1, 0.2, 0.2, 0.1, 0.1, 0.2, 0.4, 0.4, 0.3,
0.3, 0.3, 0.2, 0.4, 0.2, 0.5, 0.2, 0.2, 0.4, 0.2,
0.2, 0.2, 0.2, 0.4, 0.1, 0.2, 0.2, 0.2, 0.2, 0.1,
0.2, 0.2, 0.3, 0.3, 0.2, 0.6, 0.4, 0.3, 0.2, 0.2,
0.2, 0.2
]);
this.get('data.columns').push(
["versicolor", 1.4, 1.5, 1.5, 1.3, 1.5, 1.3, 1.6, 1.0,
1.3, 1.4, 1.0, 1.5, 1.0, 1.4, 1.3, 1.4, 1.5, 1.0,
1.5, 1.1, 1.8, 1.3, 1.5, 1.2, 1.3, 1.4, 1.4, 1.7,
1.5, 1.0, 1.1, 1.0, 1.2, 1.6, 1.5, 1.6, 1.5, 1.3,
1.3, 1.3, 1.2, 1.4, 1.2, 1.0, 1.3, 1.2, 1.3, 1.3,
1.1, 1.3
]);
this.get('data.columns').push(
["virginica", 2.5, 1.9, 2.1, 1.8, 2.2, 2.1, 1.7, 1.8,
1.8, 2.5, 2.0, 1.9, 2.1, 2.0, 2.4, 2.3, 1.8, 2.2,
2.3, 1.5, 2.3, 2.0, 2.0, 1.8, 2.1, 1.8, 1.8, 1.8,
2.1, 1.6, 1.9, 2.0, 2.2, 1.5, 1.4, 2.3, 2.4, 1.8,
1.8, 2.1, 2.4, 2.3, 1.9, 2.3, 2.5, 2.3, 1.9, 2.0,
2.3, 1.8
]);
this.notifyPropertyChange('data');
},
1500);

// FIXME: No way to unload yet
Expand All @@ -48,20 +48,20 @@ export default Controller.extend({

},

// iris data from R
data: {
// iris data from R
columns: [
['data1', 30],
['data2', 120],
],
type: 'pie',
onclick: function(d, i) {
onclick: function (d, i) {
console.log("onclick", d, i);
},
onmouseover: function(d, i) {
onmouseover: function (d, i) {
console.log("onmouseover", d, i);
},
onmouseout: function(d, i) {
onmouseout: function (d, i) {
console.log("onmouseout", d, i);
}
}
Expand Down
5 changes: 3 additions & 2 deletions tests/dummy/app/controllers/timeseries.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import Controller from '@ember/controller';

export default Controller.extend({

init: function() {
init() {
this._super(...arguments);

later(this, function() {
later(this, function () {
this.get('data.columns').push(
['data3', 400, 500, 450, 700, 600, 500]
);
Expand All @@ -28,6 +28,7 @@ export default Controller.extend({
['data2', 130, 340, 200, 500, 250, 350]
]
},

axis: {
x: {
type: 'timeseries',
Expand Down

0 comments on commit 2e731fa

Please sign in to comment.