@mathstack/viz 0.0.1-beta.7 → 0.0.1-beta.9

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.
@@ -1815,9 +1815,9 @@ class XyAxis extends XyAuxMarks {
1815
1815
  .append('g')
1816
1816
  .attr('class', this.class.axisGroup);
1817
1817
  }
1818
- // Avoid odd animations of ticks or domain lines when those things move between draws
1818
+ // Remove domain to avoid odd baseline/zero-axis positioning during transitions
1819
+ // Ticks are preserved to allow smooth transitions
1819
1820
  this.axisGroup.select('.domain').remove();
1820
- this.axisGroup.selectAll('.tick').remove();
1821
1821
  this.axisGroup
1822
1822
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1823
1823
  .transition(this.getTransition(this.axisGroup))
@@ -1827,11 +1827,28 @@ class XyAxis extends XyAuxMarks {
1827
1827
  this.processDomain();
1828
1828
  this.drawGrid();
1829
1829
  });
1830
+ // Hide elements immediately based on config to prevent flash during transition
1831
+ this.hideElementsPerConfig();
1830
1832
  this.processTickLabels();
1831
1833
  if (this.config.label) {
1832
1834
  this.createLabel();
1833
1835
  }
1834
1836
  }
1837
+ hideElementsPerConfig() {
1838
+ // Remove tick marks immediately if configured to be hidden
1839
+ if (this.config.ticks.marksDisplay === false) {
1840
+ this.axisGroup.selectAll('.tick line').interrupt().remove();
1841
+ }
1842
+ // Remove tick labels immediately if configured to be hidden
1843
+ if (this.config.ticks.labelsDisplay === false) {
1844
+ this.axisGroup.selectAll('.tick text').interrupt().remove();
1845
+ }
1846
+ // Remove baseline immediately if not displayed and no zero baseline exists
1847
+ const zeroAxisTranslate = this.getBaselineTranslate();
1848
+ if (!this.config.baseline.display && zeroAxisTranslate === null) {
1849
+ this.axisGroup.select('.domain').interrupt().remove();
1850
+ }
1851
+ }
1835
1852
  processTicks() {
1836
1853
  const tickText = select(this.elRef.nativeElement).selectAll('.tick text');
1837
1854
  if (this.config.ticks.class) {
@@ -1856,10 +1873,6 @@ class XyAxis extends XyAuxMarks {
1856
1873
  if (this.config.ticks.wrap && this.config.ticks.wrap.width !== undefined) {
1857
1874
  this.wrapAxisTickText(tickText);
1858
1875
  }
1859
- if (this.config.ticks.marksDisplay === false) {
1860
- const marks = select(this.elRef.nativeElement).selectAll(`.${this.class.axisGroup} .tick line`);
1861
- marks.remove();
1862
- }
1863
1876
  }
1864
1877
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1865
1878
  setTickFontSize(tickTextSelection) {
@@ -1903,14 +1916,8 @@ class XyAxis extends XyAuxMarks {
1903
1916
  .attr('transform', null)
1904
1917
  .attr('stroke-dasharray', null));
1905
1918
  }
1906
- if (!this.config.baseline.display && zeroAxisTranslate === null) {
1907
- this.axisGroup.call((g) => g.select('.domain').remove());
1908
- }
1909
1919
  }
1910
1920
  processTickLabels() {
1911
- if (this.config.ticks.labelsDisplay === false) {
1912
- this.axisGroup.call((g) => g.selectAll('.tick text').remove());
1913
- }
1914
1921
  if (this.config.ticks.rotate) {
1915
1922
  this.axisGroup.call((g) => g
1916
1923
  .selectAll('.tick text')
@@ -1943,8 +1950,6 @@ class XyAxis extends XyAuxMarks {
1943
1950
  .append('g')
1944
1951
  .attr('class', this.class.gridGroup);
1945
1952
  }
1946
- // Avoid odd animations of grid lines when they change between draws
1947
- this.gridGroup.selectAll('.tick').remove();
1948
1953
  this.gridGroup
1949
1954
  .transition(this.getTransition(this.gridGroup))
1950
1955
  .call(this.axis.tickSizeInner(this.getGridLineLength()))