import { EventName, SeriesCategory } from './constants'; import Chart from './core/chart'; import { DataItem, SeriesOptions } from './models'; // import { DataItem } from './models'; import Painter from './painter'; import Canvas from './renderer/canvas'; import { getId } from './utils/signature'; export interface Renderer { id: string; chart: Chart; render: () => void; } interface AtomComponentOptions { id?: string; name?: string; chart: Chart; } export default abstract class AtomComponent implements Renderer { public id: string; public name: string; public chart: Chart; protected painter: Painter; protected abstract seriesCategory: SeriesCategory; constructor({ id = getId(), name, chart }: AtomComponentOptions) { this.id = id; this.name = name; this.chart = chart; this.painter = chart.painter; } protected $on(eventName: EventName, callback) { this.chart.on(eventName, callback); } protected $emit(eventName: EventName, ...args) { this.chart.emit(eventName, ...args); } protected get canvas(): Canvas { return this.chart.canvas; } protected get dataset(): Array { return this.chart.dataset; } protected get series(): Array { return this.chart.series; } abstract render(); }