Victory

repository·main·Indexed 11 days ago

https://github.com/formidablelabs/victory

An ecosystem of composable React components for building interactive data visualizations. Compatible with both web (React) and mobile (React Native) environments, Victory provides a wide range of chart types including area, bar, box-plot, candlestick, line, and pie charts, along with specialized components like VictoryCanvas for HTML5 Canvas rendering.

Tokens
140K
Snippets
458
Records
591
Agent score
95%

What's inside Victory

  1. Getting Started with Victory

    main

    Victory is a collection of composable React components designed for building interactive data visualizations. It is highly opinionated to provide sensible defaults but is fully overridable to allow for deep customization. You can build complex charts by composing various components like VictoryChart, VictoryAxis, VictoryLine, and VictoryLegend together.

    import { VictoryChart, VictoryLine, VictoryAxis, VictoryLegend } from 'victory';
    
    function App() {
      return (
        <VictoryChart>
          <VictoryLine data={[{ x: 1, y: 2 }, { x: 2, y: 3 }]} />
          <VictoryAxis />
        </VictoryChart>
      );
    }
  2. Overview of VictoryCore exported components and utilities

    main

    victory-core is a foundational package that exports several components and utilities used by various Victory charting components. It provides the primitive building blocks for shapes, containers, animations, and mathematical utilities required for data visualization.

    Key Components

    • Containers & Layout: VictoryAnimation, VictoryClipContainer, VictoryContainer, VictoryPortal, and Portal.
    • Labels & Transitions: VictoryLabel, VictoryTheme, and VictoryTransition.
    • Primitives: Arc, Border / Box, Circle, ClipPath, LineSegment (formerly Axis / Grid), Line, Path, Point, Rect, Text, TSpan, and Whisker.

    Key Utilities

    victory-core provides a wide range of utilities for handling data, scales, and styles, including:

    • Data & Math: Data, Domain, Scale, Collection, Selection, and Immutable.
    • Visuals & Styling: Style, TextSize, LabelHelpers, and CommonProps.
    • Logic & Lifecycle: Events, addEvents, Timer, Transitions, DefaultTransitions, Helpers, Log, PropTypes, and Wrapper.
  3. Use VictoryArea components

    main

    The victory-area package provides the VictoryArea and Area components for rendering area charts. These components are used to create shaded regions under a line or between multiple data series.

    To use these components, install the package via npm or yarn and import them from victory-area.

    import { VictoryArea } from 'victory-area';
  4. Use VictoryBrushContainer

    main

    victory-brush-container provides the VictoryBrushContainer component, which is used to implement brush-based zooming and panning interactions in Victory charts.

    It exports the following primary entities:

    • VictoryBrushContainer: The main component for managing brush interactions.
    • brushContainerMixin: A mixin for adding brush container functionality to other components.
    • BrushHelpers: Utility functions to assist with brush operations.
  5. Use VictoryVoronoiContainer for Voronoi-based interaction

    main

    The victory-voronoi-container package provides VictoryVoronoiContainer, which is used to enhance Victory charts with Voronoi-based interaction. This allows for more precise mouse/touch interaction by calculating the nearest data point within a Voronoi diagram, rather than relying on exact coordinate matches.

    The package exports:

    • VictoryVoronoiContainer: The container component used to wrap charts.
    • voronoiContainerMixin: A mixin for creating custom components with Voronoi capabilities.
    • VoronoiHelpers: Utility functions for Voronoi calculations.
  6. Use VictorySelectionContainer, selectionContainerMixin, and SelectionHelpers

    main

    The victory-selection-container package provides tools for implementing selection logic within Victory charts. It exports three primary entities:

    • VictorySelectionContainer: A component used to wrap charts to enable selection capabilities.
    • selectionContainerMixin: A mixin for adding selection container functionality to existing components.
    • SelectionHelpers: A set of utility functions to assist with selection logic.

    For detailed API documentation and usage guides, refer to the official Victory documentation at https://commerce.nearform.com/open-source/victory/docs/victory-selection-container.

  7. Use VictoryCursorContainer

    main

    The victory-cursor-container package provides VictoryCursorContainer, cursorContainerMixin, and CursorHelpers. This package is used to manage and display cursor-related interactions within Victory charts.

    To use these features, install the package:

    npm install victory-cursor-container@^30.0.0

    For detailed API documentation and usage guides, refer to the official Victory documentation at https://commerce.nearform.com/open-source/victory/docs/victory-cursor-container.

  8. Install and use VictoryPie

    main

    The victory-pie package provides components for rendering pie charts. It exports the VictoryPie component for the main chart and the Slice component for individual segments.

    Ensure you install the package version compatible with your project (e.g., victory-pie@^30.0.0).

    npm install victory-pie@^30.0.0