import { DashboardVisualisationType } from '../../../_dashboards/dashboard-visualisation/types.js';
import LineTimeseriesChartSchemas from './validate.js';
import { TimeseriesChart } from '../ChartTimeseries.js';
import { LineChart } from '../line/LineChart.js';

/* eslint-disable prefer-destructuring */
class LineTimeseriesChart extends TimeseriesChart {
    definition;
    lineChartBuilder = new LineChart();
    withDefinition = (definition) => {
        this.definition = LineTimeseriesChartSchemas.LineTimeseriesSchema.parse(definition);
        this.initFromDefinition(this.definition);
        return this;
    };
    build = () => {
        this.buildDatasets();
        this.datasets = this.lineChartBuilder.augmentDataset(this.datasets);
        this.setStyles();
        this.config = this.lineChartBuilder.setBespokeOptions();
        return {
            type: DashboardVisualisationType.LINE,
            options: {
                unit: this.unit,
                timeseries: true,
            },
            data: {
                labels: this.labels,
                datasets: this.datasets,
                config: this.config,
                partialDate: this.partialDate,
            },
        };
    };
    setStyles = () => {
        this.datasets = this.datasets.map((set, datasetIndex) => {
            const colour = this.chartColoursHelper.setColourStyles(datasetIndex);
            return {
                ...set,
                ...colour,
            };
        });
    };
}

export { LineTimeseriesChart, LineTimeseriesChart as default };
//# sourceMappingURL=LineTimeseriesChart.js.map
