🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

simple-react-donut-chart

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-react-donut-chart

Creates donut charts in react

latest
Source
npmnpm
Version
0.0.8
Version published
Maintainers
1
Created
Source

React Donut Chart

This is a dead simple donut chart component implemented in React.

screenshot

To use it simply install it via npm:

npm i --save simple-react-donut-chart

demo

You can see this component in action here.

## usage

This is an example how can you use this component in your project(s)

    import DonoutChart from 'simple-react-donut-chart'
    import 'simple-react-donut-chart/src/style.css'

Yes, in this version you have to include the compiled d css also

Using the component:

<DonoutChart
    percentage={30}
    colorOn="#510E80"
    colorOff="#8217CC"
    labelOff="Me"
    labelOn="You"
    circleColor="#ffffff"
    baseClass="customize"
    textStyle={{
        color: '#ff0000',
    }}
    labelStyle={{
        off: {
            fontSize: '16px',
        },
        on: {
            fontSize: '18px',
        },
    }}
/>

props

nameisRequiredtypedefaultexampledescription
percentageyesNumber0percentage={10}the percentage the donut chart should show
colorOnyesStringnullcolorOn="#ff0000"the color that matches with the percentage on the chart
colorOffyesStringnullcolorOff="#ffff00"the color that matches the rest of the donut part on the chart
labelOnyesStringnulllabelOn="On"the text will be shown with the percentage on the chart
labelOffyesStringnulllabelOff="Off"the text will be shown with the rest of the donut part on the chart
circleColoryesString"#ffffff"circleColor="#444444"the color the circle should have on the middle of the donut chart
labelStylenoObject{}labelStyle={{ off: {,fontSize: '16px',}, on: {,fontSize: '18px',} }}styleObject passed to the labels of the donut chart
textStylenoObject{}textStyle={{ color: '#fff', }}styleObject passed to the explanation text of the donut chart
baseClassnoStringnullbaseClass={styles.chartBase}Providing a baseClass will be applied on every domNode the donut chart has. See more at the styleing section

Styleing

By providing the baseClass props, you are able to customize the chart as you wish, with CSS.

Here is a quick example how it works:

<DonoutChart
	percentage={30}
    ...
    baseClass="customize"
/>

Given the customize as the value of baseClass the following will happen.

The donutContainer class will be assigned another class, which is the baseClass prop itself.

<div class="donutContainer customize">
    ...
</div>

The rest of the dom will be suffixed with the baseClass prop's value.

classNameextended
donutContainerclassName={`donutContainer ${baseClass}`}
detailsclassName={`details details--${baseClass}`}
indicator offclassName={`indicator off indicator-off-${baseClass}`}
indicator onclassName={`indicator on, indicator-on-${baseClass}`}

More might come later if there's a need.

contribution

If you encountered an issue, or a bug, or want to request a feature, please use the issues section.

If you want to modify something yourself, feel free to fork this project, create a new branch for your feature, then send a PR and I will be happy to review and merge it. :wink:

dependencies

This package depends on styled-components

Misc

  • this package is licenced under MIT

FAQs

Package last updated on 09 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts