How to use victory-chart - 10 common examples

To help you get started, we’ve selected a few victory-chart 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.js View on Github external
const windowWidth = Dimensions.get("window").width;
    const distanceDelta = currentDistance - pinchState.initialDistance;

    // when zooming out, apply a multiplier to the scale factor to make
    // the zoom-out velocity match the equivalent zoom-in velocity
    let scaleMultiplier = 1;
    if (distanceDelta < 0) {
      const [initialStart, initialEnd] = pinchState.initialDomain.x;
      const [dataStart, dataEnd] = this.getDataDomain().x;
      if (initialStart !== initialEnd) {
        scaleMultiplier = Math.abs(dataEnd - dataStart) / Math.abs(initialEnd - initialStart);
      }
    }

    const scaleFactor = 1 - ((distanceDelta / windowWidth) * scaleMultiplier);
    const nextXDomain = ZoomHelpers.scale(
      pinchState.initialDomain.x,
      this.getDataDomain().x,
      scaleFactor
    );
    this.setDomain({ x: nextXDomain });
  }
github FormidableLabs / victory-chart-native / lib / components / victory-zoom.js View on Github external
const windowWidth = Dimensions.get("window").width;
    const distanceDelta = currentDistance - pinchState.initialDistance;

    // when zooming out, apply a multiplier to the scale factor to make
    // the zoom-out velocity match the equivalent zoom-in velocity
    let scaleMultiplier = 1;
    if (distanceDelta < 0) {
      const [initialStart, initialEnd] = pinchState.initialDomain.x;
      const [dataStart, dataEnd] = this.getDataDomain().x;
      if (initialStart !== initialEnd) {
        scaleMultiplier = Math.abs(dataEnd - dataStart) / Math.abs(initialEnd - initialStart);
      }
    }

    const scaleFactor = 1 - ((distanceDelta / windowWidth) * scaleMultiplier);
    const nextXDomain = ZoomHelpers.scale(
      pinchState.initialDomain.x,
      this.getDataDomain().x,
      scaleFactor
    );
    this.setDomain({x: nextXDomain});
  }
github FormidableLabs / victory-chart-native / lib / components / victory-zoom.js View on Github external
import { View, PanResponder, StyleSheet, Dimensions } from "react-native";
import { VictoryZoom } from "victory-chart/src";
import { VictoryClipContainer } from "victory-core-native";
import ZoomHelpers from "victory-chart/src/components/victory-zoom/helper-methods";

const styles = StyleSheet.create({
  responder: {
    flex: 1,
    alignItems: "center"
  }
});

export default class extends VictoryZoom {

  static defaultProps = {
    ...VictoryZoom.defaultProps,
    clipContainerComponent: 
  }

  constructor(props) {
    super(props);
    this.panResponder = this.getResponder();
  }

  // override default VictoryZoom events, we will handle touches
  // via a PanResponder instead. See getResponder() below
  getEvents() {
    return [];
  }

  // configure a PanResponder
  getResponder() {
github FormidableLabs / victory-native / lib / components / victory-zoom.js View on Github external
import { VictoryZoom } from "victory-chart/src";
import ZoomHelpers from "victory-chart/src/components/victory-zoom/helper-methods";

import VictoryClipContainer from "./victory-clip-container";

const styles = StyleSheet.create({
  responder: {
    flex: 1,
    alignItems: "center"
  }
});

export default class extends VictoryZoom {

  static defaultProps = {
    ...VictoryZoom.defaultProps,
    clipContainerComponent: 
  }

  constructor(props) {
    super(props);
    this.panResponder = this.getResponder();
  }

  // override default VictoryZoom events, we will handle touches
  // via a PanResponder instead. See getResponder() below
  getEvents() {
    return [];
  }

  // configure a PanResponder
  getResponder() {
github FormidableLabs / victory-chart-native / lib / components / victory-zoom.js View on Github external
handlePan(deltaX) {
    const calculatedDx = -(deltaX / this.getDomainScale());
    const nextXDomain = ZoomHelpers.pan(
      this.lastDomain.x,
      this.getDataDomain().x,
      calculatedDx
    );
    this.setDomain({x: nextXDomain});
  }
github FormidableLabs / victory-native / lib / components / victory-zoom.js View on Github external
handlePan(deltaX) {
    const calculatedDx = -(deltaX / this.getDomainScale());
    const nextXDomain = ZoomHelpers.pan(
      this.lastDomain.x,
      this.getDataDomain().x,
      calculatedDx
    );
    this.setDomain({ x: nextXDomain });
  }
github FormidableLabs / victory-native / lib / components / victory-voronoi-tooltip.js View on Github external
import React from "react";
import { Dimensions } from "react-native";
import { G } from "react-native-svg";
import { VictoryVoronoiTooltip } from "victory-chart/src";

import VictoryTooltip from "./victory-tooltip";
import VictoryContainer from "./victory-container";
import { Voronoi } from "../index";

export default class extends VictoryVoronoiTooltip {
  static defaultProps = {
    ...VictoryVoronoiTooltip.defaultProps,
    dataComponent: ,
    labelComponent: ,
    containerComponent: ,
    groupComponent:
github FormidableLabs / victory-chart-native / lib / components / victory-voronoi-tooltip.js View on Github external
import React from "react";
import { Dimensions, Platform } from "react-native";
import { G } from "react-native-svg";
import { VictoryVoronoiTooltip } from "victory-chart/src";
import { VictoryTooltip, VictoryContainer, Voronoi } from "victory-core-native";

export default class extends VictoryVoronoiTooltip {
  static defaultProps = {
    ...VictoryVoronoiTooltip.defaultProps,
    dataComponent: ,
    labelComponent: ,
    containerComponent: ,
    groupComponent:
github FormidableLabs / victory-native / lib / components / victory-chart.js View on Github external
import React from "react";
import { Dimensions } from "react-native";
import { G } from "react-native-svg";
import { VictoryChart } from "victory-chart/es";
import VictoryAxis from "./victory-axis";
import VictoryPolarAxis from "./victory-polar-axis";
import VictoryContainer from "./victory-container";

export default class extends VictoryChart {
  static defaultProps = Object.assign({}, VictoryChart.defaultProps, {
    containerComponent: ,
    groupComponent:
github FormidableLabs / victory-chart-native / lib / components / victory-area.js View on Github external
import React from "react";
import { Dimensions, Platform } from "react-native";
import { VictoryLabel, VictoryContainer, Area, VictoryClipContainer } from "victory-core-native";
import { VictoryArea } from "victory-chart/src";

export default class extends VictoryArea {
  static defaultProps = {
    ...VictoryArea.defaultProps,
    dataComponent: <area>,
    labelComponent: ,
    containerComponent: ,
    groupComponent: ,
    width: Dimensions.get("window").width
  }

  shouldAnimate() {
    return (Platform.OS === "android") ? false : Boolean(this.props.animate);
  }
}