github.com/manicqin/nomad@v0.9.5/ui/app/components/freestyle/sg-distribution-bar.js (about)

     1  import Component from '@ember/component';
     2  import { computed } from '@ember/object';
     3  import { on } from '@ember/object/evented';
     4  
     5  export default Component.extend({
     6    timerTicks: 0,
     7  
     8    startTimer: on('init', function() {
     9      this.set(
    10        'timer',
    11        setInterval(() => {
    12          this.incrementProperty('timerTicks');
    13        }, 500)
    14      );
    15    }),
    16  
    17    willDestroy() {
    18      clearInterval(this.timer);
    19    },
    20  
    21    distributionBarDatum: computed(() => {
    22      return [{ label: 'one', value: 10 }];
    23    }),
    24  
    25    distributionBarData: computed(() => {
    26      return [
    27        { label: 'one', value: 10 },
    28        { label: 'two', value: 20 },
    29        { label: 'three', value: 30 },
    30      ];
    31    }),
    32  
    33    distributionBarDataWithClasses: computed(() => {
    34      return [
    35        { label: 'Queued', value: 10, className: 'queued' },
    36        { label: 'Complete', value: 20, className: 'complete' },
    37        { label: 'Failed', value: 30, className: 'failed' },
    38      ];
    39    }),
    40  
    41    distributionBarDataRotating: computed('timerTicks', () => {
    42      return [
    43        { label: 'one', value: Math.round(Math.random() * 50) },
    44        { label: 'two', value: Math.round(Math.random() * 50) },
    45        { label: 'three', value: Math.round(Math.random() * 50) },
    46      ];
    47    }),
    48  });