@opendata-ai/openchart-engine 7.4.0 → 7.5.0

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/dist/index.js CHANGED
@@ -7408,13 +7408,16 @@ function computeScatterMarks(spec, scales, _chartArea, _strategy) {
7408
7408
  const colorEnc = encoding.color && "field" in encoding.color ? encoding.color : void 0;
7409
7409
  const isSequentialColor = colorEnc?.type === "quantitative";
7410
7410
  const colorField = colorEnc?.field;
7411
- const sizeField = encoding.size && "field" in encoding.size ? encoding.size.field : void 0;
7411
+ const sizeEnc = encoding.size && "field" in encoding.size ? encoding.size : void 0;
7412
+ const sizeField = sizeEnc?.field;
7412
7413
  let sizeScale;
7413
7414
  if (sizeField) {
7414
7415
  const sizeValues = spec.data.map((d) => Number(d[sizeField])).filter((v) => Number.isFinite(v));
7415
- const sizeMin = min2(sizeValues) ?? 0;
7416
- const sizeMax = max2(sizeValues) ?? 1;
7417
- sizeScale = sqrt2().domain([sizeMin, sizeMax]).range([MIN_BUBBLE_RADIUS, MAX_BUBBLE_RADIUS]);
7416
+ const explicitDomain = sizeEnc?.scale?.domain;
7417
+ const [sizeMin, sizeMax] = explicitDomain ?? [min2(sizeValues) ?? 0, max2(sizeValues) ?? 1];
7418
+ const explicitRange = sizeEnc?.scale?.range;
7419
+ const [radiusMin, radiusMax] = explicitRange ?? [MIN_BUBBLE_RADIUS, MAX_BUBBLE_RADIUS];
7420
+ sizeScale = sqrt2().domain([sizeMin, sizeMax]).range([radiusMin, radiusMax]).clamp(true);
7418
7421
  }
7419
7422
  const marks = [];
7420
7423
  for (const row of spec.data) {
@@ -9656,7 +9659,11 @@ function extractColorEntries(spec, theme) {
9656
9659
  if (!colorEnc) return [];
9657
9660
  if ("condition" in colorEnc) return [];
9658
9661
  if (colorEnc.type === "quantitative") return [];
9659
- const dataValues = [...new Set(spec.data.map((d) => String(d[colorEnc.field])))];
9662
+ const dataValues = [
9663
+ ...new Set(
9664
+ spec.data.filter((d) => d[colorEnc.field] != null).map((d) => String(d[colorEnc.field]))
9665
+ )
9666
+ ];
9660
9667
  const explicitDomain = colorEnc.scale?.domain;
9661
9668
  const explicitRange = colorEnc.scale?.range;
9662
9669
  const palette = explicitRange ?? theme.colors.categorical;