@vizabi/bubblechart 4.0.2 → 4.1.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.
@@ -1,4 +1,4 @@
1
- // https://github.com/vizabi/bubblechart#readme v4.0.2 build 1693653872804 Copyright 2023 Gapminder Foundation and contributors
1
+ // https://github.com/vizabi/bubblechart#readme v4.1.1 build 1701881435565 Copyright 2023 Gapminder Foundation and contributors
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@vizabi/shared-components'), require('d3'), require('mobx')) :
4
4
  typeof define === 'function' && define.amd ? define(['exports', '@vizabi/shared-components', 'd3', 'mobx'], factory) :
@@ -2076,6 +2076,8 @@
2076
2076
  y
2077
2077
  } = this.MDL;
2078
2078
 
2079
+ this.model.encoding.y.scale.d3Scale;
2080
+
2079
2081
  const {
2080
2082
  graphAll,
2081
2083
  eventArea,
@@ -2121,20 +2123,29 @@
2121
2123
  this.yScale.range(this._rangeBump([height, 0]));
2122
2124
  this.xScale.range(this._rangeBump([0, width]));
2123
2125
 
2126
+ //only applied to swimming lane sclae
2127
+ const rankScaleModifications = y.scale.type === "rank"
2128
+ ? {
2129
+ ticks: y.rollup.map(m => m.tickPosition),
2130
+ formatter: (d) => y.rollup.find(f => f.tickPosition === d).name,
2131
+ repositionLabels: Object.fromEntries(y.rollup.map(m => ([m.tickPosition, { x: 4 * infoElHeight, y: -infoElHeight }])))
2132
+ }
2133
+ : {};
2134
+
2124
2135
  //apply scales to axes and redraw
2125
2136
  this.yAxis.scale(this.yScale)
2126
2137
  .tickSizeInner(-width)
2127
2138
  .tickSizeOuter(0)
2128
2139
  .tickPadding(6)
2129
2140
  .tickSizeMinor(-width, 0)
2130
- .labelerOptions({
2141
+ .labelerOptions(Object.assign({
2131
2142
  scaleType: y.scale.type,
2132
2143
  toolMargin: margin,
2133
2144
  limitMaxTickNumber: 6,
2134
2145
  bump: this.profileConstants.maxRadiusPx / 2,
2135
2146
  viewportLength: height,
2136
2147
  formatter: this.localise
2137
- });
2148
+ }, rankScaleModifications));
2138
2149
 
2139
2150
  this.xAxis.scale(this.xScale)
2140
2151
  .tickSizeInner(-height)
@@ -2282,10 +2293,7 @@
2282
2293
  let minArea = sharedComponents.LegacyUtils.radiusToArea(Math.max(maxRadiusPx * extent[0], minRadiusPx));
2283
2294
  let maxArea = sharedComponents.LegacyUtils.radiusToArea(Math.max(maxRadiusPx * extent[1], minRadiusPx));
2284
2295
 
2285
- let range = minArea === maxArea? [minArea, maxArea] :
2286
- d3.range(minArea, maxArea, (maxArea - minArea)/(this.sScale.domain().length - 1)).concat(maxArea);
2287
-
2288
- this.sScale.range(range);
2296
+ this.sScale.range([minArea, maxArea]);
2289
2297
  this.trailSizeScale.domain(this.MDL.size.scale.domain).range([minTrailThicknessPx, maxTrailThicknessPx]);
2290
2298
  }
2291
2299
 
@@ -2409,11 +2417,11 @@
2409
2417
  .attr("x1", this.xScale(valueX) - radius);
2410
2418
  }
2411
2419
 
2412
- if (this.ui.whenHovering.higlightValueX) xAxisEl.call(
2420
+ if (this.ui.whenHovering.higlightValueX && this.MDL.x.scale.type !== "rank") xAxisEl.call(
2413
2421
  this.xAxis.highlightValue(valueX)
2414
2422
  );
2415
2423
 
2416
- if (this.ui.whenHovering.higlightValueY) yAxisEl.call(
2424
+ if (this.ui.whenHovering.higlightValueY && this.MDL.y.scale.type !== "rank") yAxisEl.call(
2417
2425
  this.yAxis.highlightValue(valueY)
2418
2426
  );
2419
2427
 
@@ -2587,7 +2595,7 @@
2587
2595
  //console.log("trailstart", trailStart)
2588
2596
  // if this bubble is trail start bubble
2589
2597
  if (trailStart >= this.MDL.frame.value || showhide) {
2590
- const trailData = this.model.getDataMapByFrameValue(trailStart).getByStr(key);
2598
+ const trailData = this.model.getDataMapByFrameValue(trailStart, "trail.addTrails").getByStr(key);
2591
2599
 
2592
2600
  cache.labelText = labelText = this.__labelWithFrame(trailData);
2593
2601
  cache.labelX0 = trailData[this._alias("x")];
@@ -2624,7 +2632,7 @@
2624
2632
  if (!this._labels.cached[key]) this._labels.cached[key] = {};
2625
2633
  const cache = this._labels.cached[key];
2626
2634
 
2627
- const datamap = (trail.show ? this.model.getDataMapByFrameValue(trail.starts[key]) : this.model.dataMap);
2635
+ const datamap = (trail.show ? this.model.getDataMapByFrameValue(trail.starts[key], "trail.addTrails") : this.model.dataMap);
2628
2636
  if (!datamap.hasByStr(key))
2629
2637
  continue;
2630
2638
 
@@ -2846,6 +2854,7 @@
2846
2854
  "size": {
2847
2855
  scale: {
2848
2856
  modelType: "size",
2857
+ allowedTypes: ["linear", "log", "genericLog", "pow", "point"],
2849
2858
  range: [0, 50]
2850
2859
  }
2851
2860
  },
@@ -2859,7 +2868,7 @@
2859
2868
  },
2860
2869
  scale: {
2861
2870
  modelType: "size",
2862
- allowedTypes: ["linear", "log", "genericLog", "pow", "point", "ordinal"]
2871
+ allowedTypes: ["linear", "log", "genericLog", "pow", "point"]
2863
2872
  }
2864
2873
  },
2865
2874
  "repeat": {
@@ -2869,7 +2878,7 @@
2869
2878
  }
2870
2879
  });
2871
2880
 
2872
- BubbleChart.versionInfo = { version: "4.0.2", build: 1693653872804, package: {"homepage":"https://github.com/vizabi/bubblechart#readme","name":"@vizabi/bubblechart","description":"Vizabi bubble chart"}, sharedComponents: sharedComponents.versionInfo};
2881
+ BubbleChart.versionInfo = { version: "4.1.1", build: 1701881435565, package: {"homepage":"https://github.com/vizabi/bubblechart#readme","name":"@vizabi/bubblechart","description":"Vizabi bubble chart"}, sharedComponents: sharedComponents.versionInfo};
2873
2882
 
2874
2883
  exports.Base = BubbleChart;
2875
2884