Giter Site home page Giter Site logo

ryan-n-may / nivo_responsivefunnelplus Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 58.5 MB

An addition to Nivo's responsive funnel that adds functionality & supports multiple data sources.

License: MIT License

TypeScript 80.69% JavaScript 19.31%
charts funnel nivo nodejs npm react reactjs webdev funnelchart

nivo_responsivefunnelplus's Introduction

Nivo Funnel ++

An extension to @Nivo/Funnel that adds functionality and features. A follow and star on the Github Page would be highly appreciated.

MIT License

Nivo Version

Authors

Features

  • Unlimited datasets drawn per chart area.
  • Auto-scaling input datasets relative to each other.
  • Colours customisable per dataset.
  • Section labels.
  • Stylised data labels.
  • Optional, fully customisable legend.

Installation

Install Funnel ++ with npm (NPM package)

 npm install @ryan-n-may/funnelplus
 "@ryan-n-may/funnelplus": "1.2.0"

Dependencies

  • @nivo/annotations
  • @nivo/colors
  • @nivo/core
  • @nivo/tooltip
  • @nivo/legends
  • @react-spring/web
  • @types/d3-scale
  • @types/d3-shape
  • d3-scale
  • d3-shape

Acknowledgements

Documentation

<ReactiveFunnelPlus
    ...={...} />

Additional paramaters:

parameter type
data FunnelDatum[] | FunnelDatum[][]
colors OrdinalColorScaleConfig<FunnelDatum> | OrdinalColorScaleConfig<FunnelDatum>[]
enableLegend boolean
legendAnchor bottom-right | bottom-left | bottom | top | top-left | top-right | right | left | undefined
legendItemDirection left-to-right | right-to-left | top-to-bottom | bottom-to-top
legendLayout row | column
legendSymbolShape circle | triangle | diamond | square | undefined
enableLabel boolean
enableAxisLabel boolean
sectionLabelColor OrdinalColorScaleConfig<FunnelDatum>
labelSpacing number
labelDirection row | column
labelStyle verbose | pretty
labelFormat (label: string) : string
labelColor OrdinalColorScaleConfig<FunnelDatum>
layers ['separators', 'parts', 'labels', 'axislabels', 'legend', 'annotations']

Data input

A singular data entry (FunnelDatum[]) is structured as follows. Adding multiple datasets would require a 2D array (FunnelDatum[][])

[
  {
    id: 'totoff',
    value: 2000,
    label: 'Total Offers',
    dataset: 'Dataset 1'
  },
  {
    id: 'finoff',
    value: 1200,
    label: 'Final Offers',
    dataset: 'Dataset 1'
  }
]

Usage/Examples

return(
    <ResponsiveFunnelPlus
        data = {[
            data[0],
            data[1],
        ]}
        colors = {[
            colorThemePalette.stackedBarChartColors.primary, 
            colorThemePalette.stackedBarChartColors.secondary, 
        ]}
        margin={{ top: 8, right: 64, bottom: 16, left: 128 }}
        fillOpacity={0.25}
        borderOpacity={0.8}
        borderWidth={8}
        shapeBlending={0.50}
        interpolation='smooth'
        direction={'vertical'}
        spacing={2}
        isInteractive={true}
        animate={true}
        currentPartSizeExtension={32}
        currentBorderWidth={16}
        motionConfig={'stiff'} 
        layers={['separators', 'parts', 'labels', 'axislabels', 'legend', 'annotations']}
        // Inputs exceed 100, so seperators need to reduce chart width.
        // Auto-scaling relatively scales chart datasets, but if maximal chart dataset exceeds
        // 100, additional seperators must be specified. 
        beforeSeparatorLength={Math.abs(data[0].data[1].value - data[1].data[1].value)}
        afterSeparatorLength={Math.abs(data[0].data[1].value - data[1].data[1].value)}
        // Legend
        enableLegend={true}
        legendAnchor={'bottom-right'}
        legendItemDirection={'left-to-right'}
        legendLayout={'column'}
        legendSymbolShape={'square'}         
        // Labels
        enableLabel={true}
        labelSpacing={0}
        labelDirection={'row'}
        labelStyle={'pretty'}
        labelFormat={() => {}} // Doesnt do anything here, we are using 'pretty'
        valueFormat={'>-.3s'}
        labelColor={{from: 'color', modifiers:[['darker', 1]]}}
        // Axis labels
        enableAxisLabel={true} 
        sectionLabelColor={'dark-gray'}
    >
)

nivo_responsivefunnelplus's People

Contributors

ryan-n-may avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.