@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.66 kB
JavaScript
'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 BarChart = require('../bar/BarChart.js');
/* eslint-disable prefer-destructuring */
class BarTimeseriesChart extends ChartTimeseries.TimeseriesChart {
definition;
BarChartBuilder = new BarChart.BarChart();
withDefinition = (definition) => {
this.definition = validate.BarTimeseriesSchema.parse(definition);
this.initFromDefinition(this.definition);
return this;
};
build = () => {
this.buildDatasets();
this.setStyles();
this.datasets = this.BarChartBuilder.augmentDataset(this.datasets);
this.BarChartBuilder.setBespokeOptions();
return {
type: types.DashboardVisualisationType.BAR,
options: {
unit: this.unit,
timeseries: true,
},
data: {
labels: this.labels,
datasets: this.datasets,
config: this.config,
},
};
};
setStyles = () => {
this.datasets = this.datasets.map((set, datasetIndex) => {
const colour = this.hexColours[datasetIndex];
return {
...set,
backgroundColor: colour,
borderColor: colour,
};
});
};
}
exports.BarTimeseriesChart = BarTimeseriesChart;
exports.default = BarTimeseriesChart;
//# sourceMappingURL=BarTimeseriesChart.js.map