@ministryofjustice/hmpps-digital-prison-reporting-frontend 4.20.2 → 4.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dpr/components/_catalogue/catalogue-list/utils.test.ts +1 -1
- package/dpr/components/_charts/chart/Chart.js +2 -0
- package/dpr/components/_charts/chart/Chart.js.map +7 -0
- package/dpr/components/_charts/chart/Chart.ts +89 -0
- package/dpr/components/_charts/chart/ChartColours.js +2 -0
- package/dpr/components/_charts/chart/ChartColours.js.map +7 -0
- package/dpr/components/_charts/chart/ChartColours.ts +36 -0
- package/dpr/components/_charts/chart/ChartTimeseries.js +2 -0
- package/dpr/components/_charts/chart/ChartTimeseries.js.map +7 -0
- package/dpr/components/_charts/chart/ChartTimeseries.ts +95 -0
- package/dpr/components/_charts/chart/bar/BarChart.js +2 -0
- package/dpr/components/_charts/chart/bar/BarChart.js.map +7 -0
- package/dpr/components/_charts/chart/bar/BarChart.ts +204 -0
- package/dpr/components/_charts/chart/bar/clientClass.mjs +0 -58
- package/dpr/components/_charts/chart/bar/types.js +2 -0
- package/dpr/components/_charts/chart/bar/types.js.map +7 -0
- package/dpr/components/_charts/chart/bar/types.ts +6 -0
- package/dpr/components/_charts/chart/bar/validate.js +2 -0
- package/dpr/components/_charts/chart/bar/validate.js.map +7 -0
- package/dpr/components/_charts/chart/bar/validate.ts +59 -0
- package/dpr/components/_charts/chart/bar-timeseries/BarTimeseriesChart.js +2 -0
- package/dpr/components/_charts/chart/bar-timeseries/BarTimeseriesChart.js.map +7 -0
- package/dpr/components/_charts/chart/bar-timeseries/BarTimeseriesChart.ts +57 -0
- package/dpr/components/_charts/chart/bar-timeseries/types.js +2 -0
- package/dpr/components/_charts/chart/bar-timeseries/types.js.map +7 -0
- package/dpr/components/_charts/chart/bar-timeseries/types.ts +5 -0
- package/dpr/components/_charts/chart/bar-timeseries/validate.js +2 -0
- package/dpr/components/_charts/chart/bar-timeseries/validate.js.map +7 -0
- package/dpr/components/_charts/chart/bar-timeseries/validate.ts +30 -0
- package/dpr/components/_charts/chart/buckets/Buckets.js +2 -0
- package/dpr/components/_charts/chart/buckets/Buckets.js.map +7 -0
- package/dpr/components/_charts/chart/{Buckets.ts → buckets/Buckets.ts} +18 -14
- package/dpr/components/_charts/chart/buckets/types.js +2 -0
- package/dpr/components/_charts/chart/buckets/types.js.map +7 -0
- package/dpr/components/_charts/chart/buckets/types.ts +4 -0
- package/dpr/components/_charts/chart/buckets/validate.js +2 -0
- package/dpr/components/_charts/chart/buckets/validate.js.map +7 -0
- package/dpr/components/_charts/chart/buckets/validate.ts +15 -0
- package/dpr/components/_charts/chart/chart-config.js +2 -0
- package/dpr/components/_charts/chart/chart-config.js.map +7 -0
- package/dpr/components/_charts/chart/chart-config.ts +108 -0
- package/dpr/components/_charts/chart/clientClass.mjs +28 -106
- package/dpr/components/_charts/chart/doughnut/DoughnutChart.js +2 -0
- package/dpr/components/_charts/chart/doughnut/DoughnutChart.js.map +7 -0
- package/dpr/components/_charts/chart/doughnut/DoughnutChart.ts +77 -0
- package/dpr/components/_charts/chart/doughnut/clientClass.mjs +0 -45
- package/dpr/components/_charts/chart/doughnut/types.js +2 -0
- package/dpr/components/_charts/chart/doughnut/types.js.map +7 -0
- package/dpr/components/_charts/chart/doughnut/types.ts +5 -0
- package/dpr/components/_charts/chart/doughnut/validate.js +2 -0
- package/dpr/components/_charts/chart/doughnut/validate.js.map +7 -0
- package/dpr/components/_charts/chart/doughnut/validate.ts +30 -0
- package/dpr/components/_charts/chart/heatmap/HeatmapChart.js +1 -1
- package/dpr/components/_charts/chart/heatmap/HeatmapChart.js.map +3 -3
- package/dpr/components/_charts/chart/heatmap/HeatmapChart.ts +122 -44
- package/dpr/components/_charts/chart/heatmap/clientClass.mjs +7 -89
- package/dpr/components/_charts/chart/heatmap/types.js +1 -1
- package/dpr/components/_charts/chart/heatmap/types.js.map +1 -1
- package/dpr/components/_charts/chart/heatmap/types.ts +5 -0
- package/dpr/components/_charts/chart/heatmap/validate.js +2 -0
- package/dpr/components/_charts/chart/heatmap/validate.js.map +7 -0
- package/dpr/components/_charts/chart/heatmap/validate.ts +25 -0
- package/dpr/components/_charts/chart/line/LineChart.js +2 -0
- package/dpr/components/_charts/chart/line/LineChart.js.map +7 -0
- package/dpr/components/_charts/chart/line/LineChart.ts +89 -0
- package/dpr/components/_charts/chart/line/clientClass.mjs +5 -36
- package/dpr/components/_charts/chart/line/types.js +2 -0
- package/dpr/components/_charts/chart/line/types.js.map +7 -0
- package/dpr/components/_charts/chart/line/types.ts +5 -0
- package/dpr/components/_charts/chart/line/validate.js +2 -0
- package/dpr/components/_charts/chart/line/validate.js.map +7 -0
- package/dpr/components/_charts/chart/line/validate.ts +30 -0
- package/dpr/components/_charts/chart/line-timeseries/LineTimeseriesChart.js +2 -0
- package/dpr/components/_charts/chart/line-timeseries/LineTimeseriesChart.js.map +7 -0
- package/dpr/components/_charts/chart/line-timeseries/LineTimeseriesChart.ts +57 -0
- package/dpr/components/_charts/chart/line-timeseries/types.js +2 -0
- package/dpr/components/_charts/chart/line-timeseries/types.js.map +7 -0
- package/dpr/components/_charts/chart/line-timeseries/types.ts +5 -0
- package/dpr/components/_charts/chart/line-timeseries/validate.js +2 -0
- package/dpr/components/_charts/chart/line-timeseries/validate.js.map +7 -0
- package/dpr/components/_charts/chart/line-timeseries/validate.ts +30 -0
- package/dpr/components/_charts/chart/view.njk +8 -1
- package/dpr/components/_charts/chart-tabs/view.njk +15 -14
- package/dpr/components/_charts/utils.js +1 -1
- package/dpr/components/_charts/utils.js.map +3 -3
- package/dpr/components/_charts/utils.test.ts +9 -3
- package/dpr/components/_charts/utils.ts +59 -193
- package/dpr/components/_dashboards/dashboard-list/types.js +2 -0
- package/dpr/components/_dashboards/dashboard-list/types.js.map +7 -0
- package/dpr/components/_dashboards/dashboard-list/types.ts +4 -0
- package/dpr/components/_dashboards/dashboard-list/validate.js +2 -0
- package/dpr/components/_dashboards/dashboard-list/validate.js.map +7 -0
- package/dpr/components/_dashboards/dashboard-list/validate.ts +28 -0
- package/dpr/components/_dashboards/dashboard-visualisation/Validate.js +2 -0
- package/dpr/components/_dashboards/dashboard-visualisation/Validate.js.map +7 -0
- package/dpr/components/_dashboards/dashboard-visualisation/Validate.ts +71 -0
- package/dpr/components/_dashboards/dashboard-visualisation/types.js +1 -1
- package/dpr/components/_dashboards/dashboard-visualisation/types.js.map +2 -2
- package/dpr/components/_dashboards/dashboard-visualisation/types.ts +32 -2
- package/dpr/components/_dashboards/scorecard/Scorecard.js +1 -1
- package/dpr/components/_dashboards/scorecard/Scorecard.js.map +3 -3
- package/dpr/components/_dashboards/scorecard/Scorecard.ts +82 -213
- package/dpr/components/_dashboards/scorecard/types.js +1 -1
- package/dpr/components/_dashboards/scorecard/types.js.map +1 -1
- package/dpr/components/_dashboards/scorecard/types.ts +11 -1
- package/dpr/components/_dashboards/scorecard/validate.js +2 -0
- package/dpr/components/_dashboards/scorecard/validate.js.map +7 -0
- package/dpr/components/_dashboards/scorecard/validate.ts +36 -0
- package/dpr/components/_dashboards/scorecard-group/ScorecardGroup.js +2 -0
- package/dpr/components/_dashboards/scorecard-group/ScorecardGroup.js.map +7 -0
- package/dpr/components/_dashboards/scorecard-group/ScorecardGroup.ts +228 -0
- package/dpr/components/_dashboards/scorecard-group/types.js +2 -0
- package/dpr/components/_dashboards/scorecard-group/types.js.map +7 -0
- package/dpr/components/_dashboards/scorecard-group/types.ts +5 -0
- package/dpr/components/_dashboards/scorecard-group/validate.js +2 -0
- package/dpr/components/_dashboards/scorecard-group/validate.js.map +7 -0
- package/dpr/components/_dashboards/scorecard-group/validate.ts +37 -0
- package/dpr/components/_filters/types.d.js.map +1 -1
- package/dpr/components/_filters/types.d.ts +6 -4
- package/dpr/routes/journeys/view-report/async/dashboard/utils.js +1 -1
- package/dpr/routes/journeys/view-report/async/dashboard/utils.js.map +3 -3
- package/dpr/routes/journeys/view-report/async/dashboard/utils.ts +22 -10
- package/dpr/routes/journeys/view-report/controller.js +1 -1
- package/dpr/routes/journeys/view-report/controller.js.map +3 -3
- package/dpr/routes/journeys/view-report/controller.ts +3 -1
- package/dpr/utils/ErrorHandler.js +1 -1
- package/dpr/utils/ErrorHandler.js.map +3 -3
- package/dpr/utils/ErrorHandler.ts +16 -0
- package/package.json +1 -1
- package/dpr/components/_charts/chart/Buckets.js +0 -2
- package/dpr/components/_charts/chart/Buckets.js.map +0 -7
- package/dpr/components/_dashboards/dashboard-visualisation/DashboardVisualisation.js +0 -2
- package/dpr/components/_dashboards/dashboard-visualisation/DashboardVisualisation.js.map +0 -7
- package/dpr/components/_dashboards/dashboard-visualisation/DashboardVisualisation.ts +0 -40
|
@@ -5,15 +5,23 @@ import { DashboardDataResponse } from '../../../../types/Metrics'
|
|
|
5
5
|
import {
|
|
6
6
|
DashboardVisualisationType,
|
|
7
7
|
DashboardVisualisationData,
|
|
8
|
+
DashboardVisualisationDataSet,
|
|
8
9
|
} from '../../../_dashboards/dashboard-visualisation/types'
|
|
9
|
-
import { MatrixChartData } from './types'
|
|
10
|
+
import { MatrixChartData, MatrixTimeseriesDefinitionType } from './types'
|
|
10
11
|
import DatasetHelper from '../../../../utils/datasetHelper'
|
|
11
|
-
import
|
|
12
|
-
import Buckets from '../Buckets'
|
|
12
|
+
import Buckets from '../buckets/Buckets'
|
|
13
13
|
import { components } from '../../../../types/api'
|
|
14
|
+
import MatrixSchema from './validate'
|
|
15
|
+
import ChartConfig from '../chart-config'
|
|
14
16
|
|
|
15
|
-
class HeatmapChart
|
|
16
|
-
private
|
|
17
|
+
class HeatmapChart {
|
|
18
|
+
private definition!: MatrixTimeseriesDefinitionType
|
|
19
|
+
|
|
20
|
+
private measures!: MatrixTimeseriesDefinitionType['columns']['measures']
|
|
21
|
+
|
|
22
|
+
private responseData: DashboardDataResponse[] = []
|
|
23
|
+
|
|
24
|
+
private granularity!: Granularity
|
|
17
25
|
|
|
18
26
|
private data: MatrixChartData[] = []
|
|
19
27
|
|
|
@@ -23,47 +31,51 @@ class HeatmapChart extends DashboardVisualisationClass {
|
|
|
23
31
|
|
|
24
32
|
private label = ''
|
|
25
33
|
|
|
26
|
-
private
|
|
34
|
+
private unit: 'NUMBER' | 'PERCENTAGE' | undefined
|
|
35
|
+
|
|
36
|
+
private bucketsHelper!: Buckets
|
|
37
|
+
|
|
38
|
+
private datasets: DashboardVisualisationDataSet[] = []
|
|
39
|
+
|
|
40
|
+
config = ChartConfig
|
|
27
41
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
) {
|
|
33
|
-
|
|
42
|
+
private xLabels: (string | number)[] = []
|
|
43
|
+
|
|
44
|
+
private yLabels: (string | number)[] = []
|
|
45
|
+
|
|
46
|
+
withDefinition = (definition: components['schemas']['DashboardVisualisationDefinition']) => {
|
|
47
|
+
this.definition = MatrixSchema.parse(definition)
|
|
48
|
+
this.init()
|
|
49
|
+
return this
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
withData = (responseData: DashboardDataResponse[]) => {
|
|
53
|
+
this.responseData = responseData
|
|
54
|
+
this.bucketsHelper = new Buckets(this.responseData, this.definition, this.valueKey, true)
|
|
55
|
+
return this
|
|
56
|
+
}
|
|
34
57
|
|
|
58
|
+
withGranularity = (granularity: Granularity) => {
|
|
35
59
|
this.granularity = granularity
|
|
60
|
+
return this
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private init = () => {
|
|
64
|
+
this.measures = this.definition.columns.measures
|
|
36
65
|
this.setLabel()
|
|
37
66
|
this.initUnit()
|
|
38
|
-
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
initUnit = () => {
|
|
70
|
+
this.unit = this.measures[0].unit ? this.measures[0].unit : undefined
|
|
39
71
|
}
|
|
40
72
|
|
|
41
73
|
private setLabel = () => {
|
|
42
|
-
const { id, display } = this.
|
|
74
|
+
const { id, display } = this.measures[1]
|
|
43
75
|
this.valueKey = id
|
|
44
76
|
this.label = display || ''
|
|
45
77
|
}
|
|
46
78
|
|
|
47
|
-
private validateDefinition = () => {
|
|
48
|
-
const { id, columns, type } = this.definition
|
|
49
|
-
const errors = []
|
|
50
|
-
|
|
51
|
-
// Validate measures
|
|
52
|
-
if (columns.measures.length !== 2) {
|
|
53
|
-
errors.push(`Measures should only have 2 columns defined. Only found ${columns.measures.length}`)
|
|
54
|
-
} else if (<DashboardVisualisationType>type === DashboardVisualisationType.MATRIX_TIMESERIES) {
|
|
55
|
-
if (columns.measures[0].id !== 'ts') {
|
|
56
|
-
errors.push(`measure at index 0 has incorrect ID. Expected ID to be "ts". Found "${columns.measures[0].id}"`)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Throw the error
|
|
61
|
-
if (errors.length) {
|
|
62
|
-
const message = `Validation: Visualisaton definition: ID: ${id}, type: ${type}, errors: ${errors.join(',')}`
|
|
63
|
-
throw new Error(message)
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
79
|
private initTimeseriesData = () => {
|
|
68
80
|
const timeBlockData = DatasetHelper.groupRowsByTimestamp(this.responseData)
|
|
69
81
|
|
|
@@ -105,6 +117,14 @@ class HeatmapChart extends DashboardVisualisationClass {
|
|
|
105
117
|
}
|
|
106
118
|
return { y, x, v, r }
|
|
107
119
|
})
|
|
120
|
+
|
|
121
|
+
this.bucketData()
|
|
122
|
+
this.datasets = [
|
|
123
|
+
{
|
|
124
|
+
label: this.label,
|
|
125
|
+
data: this.data,
|
|
126
|
+
},
|
|
127
|
+
]
|
|
108
128
|
}
|
|
109
129
|
|
|
110
130
|
private bucketData = () => {
|
|
@@ -115,22 +135,80 @@ class HeatmapChart extends DashboardVisualisationClass {
|
|
|
115
135
|
})
|
|
116
136
|
}
|
|
117
137
|
|
|
138
|
+
private setBespokeOptions = () => {
|
|
139
|
+
this.config = {
|
|
140
|
+
...this.config,
|
|
141
|
+
scales: this.setScales(),
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
setScales() {
|
|
146
|
+
this.xLabels = [
|
|
147
|
+
...new Set(
|
|
148
|
+
(<MatrixChartData[]>this.datasets[0].data).map((d) => {
|
|
149
|
+
return d.x
|
|
150
|
+
}),
|
|
151
|
+
),
|
|
152
|
+
]
|
|
153
|
+
this.yLabels = [
|
|
154
|
+
...new Set(
|
|
155
|
+
(<MatrixChartData[]>this.datasets[0].data).map((d) => {
|
|
156
|
+
return d.y
|
|
157
|
+
}),
|
|
158
|
+
),
|
|
159
|
+
]
|
|
160
|
+
const grid = {
|
|
161
|
+
display: false,
|
|
162
|
+
drawBorder: false,
|
|
163
|
+
}
|
|
164
|
+
const ticks = {
|
|
165
|
+
padding: 1,
|
|
166
|
+
maxRotation: 0,
|
|
167
|
+
stepSize: 1,
|
|
168
|
+
}
|
|
169
|
+
const offset = true
|
|
170
|
+
const common = {
|
|
171
|
+
offset,
|
|
172
|
+
ticks,
|
|
173
|
+
grid,
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return {
|
|
177
|
+
y: {
|
|
178
|
+
position: 'left',
|
|
179
|
+
type: 'category',
|
|
180
|
+
...(this.yLabels && { labels: this.yLabels }),
|
|
181
|
+
...common,
|
|
182
|
+
},
|
|
183
|
+
x: {
|
|
184
|
+
position: 'top',
|
|
185
|
+
type: 'category',
|
|
186
|
+
...(this.xLabels && { labels: this.xLabels }),
|
|
187
|
+
...common,
|
|
188
|
+
},
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
getCanvasHeight = () => {
|
|
193
|
+
return this.yLabels.length * 20 + 60
|
|
194
|
+
}
|
|
195
|
+
|
|
118
196
|
build = (): DashboardVisualisationData => {
|
|
119
|
-
this.validateDefinition()
|
|
120
197
|
this.initTimeseriesData()
|
|
121
198
|
this.bucketData()
|
|
199
|
+
this.setBespokeOptions()
|
|
200
|
+
const height = this.getCanvasHeight()
|
|
122
201
|
|
|
123
202
|
return {
|
|
124
|
-
type:
|
|
125
|
-
|
|
126
|
-
|
|
203
|
+
type: DashboardVisualisationType.MATRIX,
|
|
204
|
+
options: {
|
|
205
|
+
unit: this.unit,
|
|
206
|
+
timeseries: true,
|
|
207
|
+
height,
|
|
208
|
+
},
|
|
127
209
|
data: {
|
|
128
|
-
datasets:
|
|
129
|
-
|
|
130
|
-
label: this.label,
|
|
131
|
-
data: this.data,
|
|
132
|
-
},
|
|
133
|
-
],
|
|
210
|
+
datasets: this.datasets,
|
|
211
|
+
config: this.config,
|
|
134
212
|
},
|
|
135
213
|
}
|
|
136
214
|
}
|
|
@@ -16,7 +16,6 @@ export default class MatrixChartVisualisation extends ChartVisualisation {
|
|
|
16
16
|
|
|
17
17
|
initSettings() {
|
|
18
18
|
return {
|
|
19
|
-
options: this.setOptions({ scaleType: 'category' }),
|
|
20
19
|
toolTipOptions: this.setToolTipOptions(),
|
|
21
20
|
}
|
|
22
21
|
}
|
|
@@ -42,31 +41,20 @@ export default class MatrixChartVisualisation extends ChartVisualisation {
|
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
setOptions({ scaleType }) {
|
|
46
|
-
return {
|
|
47
|
-
scales: this.setScales({ scaleType }),
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
44
|
generateChartData(settings) {
|
|
45
|
+
const { config } = this.chartParams
|
|
52
46
|
const { options, plugins, pluginsOptions, toolTipOptions, hoverEvent } = settings
|
|
53
|
-
|
|
47
|
+
const d = {
|
|
54
48
|
type: this.type,
|
|
55
49
|
data: {
|
|
56
50
|
datasets: this.createDatasets(),
|
|
57
51
|
},
|
|
58
52
|
options: {
|
|
59
|
-
|
|
60
|
-
maintainAspectRatio: false,
|
|
61
|
-
animation: {
|
|
62
|
-
duration: 0,
|
|
63
|
-
},
|
|
64
|
-
hover: {
|
|
65
|
-
animationDuration: 0,
|
|
66
|
-
},
|
|
53
|
+
...config,
|
|
67
54
|
...(options && options),
|
|
68
55
|
...(hoverEvent && hoverEvent),
|
|
69
56
|
plugins: {
|
|
57
|
+
...config.plugins,
|
|
70
58
|
legend: {
|
|
71
59
|
position: 'bottom',
|
|
72
60
|
display: false,
|
|
@@ -76,13 +64,15 @@ export default class MatrixChartVisualisation extends ChartVisualisation {
|
|
|
76
64
|
display: false,
|
|
77
65
|
},
|
|
78
66
|
tooltip: {
|
|
79
|
-
...
|
|
67
|
+
...config.plugins.tooltip,
|
|
80
68
|
...(toolTipOptions && toolTipOptions),
|
|
81
69
|
},
|
|
82
70
|
},
|
|
83
71
|
},
|
|
84
72
|
plugins: plugins && plugins.length ? [...plugins] : [],
|
|
85
73
|
}
|
|
74
|
+
|
|
75
|
+
return d
|
|
86
76
|
}
|
|
87
77
|
|
|
88
78
|
createDatasets() {
|
|
@@ -100,76 +90,4 @@ export default class MatrixChartVisualisation extends ChartVisualisation {
|
|
|
100
90
|
}
|
|
101
91
|
})
|
|
102
92
|
}
|
|
103
|
-
|
|
104
|
-
setScales({ scaleType }) {
|
|
105
|
-
let xTime
|
|
106
|
-
let yTime
|
|
107
|
-
let xLabels
|
|
108
|
-
let yLabels
|
|
109
|
-
|
|
110
|
-
switch (scaleType) {
|
|
111
|
-
case 'time':
|
|
112
|
-
yTime = {
|
|
113
|
-
unit: 'week',
|
|
114
|
-
}
|
|
115
|
-
xTime = {
|
|
116
|
-
unit: 'day',
|
|
117
|
-
}
|
|
118
|
-
break
|
|
119
|
-
case 'category':
|
|
120
|
-
{
|
|
121
|
-
const { datasets } = this.chartParams
|
|
122
|
-
xLabels = [
|
|
123
|
-
...new Set(
|
|
124
|
-
datasets[0].data.map((d) => {
|
|
125
|
-
return d.x
|
|
126
|
-
}),
|
|
127
|
-
),
|
|
128
|
-
]
|
|
129
|
-
yLabels = [
|
|
130
|
-
...new Set(
|
|
131
|
-
datasets[0].data.map((d) => {
|
|
132
|
-
return d.y
|
|
133
|
-
}),
|
|
134
|
-
),
|
|
135
|
-
]
|
|
136
|
-
}
|
|
137
|
-
break
|
|
138
|
-
default:
|
|
139
|
-
break
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const grid = {
|
|
143
|
-
display: false,
|
|
144
|
-
drawBorder: false,
|
|
145
|
-
}
|
|
146
|
-
const ticks = {
|
|
147
|
-
padding: 1,
|
|
148
|
-
maxRotation: 0,
|
|
149
|
-
stepSize: 1,
|
|
150
|
-
}
|
|
151
|
-
const offset = true
|
|
152
|
-
const common = {
|
|
153
|
-
offset,
|
|
154
|
-
ticks,
|
|
155
|
-
grid,
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return {
|
|
159
|
-
y: {
|
|
160
|
-
left: 'left',
|
|
161
|
-
...(scaleType && { type: scaleType }),
|
|
162
|
-
...(yLabels && { labels: yLabels }),
|
|
163
|
-
...(yTime && { time: yTime }),
|
|
164
|
-
...common,
|
|
165
|
-
},
|
|
166
|
-
x: {
|
|
167
|
-
position: 'top',
|
|
168
|
-
...(scaleType && { type: scaleType }),
|
|
169
|
-
...(xLabels && { labels: xLabels }),
|
|
170
|
-
...(xTime && { time: xTime }),
|
|
171
|
-
...common,
|
|
172
|
-
},
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
93
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var f=(r,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of o(e))!s.call(r,i)&&i!==n&&m(r,i,{get:()=>e[i],enumerable:!(t=a(e,i))||t.enumerable});return r};var p=r=>f(m({},"__esModule",{value:!0}),r);var x={};module.exports=p(x);
|
|
2
2
|
//# sourceMappingURL=types.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/dpr/components/_charts/chart/heatmap/types.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["import z from 'zod'\nimport MatrixTimeseriesSchema from './validate'\n\nexport interface MatrixChartData {\n x: number | string\n y: number | string\n r?: number | undefined\n v: number\n}\n\nexport type MatrixTimeseriesDefinitionType = z.infer<typeof MatrixTimeseriesSchema>\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["types_exports", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import z from 'zod'
|
|
2
|
+
import MatrixTimeseriesSchema from './validate'
|
|
3
|
+
|
|
1
4
|
export interface MatrixChartData {
|
|
2
5
|
x: number | string
|
|
3
6
|
y: number | string
|
|
4
7
|
r?: number | undefined
|
|
5
8
|
v: number
|
|
6
9
|
}
|
|
10
|
+
|
|
11
|
+
export type MatrixTimeseriesDefinitionType = z.infer<typeof MatrixTimeseriesSchema>
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var r=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var p=(o,e)=>{for(var i in e)r(o,i,{get:e[i],enumerable:!0})},h=(o,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of l(e))!c.call(o,s)&&s!==i&&r(o,s,{get:()=>e[s],enumerable:!(n=m(e,s))||n.enumerable});return o};var u=o=>h(r({},"__esModule",{value:!0}),o);var f={};p(f,{default:()=>d});module.exports=u(f);var a=require("zod"),t=require("../../../_dashboards/dashboard-visualisation/Validate");const b=a.z.object({id:a.z.string(),optional:a.z.boolean().default(!1)}),y=a.z.object({...t.DashboardVisualisationSchema.shape,type:a.z.literal("matrix-timeseries"),options:a.z.object(t.BucketOptionsSchema.shape).optional(),columns:a.z.object({...t.DashboardColumns.shape,keys:a.z.array(b).min(1,"Key array cannot be empty").optional(),measures:a.z.array(t.DashboardVisualisationMeasureSchema).length(2,"Measure must contain a single item")})});var d=y;
|
|
2
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/dpr/components/_charts/chart/heatmap/validate.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from 'zod'\nimport {\n DashboardVisualisationSchema,\n DashboardColumns,\n DashboardVisualisationMeasureSchema,\n BucketOptionsSchema,\n} from '../../../_dashboards/dashboard-visualisation/Validate'\n\nconst matrixKeys = z.object({\n id: z.string(),\n optional: z.boolean().default(false),\n})\n\nconst MatrixTimeseriesSchema = z.object({\n ...DashboardVisualisationSchema.shape,\n type: z.literal('matrix-timeseries'),\n options: z.object(BucketOptionsSchema.shape).optional(),\n columns: z.object({\n ...DashboardColumns.shape,\n keys: z.array(matrixKeys).min(1, 'Key array cannot be empty').optional(),\n measures: z.array(DashboardVisualisationMeasureSchema).length(2, 'Measure must contain a single item'),\n }),\n})\n\nexport default MatrixTimeseriesSchema\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkB,eAClBC,EAKO,iEAEP,MAAMC,EAAa,IAAE,OAAO,CAC1B,GAAI,IAAE,OAAO,EACb,SAAU,IAAE,QAAQ,EAAE,QAAQ,EAAK,CACrC,CAAC,EAEKC,EAAyB,IAAE,OAAO,CACtC,GAAG,+BAA6B,MAChC,KAAM,IAAE,QAAQ,mBAAmB,EACnC,QAAS,IAAE,OAAO,sBAAoB,KAAK,EAAE,SAAS,EACtD,QAAS,IAAE,OAAO,CAChB,GAAG,mBAAiB,MACpB,KAAM,IAAE,MAAMD,CAAU,EAAE,IAAI,EAAG,2BAA2B,EAAE,SAAS,EACvE,SAAU,IAAE,MAAM,qCAAmC,EAAE,OAAO,EAAG,oCAAoC,CACvG,CAAC,CACH,CAAC,EAED,IAAOJ,EAAQK",
|
|
6
|
+
"names": ["validate_exports", "__export", "validate_default", "__toCommonJS", "import_zod", "import_Validate", "matrixKeys", "MatrixTimeseriesSchema"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import {
|
|
3
|
+
DashboardVisualisationSchema,
|
|
4
|
+
DashboardColumns,
|
|
5
|
+
DashboardVisualisationMeasureSchema,
|
|
6
|
+
BucketOptionsSchema,
|
|
7
|
+
} from '../../../_dashboards/dashboard-visualisation/Validate'
|
|
8
|
+
|
|
9
|
+
const matrixKeys = z.object({
|
|
10
|
+
id: z.string(),
|
|
11
|
+
optional: z.boolean().default(false),
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const MatrixTimeseriesSchema = z.object({
|
|
15
|
+
...DashboardVisualisationSchema.shape,
|
|
16
|
+
type: z.literal('matrix-timeseries'),
|
|
17
|
+
options: z.object(BucketOptionsSchema.shape).optional(),
|
|
18
|
+
columns: z.object({
|
|
19
|
+
...DashboardColumns.shape,
|
|
20
|
+
keys: z.array(matrixKeys).min(1, 'Key array cannot be empty').optional(),
|
|
21
|
+
measures: z.array(DashboardVisualisationMeasureSchema).length(2, 'Measure must contain a single item'),
|
|
22
|
+
}),
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
export default MatrixTimeseriesSchema
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var l=Object.create;var n=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var D=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty;var y=(i,t)=>{for(var s in t)n(i,s,{get:t[s],enumerable:!0})},r=(i,t,s,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of d(t))!c.call(i,e)&&e!==s&&n(i,e,{get:()=>t[e],enumerable:!(a=f(t,e))||a.enumerable});return i};var h=(i,t,s)=>(s=i!=null?l(D(i)):{},r(t||!i||!i.__esModule?n(s,"default",{value:i,enumerable:!0}):s,i)),b=i=>r(n({},"__esModule",{value:!0}),i);var k={};y(k,{LineChart:()=>o,default:()=>L});module.exports=b(k);var u=require("../../../_dashboards/dashboard-visualisation/types"),p=h(require("../Chart")),m=h(require("./validate"));class o extends p.default{constructor(){super(...arguments);this.init=()=>{this.measures=this.definition.columns.measures,this.keys=this.definition.columns.keys||[],this.initUnit(this.measures),this.getLabelId(this.keys)};this.withDefinition=s=>(this.definition=m.default.LineSchema.parse(s),this.init(),this);this.build=()=>(this.createDatasets(this.measures,this.responseData),this.datasets=this.augmentDataset(this.datasets),this.config=this.setBespokeOptions(),this.createLabels(this.measures),{type:u.DashboardVisualisationType.LINE,options:{unit:this.unit},data:{labels:this.labels,datasets:this.datasets,config:this.config}});this.augmentDataset=s=>s.map(a=>({...a,pointStyle:"circle",pointRadius:4,pointHoverRadius:10,pointHitRadius:20,datalabels:{display:!1}}));this.setBespokeOptions=()=>({...this.config,scales:{y:{min:0,ticks:{fontSize:12}},x:{ticks:{fontSize:12}}}})}}var L=o;0&&(module.exports={LineChart});
|
|
2
|
+
//# sourceMappingURL=LineChart.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/dpr/components/_charts/chart/line/LineChart.ts"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable prefer-destructuring */\nimport {\n DashboardVisualisationType,\n DashboardVisualisationData,\n VisualisationDefinitionKey,\n DashboardVisualisationDataSet,\n} from '../../../_dashboards/dashboard-visualisation/types'\nimport { components } from '../../../../types/api'\nimport Chart from '../Chart'\nimport { LineDefinitionMeasure, LineDefinitionType } from './types'\nimport LineChartSchemas from './validate'\n\nclass LineChart extends Chart {\n private definition!: LineDefinitionType\n\n private measures!: LineDefinitionMeasure[]\n\n private keys!: VisualisationDefinitionKey[]\n\n private init = () => {\n this.measures = this.definition.columns.measures\n this.keys = this.definition.columns.keys || []\n this.initUnit(this.measures)\n this.getLabelId(this.keys)\n }\n\n withDefinition = (definition: components['schemas']['DashboardVisualisationDefinition']) => {\n this.definition = LineChartSchemas.LineSchema.parse(definition)\n this.init()\n\n return this\n }\n\n build = (): DashboardVisualisationData => {\n this.createDatasets(this.measures, this.responseData)\n this.datasets = this.augmentDataset(this.datasets)\n this.config = this.setBespokeOptions()\n this.createLabels(this.measures)\n\n return {\n type: DashboardVisualisationType.LINE,\n options: {\n unit: this.unit,\n },\n data: {\n labels: this.labels,\n datasets: this.datasets,\n config: this.config,\n },\n }\n }\n\n augmentDataset = (datasets: DashboardVisualisationDataSet[]) => {\n return datasets.map((set) => {\n return {\n ...set,\n pointStyle: 'circle',\n pointRadius: 4,\n pointHoverRadius: 10,\n pointHitRadius: 20,\n datalabels: {\n display: false,\n },\n }\n })\n }\n\n setBespokeOptions = () => {\n return {\n ...this.config,\n scales: {\n y: {\n min: 0,\n ticks: {\n fontSize: 12,\n },\n },\n x: {\n ticks: {\n fontSize: 12,\n },\n },\n },\n }\n }\n}\n\nexport { LineChart }\nexport default LineChart\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,eAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAKO,8DAEPC,EAAkB,uBAElBC,EAA6B,yBAE7B,MAAML,UAAkB,EAAAM,OAAM,CAA9B,kCAOE,KAAQ,KAAO,IAAM,CACnB,KAAK,SAAW,KAAK,WAAW,QAAQ,SACxC,KAAK,KAAO,KAAK,WAAW,QAAQ,MAAQ,CAAC,EAC7C,KAAK,SAAS,KAAK,QAAQ,EAC3B,KAAK,WAAW,KAAK,IAAI,CAC3B,EAEA,oBAAkBC,IAChB,KAAK,WAAa,EAAAC,QAAiB,WAAW,MAAMD,CAAU,EAC9D,KAAK,KAAK,EAEH,MAGT,WAAQ,KACN,KAAK,eAAe,KAAK,SAAU,KAAK,YAAY,EACpD,KAAK,SAAW,KAAK,eAAe,KAAK,QAAQ,EACjD,KAAK,OAAS,KAAK,kBAAkB,EACrC,KAAK,aAAa,KAAK,QAAQ,EAExB,CACL,KAAM,6BAA2B,KACjC,QAAS,CACP,KAAM,KAAK,IACb,EACA,KAAM,CACJ,OAAQ,KAAK,OACb,SAAU,KAAK,SACf,OAAQ,KAAK,MACf,CACF,GAGF,oBAAkBE,GACTA,EAAS,IAAKC,IACZ,CACL,GAAGA,EACH,WAAY,SACZ,YAAa,EACb,iBAAkB,GAClB,eAAgB,GAChB,WAAY,CACV,QAAS,EACX,CACF,EACD,EAGH,uBAAoB,KACX,CACL,GAAG,KAAK,OACR,OAAQ,CACN,EAAG,CACD,IAAK,EACL,MAAO,CACL,SAAU,EACZ,CACF,EACA,EAAG,CACD,MAAO,CACL,SAAU,EACZ,CACF,CACF,CACF,GAEJ,CAGA,IAAOT,EAAQD",
|
|
6
|
+
"names": ["LineChart_exports", "__export", "LineChart", "LineChart_default", "__toCommonJS", "import_types", "import_Chart", "import_validate", "Chart", "definition", "LineChartSchemas", "datasets", "set"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/* eslint-disable prefer-destructuring */
|
|
2
|
+
import {
|
|
3
|
+
DashboardVisualisationType,
|
|
4
|
+
DashboardVisualisationData,
|
|
5
|
+
VisualisationDefinitionKey,
|
|
6
|
+
DashboardVisualisationDataSet,
|
|
7
|
+
} from '../../../_dashboards/dashboard-visualisation/types'
|
|
8
|
+
import { components } from '../../../../types/api'
|
|
9
|
+
import Chart from '../Chart'
|
|
10
|
+
import { LineDefinitionMeasure, LineDefinitionType } from './types'
|
|
11
|
+
import LineChartSchemas from './validate'
|
|
12
|
+
|
|
13
|
+
class LineChart extends Chart {
|
|
14
|
+
private definition!: LineDefinitionType
|
|
15
|
+
|
|
16
|
+
private measures!: LineDefinitionMeasure[]
|
|
17
|
+
|
|
18
|
+
private keys!: VisualisationDefinitionKey[]
|
|
19
|
+
|
|
20
|
+
private init = () => {
|
|
21
|
+
this.measures = this.definition.columns.measures
|
|
22
|
+
this.keys = this.definition.columns.keys || []
|
|
23
|
+
this.initUnit(this.measures)
|
|
24
|
+
this.getLabelId(this.keys)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
withDefinition = (definition: components['schemas']['DashboardVisualisationDefinition']) => {
|
|
28
|
+
this.definition = LineChartSchemas.LineSchema.parse(definition)
|
|
29
|
+
this.init()
|
|
30
|
+
|
|
31
|
+
return this
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
build = (): DashboardVisualisationData => {
|
|
35
|
+
this.createDatasets(this.measures, this.responseData)
|
|
36
|
+
this.datasets = this.augmentDataset(this.datasets)
|
|
37
|
+
this.config = this.setBespokeOptions()
|
|
38
|
+
this.createLabels(this.measures)
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
type: DashboardVisualisationType.LINE,
|
|
42
|
+
options: {
|
|
43
|
+
unit: this.unit,
|
|
44
|
+
},
|
|
45
|
+
data: {
|
|
46
|
+
labels: this.labels,
|
|
47
|
+
datasets: this.datasets,
|
|
48
|
+
config: this.config,
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
augmentDataset = (datasets: DashboardVisualisationDataSet[]) => {
|
|
54
|
+
return datasets.map((set) => {
|
|
55
|
+
return {
|
|
56
|
+
...set,
|
|
57
|
+
pointStyle: 'circle',
|
|
58
|
+
pointRadius: 4,
|
|
59
|
+
pointHoverRadius: 10,
|
|
60
|
+
pointHitRadius: 20,
|
|
61
|
+
datalabels: {
|
|
62
|
+
display: false,
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
setBespokeOptions = () => {
|
|
69
|
+
return {
|
|
70
|
+
...this.config,
|
|
71
|
+
scales: {
|
|
72
|
+
y: {
|
|
73
|
+
min: 0,
|
|
74
|
+
ticks: {
|
|
75
|
+
fontSize: 12,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
x: {
|
|
79
|
+
ticks: {
|
|
80
|
+
fontSize: 12,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export { LineChart }
|
|
89
|
+
export default LineChart
|
|
@@ -16,7 +16,6 @@ class LineChartVisualisation extends ChartVisualisation {
|
|
|
16
16
|
|
|
17
17
|
initSettings() {
|
|
18
18
|
return {
|
|
19
|
-
options: this.setOptions(),
|
|
20
19
|
toolTipOptions: this.setToolTipOptions(),
|
|
21
20
|
styling: this.setDatasetStyling(),
|
|
22
21
|
}
|
|
@@ -31,23 +30,11 @@ class LineChartVisualisation extends ChartVisualisation {
|
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
setDatasetStyling() {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
pointStyle: 'circle',
|
|
40
|
-
pointRadius: 4,
|
|
41
|
-
pointHoverRadius: 10,
|
|
42
|
-
pointHitRadius: 20,
|
|
43
|
-
datalabels: {
|
|
44
|
-
display: false,
|
|
45
|
-
},
|
|
46
|
-
segment: {
|
|
47
|
-
borderDash: (ctx) => this.setPartialStyle(ctx),
|
|
48
|
-
},
|
|
49
|
-
}
|
|
50
|
-
})
|
|
33
|
+
return {
|
|
34
|
+
segment: {
|
|
35
|
+
borderDash: (ctx) => this.setPartialStyle(ctx),
|
|
36
|
+
},
|
|
37
|
+
}
|
|
51
38
|
}
|
|
52
39
|
|
|
53
40
|
setToolTipOptions() {
|
|
@@ -70,24 +57,6 @@ class LineChartVisualisation extends ChartVisualisation {
|
|
|
70
57
|
},
|
|
71
58
|
}
|
|
72
59
|
}
|
|
73
|
-
|
|
74
|
-
setOptions() {
|
|
75
|
-
return {
|
|
76
|
-
scales: {
|
|
77
|
-
y: {
|
|
78
|
-
min: 0,
|
|
79
|
-
ticks: {
|
|
80
|
-
fontSize: 12,
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
x: {
|
|
84
|
-
ticks: {
|
|
85
|
-
fontSize: 12,
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
60
|
}
|
|
92
61
|
|
|
93
62
|
export { LineChartVisualisation }
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var t=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var f=(i,e,a,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of m(e))!p.call(i,n)&&n!==a&&t(i,n,{get:()=>e[n],enumerable:!(r=o(e,n))||r.enumerable});return i};var h=i=>f(t({},"__esModule",{value:!0}),i);var L={};module.exports=h(L);
|
|
2
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/dpr/components/_charts/chart/line/types.ts"],
|
|
4
|
+
"sourcesContent": ["import z from 'zod'\nimport LineChartSchemas from './validate'\n\nexport type LineDefinitionType = z.infer<typeof LineChartSchemas.LineSchema>\nexport type LineDefinitionMeasure = z.infer<typeof LineChartSchemas.LineMeasureSchema>\n"],
|
|
5
|
+
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
|
+
"names": ["types_exports", "__toCommonJS"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var i=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var u=(o,t)=>{for(var s in t)i(o,s,{get:t[s],enumerable:!0})},h=(o,t,s,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of m(t))!p.call(o,a)&&a!==s&&i(o,a,{get:()=>t[a],enumerable:!(r=c(t,a))||r.enumerable});return o};var b=o=>h(i({},"__esModule",{value:!0}),o);var E={};u(E,{default:()=>y});module.exports=b(E);var e=require("zod"),n=require("../../../_dashboards/dashboard-visualisation/Validate");const l=e.z.object({id:e.z.string(),display:e.z.string().optional(),unit:e.z.enum(["NUMBER","PERCENTAGE"]).optional()}),d=e.z.object({showLatest:e.z.boolean().default(!0)}),j=e.z.object({...n.DashboardVisualisationSchema.shape,display:e.z.string(),type:e.z.literal("line"),options:e.z.object(d.shape).optional(),columns:e.z.object({...n.DashboardColumns.shape,measures:e.z.array(l).min(1,"Measure must contain at least one item")})}),f={LineMeasureSchema:l,LineSchema:j};var y=f;
|
|
2
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/dpr/components/_charts/chart/line/validate.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from 'zod'\nimport { DashboardVisualisationSchema, DashboardColumns } from '../../../_dashboards/dashboard-visualisation/Validate'\n\nconst LineMeasureSchema = z.object({\n id: z.string(),\n display: z.string().optional(),\n unit: z.enum(['NUMBER', 'PERCENTAGE']).optional(),\n})\n\nconst lineOptions = z.object({\n showLatest: z.boolean().default(true),\n})\n\nconst LineSchema = z.object({\n ...DashboardVisualisationSchema.shape,\n display: z.string(),\n type: z.literal('line'),\n options: z.object(lineOptions.shape).optional(),\n columns: z.object({\n ...DashboardColumns.shape,\n measures: z.array(LineMeasureSchema).min(1, 'Measure must contain at least one item'),\n }),\n})\n\nconst LineChartSchemas = {\n LineMeasureSchema,\n LineSchema,\n}\n\nexport default LineChartSchemas\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkB,eAClBC,EAA+D,iEAE/D,MAAMC,EAAoB,IAAE,OAAO,CACjC,GAAI,IAAE,OAAO,EACb,QAAS,IAAE,OAAO,EAAE,SAAS,EAC7B,KAAM,IAAE,KAAK,CAAC,SAAU,YAAY,CAAC,EAAE,SAAS,CAClD,CAAC,EAEKC,EAAc,IAAE,OAAO,CAC3B,WAAY,IAAE,QAAQ,EAAE,QAAQ,EAAI,CACtC,CAAC,EAEKC,EAAa,IAAE,OAAO,CAC1B,GAAG,+BAA6B,MAChC,QAAS,IAAE,OAAO,EAClB,KAAM,IAAE,QAAQ,MAAM,EACtB,QAAS,IAAE,OAAOD,EAAY,KAAK,EAAE,SAAS,EAC9C,QAAS,IAAE,OAAO,CAChB,GAAG,mBAAiB,MACpB,SAAU,IAAE,MAAMD,CAAiB,EAAE,IAAI,EAAG,wCAAwC,CACtF,CAAC,CACH,CAAC,EAEKG,EAAmB,CACvB,kBAAAH,EACA,WAAAE,CACF,EAEA,IAAON,EAAQO",
|
|
6
|
+
"names": ["validate_exports", "__export", "validate_default", "__toCommonJS", "import_zod", "import_Validate", "LineMeasureSchema", "lineOptions", "LineSchema", "LineChartSchemas"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import { DashboardVisualisationSchema, DashboardColumns } from '../../../_dashboards/dashboard-visualisation/Validate'
|
|
3
|
+
|
|
4
|
+
const LineMeasureSchema = z.object({
|
|
5
|
+
id: z.string(),
|
|
6
|
+
display: z.string().optional(),
|
|
7
|
+
unit: z.enum(['NUMBER', 'PERCENTAGE']).optional(),
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
const lineOptions = z.object({
|
|
11
|
+
showLatest: z.boolean().default(true),
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const LineSchema = z.object({
|
|
15
|
+
...DashboardVisualisationSchema.shape,
|
|
16
|
+
display: z.string(),
|
|
17
|
+
type: z.literal('line'),
|
|
18
|
+
options: z.object(lineOptions.shape).optional(),
|
|
19
|
+
columns: z.object({
|
|
20
|
+
...DashboardColumns.shape,
|
|
21
|
+
measures: z.array(LineMeasureSchema).min(1, 'Measure must contain at least one item'),
|
|
22
|
+
}),
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const LineChartSchemas = {
|
|
26
|
+
LineMeasureSchema,
|
|
27
|
+
LineSchema,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default LineChartSchemas
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var u=Object.create;var r=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var c=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var b=(i,t)=>{for(var e in t)r(i,e,{get:t[e],enumerable:!0})},h=(i,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of D(t))!C.call(i,s)&&s!==e&&r(i,s,{get:()=>t[s],enumerable:!(a=f(t,s))||a.enumerable});return i};var o=(i,t,e)=>(e=i!=null?u(c(i)):{},h(t||!i||!i.__esModule?r(e,"default",{value:i,enumerable:!0}):e,i)),T=i=>h(r({},"__esModule",{value:!0}),i);var y={};b(y,{LineTimeseriesChart:()=>n,default:()=>L});module.exports=T(y);var m=require("../../../_dashboards/dashboard-visualisation/types"),l=o(require("./validate")),p=o(require("../ChartTimeseries")),d=o(require("../line/LineChart"));class n extends p.default{constructor(){super(...arguments);this.lineChartBuilder=new d.default;this.withDefinition=e=>(this.definition=l.default.LineTimeseriesSchema.parse(e),this.initFromDefinition(this.definition),this);this.build=()=>(this.buildDatasets(),this.datasets=this.lineChartBuilder.augmentDataset(this.datasets),this.setStyles(),this.config=this.lineChartBuilder.setBespokeOptions(),{type:m.DashboardVisualisationType.LINE,options:{unit:this.unit,timeseries:!0},data:{labels:this.labels,datasets:this.datasets,config:this.config,partialDate:this.partialDate}});this.setStyles=()=>{this.datasets=this.datasets.map((e,a)=>{const s=this.hexColours[a];return{...e,backgroundColor:s,borderColor:s}})}}}var L=n;0&&(module.exports={LineTimeseriesChart});
|
|
2
|
+
//# sourceMappingURL=LineTimeseriesChart.js.map
|