How to use the d3-hierarchy.packEnclose function in d3-hierarchy

To help you get started, we’ve selected a few d3-hierarchy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / d3-hierarchy / d3-hierarchy-tests.ts View on Github external
let circles: Array = [
    { r: 10, v: 'a' },
    { r: 1, v: 'b' },
    { r: 20, v: 'c' }
];

// packSiblings

circles = d3Hierarchy.packSiblings(circles);

// packEnclose

let enclosure: { r: number, x: number, y: number };

enclosure = d3Hierarchy.packEnclose(circles);
github DefinitelyTyped / DefinitelyTyped / types / d3-hierarchy / d3-hierarchy-tests.ts View on Github external
let circles: Array = [
    { r: 10, v: 'a' },
    { r: 1, v: 'b' },
    { r: 20, v: 'c' }
];

// packSiblings

circles = d3Hierarchy.packSiblings(circles);

// packEnclose

let enclosure: { r: number, x: number, y: number };

enclosure = d3Hierarchy.packEnclose(circles);
github CyberReboot / CRviz / src / features / visualization / d3-viz / pack-with-label.js View on Github external
nonleafChildren.forEach((node) => {
      node.labelSize = Math.min(labelSize, getLabelSize(maxLabelRatio)(node));
      node.r += node.labelSize / 2;
    });
  }

  const paddingSize = padding(node) * k || 0;

  // Padding is implemented by adding it to the children's radii, pack,
  // then returning the radii to their original value.
  if (paddingSize) {
    children.forEach((child) => (child.r += paddingSize));
  }

  packSiblings(children);
  const enclosingRadius = packEnclose(children).r;

  if (paddingSize) {
    children.forEach((child) => (child.r -= paddingSize));
  }

  node.r = enclosingRadius + paddingSize;
};
github CyberReboot / CRviz / src / features / visualization / d3-viz / pack-grid.js View on Github external
const packGrid = (circles) => {
  const rows = toRows(circles);
  placeRows(rows);

  // Recenter everything over the origin
  var enclosingCircle = packEnclose(circles);
  forEach((c) => {
    c.x -= enclosingCircle.x;
    c.y -= enclosingCircle.y
  }, circles);
};
github nteract / semiotic / src / components / annotationRules / orframeRules.tsx View on Github external
export const svgEncloseRule = ({ d, i, screenCoordinates }) => {
  const circle = packEnclose(
    screenCoordinates.map(p => ({ x: p[0], y: p[1], r: 2 }))
  )

  return circleEnclosure({ d, i, circle })
}
github nteract / semiotic / src / components / annotationRules / networkframeRules.tsx View on Github external
export const svgEncloseRule = ({
  d,
  i,
  projectedNodes,
  nodeIDAccessor,
  nodeSizeAccessor
}) => {
  const selectedNodes = projectedNodes.filter(
    p => d.ids.indexOf(nodeIDAccessor(p)) !== -1
  )
  if (selectedNodes.length === 0) {
    return null
  }
  const circle = packEnclose(
    selectedNodes.map(p => ({ x: p.x, y: p.y, r: nodeSizeAccessor(p) }))
  )
  return circleEnclosure({ circle, d, i })
}
github nteract / semiotic / src / components / annotationRules / xyframeRules.tsx View on Github external
export const svgEncloseAnnotation = ({ screenCoordinates, d, i }) => {
  const circle = packEnclose(
    screenCoordinates.map(p => ({ x: p[0], y: p[1], r: 2 }))
  )

  return circleEnclosure({ d, circle, i })
}