Skip to content
This repository was archived by the owner on Jul 19, 2019. It is now read-only.

Include HorizontalBar as an available type #122

Merged
merged 3 commits into from
Apr 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ rich interactive react charting components using [chart.js](http://www.chartjs.o

* Line chart
* Bar chart
* HorizontalBar chart
* Radar chart
* Polar area chart
* Pie chart
Expand Down
7 changes: 6 additions & 1 deletion lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ module.exports = {
classData.initializeChart = function(nextProps) {
var el = ReactDOM.findDOMNode(this);
var ctx = el.getContext("2d");
var type = (chartType === 'PolarArea') ? 'polarArea':chartType.toLowerCase();
var convertToType = function(string) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also write it dynamically in order to allow future types as well:

var type = chartType.charAt(0).toLowerCase() + chartType.slice(1);

if(string === 'PolarArea') { return 'polarArea'; }
if(string === 'HorizontalBar') { return 'horizontalBar'; }
return string.toLowerCase();
};
var type = convertToType(chartType);

this.state.chart = new Chart(ctx, {
type: type,
Expand Down
3 changes: 3 additions & 0 deletions lib/horizontal-bar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var vars = require('./core');

module.exports = vars.createClass('HorizontalBar', ['getHorizontalBarsAtEvent']);