@guardian/interactive-component-library 0.1.0-alpha.52 → 0.1.0-alpha.53

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.
@@ -158,6 +158,8 @@ const defaultStyles$v = {
158
158
  function preventOverlap(labelPositions, iteration = 0, labelSize = 12, coordinate = "y", moveBothLabels = true) {
159
159
  const maxIterations = 10;
160
160
  let totalOverlap = 0;
161
+ if (!isArrayWithCoordinates(labelPositions, coordinate))
162
+ return labelPositions;
161
163
  for (let index = 1; index < labelPositions.length; index++) {
162
164
  const previousElement = labelPositions[index - 1];
163
165
  const element = labelPositions[index];
@@ -195,6 +197,9 @@ function scaleLinear(domain, range) {
195
197
  return slope * x + intercept;
196
198
  };
197
199
  }
200
+ function isArrayWithCoordinates(labelPositions, coordinate) {
201
+ return labelPositions.every((position) => typeof position[coordinate] === "number");
202
+ }
198
203
  const LabelType = {
199
204
  hanging: "hanging",
200
205
  inline: "inline"