Simply use Half Doughnut Chart to compare two element ratio
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
This UI kit is simply represent ratio of two values with the pie chart. It's fully worked on react Js. In this graph is customizable, you can change color, text, font-style,back color. You can get percentage of ratio in center part.
- Highly customizable
- Very easy to implement
- Resolution independent
- Uses css for smooth animations on riced time
- Works in all modern browsers, [Chrome, FireFox, Safari]
- Simply compare ratio
- No need other front-end css stuff
- Dark, light modes available and text back colors are editable
- React JS (no dependencies)
This is a Node.js module available through the npm registry.
Before installing, download and install Node.js. Node.js 0.10 or higher is required.
Installation is done using the
npm install
command:
Using npm:
$ npm i half-pie-chart
Using yarn:
$ yarn add half-pie-chart
import { HalfPieChart } from "half-pie-chart";
import React, { Component } from "react";
class App extends Component {
constructor(props) {
super(props);
this.state = {
right: [
{
value: 20,
displayValue: "20 $",
text: "Collected",
color: "#4cb38e",
},
],
left: [
{
value: 10,
displayValue: "10 $",
text: "Pending",
color: "#eee36b",
},
],
};
}
render() {
return (
<HalfPieChart
name="rentStatus"
right={this.state.right}
left={this.state.left}
title="Rent Status"
/>
);
}
}
export default App;
import { HalfPieChart } from "half-pie-chart";
import React, { Component } from "react";
class App extends Component {
constructor(props) {
super(props);
this.state = {
right: [
{
value: 3000,
displayValue: "3000 $",
text: "Achieved",
color: "#4cb38e",
},
],
left: [
{
value: 10500,
displayValue: "10500 $",
text: "Pending",
color: "#eee36b",
},
],
};
}
render() {
return (
<HalfPieChart
name="rentStatus2"
right={this.state.right}
left={this.state.left}
dark={true}
title="Monthly Achievement"
/>
);
}
}
export default App;
import { HalfPieChart } from "half-pie-chart";
import React, { Component } from "react";
class App extends Component {
constructor(props) {
super(props);
this.state = {
right: [
{
value: 3000,
displayValue: "3000 /=",
text: "Achieved",
color: "#f19bea",
},
],
left: [
{
value: 10500,
displayValue: "10500 /=",
text: "Pending",
color: "#67d4ff",
},
],
};
}
render() {
return (
<HalfPieChart
name="rentStatus4"
right={this.state.right}
left={this.state.left}
dark={true}
title="Rent Status"
fontStyle="Montserrat"
centerText={"Target"}
centerPostText={" /="}
/>
);
}
}
export default App;
You can pass these options to the initialize function to set a custom look and feel for the plugin.
Property (Type) | Default | Type | Description |
---|---|---|---|
name | null | string | The name is must be compulsory attribute. If you not put this multiple component can't use in same time. this is for identification of our component |
right | null | Json Array | The name is must be compulsory attribute. This array sample is given above sample. |
left | null | Json Array | The name is must be compulsory attribute. This array sample is given above sample. |
dark | false | boolean | This is boolean attribute , It's true value is decided dark mode or not. |
title | null | string | This is for displaying title of component |
fontStyle | Montserrat, sans-serif | string | You can change whole component font style here |
centerText | null | string | If you define this only comes center text part. If not define not comes. |
centerPostText | null | string | This string is postfix of center text part |
cardBackColor | rgb(32, 32, 32) rgb(245, 245, 245) |
string | This is for background color of the component |
cardTextColor | #343a40 #e9e9e9 |
string | This is for text color of the component |
This array have value and visible text of pie chart
right: [
{
value: 3000,
displayValue: "3000 $",
text: "Achieved",
color: "#4cb38e",
}],
left: [{
value: 10500,
displayValue: "10500 $",
text: "Pending",
color: "#eee36b",
}]
Property (Type) | Default | Type | Description |
---|---|---|---|
value | 0 | int | This is compulsory attribute. This is for calculating value. |
displayValue | null | int | This is compulsory attribute. This is just displaying value. |
text | null | int | This is compulsory attribute. This is displaying text. |
color | null | int | This is changed color of the pie bar, you can customize any of the color. |
Native support
- Chrome
- Safari
- FireFox
Developed by
Karunaaharan Bavaram
Copyright (c) 2022 Karunaaharan Bavaram
, contributors. Released under the MIT, GPL licenses