all files / src/components/ Scatter.js

84.85% Statements 28/33
100% Branches 14/14
66.67% Functions 6/9
50% Lines 3/6
4 statements, 1 function, 6 branches Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34                                                                
import vcharts from '../external/vcharts/src';
 
export default class Scatter {
  static get options () {
    return [
      {name: 'data', type: 'table'},
      {name: 'x', type: 'string'},
      {name: 'y', type: 'string'},
      {name: 'color', type: 'string'}
    ];
  }
 
  constructor (el, options) {
    let chart = vcharts.chart('xy', {
      el: el,
      series: [{
        name: 'values',
        values: options.data,
        x: options.x,
        y: options.y
      }],
      xAxis: {
        title: options.x
      },
      yAxis: {
        title: options.y
      },
      legend: false
    });
    window.onresize = () => chart.update();
  }
}