Skip to content

Commit bf0fa1f

Browse files
committed
added horizontalBarChart
1 parent 8262192 commit bf0fa1f

File tree

7 files changed

+54
-7
lines changed

7 files changed

+54
-7
lines changed

dist/react-chartjs-2.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ exports.Doughnut = Doughnut;
1212
exports.Pie = Pie;
1313
exports.Line = Line;
1414
exports.Bar = Bar;
15+
exports.HorizontalBar = HorizontalBar;
1516
exports.Radar = Radar;
1617
exports.Polar = Polar;
1718

@@ -43,7 +44,7 @@ var ChartComponent = _react2['default'].createClass({
4344
legend: _react.PropTypes.object,
4445
options: _react.PropTypes.object,
4546
redraw: _react.PropTypes.bool,
46-
type: _react.PropTypes.oneOf(['doughnut', 'pie', 'line', 'bar', 'radar', 'polarArea']),
47+
type: _react.PropTypes.oneOf(['doughnut', 'pie', 'line', 'bar', 'horizontalBar', 'radar', 'polarArea']),
4748
width: _react.PropTypes.number
4849
},
4950

@@ -163,6 +164,10 @@ function Bar(props) {
163164
return _react2['default'].createElement(ChartComponent, _extends({}, props, { type: 'bar' }));
164165
}
165166

167+
function HorizontalBar(props) {
168+
return _react2['default'].createElement(ChartComponent, _extends({}, props, { type: 'horizontalBar' }));
169+
}
170+
166171
function Radar(props) {
167172
return _react2['default'].createElement(ChartComponent, _extends({}, props, { type: 'radar' }));
168173
}

dist/react-chartjs-2.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react';
2+
import {HorizontalBar} from 'react-chartjs-2';
3+
4+
const data = {
5+
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
6+
datasets: [
7+
{
8+
label: 'My First dataset',
9+
backgroundColor: 'rgba(255,99,132,0.2)',
10+
borderColor: 'rgba(255,99,132,1)',
11+
borderWidth: 1,
12+
hoverBackgroundColor: 'rgba(255,99,132,0.4)',
13+
hoverBorderColor: 'rgba(255,99,132,1)',
14+
data: [65, 59, 80, 81, 56, 55, 40]
15+
}
16+
]
17+
};
18+
19+
export default React.createClass({
20+
displayName: 'BarExample',
21+
22+
render() {
23+
return (
24+
<div>
25+
<h2>Horizontal Bar Example</h2>
26+
<HorizontalBar data={data} />
27+
</div>
28+
);
29+
}
30+
});

example/src/example.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import DynamicDoughnutExample from './components/dynamic-doughnut';
66
import PieExample from './components/pie';
77
import LineExample from './components/line';
88
import BarExample from './components/bar';
9+
import HorizontalBarExample from './components/horizontalBar';
910
import RadarExample from './components/radar';
1011
import PolarExample from './components/polar';
1112
import MixedDataExample from './components/mix';
@@ -25,6 +26,8 @@ class App extends React.Component {
2526
<hr />
2627
<BarExample />
2728
<hr />
29+
<HorizontalBarExample />
30+
<hr />
2831
<RadarExample />
2932
<hr />
3033
<PolarExample />

lib/Chart.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ exports.Doughnut = Doughnut;
1010
exports.Pie = Pie;
1111
exports.Line = Line;
1212
exports.Bar = Bar;
13+
exports.HorizontalBar = HorizontalBar;
1314
exports.Radar = Radar;
1415
exports.Polar = Polar;
1516

@@ -41,7 +42,7 @@ var ChartComponent = _react2['default'].createClass({
4142
legend: _react.PropTypes.object,
4243
options: _react.PropTypes.object,
4344
redraw: _react.PropTypes.bool,
44-
type: _react.PropTypes.oneOf(['doughnut', 'pie', 'line', 'bar', 'radar', 'polarArea']),
45+
type: _react.PropTypes.oneOf(['doughnut', 'pie', 'line', 'bar', 'horizontalBar', 'radar', 'polarArea']),
4546
width: _react.PropTypes.number
4647
},
4748

@@ -161,6 +162,10 @@ function Bar(props) {
161162
return _react2['default'].createElement(ChartComponent, _extends({}, props, { type: 'bar' }));
162163
}
163164

165+
function HorizontalBar(props) {
166+
return _react2['default'].createElement(ChartComponent, _extends({}, props, { type: 'horizontalBar' }));
167+
}
168+
164169
function Radar(props) {
165170
return _react2['default'].createElement(ChartComponent, _extends({}, props, { type: 'radar' }));
166171
}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"description": "react-chartjs-2",
55
"main": "lib/Chart.js",
66
"author": "Goran Udosic",
7-
"homepage": "https://github.com/gor181/react-chartjs-2",
7+
"homepage": "https://github.com/renddiyeh/react-chartjs-2",
88
"repository": {
99
"type": "git",
10-
"url": "https://github.com/gor181/react-chartjs-2.git"
10+
"url": "https://github.com/renddiyeh/react-chartjs-2.git"
1111
},
1212
"bugs": {
13-
"url": "https://github.com/gor181/react-chartjs-2/issues"
13+
"url": "https://github.com/renddiyeh/react-chartjs-2/issues"
1414
},
1515
"dependencies": {
1616
"chart.js": "^2.2.0-rc.1"

src/Chart.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const ChartComponent = React.createClass({
1313
legend: PropTypes.object,
1414
options: PropTypes.object,
1515
redraw: PropTypes.bool,
16-
type: PropTypes.oneOf(['doughnut', 'pie', 'line', 'bar', 'radar', 'polarArea']),
16+
type: PropTypes.oneOf(['doughnut', 'pie', 'line', 'bar', 'horizontalBar', 'radar', 'polarArea']),
1717
width: PropTypes.number
1818
},
1919

@@ -124,6 +124,10 @@ export function Bar (props) {
124124
return <ChartComponent {...props} type='bar' />;
125125
}
126126

127+
export function HorizontalBar (props) {
128+
return <ChartComponent {...props} type='horizontalBar' />;
129+
}
130+
127131
export function Radar (props) {
128132
return <ChartComponent {...props} type='radar' />;
129133
}

0 commit comments

Comments
 (0)