UNPKG

@ministryofjustice/hmpps-digital-prison-reporting-frontend

Version:

The Digital Prison Reporting Frontend contains templates and code to help display data effectively in UI applications.

52 lines (47 loc) 1.7 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var types = require('../../../_dashboards/dashboard-visualisation/types.js'); var validate = require('./validate.js'); var ChartTimeseries = require('../ChartTimeseries.js'); var LineChart = require('../line/LineChart.js'); /* eslint-disable prefer-destructuring */ class LineTimeseriesChart extends ChartTimeseries.TimeseriesChart { definition; lineChartBuilder = new LineChart.LineChart(); withDefinition = (definition) => { this.definition = validate.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: types.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, }; }); }; } exports.LineTimeseriesChart = LineTimeseriesChart; exports.default = LineTimeseriesChart; //# sourceMappingURL=LineTimeseriesChart.js.map