-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
maxwondercorn
committed
Oct 31, 2018
1 parent
9327906
commit 0dce973
Showing
12 changed files
with
345 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,55 @@ | ||
import Controller from '@ember/controller'; | ||
import { computed } from '@ember/object'; | ||
import { bind } from '@ember/runloop'; | ||
import Controller from "@ember/controller"; | ||
import { computed } from "@ember/object"; | ||
import { bind } from "@ember/runloop"; | ||
/* eslint ember/avoid-leaking-state-in-ember-objects: "off" */ | ||
|
||
export default Controller.extend({ | ||
message: null, | ||
hover: null, | ||
|
||
data: computed('model', function () { | ||
chart: null, | ||
legendVisible: true, | ||
lbuttonText: "Hide Legend", | ||
|
||
data: computed(function() { | ||
// iris data from R | ||
return { | ||
columns: this.get('model'), | ||
type: 'bar', | ||
types: { | ||
data3: 'spline', | ||
data4: 'line', | ||
}, | ||
groups: [ | ||
['data1', 'data2'] | ||
columns: [ | ||
["data1", 30], | ||
["data2", 120], | ||
["data3", 10], | ||
["data4", 45], | ||
["data5", 90] | ||
], | ||
|
||
type: "pie", | ||
// https://balinterdi.com/blog/ember-dot-run-dot-bind/ | ||
onclick: bind(this, this.get('actions.myClick')), | ||
onmouseover: bind(this, this.get('actions.myMouseover')) | ||
} | ||
onclick: bind(this, this.get("actions.myClick")), | ||
onmouseover: bind(this, this.get("actions.myMouseover")) | ||
}; | ||
}), | ||
|
||
padding: { top: 20 }, | ||
|
||
title: { text: "Click data 5 to Win!" }, | ||
|
||
actions: { | ||
myClick(d, i) { | ||
this.set('message', `${d.name}, value: ${d.value}`); | ||
if (d.name == 'data5') | ||
alert(`Data 5 - you're a winner`); | ||
myClick(d /* i */) { | ||
this.set("message", `${d.name}, value: ${d.value}`); | ||
if (d.name == "data5") alert(`Data 5 - you're a winner`); | ||
}, | ||
|
||
myMouseover(d /* i */) { | ||
this.set("hover", `${d.name}, value: ${d.value}`); | ||
}, | ||
|
||
toggleLegend() { | ||
let c = this.get("chart"); | ||
this.toggleProperty('legendVisible'); | ||
let v= this.get("legendVisible"); | ||
let t = v ? "Hide Legend" : "Show Legend"; | ||
this.set("lbuttonText", t); | ||
|
||
myMouseover(d, i) { | ||
this.set('hover', `${d.name}, value: ${d.value}`); | ||
if (v) c.legend.show(); | ||
else c.legend.hide(); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,66 @@ | ||
import { later } from '@ember/runloop'; | ||
import Controller from '@ember/controller'; | ||
import { later } from "@ember/runloop"; | ||
import Controller from "@ember/controller"; | ||
/* eslint ember/avoid-leaking-state-in-ember-objects: "off" */ | ||
|
||
export default Controller.extend({ | ||
|
||
chart: null, | ||
legendVisible: true, | ||
lbuttonText: "Hide Legend", | ||
|
||
init() { | ||
this._super(...arguments); | ||
|
||
later(this, function () { | ||
this.get('data.columns').push( | ||
['data3', 400, 500, 450, 700, 600, 500] | ||
); | ||
this.notifyPropertyChange('data'); | ||
}, 1000); | ||
|
||
later( | ||
this, | ||
function() { | ||
this.get("data.columns").push(["data3", 400, 500, 450, 700, 600, 500]); | ||
this.notifyPropertyChange("data"); | ||
}, | ||
1000 | ||
); | ||
}, | ||
|
||
data: { | ||
x: 'x', | ||
// xFormat: '%Y%m%d', // 'xFormat' can be used as custom format of 'x' | ||
x: "x", | ||
columns: [ | ||
['x', '2013-01-01', '2013-01-02', '2013-01-03', '2013-01-04', | ||
'2013-01-05', '2013-01-06' | ||
[ | ||
"x", | ||
"2013-01-01", | ||
"2013-01-02", | ||
"2013-01-03", | ||
"2013-01-04", | ||
"2013-01-05", | ||
"2013-01-06" | ||
], | ||
// ['x', '20130101', '20130102', '20130103', '20130104', '20130105', '20130106'], | ||
['data1', 30, 200, 100, 400, 150, 250], | ||
['data2', 130, 340, 200, 500, 250, 350] | ||
["data1", 30, 200, 100, 400, 150, 250], | ||
["data2", 130, 340, 200, 500, 250, 350] | ||
] | ||
}, | ||
|
||
axis: { | ||
x: { | ||
type: 'timeseries', | ||
type: "timeseries", | ||
tick: { | ||
format: '%Y-%m-%d' | ||
format: "%Y-%m-%d" | ||
} | ||
} | ||
} | ||
}, | ||
|
||
title: { text: "Downloads by Day" }, | ||
|
||
}); | ||
padding: { top: 20 }, | ||
|
||
actions: { | ||
toggleLegend() { | ||
let c = this.get("chart"); | ||
this.toggleProperty("legendVisible"); | ||
let v = this.get("legendVisible"); | ||
let t = v ? "Hide Legend" : "Show Legend"; | ||
this.set("lbuttonText", t); | ||
|
||
if (v) c.legend.show(); | ||
else c.legend.hide(); | ||
} | ||
} | ||
}); |
Oops, something went wrong.