# all files / candela/VisComponent/mixin/ VegaChart.js

78.18% Statements 43/55
88.57% Branches 31/35
60% Functions 9/15
35.71% Lines 5/14
10 statements, 2 functions, 15 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
    301×

    1×
    1×

    1×

     import vega from '../../util/vega';

    let VegaChart = (Base, spec) => class extends Base {
      constructor (...args) {
        super(...args);
        this.options = args[1];
        this.chart = vega.parseChart(spec, this.el, this.options);
      }

      render () {
        this.chart.then(chart => chart.update());
      }

      get serializationFormats () {
        return ['png', 'svg'];
      }

      serialize (format) {
        if (!this.chart) {
          return Promise.reject('The render() method must be called before serialize().');
        }
        return this.chart.then(vobj => {
          return vobj.toImageURL(format);
        });
      }
    };

    export default VegaChart;