@nova-ui/charts 12.0.17 → 12.0.20-4218

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.
@@ -1480,10 +1480,20 @@ class ChartCollectionIdDirective {
1480
1480
  this.chartComponent = chartComponent;
1481
1481
  this.chartCollectionService = chartCollectionService;
1482
1482
  }
1483
- ngAfterViewInit() {
1484
- this.chartCollectionService
1485
- .getChartCollection(this.collectionId)
1486
- .addChart(this.chartComponent.chart);
1483
+ ngOnChanges(changes) {
1484
+ const collectionIdChange = changes.collectionId;
1485
+ if (collectionIdChange) {
1486
+ if (collectionIdChange.previousValue) {
1487
+ this.chartCollectionService
1488
+ .getChartCollection(collectionIdChange.previousValue)
1489
+ .removeChart(this.chartComponent.chart);
1490
+ }
1491
+ if (collectionIdChange.currentValue) {
1492
+ this.chartCollectionService
1493
+ .getChartCollection(collectionIdChange.currentValue)
1494
+ .addChart(this.chartComponent.chart);
1495
+ }
1496
+ }
1487
1497
  }
1488
1498
  }
1489
1499
  ChartCollectionIdDirective.decorators = [
@@ -5385,7 +5395,9 @@ class Scale {
5385
5395
  constructor(id) {
5386
5396
  this.domainCalculator = getAutomaticDomain;
5387
5397
  this.formatters = {};
5398
+ this.isTimeseriesScale = false;
5388
5399
  this.isReversed = false;
5400
+ this._fixDomainValues = [];
5389
5401
  this.id = id || UtilityService.uuid();
5390
5402
  this._d3Scale = this.createD3Scale();
5391
5403
  }
@@ -5393,6 +5405,17 @@ class Scale {
5393
5405
  get d3Scale() {
5394
5406
  return this._d3Scale;
5395
5407
  }
5408
+ get fixDomainValues() {
5409
+ return this._fixDomainValues;
5410
+ }
5411
+ /** See {@link IScale#setFixDomainValues} */
5412
+ setFixDomainValues(values) {
5413
+ if (values.length > 1) {
5414
+ this.domain([values[0], values[values.length - 1]]);
5415
+ this.isDomainFixed = true;
5416
+ }
5417
+ this._fixDomainValues = values;
5418
+ }
5396
5419
  range(range) {
5397
5420
  if (range) {
5398
5421
  this._d3Scale.range(this.isReversed ? range.reverse() : range);
@@ -5650,6 +5673,17 @@ class InteractionLabelPlugin extends ChartPlugin {
5650
5673
  .getStream(INTERACTION_VALUES_EVENT)
5651
5674
  .pipe(takeUntil(this.destroy$))
5652
5675
  .subscribe((event) => {
5676
+ var _a;
5677
+ if ((_a = event.data.values) === null || _a === void 0 ? void 0 : _a.y) {
5678
+ const chartGrid = this.chart.getGrid();
5679
+ const eventYAxisIds = Object.keys(event.data.values.y);
5680
+ const chartLeftYAxis = chartGrid.scales.y.list[0];
5681
+ // shows label only for a chart that is currently being hovered
5682
+ if (chartLeftYAxis.isTimeseriesScale &&
5683
+ !eventYAxisIds.includes(chartLeftYAxis.id)) {
5684
+ return;
5685
+ }
5686
+ }
5653
5687
  this.lastInteractionValuesPayload = event.data;
5654
5688
  if (this.isChartInView) {
5655
5689
  this.handleLabelUpdate();
@@ -6202,6 +6236,8 @@ class Grid {
6202
6236
  x2: this.config().dimension.width() +
6203
6237
  Grid.TICK_DIMENSION_CORRECTION,
6204
6238
  y2: this.config().dimension.height() - borderMidpoint,
6239
+ class: this._config.borders.bottom.className ||
6240
+ Grid.DEFAULT_BORDER_CLASS_NAME,
6205
6241
  })
6206
6242
  .classed("hidden", !((_a = this._config.borders.bottom) === null || _a === void 0 ? void 0 : _a.visible));
6207
6243
  }
@@ -6480,12 +6516,16 @@ class XYGrid extends Grid {
6480
6516
  }
6481
6517
  /** @ignore */
6482
6518
  drawTicks(config, axis, scale, axisGenerator) {
6519
+ var _a, _b;
6483
6520
  if (config.visible) {
6484
- const bottomLabelAxis = axisGenerator(scale.d3Scale)
6521
+ const labelAxis = axisGenerator(scale.d3Scale)
6485
6522
  .ticks(config.approximateTicks)
6486
- .tickSize(0)
6487
- .tickFormat(scale.formatters["tick"]);
6488
- axis.labelGroup.call(bottomLabelAxis);
6523
+ .tickSize(0);
6524
+ if ((_a = scale.fixDomainValues) === null || _a === void 0 ? void 0 : _a.length) {
6525
+ labelAxis.tickValues(scale.fixDomainValues);
6526
+ }
6527
+ labelAxis.tickFormat(scale.formatters["tick"]);
6528
+ axis.labelGroup.call(labelAxis);
6489
6529
  let tickAxis;
6490
6530
  if (scale instanceof BandScale) {
6491
6531
  tickAxis = axisGenerator(scale.copyToLinear().d3Scale)
@@ -6494,9 +6534,11 @@ class XYGrid extends Grid {
6494
6534
  .tickFormat(() => "");
6495
6535
  }
6496
6536
  else {
6497
- tickAxis = axisGenerator(scale.d3Scale)
6498
- .tickSize(config.tickSize)
6499
- .tickFormat(() => "");
6537
+ tickAxis = axisGenerator(scale.d3Scale).tickSize(config.tickSize);
6538
+ if ((_b = scale.fixDomainValues) === null || _b === void 0 ? void 0 : _b.length) {
6539
+ tickAxis.tickValues(scale.fixDomainValues);
6540
+ }
6541
+ tickAxis.tickFormat(() => "");
6500
6542
  tickAxis.ticks(config.approximateTicks);
6501
6543
  }
6502
6544
  axis.tickGroup.call(tickAxis);
@@ -6509,13 +6551,15 @@ class XYGrid extends Grid {
6509
6551
  }
6510
6552
  /** @ignore */
6511
6553
  drawGrids(config, axis, axisGenerator, scale, size) {
6554
+ var _a;
6512
6555
  const modifyZeroLines = (gridGroupSelection) => gridGroupSelection
6513
6556
  .selectAll(".tick line")
6514
6557
  .classed("nui-zero-line", (d) => d === 0);
6515
- const leftGridLines = axisGenerator(scale.d3Scale)
6516
- .tickSize(size)
6517
- .tickFormat(() => "")
6518
- .ticks(config.approximateTicks);
6558
+ const leftGridLines = axisGenerator(scale.d3Scale).tickSize(size);
6559
+ if ((_a = scale.fixDomainValues) === null || _a === void 0 ? void 0 : _a.length) {
6560
+ leftGridLines.tickValues(scale.fixDomainValues);
6561
+ }
6562
+ leftGridLines.tickFormat(() => "").ticks(config.approximateTicks);
6519
6563
  if (config.gridTicks) {
6520
6564
  const gridSelection = axis.tickGroup.call(leftGridLines);
6521
6565
  modifyZeroLines(gridSelection);