Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A lightweight responsive bar chart component for React using SVG

License

NotificationsYou must be signed in to change notification settings

cedricdelpoux/react-svg-bar-chart

Repository files navigation

npm packageTravisCodecovModule formats

A lightweight responsive bar chart component for React using SVG

Getting started

react-svg-bar-chart

You can downloadreact-svg-bar-chart from the NPM registry via thenpm oryarn commands

yarn add react-svg-bar-chartnpm install react-svg-bar-chart --save

If you don't use package manager and you want to includereact-svg-bar-chartdirectly in your html, you could get it from the UNPKG CDN

https://unpkg.com/react-svg-bar-chart/umd/react-svg-bar-chart.js

Demo

SeeDemo page

Usage

importReactfrom"react"importBarChartfrom"react-svg-bar-chart"constdata=[]for(letx=1;x<=30;x++){data.push({x:x,y:Math.floor(Math.random()*100)})}constMyComponent=()=>(<BarChartdata={data}onHover={this.handlePointHover}/>)

Props

NamePropTypeDescriptionDefault
areaColorStringArea color (hex, rgb...)"#34495e"
areaOpacityNumberArea opacity.5
areaVisibleBooleanArea visibilityfalse
axisColorNumberAxis color"#34495e"
axisOpacityNumberAxis opacity.5
axisVisibleBooleanAxis visibilitytrue
axisWidthNumberAxis width1
barsColorStringBars color"#34495e"
barsOpacityNumberBars opacity1
barsMarginNumberBars margin left and right (> 0 && <= 0.5)0.1
dataArray of data Objectsdata is {x: number, y: number, active: bool})[]
gridColorStringGrid color"#34495e"
gridOpacityNumberGrid color.5
gridVisibleBooleanGrid visibilitytrue
gridWidthNumberGrid width1
labelsCharacterWidthNumberLabels character with (depending on your font) to calculate the width of Y labels10
labelsColorStringLabels color"#34495e"
labelsCountYNumberY labels count5
labelsFormatXFunctionCustom X labelsx => x
labelsFormatYFunctionCustom Y labelsy => y
labelsHeightXNumberX labels height (depending on your font)12
labelsOffsetXNumberX labels offset15
labelsOffsetYNumberY labels offset15
labelsStepXNumberX labels step1
labelsVisibleNumberLabels visibilitytrue
pathWidthNumberPath width1
pointsColorStringPoints color"#fff"
pointsIsHoverOnZoneBooleanonHover function callback called on zone hover instead of points hoverfalse
onClickFunctionCallback when one bar is click(point, event) => {}
onHoverFunctionCallback when one point is hovered(point, event) => {}
pointsRadiusNumberPoints radius4
pointsStrokeColorStringPoints stroke color"#34495e"
pointsStrokeWidthNumberPoints stroke width2
pointsVisibleBooleanPoints visibilityfalse
viewBoxHeightNumberSVG viewport height300
viewBoxWidthNumberSVG viewport width800

Contributing

  • ⇄ Pull/Merge requests and ★ Stars are always welcome.
  • For bugs and feature requests, pleasecreate an issue.
  • Pull requests must be accompanied by passing automated tests (npm test).

SeeCONTRIBUTING.md guidelines

Changelog

Seechangelog

License

This project is licensed under the MIT License - see theLICENCE.md file for details

About

A lightweight responsive bar chart component for React using SVG

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp