How to use the victory-core.Data.formatData 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-native / lib / components / victory-zoom-container.js View on Github external
downsampleZoomData(props, childProps, domain) {
    const { downsample } = props;
    const rawData = get(childProps, "data");
    // return undefined if downsample is not run, then default() will replace with child.props.data
    if (!downsample || !rawData || !domain) { return undefined; }

    // if data accessors are not used, skip calling expensive Data.formatData
    const data = (childProps.x || childProps.y) ? Data.formatData(rawData, childProps) : rawData;
    const maxPoints = (downsample === true) ? DEFAULT_DOWNSAMPLE : downsample;
    const dimension = props.zoomDimension || "x";

    // important: assumes data is ordered by dimension
    // get the start and end of the data that is in the current visible domain
    let startIndex = data.findIndex((d) => d[dimension] >= domain[dimension][0]);
    let endIndex = data.findIndex((d) => d[dimension] > domain[dimension][1]);
    // pick one more point (if available) at each end so that VictoryLine, VictoryArea connect
    if (startIndex !== 0) { startIndex -= 1; }
    if (endIndex !== -1) { endIndex += 1; }

    const visibleData = data.slice(startIndex, endIndex);

    return Data.downsample(visibleData, maxPoints, startIndex);
  }
github patternfly / patternfly-react / packages / patternfly-4 / react-charts / src / components / ChartDonutUtilization / ChartDonutThreshold.tsx View on Github external
React.Children.toArray(children).map((child, index) => {
      if (child.props) {
        const { data: childData, ...childProps } = child.props;
        const datum = Data.formatData([childData], childProps, ['x', 'y']); // Format child data independently of this component's props
        const dynamicTheme =
          childProps.theme ||
          getDonutThresholdDynamicTheme(childProps.themeColor || themeColor, childProps.themeVariant || themeVariant);

        return React.cloneElement(child, {
          constrainToVisibleArea,
          data: childData,
          endAngle: 360 * (datum[0]._y ? datum[0]._y / 100 : 0),
          height,
          invert,
          key: `pf-chart-donut-threshold-child-${index}`,
          padding: defaultPadding,
          radius: chartRadius - 14, // Donut utilization radius is threshold radius minus 14px spacing
          showStatic: false,
          standalone: false,
          subTitlePosition: childProps.subTitlePosition || subTitlePosition,
github FormidableLabs / victory / packages / victory-candlestick / src / helper-methods.js View on Github external
const getData = (props) => {
  const accessorTypes = ["x", "high", "low", "close", "open"];
  return Data.formatData(props.data, props, accessorTypes);
};
github FormidableLabs / victory / packages / victory-errorbar / src / helper-methods.js View on Github external
const getData = (props) => {
  const accessorTypes = ["x", "y", "errorX", "errorY"];
  if (props.data) {
    return Data.formatData(props.data, props, accessorTypes);
  } else {
    const generatedData = props.errorX || props.errorY ? Data.generateData(props) : [];
    return Data.formatData(generatedData, props, accessorTypes);
  }
};
github patternfly / patternfly-react / packages / patternfly-4 / react-charts / src / components / ChartDonutUtilization / ChartDonutUtilization.tsx View on Github external
const getData = () => {
    const datum = [{ ...data }];
    return Data.formatData(datum, { x, y, ...rest }, ['x', 'y']).sort((a: any, b: any) => a._y - b._y);
  };
github FormidableLabs / victory / packages / victory-errorbar / src / helper-methods.js View on Github external
const getData = (props) => {
  const accessorTypes = ["x", "y", "errorX", "errorY"];
  if (props.data) {
    return Data.formatData(props.data, props, accessorTypes);
  } else {
    const generatedData = props.errorX || props.errorY ? Data.generateData(props) : [];
    return Data.formatData(generatedData, props, accessorTypes);
  }
};