@ministryofjustice/hmpps-digital-prison-reporting-frontend 4.20.1 → 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/_async/async-filters-form/types.d.js +1 -1
- package/dpr/components/_async/async-filters-form/types.d.js.map +1 -1
- package/dpr/components/_async/async-filters-form/types.d.ts +7 -4
- package/dpr/components/_async/async-filters-form/utils.js +1 -1
- package/dpr/components/_async/async-filters-form/utils.js.map +2 -2
- package/dpr/components/_async/async-filters-form/utils.ts +18 -17
- 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/filter-input/types.d.js.map +1 -1
- package/dpr/components/_filters/filter-input/types.d.ts +1 -1
- package/dpr/components/_filters/types.d.js.map +1 -1
- package/dpr/components/_filters/types.d.ts +6 -4
- package/dpr/components/_reports/report-actions/types.d.js.map +1 -1
- package/dpr/components/_reports/report-actions/types.d.ts +1 -1
- package/dpr/components/report-list/types.d.js.map +1 -1
- package/dpr/components/report-list/types.d.ts +1 -1
- package/dpr/data/types.d.js +1 -1
- package/dpr/data/types.d.js.map +1 -1
- package/dpr/data/types.d.ts +2 -1
- 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/async/report/utils.js +1 -1
- package/dpr/routes/journeys/view-report/async/report/utils.js.map +2 -2
- package/dpr/routes/journeys/view-report/async/report/utils.ts +1 -1
- 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/types/Services.d.js +1 -1
- package/dpr/types/Services.d.js.map +1 -1
- package/dpr/types/Services.d.ts +0 -2
- package/dpr/utils/DataTableBuilder/types.d.js +1 -1
- package/dpr/utils/DataTableBuilder/types.d.js.map +1 -1
- package/dpr/utils/DataTableBuilder/types.d.ts +2 -2
- package/dpr/utils/ErrorHandler.js +1 -1
- package/dpr/utils/ErrorHandler.js.map +3 -3
- package/dpr/utils/ErrorHandler.ts +16 -0
- package/dpr/utils/ParentChildDataTableBuilder/types.d.js +1 -1
- package/dpr/utils/ParentChildDataTableBuilder/types.d.js.map +1 -1
- package/dpr/utils/ParentChildDataTableBuilder/types.d.ts +1 -0
- package/dpr/utils/Personalisation/types.d.js +1 -1
- package/dpr/utils/Personalisation/types.d.js.map +1 -1
- package/dpr/utils/Personalisation/types.d.ts +1 -0
- package/dpr/utils/UserStoreItemBuilder.js.map +2 -2
- package/dpr/utils/UserStoreItemBuilder.ts +1 -1
- 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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/dpr/components/_charts/chart/heatmap/HeatmapChart.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable prefer-destructuring */\nimport dayjs from 'dayjs'\nimport { Granularity } from '../../../_inputs/granular-date-range/types'\nimport { DashboardDataResponse } from '../../../../types/Metrics'\nimport {\n DashboardVisualisationType,\n DashboardVisualisationData,\n} from '../../../_dashboards/dashboard-visualisation/types'\nimport { MatrixChartData } from './types'\nimport DatasetHelper from '../../../../utils/datasetHelper'\nimport
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAkB,oBAGlBC,
|
|
6
|
-
"names": ["HeatmapChart_exports", "__export", "HeatmapChart", "HeatmapChart_default", "__toCommonJS", "import_dayjs", "import_types", "import_datasetHelper", "
|
|
4
|
+
"sourcesContent": ["/* eslint-disable prefer-destructuring */\nimport dayjs from 'dayjs'\nimport { Granularity } from '../../../_inputs/granular-date-range/types'\nimport { DashboardDataResponse } from '../../../../types/Metrics'\nimport {\n DashboardVisualisationType,\n DashboardVisualisationData,\n DashboardVisualisationDataSet,\n} from '../../../_dashboards/dashboard-visualisation/types'\nimport { MatrixChartData, MatrixTimeseriesDefinitionType } from './types'\nimport DatasetHelper from '../../../../utils/datasetHelper'\nimport Buckets from '../buckets/Buckets'\nimport { components } from '../../../../types/api'\nimport MatrixSchema from './validate'\nimport ChartConfig from '../chart-config'\n\nclass HeatmapChart {\n private definition!: MatrixTimeseriesDefinitionType\n\n private measures!: MatrixTimeseriesDefinitionType['columns']['measures']\n\n private responseData: DashboardDataResponse[] = []\n\n private granularity!: Granularity\n\n private data: MatrixChartData[] = []\n\n private dayDateFormat = 'DD/MM/YYYY'\n\n private valueKey = ''\n\n private label = ''\n\n private unit: 'NUMBER' | 'PERCENTAGE' | undefined\n\n private bucketsHelper!: Buckets\n\n private datasets: DashboardVisualisationDataSet[] = []\n\n config = ChartConfig\n\n private xLabels: (string | number)[] = []\n\n private yLabels: (string | number)[] = []\n\n withDefinition = (definition: components['schemas']['DashboardVisualisationDefinition']) => {\n this.definition = MatrixSchema.parse(definition)\n this.init()\n return this\n }\n\n withData = (responseData: DashboardDataResponse[]) => {\n this.responseData = responseData\n this.bucketsHelper = new Buckets(this.responseData, this.definition, this.valueKey, true)\n return this\n }\n\n withGranularity = (granularity: Granularity) => {\n this.granularity = granularity\n return this\n }\n\n private init = () => {\n this.measures = this.definition.columns.measures\n this.setLabel()\n this.initUnit()\n }\n\n initUnit = () => {\n this.unit = this.measures[0].unit ? this.measures[0].unit : undefined\n }\n\n private setLabel = () => {\n const { id, display } = this.measures[1]\n this.valueKey = id\n this.label = display || ''\n }\n\n private initTimeseriesData = () => {\n const timeBlockData = DatasetHelper.groupRowsByTimestamp(this.responseData)\n\n this.data = timeBlockData.map((tsData) => {\n const { raw, rag } = tsData[0][this.valueKey]\n const tsRaw = tsData[0]['ts'].raw\n\n const v: MatrixChartData['v'] = Number(raw)\n const r: MatrixChartData['r'] = rag !== undefined ? Number(tsData[0][this.valueKey].rag) : undefined\n let x: MatrixChartData['x'] = 0\n let y: MatrixChartData['y'] = 0\n\n switch (this.granularity) {\n case 'hourly':\n break\n case 'weekly':\n x = dayjs(tsRaw, this.dayDateFormat).format('ddd')\n y = dayjs(tsRaw, this.dayDateFormat).week()\n break\n case 'daily':\n x = dayjs(tsRaw, this.dayDateFormat).format('MMM YY')\n y = dayjs(tsRaw, this.dayDateFormat).format('D')\n break\n case 'monthly':\n {\n const ts = (<string>tsRaw).split(' ')\n x = ts[1]\n y = ts[0]\n }\n break\n case 'annually':\n x = 'year'\n y = <string>tsRaw\n break\n default:\n x = dayjs(tsRaw, this.dayDateFormat).format('MMM YY')\n y = dayjs(tsRaw, this.dayDateFormat).format('D')\n break\n }\n return { y, x, v, r }\n })\n\n this.bucketData()\n this.datasets = [\n {\n label: this.label,\n data: this.data,\n },\n ]\n }\n\n private bucketData = () => {\n this.data = this.data.map((d) => {\n const { v, r } = d\n const bucketData = this.bucketsHelper.getBucketForValue(v, r)\n return { ...d, c: bucketData.colour }\n })\n }\n\n private setBespokeOptions = () => {\n this.config = {\n ...this.config,\n scales: this.setScales(),\n }\n }\n\n setScales() {\n this.xLabels = [\n ...new Set(\n (<MatrixChartData[]>this.datasets[0].data).map((d) => {\n return d.x\n }),\n ),\n ]\n this.yLabels = [\n ...new Set(\n (<MatrixChartData[]>this.datasets[0].data).map((d) => {\n return d.y\n }),\n ),\n ]\n const grid = {\n display: false,\n drawBorder: false,\n }\n const ticks = {\n padding: 1,\n maxRotation: 0,\n stepSize: 1,\n }\n const offset = true\n const common = {\n offset,\n ticks,\n grid,\n }\n\n return {\n y: {\n position: 'left',\n type: 'category',\n ...(this.yLabels && { labels: this.yLabels }),\n ...common,\n },\n x: {\n position: 'top',\n type: 'category',\n ...(this.xLabels && { labels: this.xLabels }),\n ...common,\n },\n }\n }\n\n getCanvasHeight = () => {\n return this.yLabels.length * 20 + 60\n }\n\n build = (): DashboardVisualisationData => {\n this.initTimeseriesData()\n this.bucketData()\n this.setBespokeOptions()\n const height = this.getCanvasHeight()\n\n return {\n type: DashboardVisualisationType.MATRIX,\n options: {\n unit: this.unit,\n timeseries: true,\n height,\n },\n data: {\n datasets: this.datasets,\n config: this.config,\n },\n }\n }\n}\n\nexport { HeatmapChart }\nexport default HeatmapChart\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["HeatmapChart_exports", "__export", "HeatmapChart", "HeatmapChart_default", "__toCommonJS", "import_dayjs", "import_types", "import_datasetHelper", "import_Buckets", "import_validate", "import_chart_config", "ChartConfig", "definition", "MatrixSchema", "responseData", "Buckets", "granularity", "id", "display", "timeBlockData", "DatasetHelper", "tsData", "raw", "rag", "tsRaw", "v", "r", "x", "y", "dayjs", "ts", "d", "bucketData", "height", "common"]
|
|
7
7
|
}
|
|
@@ -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
|
+
}
|