@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
|
@@ -26,19 +26,9 @@ class ChartVisualisation extends DprClientClass {
|
|
|
26
26
|
this.legendElement = document.getElementById(`dpr-${this.id}-legend`)
|
|
27
27
|
this.legendElement = document.getElementById(`dpr-${this.id}-legend`)
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.daterangeInputs = document.querySelectorAll('.dpr-granular-date-range')
|
|
33
|
-
if (this.daterangeInputs && this.daterangeInputs.length) {
|
|
34
|
-
this.daterangeInputs.forEach((input) => {
|
|
35
|
-
this.partialStart = input.getAttribute('data-partial-start') === 'true'
|
|
36
|
-
this.partialEnd = input.getAttribute('data-partial-end') === 'true'
|
|
37
|
-
})
|
|
38
|
-
} else {
|
|
39
|
-
this.partialStart = false
|
|
40
|
-
this.partialEnd = false
|
|
41
|
-
}
|
|
29
|
+
if (this.chartParams.partialDate) {
|
|
30
|
+
this.partialStart = this.chartParams.partialDate.start || false
|
|
31
|
+
this.partialEnd = this.chartParams.partialDate.end || false
|
|
42
32
|
}
|
|
43
33
|
|
|
44
34
|
// flags
|
|
@@ -46,124 +36,56 @@ class ChartVisualisation extends DprClientClass {
|
|
|
46
36
|
}
|
|
47
37
|
|
|
48
38
|
initChart() {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
// Accessible colours from the MoJ Pattern Library
|
|
59
|
-
getColourPallette() {
|
|
60
|
-
return [
|
|
61
|
-
{
|
|
62
|
-
name: 'blue',
|
|
63
|
-
hex: '#5694ca',
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: 'purple',
|
|
67
|
-
hex: '#912b88',
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
name: 'green',
|
|
71
|
-
hex: '#00703c',
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
name: 'dark_blue',
|
|
75
|
-
hex: '#003078',
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
name: 'orange',
|
|
79
|
-
hex: '#f47738',
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
name: 'orange',
|
|
83
|
-
hex: '#28a197',
|
|
84
|
-
},
|
|
85
|
-
]
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
mapHexColourToName(hex, ctx) {
|
|
89
|
-
const pallette = ctx.getColourPallette()
|
|
90
|
-
const colour = pallette.find((p) => {
|
|
91
|
-
return p.hex === hex
|
|
39
|
+
// Prevent font loading issue
|
|
40
|
+
window.addEventListener('load', () => {
|
|
41
|
+
// An example of creating a chart, replace with your code:
|
|
42
|
+
Chart.defaults.font.family = 'GDS Transport'
|
|
43
|
+
Chart.defaults.font.size = 12
|
|
44
|
+
Chart.register(ChartDataLabels)
|
|
45
|
+
Chart.register(MatrixController, MatrixElement)
|
|
46
|
+
this.chart = new Chart(this.chartContext, this.chartData)
|
|
92
47
|
})
|
|
93
|
-
return colour ? colour.name : ''
|
|
94
|
-
}
|
|
95
48
|
|
|
96
|
-
|
|
97
|
-
return datasets.map((d, i) => {
|
|
98
|
-
const { label, data } = d
|
|
99
|
-
const s = styling[i % 6] ? styling[i % 6] : styling[0]
|
|
100
|
-
return {
|
|
101
|
-
label,
|
|
102
|
-
data,
|
|
103
|
-
...s,
|
|
104
|
-
}
|
|
105
|
-
})
|
|
49
|
+
this.initChartEvents()
|
|
106
50
|
}
|
|
107
51
|
|
|
108
52
|
generateChartData(settings) {
|
|
109
|
-
const { datasets, labels } = this.chartParams
|
|
110
|
-
const { options,
|
|
111
|
-
|
|
53
|
+
const { datasets, labels, config } = this.chartParams
|
|
54
|
+
const { options, datalabels, plugins, pluginsOptions, toolTipOptions, hoverEvent, styling } = settings
|
|
55
|
+
|
|
56
|
+
const chartData = {
|
|
112
57
|
type: this.type,
|
|
113
58
|
data: {
|
|
114
59
|
labels,
|
|
115
60
|
datasets: this.createDatasets(datasets, styling),
|
|
116
61
|
},
|
|
117
62
|
options: {
|
|
118
|
-
|
|
119
|
-
maintainAspectRatio: false,
|
|
120
|
-
animation: {
|
|
121
|
-
duration: 0,
|
|
122
|
-
},
|
|
123
|
-
hover: {
|
|
124
|
-
animationDuration: 0,
|
|
125
|
-
},
|
|
63
|
+
...config,
|
|
126
64
|
...(options && options),
|
|
127
65
|
...(hoverEvent && hoverEvent),
|
|
128
66
|
plugins: {
|
|
129
|
-
|
|
130
|
-
position: 'bottom',
|
|
131
|
-
},
|
|
67
|
+
...config.plugins,
|
|
132
68
|
...(pluginsOptions && pluginsOptions),
|
|
133
69
|
...(datalabels && { datalabels }),
|
|
134
70
|
tooltip: {
|
|
135
|
-
...
|
|
71
|
+
...config.plugins.tooltip,
|
|
136
72
|
...(toolTipOptions && toolTipOptions),
|
|
137
73
|
},
|
|
138
74
|
},
|
|
139
75
|
},
|
|
140
76
|
plugins: plugins && plugins.length ? [...plugins] : [],
|
|
141
77
|
}
|
|
78
|
+
|
|
79
|
+
return chartData
|
|
142
80
|
}
|
|
143
81
|
|
|
144
|
-
|
|
145
|
-
return {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
bodyFont: {
|
|
152
|
-
size: 16,
|
|
153
|
-
},
|
|
154
|
-
titleColor: '#000',
|
|
155
|
-
displayColors: false,
|
|
156
|
-
borderWidth: 1,
|
|
157
|
-
borderColor: '#b1b4b6',
|
|
158
|
-
cornerRadius: 0,
|
|
159
|
-
padding: 20,
|
|
160
|
-
footerFont: {
|
|
161
|
-
weight: 'bold',
|
|
162
|
-
},
|
|
163
|
-
animation: {
|
|
164
|
-
duration: 0,
|
|
165
|
-
},
|
|
166
|
-
}
|
|
82
|
+
createDatasets(datasets, styling) {
|
|
83
|
+
return datasets.map((dataset) => {
|
|
84
|
+
return {
|
|
85
|
+
...dataset,
|
|
86
|
+
...(styling && styling),
|
|
87
|
+
}
|
|
88
|
+
})
|
|
167
89
|
}
|
|
168
90
|
|
|
169
91
|
setHoverValue({ label, value, legend, ctx }) {
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var D=Object.create;var a=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty;var g=(t,s)=>{for(var i in s)a(t,i,{get:s[i],enumerable:!0})},r=(t,s,i,n)=>{if(s&&typeof s=="object"||typeof s=="function")for(let e of f(s))!c.call(t,e)&&e!==i&&a(t,e,{get:()=>s[e],enumerable:!(n=d(s,e))||n.enumerable});return t};var h=(t,s,i)=>(i=t!=null?D(l(t)):{},r(s||!t||!t.__esModule?a(i,"default",{value:t,enumerable:!0}):i,t)),b=t=>r(a({},"__esModule",{value:!0}),t);var k={};g(k,{DoughnutChart:()=>o,default:()=>y});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=i=>(this.definition=m.default.DoughnutSchema.parse(i),this.init(),this);this.build=()=>(this.createDatasets(this.measures,this.responseData),this.augmentDataset(),this.setBespokeOptions(),this.createLabels(this.measures),{type:u.DashboardVisualisationType.DONUT,options:{unit:this.unit},data:{labels:this.labels,datasets:this.datasets,config:this.config}});this.augmentDataset=()=>{this.datasets=this.datasets.map(i=>({...i,backgroundColor:[...this.hexColours,...this.hexColours],borderColor:void 0,hoverOffset:4,datalabels:{anchor:"center",borderWidth:0}}))};this.setBespokeOptions=()=>{const i=this.datasets.length===1?"50%":"20%";this.config={...this.config,cutout:i}}}}var y=o;0&&(module.exports={DoughnutChart});
|
|
2
|
+
//# sourceMappingURL=DoughnutChart.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/dpr/components/_charts/chart/doughnut/DoughnutChart.ts"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable prefer-destructuring */\nimport {\n DashboardVisualisationType,\n DashboardVisualisationData,\n VisualisationDefinitionKey,\n} from '../../../_dashboards/dashboard-visualisation/types'\nimport { components } from '../../../../types/api'\nimport Chart from '../Chart'\nimport { DoughnutDefinitionMeasure, DoughnutDefinitionType } from './types'\nimport DoughnutChartSchemas from './validate'\n\nclass DoughnutChart extends Chart {\n private definition!: DoughnutDefinitionType\n\n private measures!: DoughnutDefinitionMeasure[]\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 = DoughnutChartSchemas.DoughnutSchema.parse(definition)\n this.init()\n\n return this\n }\n\n build = (): DashboardVisualisationData => {\n this.createDatasets(this.measures, this.responseData)\n this.augmentDataset()\n this.setBespokeOptions()\n this.createLabels(this.measures)\n\n return {\n type: DashboardVisualisationType.DONUT,\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 private augmentDataset = () => {\n this.datasets = this.datasets.map((set) => {\n return {\n ...set,\n backgroundColor: [...this.hexColours, ...this.hexColours],\n borderColor: undefined,\n hoverOffset: 4,\n datalabels: {\n anchor: 'center',\n borderWidth: 0,\n },\n }\n })\n }\n\n private setBespokeOptions = () => {\n const cutout = this.datasets.length === 1 ? '50%' : '20%'\n this.config = {\n ...this.config,\n cutout,\n }\n }\n}\n\nexport { DoughnutChart }\nexport default DoughnutChart\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAIO,8DAEPC,EAAkB,uBAElBC,EAAiC,yBAEjC,MAAML,UAAsB,EAAAM,OAAM,CAAlC,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,QAAqB,eAAe,MAAMD,CAAU,EACtE,KAAK,KAAK,EAEH,MAGT,WAAQ,KACN,KAAK,eAAe,KAAK,SAAU,KAAK,YAAY,EACpD,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,aAAa,KAAK,QAAQ,EAExB,CACL,KAAM,6BAA2B,MACjC,QAAS,CACP,KAAM,KAAK,IACb,EACA,KAAM,CACJ,OAAQ,KAAK,OACb,SAAU,KAAK,SACf,OAAQ,KAAK,MACf,CACF,GAGF,KAAQ,eAAiB,IAAM,CAC7B,KAAK,SAAW,KAAK,SAAS,IAAKE,IAC1B,CACL,GAAGA,EACH,gBAAiB,CAAC,GAAG,KAAK,WAAY,GAAG,KAAK,UAAU,EACxD,YAAa,OACb,YAAa,EACb,WAAY,CACV,OAAQ,SACR,YAAa,CACf,CACF,EACD,CACH,EAEA,KAAQ,kBAAoB,IAAM,CAChC,MAAMC,EAAS,KAAK,SAAS,SAAW,EAAI,MAAQ,MACpD,KAAK,OAAS,CACZ,GAAG,KAAK,OACR,OAAAA,CACF,CACF,EACF,CAGA,IAAOT,EAAQD",
|
|
6
|
+
"names": ["DoughnutChart_exports", "__export", "DoughnutChart", "DoughnutChart_default", "__toCommonJS", "import_types", "import_Chart", "import_validate", "Chart", "definition", "DoughnutChartSchemas", "set", "cutout"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/* eslint-disable prefer-destructuring */
|
|
2
|
+
import {
|
|
3
|
+
DashboardVisualisationType,
|
|
4
|
+
DashboardVisualisationData,
|
|
5
|
+
VisualisationDefinitionKey,
|
|
6
|
+
} from '../../../_dashboards/dashboard-visualisation/types'
|
|
7
|
+
import { components } from '../../../../types/api'
|
|
8
|
+
import Chart from '../Chart'
|
|
9
|
+
import { DoughnutDefinitionMeasure, DoughnutDefinitionType } from './types'
|
|
10
|
+
import DoughnutChartSchemas from './validate'
|
|
11
|
+
|
|
12
|
+
class DoughnutChart extends Chart {
|
|
13
|
+
private definition!: DoughnutDefinitionType
|
|
14
|
+
|
|
15
|
+
private measures!: DoughnutDefinitionMeasure[]
|
|
16
|
+
|
|
17
|
+
private keys!: VisualisationDefinitionKey[]
|
|
18
|
+
|
|
19
|
+
private init = () => {
|
|
20
|
+
this.measures = this.definition.columns.measures
|
|
21
|
+
this.keys = this.definition.columns.keys || []
|
|
22
|
+
this.initUnit(this.measures)
|
|
23
|
+
this.getLabelId(this.keys)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
withDefinition = (definition: components['schemas']['DashboardVisualisationDefinition']) => {
|
|
27
|
+
this.definition = DoughnutChartSchemas.DoughnutSchema.parse(definition)
|
|
28
|
+
this.init()
|
|
29
|
+
|
|
30
|
+
return this
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
build = (): DashboardVisualisationData => {
|
|
34
|
+
this.createDatasets(this.measures, this.responseData)
|
|
35
|
+
this.augmentDataset()
|
|
36
|
+
this.setBespokeOptions()
|
|
37
|
+
this.createLabels(this.measures)
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
type: DashboardVisualisationType.DONUT,
|
|
41
|
+
options: {
|
|
42
|
+
unit: this.unit,
|
|
43
|
+
},
|
|
44
|
+
data: {
|
|
45
|
+
labels: this.labels,
|
|
46
|
+
datasets: this.datasets,
|
|
47
|
+
config: this.config,
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private augmentDataset = () => {
|
|
53
|
+
this.datasets = this.datasets.map((set) => {
|
|
54
|
+
return {
|
|
55
|
+
...set,
|
|
56
|
+
backgroundColor: [...this.hexColours, ...this.hexColours],
|
|
57
|
+
borderColor: undefined,
|
|
58
|
+
hoverOffset: 4,
|
|
59
|
+
datalabels: {
|
|
60
|
+
anchor: 'center',
|
|
61
|
+
borderWidth: 0,
|
|
62
|
+
},
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private setBespokeOptions = () => {
|
|
68
|
+
const cutout = this.datasets.length === 1 ? '50%' : '20%'
|
|
69
|
+
this.config = {
|
|
70
|
+
...this.config,
|
|
71
|
+
cutout,
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { DoughnutChart }
|
|
77
|
+
export default DoughnutChart
|
|
@@ -16,7 +16,6 @@ class DoughnutChartVisualisation extends ChartVisualisation {
|
|
|
16
16
|
initSettings() {
|
|
17
17
|
return {
|
|
18
18
|
options: this.setOptions(),
|
|
19
|
-
styling: this.setDatasetStyling(),
|
|
20
19
|
datalabels: this.setDataLabels(),
|
|
21
20
|
pluginsOptions: this.setPluginsOptions(),
|
|
22
21
|
toolTipOptions: this.setToolTipOptions(),
|
|
@@ -24,21 +23,6 @@ class DoughnutChartVisualisation extends ChartVisualisation {
|
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
setDatasetStyling() {
|
|
28
|
-
const pallette = this.getColourPallette()
|
|
29
|
-
const backgroundColor = pallette.map((p) => p.hex)
|
|
30
|
-
return [
|
|
31
|
-
{
|
|
32
|
-
backgroundColor: [...backgroundColor, ...backgroundColor],
|
|
33
|
-
hoverOffset: 4,
|
|
34
|
-
datalabels: {
|
|
35
|
-
anchor: 'center',
|
|
36
|
-
borderWidth: 0,
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
]
|
|
40
|
-
}
|
|
41
|
-
|
|
42
26
|
setOptions() {
|
|
43
27
|
const cutoutValue = this.chartParams.datasets.length === 1 ? '50%' : '20%'
|
|
44
28
|
return {
|
|
@@ -102,35 +86,6 @@ class DoughnutChartVisualisation extends ChartVisualisation {
|
|
|
102
86
|
}
|
|
103
87
|
}
|
|
104
88
|
|
|
105
|
-
setLegend() {
|
|
106
|
-
const classContext = this
|
|
107
|
-
const { legend, suffix } = this
|
|
108
|
-
return {
|
|
109
|
-
id: 'legend',
|
|
110
|
-
beforeInit(chart) {
|
|
111
|
-
const ul = document.createElement('ul')
|
|
112
|
-
const { labels } = chart.data
|
|
113
|
-
const { backgroundColor, data } = chart.data.datasets[0]
|
|
114
|
-
|
|
115
|
-
labels.forEach((label, i) => {
|
|
116
|
-
const colourIndex = i % backgroundColor.length
|
|
117
|
-
const colour = backgroundColor[colourIndex]
|
|
118
|
-
const colourName = classContext.mapHexColourToName(colour, classContext)
|
|
119
|
-
const value = chart.data.datasets.length === 1 ? `${data[i]}${suffix}` : ''
|
|
120
|
-
|
|
121
|
-
ul.innerHTML += `
|
|
122
|
-
<li aria-label="${label} ${value}">
|
|
123
|
-
<span class="chart-colour__${colourName}">${value}</span>
|
|
124
|
-
${label}
|
|
125
|
-
</li>
|
|
126
|
-
`
|
|
127
|
-
})
|
|
128
|
-
legend.appendChild(ul)
|
|
129
|
-
return legend.appendChild(ul)
|
|
130
|
-
},
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
89
|
setToolTipOptions() {
|
|
135
90
|
const ctx = this
|
|
136
91
|
return {
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var h=Object.defineProperty;var r=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var m=(t,e,n,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of a(e))!i.call(t,o)&&o!==n&&h(t,o,{get:()=>e[o],enumerable:!(u=r(e,o))||u.enumerable});return t};var p=t=>m(h({},"__esModule",{value:!0}),t);var D={};module.exports=p(D);
|
|
2
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/dpr/components/_charts/chart/doughnut/types.ts"],
|
|
4
|
+
"sourcesContent": ["import z from 'zod'\nimport DoughnutChartSchemas from './validate'\n\nexport type DoughnutDefinitionType = z.infer<typeof DoughnutChartSchemas.DoughnutSchema>\nexport type DoughnutDefinitionMeasure = z.infer<typeof DoughnutChartSchemas.DounutMeasureSchema>\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 h=Object.prototype.hasOwnProperty;var p=(a,o)=>{for(var e in o)i(a,e,{get:o[e],enumerable:!0})},l=(a,o,e,u)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of m(o))!h.call(a,s)&&s!==e&&i(a,s,{get:()=>o[s],enumerable:!(u=c(o,s))||u.enumerable});return a};var b=a=>l(i({},"__esModule",{value:!0}),a);var f={};p(f,{default:()=>j});module.exports=b(f);var t=require("zod"),n=require("../../../_dashboards/dashboard-visualisation/Validate");const r=t.z.object({id:t.z.string(),display:t.z.string().optional(),unit:t.z.enum(["NUMBER","PERCENTAGE"]).optional()}),d=t.z.object({showLatest:t.z.boolean().default(!0)}),g=t.z.object({...n.DashboardVisualisationSchema.shape,type:t.z.literal("doughnut"),display:t.z.string(),options:t.z.object(d.shape).optional(),columns:t.z.object({...n.DashboardColumns.shape,measures:t.z.array(r).min(2,"Measure must contain 2 items")})}),D={DoughnutSchema:g,DounutMeasureSchema:r};var j=D;
|
|
2
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/dpr/components/_charts/chart/doughnut/validate.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from 'zod'\nimport { DashboardVisualisationSchema, DashboardColumns } from '../../../_dashboards/dashboard-visualisation/Validate'\n\nconst DounutMeasureSchema = z.object({\n id: z.string(),\n display: z.string().optional(),\n unit: z.enum(['NUMBER', 'PERCENTAGE']).optional(),\n})\n\nconst DonutOptions = z.object({\n showLatest: z.boolean().default(true),\n})\n\nconst DoughnutSchema = z.object({\n ...DashboardVisualisationSchema.shape,\n type: z.literal('doughnut'),\n display: z.string(),\n options: z.object(DonutOptions.shape).optional(),\n columns: z.object({\n ...DashboardColumns.shape,\n measures: z.array(DounutMeasureSchema).min(2, 'Measure must contain 2 items'),\n }),\n})\n\nconst DoughnutChartSchemas = {\n DoughnutSchema,\n DounutMeasureSchema,\n}\n\nexport default DoughnutChartSchemas\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkB,eAClBC,EAA+D,iEAE/D,MAAMC,EAAsB,IAAE,OAAO,CACnC,GAAI,IAAE,OAAO,EACb,QAAS,IAAE,OAAO,EAAE,SAAS,EAC7B,KAAM,IAAE,KAAK,CAAC,SAAU,YAAY,CAAC,EAAE,SAAS,CAClD,CAAC,EAEKC,EAAe,IAAE,OAAO,CAC5B,WAAY,IAAE,QAAQ,EAAE,QAAQ,EAAI,CACtC,CAAC,EAEKC,EAAiB,IAAE,OAAO,CAC9B,GAAG,+BAA6B,MAChC,KAAM,IAAE,QAAQ,UAAU,EAC1B,QAAS,IAAE,OAAO,EAClB,QAAS,IAAE,OAAOD,EAAa,KAAK,EAAE,SAAS,EAC/C,QAAS,IAAE,OAAO,CAChB,GAAG,mBAAiB,MACpB,SAAU,IAAE,MAAMD,CAAmB,EAAE,IAAI,EAAG,8BAA8B,CAC9E,CAAC,CACH,CAAC,EAEKG,EAAuB,CAC3B,eAAAD,EACA,oBAAAF,CACF,EAEA,IAAOJ,EAAQO",
|
|
6
|
+
"names": ["validate_exports", "__export", "validate_default", "__toCommonJS", "import_zod", "import_Validate", "DounutMeasureSchema", "DonutOptions", "DoughnutSchema", "DoughnutChartSchemas"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import { DashboardVisualisationSchema, DashboardColumns } from '../../../_dashboards/dashboard-visualisation/Validate'
|
|
3
|
+
|
|
4
|
+
const DounutMeasureSchema = z.object({
|
|
5
|
+
id: z.string(),
|
|
6
|
+
display: z.string().optional(),
|
|
7
|
+
unit: z.enum(['NUMBER', 'PERCENTAGE']).optional(),
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
const DonutOptions = z.object({
|
|
11
|
+
showLatest: z.boolean().default(true),
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const DoughnutSchema = z.object({
|
|
15
|
+
...DashboardVisualisationSchema.shape,
|
|
16
|
+
type: z.literal('doughnut'),
|
|
17
|
+
display: z.string(),
|
|
18
|
+
options: z.object(DonutOptions.shape).optional(),
|
|
19
|
+
columns: z.object({
|
|
20
|
+
...DashboardColumns.shape,
|
|
21
|
+
measures: z.array(DounutMeasureSchema).min(2, 'Measure must contain 2 items'),
|
|
22
|
+
}),
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const DoughnutChartSchemas = {
|
|
26
|
+
DoughnutSchema,
|
|
27
|
+
DounutMeasureSchema,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default DoughnutChartSchemas
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var k=Object.create;var u=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var T=(e,t)=>{for(var a in t)u(e,a,{get:t[a],enumerable:!0})},d=(e,t,a,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of M(t))!C.call(e,i)&&i!==a&&u(e,i,{get:()=>t[i],enumerable:!(r=x(t,i))||r.enumerable});return e};var l=(e,t,a)=>(a=e!=null?k(w(e)):{},d(t||!e||!e.__esModule?u(a,"default",{value:e,enumerable:!0}):a,e)),L=e=>d(u({},"__esModule",{value:!0}),e);var R={};T(R,{HeatmapChart:()=>p,default:()=>B});module.exports=L(R);var n=l(require("dayjs")),c=require("../../../_dashboards/dashboard-visualisation/types"),D=l(require("../../../../utils/datasetHelper")),y=l(require("../buckets/Buckets")),b=l(require("./validate")),f=l(require("../chart-config"));class p{constructor(){this.responseData=[];this.data=[];this.dayDateFormat="DD/MM/YYYY";this.valueKey="";this.label="";this.datasets=[];this.config=f.default;this.xLabels=[];this.yLabels=[];this.withDefinition=t=>(this.definition=b.default.parse(t),this.init(),this);this.withData=t=>(this.responseData=t,this.bucketsHelper=new y.default(this.responseData,this.definition,this.valueKey,!0),this);this.withGranularity=t=>(this.granularity=t,this);this.init=()=>{this.measures=this.definition.columns.measures,this.setLabel(),this.initUnit()};this.initUnit=()=>{this.unit=this.measures[0].unit?this.measures[0].unit:void 0};this.setLabel=()=>{const{id:t,display:a}=this.measures[1];this.valueKey=t,this.label=a||""};this.initTimeseriesData=()=>{const t=D.default.groupRowsByTimestamp(this.responseData);this.data=t.map(a=>{const{raw:r,rag:i}=a[0][this.valueKey],s=a[0].ts.raw,g=Number(r),v=i!==void 0?Number(a[0][this.valueKey].rag):void 0;let o=0,h=0;switch(this.granularity){case"hourly":break;case"weekly":o=(0,n.default)(s,this.dayDateFormat).format("ddd"),h=(0,n.default)(s,this.dayDateFormat).week();break;case"daily":o=(0,n.default)(s,this.dayDateFormat).format("MMM YY"),h=(0,n.default)(s,this.dayDateFormat).format("D");break;case"monthly":{const m=s.split(" ");o=m[1],h=m[0]}break;case"annually":o="year",h=s;break;default:o=(0,n.default)(s,this.dayDateFormat).format("MMM YY"),h=(0,n.default)(s,this.dayDateFormat).format("D");break}return{y:h,x:o,v:g,r:v}}),this.bucketData(),this.datasets=[{label:this.label,data:this.data}]};this.bucketData=()=>{this.data=this.data.map(t=>{const{v:a,r}=t,i=this.bucketsHelper.getBucketForValue(a,r);return{...t,c:i.colour}})};this.setBespokeOptions=()=>{this.config={...this.config,scales:this.setScales()}};this.getCanvasHeight=()=>this.yLabels.length*20+60;this.build=()=>{this.initTimeseriesData(),this.bucketData(),this.setBespokeOptions();const t=this.getCanvasHeight();return{type:c.DashboardVisualisationType.MATRIX,options:{unit:this.unit,timeseries:!0,height:t},data:{datasets:this.datasets,config:this.config}}}}setScales(){this.xLabels=[...new Set(this.datasets[0].data.map(s=>s.x))],this.yLabels=[...new Set(this.datasets[0].data.map(s=>s.y))];const i={offset:!0,ticks:{padding:1,maxRotation:0,stepSize:1},grid:{display:!1,drawBorder:!1}};return{y:{position:"left",type:"category",...this.yLabels&&{labels:this.yLabels},...i},x:{position:"top",type:"category",...this.xLabels&&{labels:this.xLabels},...i}}}}var B=p;0&&(module.exports={HeatmapChart});
|
|
2
2
|
//# sourceMappingURL=HeatmapChart.js.map
|
|
@@ -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
|
}
|