How to use the victory.TextSize.approximateTextSize function in victory

To help you get started, we’ve selected a few victory 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 tidepool-org / viz / src / components / common / stat / HoverBarLabel.js View on Github external
});

  const tooltipTextSize = TextSize.approximateTextSize(tooltipText(datum), tooltipStyle);

  const labelStyle = _.assign({}, style, {
    pointerEvents: 'none',
  });

  const labelUnitsStyle = _.assign({}, labelStyle, {
    fontSize: labelStyle.fontSize / 2,
    baselineShift: -((labelStyle.fontSize / 2) * 0.25),
    fill: colors.statDefault,
  });

  const labelText = text(datum);
  const labelUnitsTextSize = TextSize.approximateTextSize(labelText[1] || '', labelUnitsStyle);

  // Ensure that the datum y value isn't below zero, or the tooltip will be incorrectly positioned
  const tooltipDatum = {
    ...datum,
    y: _.max([datum.y, 0]),
  };

  return (
github tidepool-org / viz / src / components / common / stat / HoverBarLabel.js View on Github external
text,
    tooltipText,
  } = props;

  const tooltipFontSize = _.min([barWidth / 2, 12]);
  const tooltipHeight = tooltipFontSize * 1.2;
  const tooltipRadius = tooltipHeight / 2;

  const disabled = isDisabled();

  const tooltipStyle = _.assign({}, style, {
    fontSize: tooltipFontSize,
    display: disabled ? 'none' : 'inherit',
  });

  const tooltipTextSize = TextSize.approximateTextSize(tooltipText(datum), tooltipStyle);

  const labelStyle = _.assign({}, style, {
    pointerEvents: 'none',
  });

  const labelUnitsStyle = _.assign({}, labelStyle, {
    fontSize: labelStyle.fontSize / 2,
    baselineShift: -((labelStyle.fontSize / 2) * 0.25),
    fill: colors.statDefault,
  });

  const labelText = text(datum);
  const labelUnitsTextSize = TextSize.approximateTextSize(labelText[1] || '', labelUnitsStyle);

  // Ensure that the datum y value isn't below zero, or the tooltip will be incorrectly positioned
  const tooltipDatum = {