How to use the victory-core.Scale.getScaleFromProps function in victory-core

To help you get started, we’ve selected a few victory-core 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 FormidableLabs / victory-chart / src / components / victory-chart / victory-chart.js View on Github external
x: Axis.getAxisComponent(childComponents, "x"),
      y: Axis.getAxisComponent(childComponents, "y")
    };
    const domain = {
      x: getDomain(props, "x", childComponents),
      y: getDomain(props, "y", childComponents)
    };
    const range = {
      x: props.polar ? Helpers.getPolarRange(props, "x") : Helpers.getRange(props, "x"),
      y: props.polar ? Helpers.getPolarRange(props, "y") : Helpers.getRange(props, "y")
    };
    const baseScale = {
      x: Scale.getScaleFromProps(props, "x") ||
        axisComponents.x && axisComponents.x.type.getScale(axisComponents.x.props) ||
        Scale.getDefaultScale(),
      y: Scale.getScaleFromProps(props, "y") ||
        axisComponents.y && axisComponents.y.type.getScale(axisComponents.y.props) ||
        Scale.getDefaultScale()
    };
    const scale = {
      x: baseScale.x.domain(domain.x).range(range.x),
      y: baseScale.y.domain(domain.y).range(range.y)
    };

    const origin = props.polar ? Helpers.getPolarOrigin(props) : Axis.getOrigin(domain);

    const originSign = {
      x: Axis.getOriginSign(origin.x, domain.x),
      y: Axis.getOriginSign(origin.y, domain.y)
    };

    // TODO: check
github FormidableLabs / victory / src / components / victory-polar-chart / victory-polar-chart.js View on Github external
x: Axis.getAxisComponent(childComponents, "x"),
      y: Axis.getAxisComponent(childComponents, "y")
    };
    const domain = {
      x: ChartHelpers.getDomain(props, "x", childComponents),
      y: ChartHelpers.getDomain(props, "y", childComponents)
    };
    const range = {
      x: this.getRange(props, "x"),
      y: this.getRange(props, "y")
    };
    const baseScale = {
      x: Scale.getScaleFromProps(props, "x") ||
        axisComponents.x && axisComponents.x.type.getScale(axisComponents.x.props) ||
        Scale.getDefaultScale(),
      y: Scale.getScaleFromProps(props, "y") ||
        axisComponents.y && axisComponents.y.type.getScale(axisComponents.y.props) ||
        Scale.getDefaultScale()
    };
    const scale = {
      x: baseScale.x.domain(domain.x).range(range.x),
      y: baseScale.y.domain(domain.y).range(range.y)
    };

    const origin = {
      x: Axis.getOrigin(domain.x),
      y: Axis.getOrigin(domain.y)
    };

    const originSign = {
      x: Axis.getOriginSign(origin.x, domain.x),
      y: Axis.getOriginSign(origin.y, domain.y)
github FormidableLabs / victory-chart / src / components / victory-chart / victory-chart.js View on Github external
return component.props && component.props.horizontal;
    });
    const axisComponents = {
      x: Axis.getAxisComponent(childComponents, "x"),
      y: Axis.getAxisComponent(childComponents, "y")
    };
    const domain = {
      x: getDomain(props, "x", childComponents),
      y: getDomain(props, "y", childComponents)
    };
    const range = {
      x: props.polar ? Helpers.getPolarRange(props, "x") : Helpers.getRange(props, "x"),
      y: props.polar ? Helpers.getPolarRange(props, "y") : Helpers.getRange(props, "y")
    };
    const baseScale = {
      x: Scale.getScaleFromProps(props, "x") ||
        axisComponents.x && axisComponents.x.type.getScale(axisComponents.x.props) ||
        Scale.getDefaultScale(),
      y: Scale.getScaleFromProps(props, "y") ||
        axisComponents.y && axisComponents.y.type.getScale(axisComponents.y.props) ||
        Scale.getDefaultScale()
    };
    const scale = {
      x: baseScale.x.domain(domain.x).range(range.x),
      y: baseScale.y.domain(domain.y).range(range.y)
    };

    const origin = props.polar ? Helpers.getPolarOrigin(props) : Axis.getOrigin(domain);

    const originSign = {
      x: Axis.getOriginSign(origin.x, domain.x),
      y: Axis.getOriginSign(origin.y, domain.y)
github FormidableLabs / victory-chart / src / components / victory-stack / victory-stack.js View on Github external
const horizontal = props.horizontal || childComponents.every(
      (component) => component.props.horizontal
    );
    const dataFromChildren = Wrapper.getDataFromChildren(props);
    const datasets = Wrapper.fillInMissingData(props, dataFromChildren);
    const domain = {
      x: Wrapper.getStackedDomain(props, "x", datasets),
      y: Wrapper.getStackedDomain(props, "y", datasets)
    };
    const range = {
      x: Helpers.getRange(props, "x"),
      y: Helpers.getRange(props, "y")
    };
    const baseScale = {
      x: Scale.getScaleFromProps(props, "x") || Scale.getDefaultScale(),
      y: Scale.getScaleFromProps(props, "y") || Scale.getDefaultScale()
    };
    const xScale = baseScale.x.domain(domain.x).range(range.x);
    const yScale = baseScale.y.domain(domain.y).range(range.y);
    const scale = {
      x: horizontal ? yScale : xScale,
      y: horizontal ? xScale : yScale
    };
    const categories = {
      x: Wrapper.getCategories(props, "x"),
      y: Wrapper.getCategories(props, "y")
    };
    const colorScale = props.colorScale;
    return { datasets, categories, range, domain, horizontal, scale, style, colorScale, role };
  }
github FormidableLabs / victory-chart / src / components / victory-group / victory-group.js View on Github external
const { offset, colorScale, color, polar } = modifiedProps;
    const horizontal = modifiedProps.horizontal || childComponents.every(
      (component) => component.props && component.props.horizontal
    );
    const datasets = Wrapper.getDataFromChildren(modifiedProps);
    const domain = {
      x: Wrapper.getDomain(modifiedProps, "x", childComponents),
      y: Wrapper.getDomain(modifiedProps, "y", childComponents)
    };
    const range = {
      x: Helpers.getRange(modifiedProps, "x"),
      y: Helpers.getRange(modifiedProps, "y")
    };
    const baseScale = {
      x: Scale.getScaleFromProps(modifiedProps, "x") || Scale.getDefaultScale(),
      y: Scale.getScaleFromProps(modifiedProps, "y") || Scale.getDefaultScale()
    };
    const xScale = baseScale.x.domain(domain.x).range(range.x);
    const yScale = baseScale.y.domain(domain.y).range(range.y);
    const scale = {
      x: horizontal ? yScale : xScale,
      y: horizontal ? xScale : yScale
    };
    const categories = {
      x: Wrapper.getCategories(modifiedProps, "x"),
      y: Wrapper.getCategories(modifiedProps, "y")
    };
    const origin = polar ? props.origin : Helpers.getPolarOrigin(modifiedProps);
    const padding = Helpers.getPadding(props);
    return {
      datasets, categories, range, domain, horizontal,
      scale, style, colorScale, color, offset, origin, padding
github FormidableLabs / victory / packages / victory-group / src / helper-methods.js View on Github external
const role = "group";
  props = Helpers.modifyProps(props, fallbackProps, role);
  const style = Wrapper.getStyle(props.theme, props.style, role);
  const { offset, colorScale, color, polar, horizontal } = props;
  const categories = Wrapper.getCategories(props, childComponents);
  const datasets = Wrapper.getDataFromChildren(props);
  const domain = {
    x: Wrapper.getDomain(assign({}, props, { categories }), "x", childComponents),
    y: Wrapper.getDomain(assign({}, props, { categories }), "y", childComponents)
  };
  const range = {
    x: Helpers.getRange(props, "x"),
    y: Helpers.getRange(props, "y")
  };
  const baseScale = {
    x: Scale.getScaleFromProps(props, "x") || Wrapper.getScale(props, "x"),
    y: Scale.getScaleFromProps(props, "y") || Wrapper.getScale(props, "y")
  };
  const scale = {
    x: baseScale.x
      .domain(domain.x)
      .range(props.horizontal ? range.y : range.x),
    y: baseScale.y
      .domain(domain.y)
      .range(props.horizontal ? range.x: range.y)
  };

  const origin = polar ? props.origin : Helpers.getPolarOrigin(props);
  const padding = Helpers.getPadding(props);
  return {
    datasets,
    categories,
github FormidableLabs / victory / packages / victory-chart / src / helper-methods.js View on Github external
function getCalculatedProps(props, childComponents) {
  const style = getStyles(props);
  props = Helpers.modifyProps(props, fallbackProps, "chart");
  const { horizontal, polar } = props;
  const categories = Wrapper.getCategories(props, childComponents);
  const stringMap = createStringMap(props, childComponents);
  const domain = {
    x: getDomain(assign({}, props, { categories }), "x", childComponents),
    y: getDomain(assign({}, props, { categories }), "y", childComponents)
  };
  const range = {
    x: Helpers.getRange(props, "x"),
    y: Helpers.getRange(props, "y")
  };
  const baseScale = {
    x: Scale.getScaleFromProps(props, "x") || Wrapper.getScale(props, "x"),
    y: Scale.getScaleFromProps(props, "y") || Wrapper.getScale(props, "y")
  };
  const scale = {
    x: baseScale.x.domain(domain.x).range(horizontal ? range.y : range.x),
    y: baseScale.y.domain(domain.y).range(horizontal ? range.x : range.y)
  };
  const origin = polar ? Helpers.getPolarOrigin(props) : Axis.getOrigin(domain);

  const originSign = {
    x: Axis.getOriginSign(origin.x, domain.x),
    y: Axis.getOriginSign(origin.y, domain.y)
  };

  const orientations = {
    x: getOrientation("x", originSign.y, horizontal),
    y: getOrientation("y", originSign.x, horizontal)