Skip to content

Commit

Permalink
shim imports
Browse files Browse the repository at this point in the history
  • Loading branch information
jsvg authored Aug 16, 2016
1 parent 508eb3f commit 9258a63
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions addon/components/c3-chart.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* global c3*/
import Ember from 'ember';
const { Component, get, getProperties, set, run } = Ember;
import Component from 'ember-component';
import get from 'ember-metal/get';
import set from 'ember-metal/set';
import { getProperties } from 'ember-metal/get';
import { debounce, later, scheduleOnce } from 'ember-runloop';
import c3 from 'c3';

export default Component.extend({
tagName: 'div',
Expand All @@ -17,7 +20,7 @@ export default Component.extend({
// default animation is 350ms
// t/f data must by loaded after unload animation (400)
// or chart will not properly render
run.later(this, function() {
later(this, function() {
chart.load(
// data, axis, color are only mutable elements
get(this, 'data'),
Expand Down Expand Up @@ -72,19 +75,23 @@ export default Component.extend({
* Component lifecycle hooks to control rendering actions
***/

didInsertElement() {
didReceiveAttrs() {
// if DOM is not ready when component is inserted,
// rendering issues can occur
// t/f use 'afterRender' property to ensure
// state readiness
run.scheduleOnce('afterRender', this, this._setupc3);
try {
scheduleOnce('afterRender', this, this._setupc3);
} catch(err) {
console.log(err);
}
},

didUpdateAttrs() {
// if data proprety is dependent on async relationships,
// animations can cause buggy renders, therefore debounce
// component update to ensure proper visualization
run.debounce(this, this._reload, 360);
debounce(this, this._reload, 360);
},

willDestroyElement() {
Expand Down

0 comments on commit 9258a63

Please sign in to comment.