From 3cfa2945e3337895161dd68a8258cc9b5854bdf6 Mon Sep 17 00:00:00 2001 From: Paul Bennett-Freeman Date: Tue, 21 Jun 2016 16:28:42 +0100 Subject: [PATCH 1/3] Add a horizontal-bar type, and refactor passed to chart.js --- lib/core.js | 7 ++++++- lib/horizontal-bar.js | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 lib/horizontal-bar.js diff --git a/lib/core.js b/lib/core.js index 3da694b..3f9f0a4 100644 --- a/lib/core.js +++ b/lib/core.js @@ -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(); + let convertToType = function(string){ + 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, diff --git a/lib/horizontal-bar.js b/lib/horizontal-bar.js new file mode 100644 index 0000000..1e51b3a --- /dev/null +++ b/lib/horizontal-bar.js @@ -0,0 +1,3 @@ +var vars = require('./core'); + +module.exports = vars.createClass('HorizontalBar', ['getHorizontalBarsAtEvent']); From 70feda4ad1c3fec0ad49bea01bde720d9e40bf08 Mon Sep 17 00:00:00 2001 From: Paul Bennett-Freeman Date: Tue, 21 Jun 2016 16:32:05 +0100 Subject: [PATCH 2/3] Update README to include HorizontalBar as listed type --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 228485c..71d55bf 100644 --- a/README.md +++ b/README.md @@ -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 From 92aa566611e73488c35b290c8b776dd6ba98ba5a Mon Sep 17 00:00:00 2001 From: Paul Bennett-Freeman Date: Tue, 21 Jun 2016 16:37:23 +0100 Subject: [PATCH 3/3] Switch to use not and improve style of syntax --- lib/core.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/core.js b/lib/core.js index 3f9f0a4..5cfe610 100644 --- a/lib/core.js +++ b/lib/core.js @@ -73,11 +73,11 @@ module.exports = { classData.initializeChart = function(nextProps) { var el = ReactDOM.findDOMNode(this); var ctx = el.getContext("2d"); - let convertToType = function(string){ - if(string === 'PolarArea') { return 'polarArea' } - if(string === 'HorizontalBar') { return 'horizontalBar' } + var convertToType = function(string) { + if(string === 'PolarArea') { return 'polarArea'; } + if(string === 'HorizontalBar') { return 'horizontalBar'; } return string.toLowerCase(); - } + }; var type = convertToType(chartType); this.state.chart = new Chart(ctx, {