@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
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/dpr/components/_charts/chart/buckets/types.ts"],
|
|
4
|
+
"sourcesContent": ["import z from 'zod'\nimport BucketOptionsSchema from './validate'\n\nexport type BucketOptionsDefinition = z.infer<typeof BucketOptionsSchema>\n"],
|
|
5
|
+
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
|
+
"names": ["types_exports", "__toCommonJS"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var n=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var c=(t,o)=>{for(var r in o)n(t,r,{get:o[r],enumerable:!0})},p=(t,o,r,l)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of i(o))!b.call(t,a)&&a!==r&&n(t,a,{get:()=>o[a],enumerable:!(l=s(o,a))||l.enumerable});return t};var m=t=>p(n({},"__esModule",{value:!0}),t);var f={};c(f,{BucketOptionsSchema:()=>u,default:()=>d});module.exports=m(f);var e=require("zod");const x=e.z.object({min:e.z.number().optional(),max:e.z.number().optional(),hexColour:e.z.string().regex(/^#/).optional()}),u=e.z.object({useRagColour:e.z.boolean().default(!1),buckets:e.z.array(x).default([]),baseColour:e.z.string().regex(/^#/).optional()});var d=u;0&&(module.exports={BucketOptionsSchema});
|
|
2
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/dpr/components/_charts/chart/buckets/validate.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from 'zod'\n\nconst dashboardBucket = z.object({\n min: z.number().optional(),\n max: z.number().optional(),\n hexColour: z.string().regex(/^#/).optional(),\n})\n\nexport const BucketOptionsSchema = z.object({\n useRagColour: z.boolean().default(false),\n buckets: z.array(dashboardBucket).default([]),\n baseColour: z.string().regex(/^#/).optional(),\n})\n\nexport default BucketOptionsSchema\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAAkB,eAElB,MAAMC,EAAkB,IAAE,OAAO,CAC/B,IAAK,IAAE,OAAO,EAAE,SAAS,EACzB,IAAK,IAAE,OAAO,EAAE,SAAS,EACzB,UAAW,IAAE,OAAO,EAAE,MAAM,IAAI,EAAE,SAAS,CAC7C,CAAC,EAEYJ,EAAsB,IAAE,OAAO,CAC1C,aAAc,IAAE,QAAQ,EAAE,QAAQ,EAAK,EACvC,QAAS,IAAE,MAAMI,CAAe,EAAE,QAAQ,CAAC,CAAC,EAC5C,WAAY,IAAE,OAAO,EAAE,MAAM,IAAI,EAAE,SAAS,CAC9C,CAAC,EAED,IAAOH,EAAQD",
|
|
6
|
+
"names": ["validate_exports", "__export", "BucketOptionsSchema", "validate_default", "__toCommonJS", "import_zod", "dashboardBucket"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
const dashboardBucket = z.object({
|
|
4
|
+
min: z.number().optional(),
|
|
5
|
+
max: z.number().optional(),
|
|
6
|
+
hexColour: z.string().regex(/^#/).optional(),
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
export const BucketOptionsSchema = z.object({
|
|
10
|
+
useRagColour: z.boolean().default(false),
|
|
11
|
+
buckets: z.array(dashboardBucket).default([]),
|
|
12
|
+
baseColour: z.string().regex(/^#/).optional(),
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
export default BucketOptionsSchema
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var p=(t,o)=>{for(var n in o)e(t,n,{get:o[n],enumerable:!0})},b=(t,o,n,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of s(o))!l.call(t,i)&&i!==n&&e(t,i,{get:()=>o[i],enumerable:!(r=a(o,i))||r.enumerable});return t};var d=t=>b(e({},"__esModule",{value:!0}),t);var y={};p(y,{default:()=>g});module.exports=d(y);const u={backgroundColor:"#FFF",bodyColor:"#000",titleFont:{size:16},bodyFont:{size:16},titleColor:"#000",displayColors:!1,borderWidth:1,borderColor:"#b1b4b6",cornerRadius:0,padding:20,footerFont:{weight:"bold"},animation:{duration:0}},m={responsive:!0,maintainAspectRatio:!1,animation:{duration:0},hover:{animationDuration:0},plugins:{legend:{position:"bottom"},tooltip:u}};var g=m;
|
|
2
|
+
//# sourceMappingURL=chart-config.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/dpr/components/_charts/chart/chart-config.ts"],
|
|
4
|
+
"sourcesContent": ["const tooltip: ChartTooltipType = {\n backgroundColor: '#FFF',\n bodyColor: '#000',\n titleFont: {\n size: 16,\n },\n bodyFont: {\n size: 16,\n },\n titleColor: '#000',\n displayColors: false,\n borderWidth: 1,\n borderColor: '#b1b4b6',\n cornerRadius: 0,\n padding: 20,\n footerFont: {\n weight: 'bold',\n },\n animation: {\n duration: 0,\n },\n}\n\nconst chartConfig: ChartOptionsType = {\n responsive: true,\n maintainAspectRatio: false,\n animation: {\n duration: 0,\n },\n hover: {\n animationDuration: 0,\n },\n plugins: {\n legend: {\n position: 'bottom',\n },\n tooltip,\n },\n}\n\ntype ChartTooltipType = {\n backgroundColor: string\n bodyColor: string\n titleFont: {\n size: number\n }\n bodyFont: {\n size: number\n }\n titleColor: string\n displayColors: false\n borderWidth: number\n borderColor: string\n cornerRadius: number\n padding: number\n footerFont: {\n weight: string\n }\n animation: {\n duration: number\n }\n}\n\nexport type ChartOptionsType = {\n responsive: boolean\n maintainAspectRatio: boolean\n animation: {\n duration: number\n }\n hover: {\n animationDuration: number\n }\n plugins: {\n legend: {\n position: string\n }\n tooltip: ChartTooltipType\n }\n indexAxis?: string\n cutout?: string\n scales?: ChartScalesType\n}\n\ntype ChartScalesType = {\n y?: ChartScaleAxis\n x?: ChartScaleAxis\n}\n\ntype ChartScaleAxis = {\n stacked?: boolean\n position?: string\n type?: string\n min?: number\n offset?: boolean\n labels?: Array<string | number>\n grid?: {\n display: boolean\n drawBorder: boolean\n }\n ticks?: {\n fontSize?: number\n padding?: number\n maxRotation?: number\n stepSize?: number\n }\n}\n\nexport default chartConfig\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,MAAMI,EAA4B,CAChC,gBAAiB,OACjB,UAAW,OACX,UAAW,CACT,KAAM,EACR,EACA,SAAU,CACR,KAAM,EACR,EACA,WAAY,OACZ,cAAe,GACf,YAAa,EACb,YAAa,UACb,aAAc,EACd,QAAS,GACT,WAAY,CACV,OAAQ,MACV,EACA,UAAW,CACT,SAAU,CACZ,CACF,EAEMC,EAAgC,CACpC,WAAY,GACZ,oBAAqB,GACrB,UAAW,CACT,SAAU,CACZ,EACA,MAAO,CACL,kBAAmB,CACrB,EACA,QAAS,CACP,OAAQ,CACN,SAAU,QACZ,EACA,QAAAD,CACF,CACF,EAqEA,IAAOF,EAAQG",
|
|
6
|
+
"names": ["chart_config_exports", "__export", "chart_config_default", "__toCommonJS", "tooltip", "chartConfig"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
const tooltip: ChartTooltipType = {
|
|
2
|
+
backgroundColor: '#FFF',
|
|
3
|
+
bodyColor: '#000',
|
|
4
|
+
titleFont: {
|
|
5
|
+
size: 16,
|
|
6
|
+
},
|
|
7
|
+
bodyFont: {
|
|
8
|
+
size: 16,
|
|
9
|
+
},
|
|
10
|
+
titleColor: '#000',
|
|
11
|
+
displayColors: false,
|
|
12
|
+
borderWidth: 1,
|
|
13
|
+
borderColor: '#b1b4b6',
|
|
14
|
+
cornerRadius: 0,
|
|
15
|
+
padding: 20,
|
|
16
|
+
footerFont: {
|
|
17
|
+
weight: 'bold',
|
|
18
|
+
},
|
|
19
|
+
animation: {
|
|
20
|
+
duration: 0,
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const chartConfig: ChartOptionsType = {
|
|
25
|
+
responsive: true,
|
|
26
|
+
maintainAspectRatio: false,
|
|
27
|
+
animation: {
|
|
28
|
+
duration: 0,
|
|
29
|
+
},
|
|
30
|
+
hover: {
|
|
31
|
+
animationDuration: 0,
|
|
32
|
+
},
|
|
33
|
+
plugins: {
|
|
34
|
+
legend: {
|
|
35
|
+
position: 'bottom',
|
|
36
|
+
},
|
|
37
|
+
tooltip,
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type ChartTooltipType = {
|
|
42
|
+
backgroundColor: string
|
|
43
|
+
bodyColor: string
|
|
44
|
+
titleFont: {
|
|
45
|
+
size: number
|
|
46
|
+
}
|
|
47
|
+
bodyFont: {
|
|
48
|
+
size: number
|
|
49
|
+
}
|
|
50
|
+
titleColor: string
|
|
51
|
+
displayColors: false
|
|
52
|
+
borderWidth: number
|
|
53
|
+
borderColor: string
|
|
54
|
+
cornerRadius: number
|
|
55
|
+
padding: number
|
|
56
|
+
footerFont: {
|
|
57
|
+
weight: string
|
|
58
|
+
}
|
|
59
|
+
animation: {
|
|
60
|
+
duration: number
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type ChartOptionsType = {
|
|
65
|
+
responsive: boolean
|
|
66
|
+
maintainAspectRatio: boolean
|
|
67
|
+
animation: {
|
|
68
|
+
duration: number
|
|
69
|
+
}
|
|
70
|
+
hover: {
|
|
71
|
+
animationDuration: number
|
|
72
|
+
}
|
|
73
|
+
plugins: {
|
|
74
|
+
legend: {
|
|
75
|
+
position: string
|
|
76
|
+
}
|
|
77
|
+
tooltip: ChartTooltipType
|
|
78
|
+
}
|
|
79
|
+
indexAxis?: string
|
|
80
|
+
cutout?: string
|
|
81
|
+
scales?: ChartScalesType
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
type ChartScalesType = {
|
|
85
|
+
y?: ChartScaleAxis
|
|
86
|
+
x?: ChartScaleAxis
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
type ChartScaleAxis = {
|
|
90
|
+
stacked?: boolean
|
|
91
|
+
position?: string
|
|
92
|
+
type?: string
|
|
93
|
+
min?: number
|
|
94
|
+
offset?: boolean
|
|
95
|
+
labels?: Array<string | number>
|
|
96
|
+
grid?: {
|
|
97
|
+
display: boolean
|
|
98
|
+
drawBorder: boolean
|
|
99
|
+
}
|
|
100
|
+
ticks?: {
|
|
101
|
+
fontSize?: number
|
|
102
|
+
padding?: number
|
|
103
|
+
maxRotation?: number
|
|
104
|
+
stepSize?: number
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export default chartConfig
|
|
@@ -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
|