import hbs from 'htmlbars-inline-precompile';
import EmberObject, { computed } from '@ember/object';
import { on } from '@ember/object/evented';
export default {
title: 'Charts/Progress Bar',
};
export let Standard = () => {
return {
template: hbs`
Progress Bar
`,
};
};
export let Colors = () => {
return {
template: hbs`
Progress Bar colors
`,
};
};
export let LiveUpdates = () => {
return {
template: hbs`
Progress Bar with live updates
`,
context: {
data: EmberObject.extend({
timerTicks: 0,
startTimer: on('init', function () {
this.set(
'timer',
setInterval(() => {
this.incrementProperty('timerTicks');
}, 1000)
);
}),
willDestroy() {
clearInterval(this.timer);
},
denominator: computed('timerTicks', function () {
return Math.round(Math.random() * 1000);
}),
percentage: computed('timerTicks', function () {
return Math.round(Math.random() * 100) / 100;
}),
numerator: computed('denominator', 'percentage', function () {
return Math.round(this.denominator * this.percentage * 100) / 100;
}),
liveDetails: computed(
'denominator',
'numerator',
'percentage',
function () {
return this.getProperties('denominator', 'numerator', 'percentage');
}
),
}).create(),
},
};
};