@esfaenza/es-charts 11.2.10 → 11.2.14

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.
@@ -84,10 +84,13 @@
84
84
  * Costruttore
85
85
  *
86
86
  * @param {LineSerie[]} series Lista di serie da graficare
87
+ * @param {{upper: lower}}
87
88
  */
88
- function LineChartData(series) {
89
+ function LineChartData(series, limit, limitColors) {
89
90
  if (series === void 0) { series = []; }
90
91
  this.series = series;
92
+ this.limit = limit;
93
+ this.limitColors = limitColors;
91
94
  }
92
95
  return LineChartData;
93
96
  }());
@@ -593,6 +596,18 @@
593
596
  return LegendPad;
594
597
  }());
595
598
 
599
+ /**
600
+ * Modello che identifica un limite superiore - inferiore
601
+ */
602
+ var Limit = /** @class */ (function () {
603
+ /** @ignore */
604
+ function Limit(upper, lower) {
605
+ this.upper = upper;
606
+ this.lower = lower;
607
+ }
608
+ return Limit;
609
+ }());
610
+
596
611
  /**
597
612
  * Modello che identifica la coppia Data-Valore
598
613
  */
@@ -640,15 +655,17 @@
640
655
  * @param {string} name Nome della serie
641
656
  * @param {DateValue[]} values Valori della serie
642
657
  * @param {BaseInterval} interval Intervallo della serie. Viene utilizzato per gestire Gap e date in Istante Finale
643
- * @param {string} color Colore della serie, verrà usato sia per la lineaa base che eventualmente per il riempimento (in caso si utilizzi l'Input **Fill** nel grafico)
658
+ * @param {string} color Colore della serie, verrà usato sia per la linea base che eventualmente per il riempimento (in caso si utilizzi l'Input **Fill** nel grafico)
644
659
  * @param {string} uom Unità di misura da presentare nell'asse delle Y
660
+ * @param {boolean} fill Override della proprietà **Fill** del grafico, specifico per ogni serie
645
661
  */
646
- function LineSerie(name, values, interval, color, uom) {
662
+ function LineSerie(name, values, interval, color, uom, fill) {
647
663
  this.name = name;
648
664
  this.values = values;
649
665
  this.interval = interval;
650
666
  this.color = color;
651
667
  this.uom = uom;
668
+ this.fill = fill;
652
669
  }
653
670
  return LineSerie;
654
671
  }());
@@ -1439,7 +1456,7 @@
1439
1456
  */
1440
1457
  LineChartService.prototype.graphicate = function (data, settings) {
1441
1458
  var _this = this;
1442
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
1459
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1443
1460
  var dataConverted = this.Adapter ? this.Adapter.adaptDataForLineChart(data) : data;
1444
1461
  var threshold = (_a = settings.DataGroupingThreshold) !== null && _a !== void 0 ? _a : 3000;
1445
1462
  var singleDataSet = (_b = settings.MergeDatasets) !== null && _b !== void 0 ? _b : false;
@@ -1450,7 +1467,6 @@
1450
1467
  var interval = seriesWithInterval ? dataConverted.series.find(function (t) { return t.interval; }).interval : null;
1451
1468
  var gapsAllowed = (settings === null || settings === void 0 ? void 0 : settings.AllowGaps) == null ? seriesWithInterval : settings === null || settings === void 0 ? void 0 : settings.AllowGaps;
1452
1469
  var finalInstant = (_c = settings === null || settings === void 0 ? void 0 : settings.FinalInstants) !== null && _c !== void 0 ? _c : true;
1453
- var fill = (_d = settings === null || settings === void 0 ? void 0 : settings.Fill) !== null && _d !== void 0 ? _d : false;
1454
1470
  //Per evitare di dimenticarmeli e gestire comunque bene gli ngif ecc...
1455
1471
  am4core__namespace.options.autoDispose = true;
1456
1472
  this.ChartInstance = am4core__namespace.create(settings.Name, am4charts__namespace.XYChart);
@@ -1464,6 +1480,22 @@
1464
1480
  yAxis.min = settings.Min;
1465
1481
  if (settings.Max)
1466
1482
  yAxis.max = settings.Max;
1483
+ if (dataConverted.limit) {
1484
+ if (dataConverted.limit.upper != null && dataConverted.limit.upper != undefined) {
1485
+ var range = yAxis.axisRanges.create();
1486
+ range.value = dataConverted.limit.upper;
1487
+ range.grid.stroke = am4core__namespace.color(((_d = dataConverted === null || dataConverted === void 0 ? void 0 : dataConverted.limitColors) === null || _d === void 0 ? void 0 : _d.upper) || "#F92200");
1488
+ range.grid.strokeWidth = 2;
1489
+ range.grid.strokeOpacity = 1;
1490
+ }
1491
+ if (dataConverted.limit.lower != null && dataConverted.limit.lower != undefined) {
1492
+ var range = yAxis.axisRanges.create();
1493
+ range.value = dataConverted.limit.lower;
1494
+ range.grid.stroke = am4core__namespace.color(((_e = dataConverted === null || dataConverted === void 0 ? void 0 : dataConverted.limitColors) === null || _e === void 0 ? void 0 : _e.lower) || "#F92200");
1495
+ range.grid.strokeWidth = 2;
1496
+ range.grid.strokeOpacity = 1;
1497
+ }
1498
+ }
1467
1499
  var dateAxis = ChartInstanceCasted.xAxes.push(new am4charts__namespace.DateAxis());
1468
1500
  if (settings.XAxisTitle) {
1469
1501
  dateAxis.title.text = settings.XAxisTitle;
@@ -1477,11 +1509,11 @@
1477
1509
  dateAxis.renderer.ticks.template.length = 10;
1478
1510
  dateAxis.renderer.ticks.template.location = 0;
1479
1511
  }
1480
- dateAxis.renderer.minGridDistance = (_e = settings === null || settings === void 0 ? void 0 : settings.MinGridDistance) !== null && _e !== void 0 ? _e : 50;
1512
+ dateAxis.renderer.minGridDistance = (_f = settings === null || settings === void 0 ? void 0 : settings.MinGridDistance) !== null && _f !== void 0 ? _f : 50;
1481
1513
  dateAxis.renderer.grid.template.location = 0;
1482
1514
  dateAxis.minZoomCount = 5;
1483
1515
  dateAxis.groupData = dataShouldBeGrouped;
1484
- dateAxis.groupCount = (_f = settings.DataGroupBucketSize) !== null && _f !== void 0 ? _f : this.DataGroupBucketSize;
1516
+ dateAxis.groupCount = (_g = settings.DataGroupBucketSize) !== null && _g !== void 0 ? _g : this.DataGroupBucketSize;
1485
1517
  //Se ho almeno una serie ad intervallo e i settings non mi impediscono esplicitamente di usare i gaps, visualizzo i dati col gap
1486
1518
  if (gapsAllowed) {
1487
1519
  if (!seriesWithInterval) {
@@ -1525,7 +1557,7 @@
1525
1557
  }
1526
1558
  //-- Fine generazione
1527
1559
  dataConverted.series.forEach(function (s, index) {
1528
- var _a, _b;
1560
+ var _a, _b, _c;
1529
1561
  if (s.values[0] && !(s.values[0].d instanceof Date)) {
1530
1562
  for (var v = 0; v < s.values.length; v++)
1531
1563
  s.values[v].d = new Date(s.values[v].d);
@@ -1542,12 +1574,13 @@
1542
1574
  }
1543
1575
  if (!correctOrder)
1544
1576
  s.values.sort(function (d1, d2) { return d1.d.getTime() - d2.d.getTime(); });
1577
+ var fill = s.fill != null && s.fill != undefined ? s.fill : ((_a = settings === null || settings === void 0 ? void 0 : settings.Fill) !== null && _a !== void 0 ? _a : false);
1545
1578
  var series = (settings === null || settings === void 0 ? void 0 : settings.Step) ? new am4charts__namespace.StepLineSeries() : new am4charts__namespace.LineSeries();
1546
1579
  series.dataFields.valueY = "v" + (singleDataSet ? index : "");
1547
1580
  series.dataFields.dateX = "d";
1548
1581
  series.dataFields.measureUnit = s.uom;
1549
1582
  series.name = s.name;
1550
- series.strokeWidth = (_a = settings === null || settings === void 0 ? void 0 : settings.StrokeSize) !== null && _a !== void 0 ? _a : 1;
1583
+ series.strokeWidth = (_b = settings === null || settings === void 0 ? void 0 : settings.StrokeSize) !== null && _b !== void 0 ? _b : 1;
1551
1584
  series.connect = !gapsAllowed;
1552
1585
  series.minBulletDistance = 10;
1553
1586
  series.tooltipText = singleDataSet ? "" : "{name}: [bold]{valueY}[/]";
@@ -1598,7 +1631,7 @@
1598
1631
  series.data = s.values;
1599
1632
  var segment = series.segments.template;
1600
1633
  var hoverState = segment.states.create("hover");
1601
- hoverState.properties.strokeWidth = ((_b = settings === null || settings === void 0 ? void 0 : settings.StrokeSize) !== null && _b !== void 0 ? _b : 1) + 1;
1634
+ hoverState.properties.strokeWidth = ((_c = settings === null || settings === void 0 ? void 0 : settings.StrokeSize) !== null && _c !== void 0 ? _c : 1) + 1;
1602
1635
  var dimmed = segment.states.create("dimmed");
1603
1636
  dimmed.properties.stroke = am4core__namespace.color("#dadada");
1604
1637
  //Se la serie ha un colore, uso quello, altrimenti pesco dai colori di default andando in ordine
@@ -1619,17 +1652,17 @@
1619
1652
  });
1620
1653
  if (settings.Legend) {
1621
1654
  this.ChartInstance.legend = new am4charts__namespace.Legend();
1622
- this.ChartInstance.legend.position = (_g = settings === null || settings === void 0 ? void 0 : settings.LegendPosition) !== null && _g !== void 0 ? _g : 'right';
1655
+ this.ChartInstance.legend.position = (_h = settings === null || settings === void 0 ? void 0 : settings.LegendPosition) !== null && _h !== void 0 ? _h : 'right';
1623
1656
  this.ChartInstance.legend.scrollable = true;
1624
1657
  this.ChartInstance.legend.itemContainers.template.tooltipText = "{name}";
1625
- this.ChartInstance.legend.itemContainers.template.events.on("over", function (event) { _this.processOver(event.target.dataItem.dataContext, fill); });
1626
- this.ChartInstance.legend.itemContainers.template.events.on("out", function (event) { _this.processOut(fill); });
1658
+ this.ChartInstance.legend.itemContainers.template.events.on("over", function (event) { _this.processOver(event.target.dataItem.dataContext); });
1659
+ this.ChartInstance.legend.itemContainers.template.events.on("out", function () { _this.processOut(); });
1627
1660
  if (settings.LegendPadding) {
1628
1661
  var template = this.ChartInstance.legend.itemContainers.template;
1629
- template.paddingTop = (_h = settings.LegendPadding.top) !== null && _h !== void 0 ? _h : 0;
1630
- template.paddingBottom = (_j = settings.LegendPadding.bottom) !== null && _j !== void 0 ? _j : 0;
1631
- template.paddingLeft = (_k = settings.LegendPadding.left) !== null && _k !== void 0 ? _k : 0;
1632
- template.paddingRight = (_l = settings.LegendPadding.right) !== null && _l !== void 0 ? _l : 0;
1662
+ template.paddingTop = (_j = settings.LegendPadding.top) !== null && _j !== void 0 ? _j : 0;
1663
+ template.paddingBottom = (_k = settings.LegendPadding.bottom) !== null && _k !== void 0 ? _k : 0;
1664
+ template.paddingLeft = (_l = settings.LegendPadding.left) !== null && _l !== void 0 ? _l : 0;
1665
+ template.paddingRight = (_m = settings.LegendPadding.right) !== null && _m !== void 0 ? _m : 0;
1633
1666
  }
1634
1667
  }
1635
1668
  this.ChartInstance.cursor = new am4charts__namespace.XYCursor();
@@ -1672,9 +1705,10 @@
1672
1705
  }
1673
1706
  };
1674
1707
  /** @ignore */
1675
- LineChartService.prototype.processOver = function (hoveredSeries, fill) {
1708
+ LineChartService.prototype.processOver = function (hoveredSeries) {
1676
1709
  var _this = this;
1677
1710
  hoveredSeries.toFront();
1711
+ var fill = hoveredSeries.stacked;
1678
1712
  hoveredSeries.segments.each(function (segment) {
1679
1713
  segment.setState("hover");
1680
1714
  if (!fill)
@@ -1683,17 +1717,20 @@
1683
1717
  if (!fill)
1684
1718
  hoveredSeries.legendDataItem.marker.children.getIndex(1).fillOpacity = this.OpacityOnSelected;
1685
1719
  this.ChartInstance.series.each(function (series) {
1686
- if (series != hoveredSeries)
1720
+ if (series != hoveredSeries) {
1721
+ var fill_1 = series.stacked;
1687
1722
  series.segments.each(function (segment) {
1688
1723
  segment.setState("dimmed");
1689
- if (!fill)
1724
+ if (!fill_1)
1690
1725
  segment.fillSprite.fillOpacity = 0;
1691
1726
  });
1727
+ }
1692
1728
  });
1693
1729
  };
1694
1730
  /** @ignore */
1695
- LineChartService.prototype.processOut = function (fill) {
1731
+ LineChartService.prototype.processOut = function () {
1696
1732
  this.ChartInstance.series.each(function (series) {
1733
+ var fill = series.stacked;
1697
1734
  series.segments.each(function (segment) {
1698
1735
  segment.setState("default");
1699
1736
  if (!fill)
@@ -3127,6 +3164,7 @@
3127
3164
  exports.KeyValue = KeyValue;
3128
3165
  exports.KeyValueColor = KeyValueColor;
3129
3166
  exports.LegendPad = LegendPad;
3167
+ exports.Limit = Limit;
3130
3168
  exports.LineChartData = LineChartData;
3131
3169
  exports.LineChartSettings = LineChartSettings;
3132
3170
  exports.LineSerie = LineSerie;