Skip to content

Instantly share code, notes, and snippets.

@victorouse
Created May 4, 2020 02:16
Show Gist options
  • Select an option

  • Save victorouse/e9396b970869cf94d1c845f59f58d43e to your computer and use it in GitHub Desktop.

Select an option

Save victorouse/e9396b970869cf94d1c845f59f58d43e to your computer and use it in GitHub Desktop.

Revisions

  1. victorouse renamed this gist May 4, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. victorouse created this gist May 4, 2020.
    91 changes: 91 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,91 @@
    ## Charts

    - [Recharts](http://recharts.org/en-US/)
    - [Victory](https://formidable.com/open-source/victory/)
    - [React-vis](https://uber.github.io/react-vis/)
    - [Nivo](https://nivo.rocks/)
    - [VX](https://vx-demo.now.sh/)
    - [ChartJS](https://github.com/jerairrest/react-chartjs-2)

    ### Requirements

    - Render a pie chart
    - Render labels (either inside or outside the pie - inside labels can be problematic with small slices + potentially render SVGs for the labels
    - On hover event handlers
    - Render a gap between the active "slice" and the rest of the pie chart
    - Grow the active slice larger than the existing slices
    - Typescript

    ### Nice to haves

    - *Ergonomic API*: balance between low level primitives and high level abstractions (make it easy, but don't lose flexibility)
    - *Composable API*: enable flexibility to compose different chart elements together (pie slices, labels, legends, etc.)
    - *Component API*: uses components rather than wrapping an `options` object than spits out a graph to a dom node
    - *SVG-backed implementation*: canvas graphing libraries more often than not, suck

    ### Disqualified

    - React-vis
    - No official Typescript definitions (https://github.com/uber/react-vis/issues/636)
    - Nivo
    - `onMouseEnter` / `onMouseLeave` properties not exported in Typescript definitions (https://github.com/plouc/nivo/issues/724)
    - ChartJS
    - Honestly, this API is just incredibly cumbersome and it uses canvas as well - the react wrapper for this lib leaves a lot to be desired..

    ## Comparisons / thoughts:

    ### Recharts

    #### Pros

    - API is very simple
    - API is easily composable (all chart elements are children of the parent chart)

    #### Cons

    - Sometimes math is required (radians, angles, calculating radii, label placement)
    - API docs are okay, but could use a lot more context


    ### Victory

    #### Pros

    - Simpler API surface (less math)
    - Less hands on, more configuration via props
    - Docs are pretty extensive
    - Backed by fairly large organisation (Formidable Labs)
    - [Matching React Native lib with almost identical API](https://github.com/FormidableLabs/victory-native)

    #### Cons

    - `onMouse` events are incredibly flexible but can be difficult to reach into to figure out
    - Generally less composable, end up with fat components and only the surface API to configure

    ### VX

    #### Pros

    - Incredibly flexible and composable, mostly helpers around low-level svg primitives - can pretty much make *anything* with this

    #### Cons

    - Docs are incredibly lacking
    - Maybe too low level to be ergonomic
    - Sometimes math

    ## Screenshots

    ### Recharts

    ![image](https://user-images.githubusercontent.com/1930296/80931427-1f530c00-8dfd-11ea-8471-b0285b304f8e.png)


    ### Victory

    ![image](https://user-images.githubusercontent.com/1930296/80931433-2712b080-8dfd-11ea-9894-9e39cfde0eb8.png)


    ### VX

    ![image](https://user-images.githubusercontent.com/1930296/80931437-2d089180-8dfd-11ea-8600-418b0383cd90.png)