@massimo-cassandro/minimo 1.18.4 → 1.19.1
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/README.md +5 -1
- package/design-tokens/{utilities/readme.md → README.md} +26 -16
- package/design-tokens/tokens/src/components/unsplash-page/unsplash-page.minimo.tokens.jsonc +69 -31
- package/design-tokens/{utilities/tokens-config-sample.mjs → tokens-config-sample.mjs} +18 -10
- package/design-tokens/utilities/build-tokens-src/config.mjs +5 -0
- package/design-tokens/utilities/build-tokens-src/formats/css.mjs +18 -2
- package/design-tokens/utilities/build-tokens-src/merge-css.mjs +60 -0
- package/design-tokens/utilities/build-tokens.mjs +12 -0
- package/dev-tools/README.md +8 -0
- package/dev-tools/starter-kit/starter-install.sh +46 -26
- package/package.json +6 -2
- package/snippets/error-pages/error-pages.js +3 -2
- package/src/components/unsplash-page/unsplash-page.minimo.tokens.mjs +78 -39
- package/src/components/unsplash-page/unsplash-page.module.css +25 -6
- package/src/custom-properties.css +8 -1
- package/src/minimo.css +1 -1
- package/src/web-components/s-datatable-component/s-datatable-component.js +4 -1
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/index.js +0 -92
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/hbars.js +0 -356
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/pie.js +0 -245
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/radial-bars.js +0 -177
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/rating-display.js +0 -835
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/settimanale-mensile-src/costruzione-assi.js +0 -212
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/settimanale-mensile-src/costruzione-linee.js +0 -101
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/settimanale-mensile-src/defaults.js +0 -185
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/settimanale-mensile-src/display-current.js +0 -27
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/settimanale-mensile-src/grid-areas.js +0 -129
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/settimanale-mensile-src/parse-opts.js +0 -64
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/settimanale-mensile-src/paths-setup.js +0 -73
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/settimanale-mensile.js +0 -126
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/signal-bars.js +0 -290
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/week-utils.js +0 -122
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/browser-test/src/hbars-test.js +0 -52
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/browser-test/src/mcn-test.js +0 -74
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/browser-test/src/pie-test.js +0 -16
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/browser-test/src/radial-bars-test.js +0 -48
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/browser-test/src/settimanale-mensile-dati-settimanale.js +0 -426
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/browser-test/src/settimanale-mensile-test.js +0 -260
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/browser-test/src/signal-bars-test.js +0 -64
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/node-test/node-test.mjs +0 -86
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/node-test/src/hBars-node-test.mjs +0 -40
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/node-test/src/lines-node-test.mjs +0 -73
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/node-test/src/mcn-node-test.mjs +0 -64
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/node-test/src/pie-node-test.mjs +0 -12
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/node-test/src/radialsBar-node-test.mjs +0 -44
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/node-test/src/settimanale-mensile-node-test.mjs +0 -258
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/node-test/src/signalBars-node-test.mjs +0 -36
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/test-readme.md +0 -24
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/textToPath-test.mjs +0 -14
- package/charts/TODO charts/???/InfoBox.js +0 -456
- package/charts/TODO charts/???/README-upg OLD/342/206/222NEW.md" +0 -53
- package/charts/TODO charts/???/README.md +0 -1
- package/charts/TODO charts/???/TODO.md +0 -39
- package/charts/TODO charts/???/base-cfg.js +0 -66
- package/charts/TODO charts/???/rating-displayOLD.js +0 -837
- package/charts/TODO charts/docs/TODO.md +0 -1
- package/charts/TODO charts/docs/costruzione display rating.md +0 -145
- package/charts/TODO charts/test/node-test.mjs +0 -92
- package/charts/TODO charts/test/test-readme.md +0 -23
- package/charts/TODO charts/test/test-src/rating-display-extra-test.js +0 -132
- package/charts/TODO charts/test/test-src/rating-display-test.js +0 -155
- package/charts/TODO charts/test/textToPath-test.mjs +0 -14
- package/charts/TODO.md +0 -7
- package/charts/src/node-helpers/TODO.md +0 -2
- package/dev-tools/starter-kit/TODO.md +0 -135
- package/src/components/TODO form-multiselect/form-multiselect.css +0 -40
- package/src/components/TODO form-multiselect/form-multiselect.js +0 -83
- package/src/components/TODO vanilla-cookie-consent/cookie-consent.css +0 -20
- package/src/components/TODO vanilla-cookie-consent/cookie-consent.js +0 -76
- package/src/components/TODO vanilla-cookie-consent/render-cookie-list.js +0 -32
- package/src/components/TODO vanilla-cookie-consent/src/cookie-list.js +0 -85
- package/src/components/TODO vanilla-cookie-consent/src/it-translation.js +0 -38
- package/src/components/TODO vanilla-cookie-consent/src/run-analytics.js +0 -54
- package/src/components/TODO vanilla-cookie-consent/src/run-recaptcha.js +0 -71
- package/src/components/autocomplete/TODO.md +0 -4
- package/src/web-components/TODO json-table/README.md +0 -67
- package/src/web-components/TODO json-table/TODO.md +0 -12
- package/src/web-components/TODO json-table/_work/OLD/docs/custom-props-list.md +0 -69
- package/src/web-components/TODO json-table/_work/OLD/script/create-css-custom-props-doc.mjs +0 -113
- package/src/web-components/TODO json-table/_work/OLD/script/src/custom-props-end.md +0 -4
- package/src/web-components/TODO json-table/_work/OLD/script/src/custom-props-start.md +0 -30
- package/src/web-components/TODO json-table/_work/OLD/src/css/icons.module.css +0 -22
- package/src/web-components/TODO json-table/_work/OLD/src/css/info.module.css +0 -42
- package/src/web-components/TODO json-table/_work/OLD/src/css/main-wrapper.module.css +0 -4
- package/src/web-components/TODO json-table/_work/OLD/src/css/table.module.css +0 -154
- package/src/web-components/TODO json-table/_work/OLD/src/css/utility.module.css +0 -9
- package/src/web-components/TODO json-table/_work/OLD/src/icons/false.svg +0 -1
- package/src/web-components/TODO json-table/_work/OLD/src/icons/search-arrows.svg +0 -1
- package/src/web-components/TODO json-table/_work/OLD/src/icons/true.svg +0 -1
- package/src/web-components/TODO json-table/_work/OLD/src/index.js +0 -56
- package/src/web-components/TODO json-table/_work/OLD/src/js/default-columns-data-types.js +0 -172
- package/src/web-components/TODO json-table/_work/OLD/src/js/defaults.js +0 -156
- package/src/web-components/TODO json-table/_work/OLD/src/js/info-section.js +0 -31
- package/src/web-components/TODO json-table/_work/OLD/src/js/listeners.js +0 -17
- package/src/web-components/TODO json-table/_work/OLD/src/js/main-builder.js +0 -26
- package/src/web-components/TODO json-table/_work/OLD/src/js/parse-params.js +0 -121
- package/src/web-components/TODO json-table/_work/OLD/src/js/set-column-classname.js +0 -22
- package/src/web-components/TODO json-table/_work/OLD/src/js/table-builder.js +0 -64
- package/src/web-components/TODO json-table/_work/OLD/src/js/table-foot.js +0 -8
- package/src/web-components/TODO json-table/_work/OLD/src/js/table-head.js +0 -47
- package/src/web-components/TODO json-table/_work/OLD/src/js/table-row.js +0 -83
- package/src/web-components/TODO json-table/_work/OLD/src/js/utilities.js +0 -5
- package/src/web-components/TODO json-table/_work/__json-table-react/index.js +0 -4
- package/src/web-components/TODO json-table/_work/__json-table-react/src/build-page-array.js +0 -73
- package/src/web-components/TODO json-table/_work/__json-table-react/src/columns-data-types.js +0 -73
- package/src/web-components/TODO json-table/_work/__json-table-react/src/defaults.js +0 -50
- package/src/web-components/TODO json-table/_work/__json-table-react/src/download-excel.js +0 -156
- package/src/web-components/TODO json-table/_work/__json-table-react/src/set-className.js +0 -19
- package/src/web-components/TODO json-table/_work/__json-table-react/src/set-download-filename.js +0 -17
- package/src/web-components/TODO json-table/_work/__json-table-react/src/table-to-csv.js +0 -48
- package/src/web-components/TODO json-table/_work/archived/table-to-csv.js +0 -48
- package/src/web-components/TODO json-table/_work/arrow.svg +0 -3
- package/src/web-components/TODO json-table/_work/da decidere/get-cell-data.js +0 -18
- package/src/web-components/TODO json-table/_work/download-button.js +0 -29
- package/src/web-components/TODO json-table/_work/download-excel.js +0 -155
- package/src/web-components/TODO json-table/_work/pagination-array-builder.js +0 -73
- package/src/web-components/TODO json-table/_work/pagination.js +0 -37
- package/src/web-components/TODO json-table/_work/set-download-filename.js +0 -19
- package/src/web-components/TODO json-table/_work/table-info.js +0 -24
- package/src/web-components/TODO json-table/demo/README.md +0 -66
- package/src/web-components/TODO json-table/demo/assets/link-simple.svg +0 -1
- package/src/web-components/TODO json-table/demo/demo-data/json-static-table-demo-data.js +0 -512
- package/src/web-components/TODO json-table/demo/demo.css +0 -32
- package/src/web-components/TODO json-table/demo/demo.js +0 -24
- package/src/web-components/TODO json-table/demo/js/demo-ajax-table.js +0 -165
- package/src/web-components/TODO json-table/demo/js/demo-static-table.js +0 -180
- package/src/web-components/TODO json-table/demo/webpack-modules/css-rules.mjs +0 -122
- package/src/web-components/TODO json-table/demo/webpack-modules/get-jsConfig-aliases.mjs +0 -33
- package/src/web-components/TODO json-table/demo/webpack-modules/svg-rules.mjs +0 -108
- package/src/web-components/TODO json-table/demo/webpack-modules/svgo.config.mjs +0 -26
- package/src/web-components/TODO json-table/demo/webpack.config.mjs +0 -333
- package/src/web-components/TODO json-table/docs/custom-props-list.md +0 -74
- package/src/web-components/TODO json-table/docs-builder/create-css-custom-props-doc.mjs +0 -157
- package/src/web-components/TODO json-table/docs-builder/src/custom-props-end.md +0 -6
- package/src/web-components/TODO json-table/docs-builder/src/custom-props-start.md +0 -29
- package/src/web-components/TODO json-table/src/TODO.md +0 -1
- package/src/web-components/TODO json-table/src/__json-table-react/build-page-array.js +0 -73
- package/src/web-components/TODO json-table/src/__json-table-react/columns-data-types.js +0 -73
- package/src/web-components/TODO json-table/src/__json-table-react/defaults.js +0 -50
- package/src/web-components/TODO json-table/src/__json-table-react/download-excel.js +0 -156
- package/src/web-components/TODO json-table/src/__json-table-react/set-className.js +0 -19
- package/src/web-components/TODO json-table/src/__json-table-react/set-download-filename.js +0 -17
- package/src/web-components/TODO json-table/src/__json-table-react/table-to-csv.js +0 -48
- package/src/web-components/TODO json-table/src/css/custom-media.css +0 -16
- package/src/web-components/TODO json-table/src/css/icons.module.css +0 -22
- package/src/web-components/TODO json-table/src/css/info-section.module.css +0 -78
- package/src/web-components/TODO json-table/src/css/main-builder.module.css +0 -6
- package/src/web-components/TODO json-table/src/css/table.module.css +0 -172
- package/src/web-components/TODO json-table/src/css/utility.module.css +0 -9
- package/src/web-components/TODO json-table/src/icons/arrow-down-bold.svg +0 -1
- package/src/web-components/TODO json-table/src/icons/false.svg +0 -1
- package/src/web-components/TODO json-table/src/icons/true.svg +0 -1
- package/src/web-components/TODO json-table/src/index.js +0 -125
- package/src/web-components/TODO json-table/src/js/default-columns-data-types.js +0 -172
- package/src/web-components/TODO json-table/src/js/defaults.js +0 -510
- package/src/web-components/TODO json-table/src/js/get-ajax-data.js +0 -72
- package/src/web-components/TODO json-table/src/js/info-section.js +0 -39
- package/src/web-components/TODO json-table/src/js/init-ajax-table.js +0 -30
- package/src/web-components/TODO json-table/src/js/init-static-table.js +0 -18
- package/src/web-components/TODO json-table/src/js/main-builder.js +0 -87
- package/src/web-components/TODO json-table/src/js/parse-data-row.js +0 -123
- package/src/web-components/TODO json-table/src/js/parse-params.js +0 -118
- package/src/web-components/TODO json-table/src/js/set-search-listener.js +0 -62
- package/src/web-components/TODO json-table/src/js/set-sort-listeners.js +0 -115
- package/src/web-components/TODO json-table/src/js/static-data-sorting.js +0 -23
- package/src/web-components/TODO json-table/src/js/table-builder.js +0 -45
- package/src/web-components/TODO json-table/src/js/table-row.js +0 -43
- package/src/web-components/TODO json-table/src/js/table-tfoot.js +0 -9
- package/src/web-components/TODO json-table/src/js/table-thead.js +0 -91
- package/src/web-components/TODO json-table/src/js/update-info.js +0 -42
- package/src/web-components/TODO json-table/src/js/utilities.js +0 -5
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export function pie({
|
|
3
|
-
|
|
4
|
-
/** container (selettore o elementio DOM), se null viene restituito il codice SVG */
|
|
5
|
-
container = null,
|
|
6
|
-
|
|
7
|
-
/** raggio del cerchio */
|
|
8
|
-
radius = 60,
|
|
9
|
-
|
|
10
|
-
/** raggio cerchio interno, da impostare nel caso si voglia creare un grafico a ciambella */
|
|
11
|
-
innerRadius = null,
|
|
12
|
-
|
|
13
|
-
/** valori da associare alle "fette" del grafico */
|
|
14
|
-
values = [],
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
array dei colori delle fette da associare ai corrispondenti valori in base al loro indice.
|
|
18
|
-
Impostare solo se non si vogliono usare i colori di default
|
|
19
|
-
*/
|
|
20
|
-
colors = null,
|
|
21
|
-
|
|
22
|
-
/** se false le classi vengono ignorate */
|
|
23
|
-
useClasses = false,
|
|
24
|
-
|
|
25
|
-
/** array di eventuali classi da associare ai corrispondenti valori in base al loro indice */
|
|
26
|
-
valClasses = null,
|
|
27
|
-
|
|
28
|
-
/** valore angolo (in gradi) da cui avviare il disegno */
|
|
29
|
-
startAt = 90,
|
|
30
|
-
|
|
31
|
-
/** verso del grafico */
|
|
32
|
-
clockwise = true,
|
|
33
|
-
|
|
34
|
-
/** se true, attiva l'animazione */ // NB non attivo
|
|
35
|
-
// animazione = false, // non implementato
|
|
36
|
-
|
|
37
|
-
/** frame per secondo dell'animazione */ // NB non attivo
|
|
38
|
-
// fps = 60
|
|
39
|
-
} = {}) {
|
|
40
|
-
|
|
41
|
-
// TODO animazione
|
|
42
|
-
const animazione = false;
|
|
43
|
-
|
|
44
|
-
try {
|
|
45
|
-
|
|
46
|
-
// colori forniti o di default
|
|
47
|
-
colors??= this.defaults.colors;
|
|
48
|
-
|
|
49
|
-
this.utils.parseContainer(container);
|
|
50
|
-
|
|
51
|
-
const svgCanvas = this.createSvgCanvas(container);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const isDonut = innerRadius != null
|
|
55
|
-
,donutWidth = radius - innerRadius
|
|
56
|
-
,baseColor = '#ccc' // colore neutro per gli elementi di sfondo
|
|
57
|
-
,circleCenter = { x: radius, y: radius }
|
|
58
|
-
|
|
59
|
-
// restituisce l'attributo `d` dell'arco di cerchio descritto dall'angolo
|
|
60
|
-
// corrispondente alla percentuale data e alle percentuali del punto finale
|
|
61
|
-
,generateAttrD = (params) => {
|
|
62
|
-
|
|
63
|
-
let d = [
|
|
64
|
-
`M${params.start.x},${params.start.y}`,
|
|
65
|
-
`A${radius},${radius}`,
|
|
66
|
-
0, //xAxisRotation,
|
|
67
|
-
(params.arcAngle <= 180 ? 0 : 1), // largeArcFlag
|
|
68
|
-
clockwise && params.arcAngle < 360? 1 : 0, // sweepFlag
|
|
69
|
-
`${params.end.x},${params.end.y}`,
|
|
70
|
-
...(isDonut? [] : [
|
|
71
|
-
`L${circleCenter.x},${circleCenter.y}`,
|
|
72
|
-
'Z'
|
|
73
|
-
])
|
|
74
|
-
].join(' ');
|
|
75
|
-
|
|
76
|
-
return d;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// CALCOLO PARAMETRI
|
|
80
|
-
,calcolaParametri = (perc, angolo_inizio) => {
|
|
81
|
-
|
|
82
|
-
let parametri = {};
|
|
83
|
-
|
|
84
|
-
// angolo corrispondente alla percentuale indicata
|
|
85
|
-
parametri.arcAngle = 360/100 * perc;
|
|
86
|
-
|
|
87
|
-
parametri.angolo_fine = clockwise? angolo_inizio - parametri.arcAngle :
|
|
88
|
-
angolo_inizio + parametri.arcAngle;
|
|
89
|
-
|
|
90
|
-
// questo non dovrebbe servire mai,
|
|
91
|
-
// ma potrebbe verificarsi per somma di arrotondamenti
|
|
92
|
-
angolo_inizio = angolo_inizio >= 360? Math.abs(360 - angolo_inizio) : angolo_inizio;
|
|
93
|
-
parametri.angolo_fine = parametri.angolo_fine >= 360? Math.abs(360 - parametri.angolo_fine) : parametri.angolo_fine;
|
|
94
|
-
|
|
95
|
-
if(perc === 100) {
|
|
96
|
-
angolo_inizio = 0;
|
|
97
|
-
parametri.angolo_fine = 359.9999;
|
|
98
|
-
|
|
99
|
-
} else if(perc === 0) {
|
|
100
|
-
parametri.angolo_fine = angolo_inizio;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// coordinate inizio e fine
|
|
104
|
-
parametri.start = this.utils.polarToCartesian(angolo_inizio, circleCenter, radius);
|
|
105
|
-
parametri.end = this.utils.polarToCartesian(parametri.angolo_fine, circleCenter, radius);
|
|
106
|
-
|
|
107
|
-
parametri.perc = perc; // serve per eliminare eventuali valori nulli
|
|
108
|
-
parametri.angolo_inizio = angolo_inizio; // per debug
|
|
109
|
-
|
|
110
|
-
// console.log(parametri);
|
|
111
|
-
|
|
112
|
-
return parametri;
|
|
113
|
-
}
|
|
114
|
-
;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
// determinazione sezioni della torta
|
|
119
|
-
let angolo_inizio = startAt; // angolo di partenza del grafico (viene aggiornato per ogni arco)
|
|
120
|
-
const totale = values.reduce((a,b) => a + b, 0),
|
|
121
|
-
pieSlices = values.map( (val, idx) => {
|
|
122
|
-
let params= calcolaParametri(val / totale * 100, angolo_inizio);
|
|
123
|
-
angolo_inizio = params.angolo_fine;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
// associazione colore e classe
|
|
127
|
-
params.color = colors? colors[idx] : null;
|
|
128
|
-
params.className = (valClasses != null && useClasses)? valClasses[idx]?? null : null;
|
|
129
|
-
|
|
130
|
-
return params;
|
|
131
|
-
}).filter(item => item.perc > 0);
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if(isDonut) {
|
|
135
|
-
svgCanvas.viewbox(-donutWidth/2, -donutWidth/2, radius * 2 + donutWidth, radius * 2 + donutWidth);
|
|
136
|
-
} else {
|
|
137
|
-
svgCanvas.viewbox(0, 0, radius * 2, radius * 2);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
svgCanvas.circle({
|
|
141
|
-
...(isDonut
|
|
142
|
-
? {'stroke-width': donutWidth, stroke: baseColor, fill: 'none'}
|
|
143
|
-
: {fill: baseColor}
|
|
144
|
-
),
|
|
145
|
-
cx: radius,
|
|
146
|
-
cy: radius,
|
|
147
|
-
r: radius
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
const sectionsGroup = svgCanvas.group(useClasses? {class: 'mChart-pie-sections-wrapper'}: {});
|
|
151
|
-
|
|
152
|
-
if(!animazione) {
|
|
153
|
-
|
|
154
|
-
pieSlices.forEach(params => {
|
|
155
|
-
sectionsGroup.path(generateAttrD(params))
|
|
156
|
-
.attr({
|
|
157
|
-
...(useClasses? {class: this.utils.classnames('mChart-pie-section', params.className)} : {}),
|
|
158
|
-
...(isDonut
|
|
159
|
-
? {'stroke-width': donutWidth, stroke: params.color, fill: 'none'}
|
|
160
|
-
: {fill: params.color}
|
|
161
|
-
)
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if(!container) {
|
|
167
|
-
return svgCanvas.svg();
|
|
168
|
-
}
|
|
169
|
-
} catch(e) {
|
|
170
|
-
console.error( 'AdaCharts → pie', e ); // eslint-disable-line
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
// TODO animazione
|
|
177
|
-
// if(animazione) {
|
|
178
|
-
|
|
179
|
-
// let idx = 0;
|
|
180
|
-
|
|
181
|
-
// const animazione_arco = () => {
|
|
182
|
-
|
|
183
|
-
// let animationRequest,
|
|
184
|
-
// parametri_arco=pieSlices[idx],
|
|
185
|
-
// arco, d, arco_path,
|
|
186
|
-
// this_perc = 0,
|
|
187
|
-
// start_timestamp = Date.now(),
|
|
188
|
-
// fine_animazione = false,
|
|
189
|
-
// elapsed, now,
|
|
190
|
-
// fps = fps,
|
|
191
|
-
// fpsInterval = 1000/fps;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
// const step = () => {
|
|
195
|
-
// now = Date.now();
|
|
196
|
-
// elapsed = now - start_timestamp;
|
|
197
|
-
|
|
198
|
-
// if((this_perc >= parametri_arco.perc) ) {
|
|
199
|
-
// this_perc = parametri_arco.perc;
|
|
200
|
-
// fine_animazione = true;
|
|
201
|
-
// }
|
|
202
|
-
|
|
203
|
-
// // request another frame
|
|
204
|
-
// animationRequest = window.requestAnimationFrame(step);
|
|
205
|
-
|
|
206
|
-
// // if enough time has elapsed, draw the next frame
|
|
207
|
-
// if (elapsed > fpsInterval) {
|
|
208
|
-
|
|
209
|
-
// // Get ready for next frame by setting start_timestamp=now, but...
|
|
210
|
-
// // Also, adjust for fpsInterval not being multiple of 16.67
|
|
211
|
-
// start_timestamp = now - (elapsed % fpsInterval);
|
|
212
|
-
|
|
213
|
-
// if( this_perc === 0 ) {
|
|
214
|
-
// arco = generateArcPathTag(
|
|
215
|
-
// calcolaParametri(0, parametri_arco.angolo_inizio),
|
|
216
|
-
// colors[idx]
|
|
217
|
-
// );
|
|
218
|
-
// chart_container.insertAdjacentHTML('afterbegin', arco.chart_segment );
|
|
219
|
-
// arco_path = chart_container.querySelector(`.chart-arc.item-${idx}`);
|
|
220
|
-
|
|
221
|
-
// } else {
|
|
222
|
-
// arco = calcolaParametri(this_perc, parametri_arco.angolo_inizio);
|
|
223
|
-
// d = generateAttrD(arco);
|
|
224
|
-
// arco_path.setAttribute('d', d);
|
|
225
|
-
// }
|
|
226
|
-
|
|
227
|
-
// if(fine_animazione) {
|
|
228
|
-
// window.cancelAnimationFrame(animationRequest);
|
|
229
|
-
// idx++;
|
|
230
|
-
// if(idx < pieSlices.length) {
|
|
231
|
-
// animazione_arco();
|
|
232
|
-
// }
|
|
233
|
-
// } else {
|
|
234
|
-
// this_perc++;
|
|
235
|
-
// }
|
|
236
|
-
// }
|
|
237
|
-
|
|
238
|
-
// };// end step
|
|
239
|
-
|
|
240
|
-
// step();
|
|
241
|
-
// }; // end animazione_arco
|
|
242
|
-
|
|
243
|
-
// animazione_arco();
|
|
244
|
-
|
|
245
|
-
// } // end if animazione
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
// radial bars
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export async function radialBars({
|
|
5
|
-
container = null, // container (selettore o elemento)
|
|
6
|
-
svgClassName = null,
|
|
7
|
-
gap = 5, // px
|
|
8
|
-
strokeWidth = 20, // px
|
|
9
|
-
clockwise = true,
|
|
10
|
-
start = 'bottom', // bottom | top
|
|
11
|
-
circleRadius = null, // se null è calcolato dalla larghezza del container
|
|
12
|
-
|
|
13
|
-
barClassName = null, // classe per le barre (solo web)
|
|
14
|
-
barStrokeLinecap = 'round', // bars stroke-linecap (round, butt, square)
|
|
15
|
-
barColors = null, // array di colori per le barre, se non presente vengono utilizzati i colori di default
|
|
16
|
-
|
|
17
|
-
labelsClassName = null, // classe per tutte le etichette
|
|
18
|
-
labelsFillColor = null, // fill per tutte le etichette, se null viene usato il colore impostato in `data`
|
|
19
|
-
labelsFontFilePath = null, // percorso font per textToPath
|
|
20
|
-
labelsFont = null, // obj || null, -> oggetto analogo a this.defaults.font
|
|
21
|
-
|
|
22
|
-
data = [],
|
|
23
|
-
|
|
24
|
-
debug = false, // draws a circle under each bar
|
|
25
|
-
} = {}) {
|
|
26
|
-
|
|
27
|
-
const bars_data_defaults = {
|
|
28
|
-
label : '_label_',
|
|
29
|
-
labelFillColor : '#000', // se null viene utilizzato il valore globale `labelFillColor` o, se `null` quello della barra
|
|
30
|
-
barFillColor : null, // fill specifico per la barra
|
|
31
|
-
barStrokeColor : null, // stroke specifico per la barra, bypassa il valore di barColors
|
|
32
|
-
value : 0,
|
|
33
|
-
|
|
34
|
-
barClassName : null, // optional extra class for bar
|
|
35
|
-
labelClassName : null // optional extra class for label
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
data = (data?? []).map(item => { return {...bars_data_defaults, ...item}; });
|
|
39
|
-
|
|
40
|
-
barColors??= this.defaults.colors;
|
|
41
|
-
labelsFont = {...this.defaults.font, ...(labelsFont??{}) };
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
|
|
45
|
-
if(['top', 'bottom'].indexOf(start) === -1) {
|
|
46
|
-
throw 'The `start` option must be `top` or `bottom`';
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
let [, width, height] = this.utils.parseContainer(container);
|
|
50
|
-
|
|
51
|
-
if(circleRadius) {
|
|
52
|
-
width = height = circleRadius * 2;
|
|
53
|
-
|
|
54
|
-
} else if (width) {
|
|
55
|
-
circleRadius??= width / 2;
|
|
56
|
-
|
|
57
|
-
} else {
|
|
58
|
-
throw 'Devi specificare almeno uno tra `container` e `circleRadius`';
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const viewBox = [
|
|
62
|
-
-strokeWidth / 2,
|
|
63
|
-
-strokeWidth / 2,
|
|
64
|
-
circleRadius * 2 + strokeWidth,
|
|
65
|
-
circleRadius * 2 + strokeWidth
|
|
66
|
-
].join(' ');
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const svgCanvas = this.createSvgCanvas(container)
|
|
70
|
-
.size(width, height)
|
|
71
|
-
.viewbox(viewBox)
|
|
72
|
-
.attr({
|
|
73
|
-
class: this.utils.classnamesNull('radial-bars-chart', svgClassName)
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
if(!this.textToPath) {
|
|
77
|
-
svgCanvas.css('--stroke-width', strokeWidth + 'px');
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const start_angle = start === 'bottom'? 270 : 90,
|
|
82
|
-
max_value = Math.max(...data.map(i => i.value)),
|
|
83
|
-
center = {
|
|
84
|
-
x: circleRadius,
|
|
85
|
-
y: circleRadius
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
for await (const [idx, item] of data.entries()) {
|
|
89
|
-
|
|
90
|
-
const barGroup = svgCanvas.group()
|
|
91
|
-
.attr({'data-debug-info': debug? `radial-bars: gruppo ${idx}` : null})
|
|
92
|
-
|
|
93
|
-
,radius = circleRadius - (idx * (strokeWidth + gap))
|
|
94
|
-
,thisBarColor = barColors[idx]?? '#ccc'
|
|
95
|
-
;
|
|
96
|
-
|
|
97
|
-
// guide
|
|
98
|
-
if(debug) {
|
|
99
|
-
barGroup.circle()
|
|
100
|
-
.attr({
|
|
101
|
-
'data-debug-info': debug? `radial-bars: guida ${idx}` : null,
|
|
102
|
-
cx: center.x,
|
|
103
|
-
cy: center.y,
|
|
104
|
-
r : radius,
|
|
105
|
-
// 'stroke-width': strokeWidth,
|
|
106
|
-
// stroke: 'hsla(208, 18%, 80%, 0.302)',
|
|
107
|
-
'stroke-width': '.5px',
|
|
108
|
-
stroke: '#f104ed',
|
|
109
|
-
fill: 'none'
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
} // end if(debug)
|
|
113
|
-
|
|
114
|
-
// bar
|
|
115
|
-
barGroup.path(this.utils.calcAttrD({
|
|
116
|
-
start_angle : start_angle,
|
|
117
|
-
percentage : item.value / max_value,
|
|
118
|
-
max_arc : 270,
|
|
119
|
-
center : center,
|
|
120
|
-
radius : radius,
|
|
121
|
-
clockwise : clockwise
|
|
122
|
-
}))
|
|
123
|
-
.attr({
|
|
124
|
-
'data-debug-info' : debug? `radial-bars: barra ${idx}` : null,
|
|
125
|
-
'stroke-width' : strokeWidth,
|
|
126
|
-
fill : item.barFillColor?? 'none',
|
|
127
|
-
'stroke-linecap' : barStrokeLinecap,
|
|
128
|
-
stroke : item.barStrokeColor?? thisBarColor,
|
|
129
|
-
class: this.utils.classnamesNull(barClassName,item.barClassName)
|
|
130
|
-
})
|
|
131
|
-
;
|
|
132
|
-
|
|
133
|
-
// label
|
|
134
|
-
let text_align = 'start',
|
|
135
|
-
text_margin = 20;
|
|
136
|
-
|
|
137
|
-
if((start === 'top' && clockwise) || (start === 'bottom' && !clockwise)) {
|
|
138
|
-
text_align = 'end';
|
|
139
|
-
text_margin = -20;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const [label_bbox, labelEl] = await this.createTextEl ({
|
|
143
|
-
text: item.label,
|
|
144
|
-
textFill: item.labelFillColor?? labelsFillColor,
|
|
145
|
-
fontAttr: labelsFont,
|
|
146
|
-
fontFilePath: labelsFontFilePath,
|
|
147
|
-
parentElement: barGroup
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
labelEl
|
|
151
|
-
.move(
|
|
152
|
-
circleRadius + text_margin,
|
|
153
|
-
start === 'top'
|
|
154
|
-
? idx * (strokeWidth + gap)
|
|
155
|
-
: (circleRadius * 2 - idx * (strokeWidth + gap)) - label_bbox.height / 2
|
|
156
|
-
)
|
|
157
|
-
.attr({
|
|
158
|
-
'text-anchor': !this.textToPath? text_align : null,
|
|
159
|
-
// 'dominant-baseline': !this.textToPath? 'middle': null,
|
|
160
|
-
|
|
161
|
-
class: this.utils.classnamesNull(labelsClassName, item.labelClassName)
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
if(start === 'top') {
|
|
165
|
-
labelEl.dy(-label_bbox.height / 2);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
} // end for await data
|
|
169
|
-
|
|
170
|
-
if(!container) {
|
|
171
|
-
return svgCanvas.svg();
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
} catch(e) {
|
|
175
|
-
console.error( 'AdaCharts → radialBars', e ); // eslint-disable-line
|
|
176
|
-
}
|
|
177
|
-
}
|