@widergy/energy-ui 3.112.1 → 3.114.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/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ ## [3.114.1](https://github.com/widergy/energy-ui/compare/v3.114.0...v3.114.1) (2025-10-30)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * [COLB-96] schema refactor ([#708](https://github.com/widergy/energy-ui/issues/708)) ([70e4056](https://github.com/widergy/energy-ui/commit/70e40564e129988c5c6512651465d6f5b0b06695))
7
+
8
+ # [3.114.0](https://github.com/widergy/energy-ui/compare/v3.113.0...v3.114.0) (2025-10-30)
9
+
10
+
11
+ ### Features
12
+
13
+ * [COLB-100] legends utgraph ([#707](https://github.com/widergy/energy-ui/issues/707)) ([bfa9d41](https://github.com/widergy/energy-ui/commit/bfa9d4174b8e68de2d731f448a7eb32e399aa90b))
14
+
15
+ # [3.113.0](https://github.com/widergy/energy-ui/compare/v3.112.1...v3.113.0) (2025-10-30)
16
+
17
+
18
+ ### Features
19
+
20
+ * [COLB-101] tabs + resizing utgraph ([#706](https://github.com/widergy/energy-ui/issues/706)) ([d2d9bb6](https://github.com/widergy/energy-ui/commit/d2d9bb62e3850ad22ddfe4f878462663a7727eb1))
21
+
1
22
  ## [3.112.1](https://github.com/widergy/energy-ui/compare/v3.112.0...v3.112.1) (2025-10-30)
2
23
 
3
24
 
@@ -8,6 +8,6 @@ import * as UTGraphStories from './UTGraph.stories';
8
8
 
9
9
  <Description of={UTGraphStories} />
10
10
 
11
- <Canvas of={UTGraphStories.Default} withToolbar name="UTGraph" />
11
+ <Canvas of={UTGraphStories.BarAndLineChart} withToolbar name="UTGraph" />
12
12
 
13
13
  <ArgTypes />
@@ -4,92 +4,175 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = exports.DualAxisChart = exports.BarAndLineChart = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
7
8
  var _reportSchema = _interopRequireDefault(require("./report.schema.json"));
8
9
  var _ = _interopRequireDefault(require("."));
9
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
11
  const BarAndLineChartData = {
11
12
  meta: {
13
+ id: 1,
12
14
  code: 'economico',
13
- enabled: true,
14
- report_type: 'chart',
15
- tabs: [{
15
+ chart_layout: 'cartesian',
16
+ chart_tabs: [{
17
+ id: 1,
16
18
  code: 'economico',
17
- name: 'Económico',
18
- icon: 'IconFilePlus',
19
+ order: 1,
20
+ name: 'Porcentaje de carga por mes',
21
+ tooltip: 'Este es el porcentaje de carga por mes, el cual se refiere a la cantidad de carga que se consume en un mes',
22
+ icon: 'IconPercentage',
19
23
  orientation: 'horizontal',
20
- mainAxis: {
24
+ domain: {
21
25
  binding: 'categorical'
22
26
  },
23
- crossAxes: {
27
+ ranges: {
24
28
  left: {
25
29
  label: 'Monto',
26
30
  unit: '$'
27
31
  }
28
32
  },
29
- subitems_catalog: [[{
30
- name: 'Item A',
33
+ subitems: [[{
34
+ name: 'Barra izq stack 1',
35
+ type: 'bar',
36
+ range: 'left',
37
+ bindings: {
38
+ range: 'a'
39
+ }
40
+ }, {
41
+ name: 'Barra izq stack 2',
42
+ type: 'bar',
43
+ range: 'left',
44
+ bindings: {
45
+ range: 'b'
46
+ }
47
+ }, {
48
+ name: 'Año actual',
49
+ type: 'line',
50
+ range: 'left',
51
+ bindings: {
52
+ range: 'f'
53
+ }
54
+ }], [{
55
+ name: 'Barra der stack 1',
56
+ type: 'bar',
57
+ range: 'left',
58
+ bindings: {
59
+ range: 'c'
60
+ }
61
+ }, {
62
+ name: 'Barra der stack 2',
63
+ type: 'bar',
64
+ range: 'left',
65
+ bindings: {
66
+ range: 'd'
67
+ }
68
+ }, {
69
+ name: 'Barra der stack 3',
31
70
  type: 'bar',
32
- crossAxis: 'left',
71
+ range: 'left',
72
+ bindings: {
73
+ range: 'e'
74
+ }
75
+ }, {
76
+ name: 'Año anterior stack 1',
77
+ type: 'line',
78
+ range: 'left',
79
+ bindings: {
80
+ range: 'g'
81
+ }
82
+ }, {
83
+ name: 'Año anterior stack 2',
84
+ type: 'line',
85
+ range: 'left',
86
+ bindings: {
87
+ range: 'h'
88
+ }
89
+ }]]
90
+ }, {
91
+ id: 2,
92
+ code: 'consumo',
93
+ order: 2,
94
+ name: 'Consumo de carga por mes',
95
+ tooltip: 'Este es el consumo de carga por mes, el cual se refiere a la cantidad de carga que se consume en un mes',
96
+ icon: 'IconLetterN',
97
+ orientation: 'horizontal',
98
+ domain: {
99
+ binding: 'categorical'
100
+ },
101
+ ranges: {
102
+ left: {
103
+ label: 'Monto',
104
+ unit: '$'
105
+ }
106
+ },
107
+ subitems: [[{
108
+ name: 'Item A',
109
+ type: 'line',
110
+ range: 'left',
33
111
  bindings: {
34
- crossAxis: 'a'
112
+ range: 'a'
35
113
  }
36
114
  }, {
37
115
  name: 'Item B',
38
116
  type: 'bar',
39
- crossAxis: 'left',
117
+ range: 'left',
40
118
  bindings: {
41
- crossAxis: 'b'
119
+ range: 'b'
42
120
  }
43
121
  }, {
44
122
  name: 'Item F',
45
- type: 'line',
46
- crossAxis: 'left',
123
+ type: 'bar',
124
+ range: 'left',
47
125
  bindings: {
48
- crossAxis: 'f'
126
+ range: 'f'
49
127
  }
50
128
  }], [{
51
129
  name: 'Item C',
52
- type: 'bar',
53
- crossAxis: 'left',
130
+ type: 'line',
131
+ range: 'left',
54
132
  bindings: {
55
- crossAxis: 'c'
133
+ range: 'c'
56
134
  }
57
135
  }, {
58
136
  name: 'Item D',
59
- type: 'bar',
60
- crossAxis: 'left',
137
+ type: 'line',
138
+ range: 'left',
61
139
  bindings: {
62
- crossAxis: 'd'
140
+ range: 'd'
63
141
  }
64
142
  }, {
65
143
  name: 'Item E',
66
144
  type: 'bar',
67
- crossAxis: 'left',
145
+ range: 'left',
68
146
  bindings: {
69
- crossAxis: 'e'
147
+ range: 'e'
70
148
  }
71
149
  }, {
72
150
  name: 'Item G',
73
- type: 'line',
74
- crossAxis: 'left',
151
+ type: 'bar',
152
+ range: 'left',
75
153
  bindings: {
76
- crossAxis: 'g'
154
+ range: 'g'
77
155
  }
78
156
  }, {
79
157
  name: 'Item H',
80
- type: 'line',
81
- crossAxis: 'left',
158
+ type: 'bar',
159
+ range: 'left',
82
160
  bindings: {
83
- crossAxis: 'h'
161
+ range: 'h'
84
162
  }
85
163
  }]]
86
- }]
164
+ }],
165
+ configuration: {
166
+ cartesianPlane: {
167
+ rangeLeftTicks: 8
168
+ }
169
+ }
87
170
  },
88
171
  datasets: [{
89
172
  code: 'economico',
90
- mainAxis: [{
91
- name: 'Ene',
92
- subitems: [{
173
+ domain: [{
174
+ domain_value: 'Ene',
175
+ concepts: [{
93
176
  code: 'a',
94
177
  value: 30
95
178
  }, {
@@ -115,8 +198,8 @@ const BarAndLineChartData = {
115
198
  value: 200
116
199
  }]
117
200
  }, {
118
- name: 'Feb',
119
- subitems: [{
201
+ domain_value: 'Feb',
202
+ concepts: [{
120
203
  code: 'a',
121
204
  value: 42
122
205
  }, {
@@ -142,8 +225,8 @@ const BarAndLineChartData = {
142
225
  value: 230
143
226
  }]
144
227
  }, {
145
- name: 'Mar',
146
- subitems: [{
228
+ domain_value: 'Mar',
229
+ concepts: [{
147
230
  code: 'a',
148
231
  value: 60
149
232
  }, {
@@ -169,8 +252,8 @@ const BarAndLineChartData = {
169
252
  value: 300
170
253
  }]
171
254
  }, {
172
- name: 'Abr',
173
- subitems: [{
255
+ domain_value: 'Abr',
256
+ concepts: [{
174
257
  code: 'a',
175
258
  value: 80
176
259
  }, {
@@ -196,8 +279,8 @@ const BarAndLineChartData = {
196
279
  value: 270
197
280
  }]
198
281
  }, {
199
- name: 'May',
200
- subitems: [{
282
+ domain_value: 'May',
283
+ concepts: [{
201
284
  code: 'a',
202
285
  value: 120
203
286
  }, {
@@ -223,8 +306,8 @@ const BarAndLineChartData = {
223
306
  value: 280
224
307
  }]
225
308
  }, {
226
- name: 'Jun',
227
- subitems: [{
309
+ domain_value: 'Jun',
310
+ concepts: [{
228
311
  code: 'a',
229
312
  value: 150
230
313
  }, {
@@ -250,8 +333,8 @@ const BarAndLineChartData = {
250
333
  value: 220
251
334
  }]
252
335
  }, {
253
- name: 'Jul',
254
- subitems: [{
336
+ domain_value: 'Jul',
337
+ concepts: [{
255
338
  code: 'a',
256
339
  value: 150
257
340
  }, {
@@ -277,22 +360,216 @@ const BarAndLineChartData = {
277
360
  value: 200
278
361
  }]
279
362
  }]
363
+ }, {
364
+ code: 'consumo',
365
+ domain: [{
366
+ domain_value: 'Ene',
367
+ concepts: [{
368
+ code: 'a',
369
+ value: 30
370
+ }, {
371
+ code: 'b',
372
+ value: 55
373
+ }, {
374
+ code: 'c',
375
+ value: 42
376
+ }, {
377
+ code: 'd',
378
+ value: 60
379
+ }, {
380
+ code: 'e',
381
+ value: 75
382
+ }, {
383
+ code: 'f',
384
+ value: 200
385
+ }, {
386
+ code: 'g',
387
+ value: 200
388
+ }, {
389
+ code: 'h',
390
+ value: 200
391
+ }]
392
+ }, {
393
+ domain_value: 'Feb',
394
+ concepts: [{
395
+ code: 'a',
396
+ value: 42
397
+ }, {
398
+ code: 'b',
399
+ value: 60
400
+ }, {
401
+ code: 'c',
402
+ value: 75
403
+ }, {
404
+ code: 'd',
405
+ value: 90
406
+ }, {
407
+ code: 'e',
408
+ value: 105
409
+ }, {
410
+ code: 'f',
411
+ value: 200
412
+ }, {
413
+ code: 'g',
414
+ value: 200
415
+ }, {
416
+ code: 'h',
417
+ value: 200
418
+ }]
419
+ }, {
420
+ domain_value: 'Mar',
421
+ concepts: [{
422
+ code: 'a',
423
+ value: 60
424
+ }, {
425
+ code: 'b',
426
+ value: 80
427
+ }, {
428
+ code: 'c',
429
+ value: 95
430
+ }, {
431
+ code: 'd',
432
+ value: 110
433
+ }, {
434
+ code: 'e',
435
+ value: 125
436
+ }, {
437
+ code: 'f',
438
+ value: 200
439
+ }, {
440
+ code: 'g',
441
+ value: 200
442
+ }, {
443
+ code: 'h',
444
+ value: 200
445
+ }]
446
+ }, {
447
+ domain_value: 'Abr',
448
+ concepts: [{
449
+ code: 'a',
450
+ value: 80
451
+ }, {
452
+ code: 'b',
453
+ value: 120
454
+ }, {
455
+ code: 'c',
456
+ value: 135
457
+ }, {
458
+ code: 'd',
459
+ value: 150
460
+ }, {
461
+ code: 'e',
462
+ value: 165
463
+ }, {
464
+ code: 'f',
465
+ value: 200
466
+ }, {
467
+ code: 'g',
468
+ value: 200
469
+ }, {
470
+ code: 'h',
471
+ value: 200
472
+ }]
473
+ }, {
474
+ domain_value: 'May',
475
+ concepts: [{
476
+ code: 'a',
477
+ value: 120
478
+ }, {
479
+ code: 'b',
480
+ value: 150
481
+ }, {
482
+ code: 'c',
483
+ value: 165
484
+ }, {
485
+ code: 'd',
486
+ value: 180
487
+ }, {
488
+ code: 'e',
489
+ value: 195
490
+ }, {
491
+ code: 'f',
492
+ value: 200
493
+ }, {
494
+ code: 'g',
495
+ value: 200
496
+ }, {
497
+ code: 'h',
498
+ value: 200
499
+ }]
500
+ }, {
501
+ domain_value: 'Jun',
502
+ concepts: [{
503
+ code: 'a',
504
+ value: 150
505
+ }, {
506
+ code: 'b',
507
+ value: 200
508
+ }, {
509
+ code: 'c',
510
+ value: 215
511
+ }, {
512
+ code: 'd',
513
+ value: 230
514
+ }, {
515
+ code: 'e',
516
+ value: 245
517
+ }, {
518
+ code: 'f',
519
+ value: 200
520
+ }, {
521
+ code: 'g',
522
+ value: 200
523
+ }, {
524
+ code: 'h',
525
+ value: 200
526
+ }]
527
+ }, {
528
+ domain_value: 'Jul',
529
+ concepts: [{
530
+ code: 'a',
531
+ value: 150
532
+ }, {
533
+ code: 'b',
534
+ value: 200
535
+ }, {
536
+ code: 'c',
537
+ value: 215
538
+ }, {
539
+ code: 'd',
540
+ value: 230
541
+ }, {
542
+ code: 'e',
543
+ value: 245
544
+ }, {
545
+ code: 'f',
546
+ value: 200
547
+ }, {
548
+ code: 'g',
549
+ value: 200
550
+ }, {
551
+ code: 'h',
552
+ value: 200
553
+ }]
554
+ }]
280
555
  }]
281
556
  };
282
557
  const DualAxisChartData = {
283
558
  meta: {
559
+ id: 2,
284
560
  code: 'consumo',
285
- enabled: true,
286
- report_type: 'chart',
287
- tabs: [{
561
+ chart_layout: 'cartesian',
562
+ chart_tabs: [{
563
+ id: 1,
288
564
  code: 'consumo',
565
+ order: 1,
289
566
  name: 'Consumo',
290
- icon: 'IconFilePlus',
567
+ icon: 'IconPercentage',
291
568
  orientation: 'horizontal',
292
- mainAxis: {
569
+ domain: {
293
570
  binding: 'categorical'
294
571
  },
295
- crossAxes: {
572
+ ranges: {
296
573
  left: {
297
574
  label: 'Monto',
298
575
  unit: '$'
@@ -302,28 +579,33 @@ const DualAxisChartData = {
302
579
  unit: 'kW'
303
580
  }
304
581
  },
305
- subitems_catalog: [[{
582
+ subitems: [[{
306
583
  name: 'Item A',
307
584
  type: 'bar',
308
- crossAxis: 'left',
585
+ range: 'left',
309
586
  bindings: {
310
- crossAxis: 'a'
587
+ range: 'a'
311
588
  }
312
589
  }, {
313
590
  name: 'Item B',
314
591
  type: 'line',
315
- crossAxis: 'right',
592
+ range: 'right',
316
593
  bindings: {
317
- crossAxis: 'b'
594
+ range: 'b'
318
595
  }
319
596
  }]]
320
- }]
597
+ }],
598
+ configuration: {
599
+ cartesianPlane: {
600
+ rangeRightTicks: 6
601
+ }
602
+ }
321
603
  },
322
604
  datasets: [{
323
605
  code: 'consumo',
324
- mainAxis: [{
325
- name: 'Ene',
326
- subitems: [{
606
+ domain: [{
607
+ domain_value: 'Ene',
608
+ concepts: [{
327
609
  code: 'a',
328
610
  value: 30
329
611
  }, {
@@ -331,8 +613,8 @@ const DualAxisChartData = {
331
613
  value: 550
332
614
  }]
333
615
  }, {
334
- name: 'Feb',
335
- subitems: [{
616
+ domain_value: 'Feb',
617
+ concepts: [{
336
618
  code: 'a',
337
619
  value: 42
338
620
  }, {
@@ -340,8 +622,8 @@ const DualAxisChartData = {
340
622
  value: 600
341
623
  }]
342
624
  }, {
343
- name: 'Mar',
344
- subitems: [{
625
+ domain_value: 'Mar',
626
+ concepts: [{
345
627
  code: 'a',
346
628
  value: 60
347
629
  }, {
@@ -349,8 +631,8 @@ const DualAxisChartData = {
349
631
  value: 800
350
632
  }]
351
633
  }, {
352
- name: 'Abr',
353
- subitems: [{
634
+ domain_value: 'Abr',
635
+ concepts: [{
354
636
  code: 'a',
355
637
  value: 80
356
638
  }, {
@@ -358,8 +640,8 @@ const DualAxisChartData = {
358
640
  value: 1200
359
641
  }]
360
642
  }, {
361
- name: 'May',
362
- subitems: [{
643
+ domain_value: 'May',
644
+ concepts: [{
363
645
  code: 'a',
364
646
  value: 120
365
647
  }, {
@@ -367,8 +649,8 @@ const DualAxisChartData = {
367
649
  value: 1500
368
650
  }]
369
651
  }, {
370
- name: 'Jun',
371
- subitems: [{
652
+ domain_value: 'Jun',
653
+ concepts: [{
372
654
  code: 'a',
373
655
  value: 150
374
656
  }, {
@@ -376,8 +658,8 @@ const DualAxisChartData = {
376
658
  value: 2000
377
659
  }]
378
660
  }, {
379
- name: 'Jul',
380
- subitems: [{
661
+ domain_value: 'Jul',
662
+ concepts: [{
381
663
  code: 'a',
382
664
  value: 150
383
665
  }, {
@@ -390,6 +672,12 @@ const DualAxisChartData = {
390
672
  var _default = exports.default = {
391
673
  title: 'UTGraph',
392
674
  component: _.default,
675
+ render: args => /*#__PURE__*/_react.default.createElement("div", {
676
+ style: {
677
+ width: '100%',
678
+ height: 600
679
+ }
680
+ }, /*#__PURE__*/_react.default.createElement(_.default, args)),
393
681
  parameters: {
394
682
  jsonschema: {
395
683
  schema: _reportSchema.default
@@ -22,16 +22,16 @@ const Bars = _ref => {
22
22
  color
23
23
  } = _ref;
24
24
  const clusterScale = (0, _react.useMemo)(() => {
25
- const count = tab.subitems_catalog.length;
25
+ const count = tab.subitems.length;
26
26
  return d3.scaleBand().domain(d3.range(count)).range([0, mainAxis.bandwidth()]).padding(0.15);
27
27
  }, [tab, mainAxis]);
28
28
  const valuesByCategory = (0, _react.useMemo)(() => (0, _utils.getValuesMapByCategory)(dataset), [dataset]);
29
29
  return /*#__PURE__*/_react.default.createElement("g", null, mainAxisDomain.map(category => {
30
30
  const categoryXPosition = mainAxis(category);
31
31
  const valuesByCode = valuesByCategory.get(category);
32
- return tab.subitems_catalog.map((cluster, clusterIndex) => {
33
- const leftCodes = cluster.filter(series => series.type === _constants.BAR_TYPE && (series.crossAxis || _constants.LEFT_SIDE) === _constants.LEFT_SIDE).map(series => series.bindings.crossAxis);
34
- const rightCodes = cluster.filter(series => series.type === _constants.BAR_TYPE && (series.crossAxis || _constants.RIGHT_SIDE) === _constants.RIGHT_SIDE).map(series => series.bindings.crossAxis);
32
+ return tab.subitems.map((cluster, clusterIndex) => {
33
+ const leftCodes = cluster.filter(series => series.type === _constants.BAR_TYPE && (series.range || _constants.LEFT_SIDE) === _constants.LEFT_SIDE).map(series => series.bindings.range);
34
+ const rightCodes = cluster.filter(series => series.type === _constants.BAR_TYPE && (series.range || _constants.RIGHT_SIDE) === _constants.RIGHT_SIDE).map(series => series.bindings.range);
35
35
  if (leftCodes.length === 0 && rightCodes.length === 0) return null;
36
36
  const x = categoryXPosition + clusterScale(clusterIndex);
37
37
  const w = clusterScale.bandwidth();
@@ -17,8 +17,10 @@ const CartesianPlane = _ref => {
17
17
  width,
18
18
  height,
19
19
  margin,
20
- crossAxisTicks,
21
- crossAxisTickFormat,
20
+ crossAxisLeftTicks,
21
+ crossAxisLeftTickFormat,
22
+ crossAxisRightTicks,
23
+ crossAxisRightTickFormat,
22
24
  mainAxisTicks,
23
25
  mainAxisTickFormat,
24
26
  hasLeft,
@@ -42,18 +44,19 @@ const CartesianPlane = _ref => {
42
44
  }, [mainAxis, mainAxisTicks, mainAxisTickFormat]);
43
45
  (0, _react.useEffect)(() => {
44
46
  if (!hasLeft) return;
45
- const axis = d3.axisLeft(crossAxisLeft).ticks(crossAxisTicks, crossAxisTickFormat).tickSize(0).tickSizeOuter(0);
47
+ const axis = d3.axisLeft(crossAxisLeft).ticks(crossAxisLeftTicks, crossAxisLeftTickFormat).tickSize(0).tickSizeOuter(0);
46
48
  d3.select(crossAxisLeftRef.current).call(axis);
47
49
  d3.select(crossAxisLeftRef.current).selectAll('.tick text').attr('text-anchor', 'end');
48
- }, [crossAxisLeft, crossAxisTicks, crossAxisTickFormat]);
50
+ }, [crossAxisLeft, crossAxisLeftTicks, crossAxisLeftTickFormat]);
49
51
  (0, _react.useEffect)(() => {
50
52
  if (!hasRight) return;
51
- const axis = d3.axisRight(crossAxisRight).ticks(crossAxisTicks, crossAxisTickFormat).tickSize(0).tickSizeOuter(0);
53
+ const axis = d3.axisRight(crossAxisRight).ticks(crossAxisRightTicks, crossAxisRightTickFormat).tickSize(0).tickSizeOuter(0);
52
54
  d3.select(crossAxisRightRef.current).call(axis);
53
55
  d3.select(crossAxisRightRef.current).selectAll('.tick text').attr('text-anchor', 'start');
54
- }, [crossAxisRight, crossAxisTicks, crossAxisTickFormat]);
56
+ }, [crossAxisRight, crossAxisRightTicks, crossAxisRightTickFormat]);
55
57
  (0, _react.useEffect)(() => {
56
58
  const crossAxis = hasLeft ? crossAxisLeft : hasRight ? crossAxisRight : null;
59
+ const crossAxisTicks = hasLeft ? crossAxisLeftTicks : crossAxisRightTicks;
57
60
  const g = d3.select(gridRef.current);
58
61
  g.selectAll('*').remove();
59
62
  if (!crossAxis) return;
@@ -61,7 +64,7 @@ const CartesianPlane = _ref => {
61
64
  g.call(grid);
62
65
  g.selectAll('.tick line').attr('stroke', '#000').attr('stroke-opacity', 0.5).attr('stroke-dasharray', '5 5');
63
66
  g.select('.domain').remove();
64
- }, [crossAxisLeft, crossAxisRight, innerWidth, crossAxisTicks, crossAxisTickFormat]);
67
+ }, [crossAxisLeft, crossAxisRight, innerWidth, crossAxisLeftTicks, crossAxisRightTicks]);
65
68
  return /*#__PURE__*/_react.default.createElement("svg", {
66
69
  width: width,
67
70
  height: height
@@ -21,10 +21,10 @@ const Lines = _ref => {
21
21
  color
22
22
  } = _ref;
23
23
  const valuesByCategory = (0, _react.useMemo)(() => (0, _utils.getValuesMapByCategory)(dataset), [dataset]);
24
- const splitLineClusters = (0, _react.useMemo)(() => tab.subitems_catalog.map(cluster => {
24
+ const splitLineClusters = (0, _react.useMemo)(() => tab.subitems.map(cluster => {
25
25
  const lineSeries = cluster.filter(s => s.type === _constants.LINE_TYPE);
26
- const leftCodes = lineSeries.filter(s => (s.crossAxis || _constants.LEFT_SIDE) === _constants.LEFT_SIDE).map(s => s.bindings.crossAxis);
27
- const rightCodes = lineSeries.filter(s => (s.crossAxis || _constants.RIGHT_SIDE) === _constants.RIGHT_SIDE).map(s => s.bindings.crossAxis);
26
+ const leftCodes = lineSeries.filter(s => (s.range || _constants.LEFT_SIDE) === _constants.LEFT_SIDE).map(s => s.bindings.range);
27
+ const rightCodes = lineSeries.filter(s => (s.range || _constants.RIGHT_SIDE) === _constants.RIGHT_SIDE).map(s => s.bindings.range);
28
28
  return {
29
29
  leftCodes,
30
30
  rightCodes
@@ -3,8 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.RIGHT_SIDE = exports.LINE_TYPE = exports.LEFT_SIDE = exports.BAR_TYPE = void 0;
6
+ exports.TOOLTIP_SIZE = exports.RIGHT_SIDE = exports.LINE_TYPE = exports.LEFT_SIDE = exports.DEFAULT_RANGE_TICK_FORMAT = exports.DEFAULT_RANGE_TICKS = exports.DEFAULT_CARTESIAN_PLANE_MARGINS = exports.BAR_TYPE = void 0;
7
7
  const LEFT_SIDE = exports.LEFT_SIDE = 'left';
8
8
  const RIGHT_SIDE = exports.RIGHT_SIDE = 'right';
9
9
  const LINE_TYPE = exports.LINE_TYPE = 'line';
10
- const BAR_TYPE = exports.BAR_TYPE = 'bar';
10
+ const BAR_TYPE = exports.BAR_TYPE = 'bar';
11
+ const TOOLTIP_SIZE = exports.TOOLTIP_SIZE = 17;
12
+ const DEFAULT_RANGE_TICK_FORMAT = exports.DEFAULT_RANGE_TICK_FORMAT = '~s';
13
+ const DEFAULT_RANGE_TICKS = exports.DEFAULT_RANGE_TICKS = 4;
14
+ const DEFAULT_CARTESIAN_PLANE_MARGINS = exports.DEFAULT_CARTESIAN_PLANE_MARGINS = {
15
+ top: 24,
16
+ right: 24,
17
+ bottom: 24,
18
+ left: 24
19
+ };
@@ -7,47 +7,137 @@ exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var d3 = _interopRequireWildcard(require("d3"));
9
9
  var _propTypes = require("prop-types");
10
+ var _classesUtils = require("../../utils/classesUtils");
11
+ var _WithTheme = _interopRequireDefault(require("../WithTheme"));
12
+ var _UTLabel = _interopRequireDefault(require("../UTLabel"));
13
+ var _UTButtonGroup = _interopRequireDefault(require("../UTButtonGroup"));
14
+ var _UTIcon = _interopRequireDefault(require("../UTIcon"));
15
+ var _UTTooltip = _interopRequireDefault(require("../UTTooltip"));
10
16
  var _Bars = _interopRequireDefault(require("./components/Bars"));
11
17
  var _Lines = _interopRequireDefault(require("./components/Lines"));
12
18
  var _CartesianPlane = _interopRequireDefault(require("./components/CartesianPlane"));
13
19
  var _utils = require("./utils");
14
20
  var _constants = require("./constants");
21
+ var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
22
+ var _theme = require("./theme");
15
23
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
24
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
17
25
  const UTGraph = _ref => {
26
+ var _meta$configuration;
18
27
  let {
19
28
  meta,
20
- datasets
29
+ datasets,
30
+ classNames,
31
+ classes: theme
21
32
  } = _ref;
22
- const tab = meta.tabs[0];
23
- const dataset = (0, _react.useMemo)(() => datasets.find(ds => ds.code === tab.code), [datasets, tab]);
24
- const mainAxisDomain = (0, _react.useMemo)(() => dataset.mainAxis.map(item => item.name), [dataset]);
25
- const crossAxisLeftDomain = (0, _react.useMemo)(() => (0, _utils.applyHeadroom)((0, _utils.computeCrossAxisDomainForSide)(tab, dataset, _constants.LEFT_SIDE)), [tab, dataset]);
26
- const crossAxisRightDomain = (0, _react.useMemo)(() => (0, _utils.applyHeadroom)((0, _utils.computeCrossAxisDomainForSide)(tab, dataset, _constants.RIGHT_SIDE)), [tab, dataset]);
33
+ const {
34
+ margin: cartesianPlaneMargin,
35
+ rangeLeftTickFormat,
36
+ rangeLeftTicks,
37
+ rangeRightTickFormat,
38
+ rangeRightTicks
39
+ } = ((_meta$configuration = meta.configuration) === null || _meta$configuration === void 0 ? void 0 : _meta$configuration.cartesianPlane) || {};
40
+ const styles = (0, _react.useMemo)(() => (0, _classesUtils.mergeMultipleClassNames)(_stylesModule.default, theme, classNames), [_stylesModule.default, theme, classNames]);
41
+ const [selectedTab, setSelectedTab] = (0, _react.useState)(meta.chart_tabs[0]);
42
+ const tabOptions = (0, _react.useMemo)(() => {
43
+ var _meta$chart_tabs;
44
+ return meta.chart_tabs ? (_meta$chart_tabs = meta.chart_tabs) === null || _meta$chart_tabs === void 0 ? void 0 : _meta$chart_tabs.map(tab => ({
45
+ Icon: tab.icon,
46
+ id: tab.code,
47
+ onClick: () => setSelectedTab(tab),
48
+ value: tab.code
49
+ })) : [];
50
+ }, [meta.chart_tabs]);
51
+ const dataset = (0, _react.useMemo)(() => datasets.find(ds => ds.code === selectedTab.code), [datasets, selectedTab]);
52
+ const mainAxisDomain = (0, _react.useMemo)(() => dataset ? dataset.domain.map(item => item.domain_value) : [], [dataset]);
53
+ const crossAxisLeftDomain = (0, _react.useMemo)(() => (0, _utils.applyHeadroom)((0, _utils.computeCrossAxisDomainForSide)(selectedTab, dataset, _constants.LEFT_SIDE)), [selectedTab, dataset]);
54
+ const crossAxisRightDomain = (0, _react.useMemo)(() => (0, _utils.applyHeadroom)((0, _utils.computeCrossAxisDomainForSide)(selectedTab, dataset, _constants.RIGHT_SIDE)), [selectedTab, dataset]);
27
55
  const {
28
56
  hasLeft,
29
57
  hasRight
30
- } = (0, _utils.detectAxisSides)(tab);
58
+ } = (0, _utils.detectAxisSides)(selectedTab);
31
59
 
32
60
  // TBD: colors should be retrieved from the report's meta
33
- const codeList = (0, _react.useMemo)(() => tab.subitems_catalog.flatMap(cluster => cluster.map(series => series.bindings.crossAxis)), [tab]);
61
+ const codeList = (0, _react.useMemo)(() => selectedTab.subitems.flatMap(cluster => cluster.map(series => series.bindings.range)), [selectedTab]);
34
62
  const color = (0, _react.useMemo)(() => d3.scaleOrdinal(codeList, d3.schemeTableau10), [codeList]);
35
- return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_CartesianPlane.default, {
63
+ const legendItems = (0, _react.useMemo)(() => {
64
+ const seen = new Set();
65
+ return selectedTab.subitems.flat().filter(series => {
66
+ const code = series.bindings.range;
67
+ if (!code || seen.has(code)) return false;
68
+ seen.add(code);
69
+ return true;
70
+ }).map(series => ({
71
+ code: series.bindings.range,
72
+ name: series.name,
73
+ type: series.type
74
+ }));
75
+ }, [selectedTab]);
76
+ const containerRef = (0, _react.useRef)(null);
77
+ const planeWrapperRef = (0, _react.useRef)(null);
78
+ const [containerSize, setContainerSize] = (0, _react.useState)({
79
+ width: 0,
80
+ height: 0
81
+ });
82
+ (0, _react.useEffect)(() => {
83
+ if (!containerRef.current || !planeWrapperRef.current) return;
84
+ const resizeObserver = new ResizeObserver(entries => {
85
+ if (!entries[0]) return;
86
+ const {
87
+ width,
88
+ height
89
+ } = entries[0].contentRect;
90
+ setContainerSize(prev => {
91
+ const next = {
92
+ width,
93
+ height: Math.max(height, 0)
94
+ };
95
+ if (Math.abs(prev.width - next.width) < 1 && Math.abs(prev.height - next.height) < 1) return prev;
96
+ return next;
97
+ });
98
+ });
99
+ resizeObserver.observe(planeWrapperRef.current);
100
+ return () => {
101
+ resizeObserver.disconnect();
102
+ };
103
+ }, []);
104
+ return /*#__PURE__*/_react.default.createElement("div", {
105
+ className: styles.container,
106
+ ref: containerRef
107
+ }, /*#__PURE__*/_react.default.createElement("div", {
108
+ className: styles.header
109
+ }, /*#__PURE__*/_react.default.createElement("div", {
110
+ className: styles.title
111
+ }, /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
112
+ variant: "subtitle1",
113
+ weight: "medium",
114
+ title: selectedTab.name
115
+ }, selectedTab.name), (selectedTab === null || selectedTab === void 0 ? void 0 : selectedTab.tooltip) && /*#__PURE__*/_react.default.createElement(_UTTooltip.default, {
116
+ content: selectedTab.tooltip
117
+ }, /*#__PURE__*/_react.default.createElement("div", {
118
+ className: styles.tooltipIcon
119
+ }, /*#__PURE__*/_react.default.createElement(_UTIcon.default, {
120
+ name: "IconInfoCircle",
121
+ size: _constants.TOOLTIP_SIZE
122
+ })))), tabOptions.length > 1 && /*#__PURE__*/_react.default.createElement(_UTButtonGroup.default, {
123
+ actions: tabOptions,
124
+ selected: selectedTab.code
125
+ })), /*#__PURE__*/_react.default.createElement("div", {
126
+ className: styles.planeWrapper,
127
+ ref: planeWrapperRef
128
+ }, /*#__PURE__*/_react.default.createElement(_CartesianPlane.default, {
36
129
  crossAxisLeftDomain: crossAxisLeftDomain,
37
130
  crossAxisRightDomain: crossAxisRightDomain,
38
- crossAxisTickFormat: "~s",
39
- crossAxisTicks: 4,
40
- height: 700,
131
+ crossAxisLeftTickFormat: rangeLeftTickFormat || _constants.DEFAULT_RANGE_TICK_FORMAT,
132
+ crossAxisLeftTicks: rangeLeftTicks || _constants.DEFAULT_RANGE_TICKS,
133
+ crossAxisRightTickFormat: rangeRightTickFormat || _constants.DEFAULT_RANGE_TICK_FORMAT,
134
+ crossAxisRightTicks: rangeRightTicks || _constants.DEFAULT_RANGE_TICKS,
135
+ height: containerSize.height,
41
136
  mainAxisDomain: mainAxisDomain,
42
137
  mainAxisTickFormat: "~s",
43
138
  mainAxisTicks: 4,
44
- margin: {
45
- top: 32,
46
- right: 32,
47
- bottom: 32,
48
- left: 64
49
- },
50
- width: 1000,
139
+ margin: cartesianPlaneMargin || _constants.DEFAULT_CARTESIAN_PLANE_MARGINS,
140
+ width: containerSize.width,
51
141
  hasLeft: hasLeft,
52
142
  hasRight: hasRight
53
143
  }, _ref2 => {
@@ -62,7 +152,7 @@ const UTGraph = _ref => {
62
152
  dataset: dataset,
63
153
  mainAxis: mainAxis,
64
154
  mainAxisDomain: mainAxisDomain,
65
- tab: tab,
155
+ tab: selectedTab,
66
156
  color: color
67
157
  }), /*#__PURE__*/_react.default.createElement(_Lines.default, {
68
158
  crossAxisLeft: crossAxisLeft,
@@ -70,13 +160,29 @@ const UTGraph = _ref => {
70
160
  dataset: dataset,
71
161
  mainAxis: mainAxis,
72
162
  mainAxisDomain: mainAxisDomain,
73
- tab: tab,
163
+ tab: selectedTab,
74
164
  color: color
75
165
  }));
76
- }));
166
+ })), /*#__PURE__*/_react.default.createElement("div", {
167
+ className: styles.legends
168
+ }, legendItems.map(item => /*#__PURE__*/_react.default.createElement("div", {
169
+ key: item.code,
170
+ className: styles.legendItem,
171
+ title: item.name
172
+ }, /*#__PURE__*/_react.default.createElement("div", {
173
+ style: {
174
+ backgroundColor: color(item.code)
175
+ },
176
+ className: item.type === _constants.LINE_TYPE ? styles.legendLine : styles.legendBar
177
+ }), /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
178
+ variant: "xsmall",
179
+ className: styles.legendLabel
180
+ }, item.name)))));
77
181
  };
78
182
  UTGraph.propTypes = {
183
+ classes: (0, _propTypes.objectOf)(_propTypes.string),
184
+ classNames: (0, _propTypes.objectOf)(_propTypes.string),
79
185
  meta: _propTypes.object,
80
186
  datasets: _propTypes.array
81
187
  };
82
- var _default = exports.default = UTGraph;
188
+ var _default = exports.default = (0, _WithTheme.default)(_theme.retrieveStyle)(UTGraph);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
3
  "$id": "https://utgraph.dev/schemas/report.schema.json",
4
- "title": "UTGraph Report",
4
+ "title": "UTGraph",
5
5
  "type": "object",
6
6
  "additionalProperties": false,
7
7
  "required": ["meta", "datasets"],
@@ -9,28 +9,41 @@
9
9
  "meta": {
10
10
  "type": "object",
11
11
  "additionalProperties": false,
12
- "required": ["code", "enabled", "report_type", "tabs"],
12
+ "required": ["id", "code", "chart_layout", "chart_tabs"],
13
13
  "properties": {
14
- "code": { "type": "string", "description": "unique identifier for this graph" },
15
- "enabled": { "type": "boolean", "default": true },
16
- "report_type": { "type": "string", "enum": ["chart", "pie"], "default": "chart" },
17
- "tabs": {
14
+ "id": { "type": "number", "description": "identifier for this graph" },
15
+ "code": { "type": "string", "description": "code for this graph" },
16
+ "chart_layout": { "type": "string", "enum": ["cartesian", "radial"], "default": "cartesian" },
17
+ "chart_tabs": {
18
18
  "type": "array",
19
19
  "minItems": 1,
20
20
  "items": {
21
21
  "type": "object",
22
22
  "additionalProperties": false,
23
- "required": ["code", "name", "icon", "orientation", "mainAxis", "crossAxes", "subitems_catalog"],
23
+ "required": [
24
+ "id",
25
+ "code",
26
+ "order",
27
+ "name",
28
+ "icon",
29
+ "orientation",
30
+ "domain",
31
+ "ranges",
32
+ "subitems"
33
+ ],
24
34
  "properties": {
35
+ "id": { "type": "number", "description": "identifier for this tab" },
25
36
  "code": { "type": "string", "description": "must match a dataset code from datasets" },
37
+ "order": { "type": "number", "description": "order of this tab" },
26
38
  "name": { "type": "string" },
39
+ "tooltip": { "type": "string" },
27
40
  "icon": { "type": "string" },
28
41
  "orientation": {
29
42
  "type": "string",
30
43
  "enum": ["horizontal", "vertical"],
31
44
  "default": "vertical"
32
45
  },
33
- "mainAxis": {
46
+ "domain": {
34
47
  "type": "object",
35
48
  "additionalProperties": false,
36
49
  "required": ["binding"],
@@ -39,11 +52,11 @@
39
52
  "type": "string",
40
53
  "enum": ["categorical", "numerical"],
41
54
  "default": "categorical",
42
- "description": "defines how to bind the main axis to the dataset.\n\n\"categorical\" uses each dataset.mainAxis[i].name to render a category (use this for bar and line charts).\n\n\"numerical\" renders a continuous axis using the value defined in subitems_catalog[].bindings.mainAxis to set a domain with ticks (use this for scatter charts)."
55
+ "description": "defines how to bind the main axis to the dataset.\n\n\"categorical\" uses each dataset.domain[i].domain_value to render a category (use this for bar and line charts).\n\n\"numerical\" renders a continuous axis using the value defined in subitems[].bindings.domain to set a domain with ticks (use this for scatter charts)."
43
56
  }
44
57
  }
45
58
  },
46
- "crossAxes": {
59
+ "ranges": {
47
60
  "type": "object",
48
61
  "additionalProperties": false,
49
62
  "properties": {
@@ -69,7 +82,7 @@
69
82
  }
70
83
  }
71
84
  },
72
- "subitems_catalog": {
85
+ "subitems": {
73
86
  "type": "array",
74
87
  "minItems": 1,
75
88
  "description": "First dimension: clusters (side-by-side). Second dimension: series (stacked)",
@@ -79,22 +92,21 @@
79
92
  "items": {
80
93
  "type": "object",
81
94
  "additionalProperties": false,
82
- "required": ["name", "type", "crossAxis", "bindings"],
95
+ "required": ["name", "type", "range", "bindings"],
83
96
  "properties": {
84
97
  "name": { "type": "string" },
85
98
  "type": { "type": "string", "enum": ["bar", "line", "point"] },
86
- "crossAxis": { "type": "string", "enum": ["left", "right"], "default": "left" },
99
+ "range": { "type": "string", "enum": ["left", "right"], "default": "left" },
87
100
  "bindings": {
88
101
  "type": "object",
89
102
  "description": "defines how to bind each subitem attribute to the dataset. ",
90
103
  "additionalProperties": false,
91
- "required": ["crossAxis"],
92
104
  "properties": {
93
- "crossAxis": {
105
+ "range": {
94
106
  "type": "string",
95
107
  "description": "REQUIRED for all series. Defines the placement of the element in the cross axis. Must match a dataset subitem code"
96
108
  },
97
- "mainAxis": {
109
+ "domain": {
98
110
  "type": "string",
99
111
  "description": "REQUIRED, only for numerical binding. Defines the placement of the element in the main axis. Must match a dataset subitem code"
100
112
  },
@@ -110,6 +122,48 @@
110
122
  }
111
123
  }
112
124
  }
125
+ },
126
+ "configuration": {
127
+ "type": "object",
128
+ "additionalProperties": false,
129
+ "properties": {
130
+ "cartesianPlane": {
131
+ "type": "object",
132
+ "additionalProperties": false,
133
+ "properties": {
134
+ "rangeLeftTicks": {
135
+ "type": "number",
136
+ "default": 4,
137
+ "description": "defines the number of ticks in the left cross axis"
138
+ },
139
+ "rangeRightTicks": {
140
+ "type": "number",
141
+ "default": 4,
142
+ "description": "defines the number of ticks in the right cross axis"
143
+ },
144
+ "rangeLeftTickFormat": {
145
+ "type": "string",
146
+ "default": "~s",
147
+ "description": "defines the tick format in the left cross axis"
148
+ },
149
+ "rangeRightTickFormat": {
150
+ "type": "string",
151
+ "default": "~s",
152
+ "description": "defines the tick format in the right cross axis"
153
+ },
154
+ "margin": {
155
+ "type": "object",
156
+ "additionalProperties": false,
157
+ "properties": {
158
+ "top": { "type": "number", "default": 24 },
159
+ "right": { "type": "number", "default": 24 },
160
+ "bottom": { "type": "number", "default": 24 },
161
+ "left": { "type": "number", "default": 24 }
162
+ }
163
+ }
164
+ }
165
+ }
166
+ }
113
167
  }
114
168
  }
115
169
  },
@@ -119,22 +173,22 @@
119
173
  "items": {
120
174
  "type": "object",
121
175
  "additionalProperties": false,
122
- "required": ["code", "mainAxis"],
176
+ "required": ["code", "domain"],
123
177
  "properties": {
124
178
  "code": { "type": "string", "description": "must match a tab code from meta" },
125
- "mainAxis": {
179
+ "domain": {
126
180
  "type": "array",
127
181
  "minItems": 1,
128
182
  "items": {
129
183
  "type": "object",
130
184
  "additionalProperties": false,
131
- "required": ["name", "subitems"],
185
+ "required": ["domain_value", "concepts"],
132
186
  "properties": {
133
- "name": {
187
+ "domain_value": {
134
188
  "type": "string",
135
189
  "description": "label to display below this category's main axis"
136
190
  },
137
- "subitems": {
191
+ "concepts": {
138
192
  "type": "array",
139
193
  "minItems": 1,
140
194
  "items": {
@@ -0,0 +1,61 @@
1
+ $TOOLTIP_SIZE: 17px;
2
+
3
+ .container {
4
+ flex: 1;
5
+ border-radius: 8px;
6
+ display: flex;
7
+ flex-direction: column;
8
+ padding: 24px;
9
+ grid-gap: 24px;
10
+ height: 100%;
11
+ min-height: 0;
12
+ }
13
+
14
+ .header {
15
+ align-items: center;
16
+ display: flex;
17
+ grid-gap: 16px;
18
+ justify-content: space-between;
19
+ flex: 0 0 auto;
20
+ }
21
+
22
+ .planeWrapper {
23
+ flex: 1 1 auto;
24
+ min-height: 0;
25
+ display: flex;
26
+ }
27
+
28
+ .title {
29
+ align-items: center;
30
+ display: flex;
31
+ grid-gap: 10px;
32
+ }
33
+
34
+ .tooltipIcon {
35
+ height: $TOOLTIP_SIZE;
36
+ }
37
+
38
+ .legends {
39
+ display: flex;
40
+ flex-wrap: wrap;
41
+ grid-gap: 16px;
42
+ align-items: center;
43
+ flex: 0 0 auto;
44
+ }
45
+
46
+ .legendItem {
47
+ display: flex;
48
+ align-items: center;
49
+ grid-gap: 12px;
50
+ }
51
+
52
+ .legendBar {
53
+ width: 16px;
54
+ height: 16px;
55
+ border-radius: 2px;
56
+ }
57
+
58
+ .legendLine {
59
+ width: 16px;
60
+ height: 2px;
61
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.retrieveStyle = void 0;
7
+ var _shadowUtils = require("../../utils/shadowUtils");
8
+ var _Palette = require("../../constants/Palette");
9
+ const retrieveStyle = _ref => {
10
+ var _theme$Palette$shadow;
11
+ let {
12
+ theme
13
+ } = _ref;
14
+ return {
15
+ container: {
16
+ backgroundColor: theme.Palette[_Palette.COLOR_THEMES.light][_Palette.COLOR_SHADES.shade01],
17
+ boxShadow: (0, _shadowUtils.getShadow)({
18
+ color: (_theme$Palette$shadow = theme.Palette.shadows) === null || _theme$Palette$shadow === void 0 ? void 0 : _theme$Palette$shadow.grayscale,
19
+ level: 1
20
+ })
21
+ }
22
+ };
23
+ };
24
+ exports.retrieveStyle = retrieveStyle;
@@ -6,11 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getValuesMapByCategory = exports.detectAxisSides = exports.computeCrossAxisDomainForSide = exports.computeCrossAxisDomain = exports.applyHeadroom = void 0;
7
7
  var _constants = require("./constants");
8
8
  const computeCrossAxisDomain = (tab, dataset) => {
9
+ if (!dataset) return [0, 1];
9
10
  const {
10
11
  yMin,
11
12
  yMax
12
- } = dataset.mainAxis.reduce((acc, record) => {
13
- const clusterMaxValues = tab.subitems_catalog.map(cluster => {
13
+ } = dataset.domain.reduce((acc, record) => {
14
+ const clusterMaxValues = tab.subitems.map(cluster => {
14
15
  const typeGroups = cluster.reduce((groups, series) => {
15
16
  if (!groups[series.type]) groups[series.type] = [];
16
17
  groups[series.type].push(series);
@@ -19,12 +20,12 @@ const computeCrossAxisDomain = (tab, dataset) => {
19
20
  const typeSums = Object.entries(typeGroups).map(_ref => {
20
21
  let [type, typeSeries] = _ref;
21
22
  const positiveSum = typeSeries.map(series => {
22
- var _record$subitems$find, _record$subitems$find2;
23
- return (_record$subitems$find = (_record$subitems$find2 = record.subitems.find(datum => datum.code === series.bindings.crossAxis)) === null || _record$subitems$find2 === void 0 ? void 0 : _record$subitems$find2.value) !== null && _record$subitems$find !== void 0 ? _record$subitems$find : 0;
23
+ var _record$concepts$find, _record$concepts$find2;
24
+ return (_record$concepts$find = (_record$concepts$find2 = record.concepts.find(datum => datum.code === series.bindings.range)) === null || _record$concepts$find2 === void 0 ? void 0 : _record$concepts$find2.value) !== null && _record$concepts$find !== void 0 ? _record$concepts$find : 0;
24
25
  }).filter(Number.isFinite).reduce((sum, v) => v >= 0 ? sum + v : sum, 0);
25
26
  const negativeSum = typeSeries.map(series => {
26
- var _record$subitems$find3, _record$subitems$find4;
27
- return (_record$subitems$find3 = (_record$subitems$find4 = record.subitems.find(datum => datum.code === series.bindings.crossAxis)) === null || _record$subitems$find4 === void 0 ? void 0 : _record$subitems$find4.value) !== null && _record$subitems$find3 !== void 0 ? _record$subitems$find3 : 0;
27
+ var _record$concepts$find3, _record$concepts$find4;
28
+ return (_record$concepts$find3 = (_record$concepts$find4 = record.concepts.find(datum => datum.code === series.bindings.range)) === null || _record$concepts$find4 === void 0 ? void 0 : _record$concepts$find4.value) !== null && _record$concepts$find3 !== void 0 ? _record$concepts$find3 : 0;
28
29
  }).filter(Number.isFinite).reduce((sum, v) => v < 0 ? sum + v : sum, 0);
29
30
  return {
30
31
  type,
@@ -54,9 +55,9 @@ exports.computeCrossAxisDomain = computeCrossAxisDomain;
54
55
  const computeCrossAxisDomainForSide = (tab, dataset, side) => {
55
56
  const filteredTab = {
56
57
  ...tab,
57
- subitems_catalog: tab.subitems_catalog.map(cluster => cluster.filter(series => (series.crossAxis || _constants.LEFT_SIDE) === side))
58
+ subitems: tab.subitems.map(cluster => cluster.filter(series => (series.range || _constants.LEFT_SIDE) === side))
58
59
  };
59
- filteredTab.subitems_catalog = filteredTab.subitems_catalog.filter(cluster => cluster.length > 0);
60
+ filteredTab.subitems = filteredTab.subitems.filter(cluster => cluster.length > 0);
60
61
  return computeCrossAxisDomain(filteredTab, dataset);
61
62
  };
62
63
  exports.computeCrossAxisDomainForSide = computeCrossAxisDomainForSide;
@@ -70,8 +71,9 @@ const applyHeadroom = function (_ref2) {
70
71
  exports.applyHeadroom = applyHeadroom;
71
72
  const getValuesMapByCategory = dataset => {
72
73
  const map = new Map();
73
- dataset.mainAxis.forEach(record => {
74
- map.set(record.name, Object.fromEntries(record.subitems.map(datum => [datum.code, datum.value])));
74
+ if (!dataset) return map;
75
+ dataset.domain.forEach(record => {
76
+ map.set(record.domain_value, Object.fromEntries(record.concepts.map(datum => [datum.code, datum.value])));
75
77
  });
76
78
  return map;
77
79
  };
@@ -79,10 +81,10 @@ exports.getValuesMapByCategory = getValuesMapByCategory;
79
81
  const detectAxisSides = tab => {
80
82
  let hasLeft = false;
81
83
  let hasRight = false;
82
- tab.subitems_catalog.forEach(cluster => {
84
+ tab.subitems.forEach(cluster => {
83
85
  cluster.forEach(s => {
84
86
  if (s.type === _constants.LINE_TYPE || s.type === _constants.BAR_TYPE) {
85
- const side = s.crossAxis || _constants.LEFT_SIDE;
87
+ const side = s.range || _constants.LEFT_SIDE;
86
88
  if (side === _constants.LEFT_SIDE) hasLeft = true;
87
89
  if (side === _constants.RIGHT_SIDE) hasRight = true;
88
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widergy/energy-ui",
3
- "version": "3.112.1",
3
+ "version": "3.114.1",
4
4
  "description": "Widergy Web Components",
5
5
  "author": "widergy",
6
6
  "license": "MIT",