blob: a334b6f750e5fd2adb1c2ad07cec489403ddfd15 [file] [log] [blame] [edit]
// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {MetaMapSet, MetaMap} from '@parallax/data/meta';
import {ParallaxError} from '@parallax/common/error';
import {PlotRow} from '@parallax/interface/plot_row';
/**
* Generic abstract class to handle any drawable chart.
*/
export abstract class Chart {
protected axisMeta: MetaMap[] = [];
/**
* Assigns metadata fields to the chart for lookup.
*
* @param metas Metadata associated with the chart.
*/
constructor(metas: any) {
if (!Array.isArray(metas)) {
throw new ParallaxError('Meta data must be an array', metas);
}
for (const meta of metas) {
this.axisMeta.push(new MetaMap(meta));
}
}
/**
* Draws the plot
* @param plot PlotRow
*/
abstract draw(plotRow: PlotRow): void;
}