@massimo-cassandro/minimo 1.4.2 → 1.4.3

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.
@@ -44,6 +44,8 @@ export function polarToCartesianString(degrees_angle, cx, cy, circleRadius) {
44
44
  return `${x},${y}`;
45
45
  }
46
46
 
47
+
48
+ // TODO unificare con classnames globale
47
49
  /**
48
50
  * Concatena i nomi delle classi filtrando i valori falsy.
49
51
  * @param {...any} args - I nomi delle classi o condizioni.
@@ -14,7 +14,8 @@ export function parseStdAxisOpts(params = {} ) {
14
14
  try {
15
15
 
16
16
 
17
-
17
+ // TODO eti_asseX_height e eti_asseY_width capire se è possibile inserire un calcolo dinamico delle dimensioni
18
+ // mettere quindi auto (o null) come default che innesci il calcolo automatico
18
19
  const parsed = {};
19
20
 
20
21
  // default
@@ -61,9 +62,11 @@ export function parseStdAxisOpts(params = {} ) {
61
62
  parsed.min_value = params.min_value;
62
63
  }
63
64
 
64
- const legenda_height = params.legenda.height?? 0;
65
+ const legenda_height = params.legenda?.height?? 0;
65
66
  const gap_legenda = legenda_height? 10 : 0; // spazio tra legenda e grafico
66
67
 
68
+ console.log(params.eti_asseY_width, params.ticksLength, params.padding);
69
+
67
70
  // =>> chart area
68
71
  // coordinate e dimensioni del rettangolo interno all'svg entro cui viene disegnato il grafico
69
72
  // i lati sx e inferiore corrispondono agli assi
@@ -220,9 +220,10 @@ export async function lines(params) {
220
220
 
221
221
  // =>> legenda
222
222
  // costruzione delle opzioni per la legenda
223
- const opts_legenda = {
223
+ if(params.legenda != null) {
224
+
225
+ params.legenda = {
224
226
 
225
- ...{
226
227
  /** altezza legenda */
227
228
  height: 20,
228
229
 
@@ -239,25 +240,26 @@ export async function lines(params) {
239
240
  'font-weight': 400
240
241
  },
241
242
  fontFilePath: null,
242
- },
243
243
 
244
- ...params.legenda
245
- };
246
244
 
247
- // legenda.items (elementi della legenda)
248
- // il ciclo viene eseguito su params.data_lines_attrs per essere certi che il numero di elementi coincida
249
- // è utilizzato in ordine inverso in modo che il primo elmento della legenda corrisponda alla linea in primo piano
250
- opts_legenda.items = params.data_lines_attrs.toReversed().map((line_attr, idx) => {
251
- const thisLegendaItem = params.legenda.items.toReversed()[idx]?? {};
252
- return {
253
- ...thisLegendaItem,
254
- shape: 'line',
255
- attrs: {
256
- ...(thisLegendaItem.attrs?? {}),
257
- ...line_attr
258
- }
245
+ ...(params.legenda??[])
259
246
  };
260
- });
247
+
248
+ // legenda.items (elementi della legenda)
249
+ // il ciclo viene eseguito su params.data_lines_attrs per essere certi che il numero di elementi coincida
250
+ // è utilizzato in ordine inverso in modo che il primo elmento della legenda corrisponda alla linea in primo piano
251
+ params.legenda.items = params.data_lines_attrs.toReversed().map((line_attr, idx) => {
252
+ const thisLegendaItem = params.legenda.items.toReversed()[idx]?? {};
253
+ return {
254
+ ...thisLegendaItem,
255
+ shape: 'line',
256
+ attrs: {
257
+ ...(thisLegendaItem.attrs?? {}),
258
+ ...line_attr
259
+ }
260
+ };
261
+ });
262
+ }
261
263
 
262
264
 
263
265
  // numero di step dell'asse X
@@ -281,7 +283,7 @@ export async function lines(params) {
281
283
  max_value: params.max_value,
282
284
  min_value: params.min_value,
283
285
  values: flatValues,
284
- legenda: opts_legenda,
286
+ legenda: params.legenda,
285
287
  padding: params.padding,
286
288
  width: params.width,
287
289
  height: params.height,
@@ -324,11 +326,15 @@ export async function lines(params) {
324
326
 
325
327
  lineDataArray.forEach((pointValue, pointIdx) => {
326
328
  // trasformazione valore in coordinate
329
+ // i valori null vengono ignorati
330
+
331
+ if(pointValue != null) {
327
332
 
328
- const x = chart_area.left + stepX_size * pointIdx,
329
- y = chart_area.top + chart_area.height - (((pointValue - min_value) * chart_area.height) / (max_value - min_value));
333
+ const x = chart_area.left + stepX_size * pointIdx,
334
+ y = chart_area.top + chart_area.height - (((pointValue - min_value) * chart_area.height) / (max_value - min_value));
330
335
 
331
- coords.push([x,y]);
336
+ coords.push([x,y]);
337
+ }
332
338
  });
333
339
 
334
340
  thisLineGroup.polyline(coords).attr(params.data_lines_attrs[idx]);
@@ -356,19 +362,21 @@ export async function lines(params) {
356
362
 
357
363
 
358
364
  // =>> Legenda
359
- const legendaEl = await legenda(chartInstance, opts_legenda);
360
- legendaEl.attr({ 'data-cfg.debug-info': params.debug? 'Legenda' : null });
361
- const legendaBbox = legendaEl.bbox();
365
+ if(params.legenda) {
366
+ const legendaEl = await legenda(chartInstance, params.legenda);
367
+ legendaEl.attr({ 'data-cfg.debug-info': params.debug? 'Legenda' : null });
368
+ const legendaBbox = legendaEl.bbox();
362
369
 
363
- legendaEl.dmove(
364
- (params.width - legendaBbox.width) / 2,
365
- params.padding
366
- );
367
- legendaEl.y(params.padding);
370
+ legendaEl.dmove(
371
+ (params.width - legendaBbox.width) / 2,
372
+ params.padding
373
+ );
374
+ legendaEl.y(params.padding);
368
375
 
369
- legendaEl.x((params.width - legendaBbox.width) / 2);
376
+ legendaEl.x((params.width - legendaBbox.width) / 2);
370
377
 
371
- svgCanvas.add(legendaEl);
378
+ svgCanvas.add(legendaEl);
379
+ }
372
380
 
373
381
 
374
382
  if(!params.container) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massimo-cassandro/minimo",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "description": "Light css framework & utilities",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/massimo-cassandro/minimo#readme",