/**
* @augments EicComponent
* @category EICUI/Components
*/
class Chart extends EicComponent {
constructor(el, options) {
super(el, options);
if(this._constructed) return this;
this.el.innerHTML = ``;
this.plotter = ui.create(``)
this.el.append(this.plotter);
this.el.setAttribute(this.options.identifier, '')
}
set data(value) {
this.options.data = value;
this.redraw()
}
get data() { return this.options.data }
redraw() {}
clear() {
this.options.data = [];
this.redraw();
}
}
/**
* @augments EicComponent
* @category EICUI/Components
*/
class BarChart extends Chart {
constructor(el, options) {
let defaultOptions = {
title: '',
subtitle: '',
height: 'auto',
showLabels: true,
showValues: true,
maxPlot: 0,
data: [],
identifier: 'eicbarchart'
}
super(el, {...defaultOptions, ...(options || null)});
if(this._constructed) return this;
this.redraw();
}
redraw() {
let series = this.options.data;
let minValue = 0;
let maxValue = 0;
let w = this.position.width;
let h = this.options.height == 'auto' ? this.position.height: this.options.height;
let bh = Math.max(h - 30, 0);
this.plotter.innerHTML = '';
if(this.options.title) {
this.plotter.append(ui.create(`