@opendata-ai/openchart-engine 7.4.1 → 7.6.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) {
@@ -7520,9 +7523,11 @@ function computeTrendLine(marks) {
7520
7523
  var scatterRenderer = (spec, scales, chartArea, strategy, _theme) => {
7521
7524
  const pointMarks = computeScatterMarks(spec, scales, chartArea, strategy);
7522
7525
  const marks = [...pointMarks];
7523
- const trendLine = computeTrendLine(pointMarks);
7524
- if (trendLine) {
7525
- marks.unshift(trendLine);
7526
+ if (spec.markDef?.trendline !== false) {
7527
+ const trendLine = computeTrendLine(pointMarks);
7528
+ if (trendLine) {
7529
+ marks.unshift(trendLine);
7530
+ }
7526
7531
  }
7527
7532
  return marks;
7528
7533
  };