From 11a90058b92824c7c55e4114bdf3f804f4ca63e5 Mon Sep 17 00:00:00 2001 From: Jack Coulter Date: Mon, 18 Jul 2016 12:44:50 +1000 Subject: [PATCH 1/8] Add change-case dependency --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 1c3e207..550f2f6 100644 --- a/package.json +++ b/package.json @@ -33,5 +33,8 @@ "devDependencies": { "uglify-js": "^2.4.16", "webpack": "^1.4.14" + }, + "dependencies": { + "change-case": "^3.0.0" } } From e3b7da0fd76dea09a3a97175b3489fca7c1fc363 Mon Sep 17 00:00:00 2001 From: Jack Coulter Date: Mon, 18 Jul 2016 12:45:01 +1000 Subject: [PATCH 2/8] Convert chartType to camelCase --- lib/core.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/core.js b/lib/core.js index 3da694b..c06e03a 100644 --- a/lib/core.js +++ b/lib/core.js @@ -8,6 +8,7 @@ var React = require('react'); var ReactDOM = require('react-dom'); var Chart = require('chart.js'); +var camelCase = require('change-case').camelCase; module.exports = { createClass: function(chartType, methodNames, dataKey) { @@ -73,7 +74,8 @@ module.exports = { classData.initializeChart = function(nextProps) { var el = ReactDOM.findDOMNode(this); var ctx = el.getContext("2d"); - var type = (chartType === 'PolarArea') ? 'polarArea':chartType.toLowerCase(); + // Convert to camelCase for PolarArea / HorizontalBar chart types + var type = camelCase(chartType); this.state.chart = new Chart(ctx, { type: type, From 8191c9bb6f17398c9720b7a07a30e825e9de98fc Mon Sep 17 00:00:00 2001 From: Jack Coulter Date: Mon, 18 Jul 2016 12:45:10 +1000 Subject: [PATCH 3/8] Add support for HorizontalBar chart --- lib/horizontal-bar.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 lib/horizontal-bar.js diff --git a/lib/horizontal-bar.js b/lib/horizontal-bar.js new file mode 100644 index 0000000..a86c6cc --- /dev/null +++ b/lib/horizontal-bar.js @@ -0,0 +1,3 @@ +var vars = require('./core'); + +module.exports = vars.createClass('HorizontalBar', ['getBarsAtEvent']); From 699d9a407be5e15648e0e2cc2f40085b9df52168 Mon Sep 17 00:00:00 2001 From: Jack Coulter Date: Mon, 18 Jul 2016 13:37:28 +1000 Subject: [PATCH 4/8] Remove deprecated method from methodName array --- lib/horizontal-bar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/horizontal-bar.js b/lib/horizontal-bar.js index a86c6cc..218a57d 100644 --- a/lib/horizontal-bar.js +++ b/lib/horizontal-bar.js @@ -1,3 +1,3 @@ var vars = require('./core'); -module.exports = vars.createClass('HorizontalBar', ['getBarsAtEvent']); +module.exports = vars.createClass('HorizontalBar', []); From 5d499427c289a507b6ebaf90e5af6c67d56900ac Mon Sep 17 00:00:00 2001 From: Jack Coulter Date: Mon, 18 Jul 2016 13:38:20 +1000 Subject: [PATCH 5/8] Update README with newly supported chart 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 ba1533d8894247b1cecbd5cf517af34193eddd4e Mon Sep 17 00:00:00 2001 From: Jack Coulter Date: Mon, 18 Jul 2016 13:48:49 +1000 Subject: [PATCH 6/8] Rebuild dist --- dist/react-chartjs.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/react-chartjs.min.js b/dist/react-chartjs.min.js index d45285f..91b34fe 100644 --- a/dist/react-chartjs.min.js +++ b/dist/react-chartjs.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("react-dom"),require("Chartjs")):"function"==typeof define&&define.amd?define(["react","react-dom","Chartjs"],e):"object"==typeof exports?exports["react-chartjs"]=e(require("react"),require("react-dom"),require("Chartjs")):t["react-chartjs"]=e(t.React,t.ReactDOM,t.Chart)}(this,function(t,e,a){return function(t){function e(r){if(a[r])return a[r].exports;var n=a[r]={exports:{},id:r,loaded:!1};return t[r].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var a={};return e.m=t,e.c=a,e.p="",e(0)}([function(t,e,a){t.exports={Bar:a(1),Bubble:a(6),Doughnut:a(7),Line:a(8),Pie:a(9),PolarArea:a(10),Radar:a(11),Scatter:a(12),createClass:a(2).createClass}},function(t,e,a){var r=a(2);t.exports=r.createClass("Bar",["getBarsAtEvent"])},function(t,e,a){var r=a(3),n=a(4),s=a(5);t.exports={createClass:function(t,e,a){function o(t){i[t]=function(){return this.state.chart[t].apply(this.state.chart,arguments)}}var i={displayName:t+"Chart",getInitialState:function(){return{}},render:function(){var t={ref:"canvass"};for(var e in this.props)this.props.hasOwnProperty(e)&&"data"!==e&&"options"!==e&&(t[e]=this.props[e]);return r.createElement("canvas",t)}},c=["clear","stop","resize","toBase64Image","generateLegend","update","addData","removeData"];i.componentDidMount=function(){this.initializeChart(this.props)},i.componentWillUnmount=function(){var t=this.state.chart;t.destroy()},i.componentWillReceiveProps=function(t){var e=this.state.chart;t.redraw?(e.destroy(),this.initializeChart(t)):(t.data.datasets.forEach(function(t,a){var r=e.data.datasets[a];for(var n in t)t.hasOwnProperty(n)&&(r[n]=t[n])}),e.data.labels=t.data.labels,e.update())},i.initializeChart=function(e){var a=n.findDOMNode(this),r=a.getContext("2d"),o="PolarArea"===t?"polarArea":t.toLowerCase();this.state.chart=new s(r,{type:o,data:e.data,options:e.options})},i.getChart=function(){return this.state.chart},i.getCanvass=function(){return this.refs.canvass},i.getCanvas=i.getCanvass;var u;for(u=0;u Date: Mon, 18 Jul 2016 14:25:50 +1000 Subject: [PATCH 7/8] Add HorizontalBar to index.js --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index d674c1c..41f55df 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,7 @@ module.exports = { Bar: require('./lib/bar'), Bubble: require('./lib/bubble'), Doughnut: require('./lib/doughnut'), + HorizontalBar: require('./lib/horizontal-bar'), Line: require('./lib/line'), Pie: require('./lib/pie'), PolarArea: require('./lib/polar-area'), From 8b663aaaae5eaf6cfb253ea205c1c7ff8b8d49df Mon Sep 17 00:00:00 2001 From: Jack Coulter Date: Mon, 18 Jul 2016 14:28:28 +1000 Subject: [PATCH 8/8] Rebuild dist again --- dist/react-chartjs.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/react-chartjs.min.js b/dist/react-chartjs.min.js index 91b34fe..821b89b 100644 --- a/dist/react-chartjs.min.js +++ b/dist/react-chartjs.min.js @@ -1 +1 @@ -!function(u,A){"object"==typeof exports&&"object"==typeof module?module.exports=A(require("react"),require("react-dom"),require("Chartjs")):"function"==typeof define&&define.amd?define(["react","react-dom","Chartjs"],A):"object"==typeof exports?exports["react-chartjs"]=A(require("react"),require("react-dom"),require("Chartjs")):u["react-chartjs"]=A(u.React,u.ReactDOM,u.Chart)}(this,function(u,A,E){return function(u){function A(C){if(E[C])return E[C].exports;var F=E[C]={exports:{},id:C,loaded:!1};return u[C].call(F.exports,F,F.exports,A),F.loaded=!0,F.exports}var E={};return A.m=u,A.c=E,A.p="",A(0)}([function(u,A,E){u.exports={Bar:E(1),Bubble:E(28),Doughnut:E(29),Line:E(30),Pie:E(31),PolarArea:E(32),Radar:E(33),Scatter:E(34),createClass:E(2).createClass}},function(u,A,E){var C=E(2);u.exports=C.createClass("Bar",["getBarsAtEvent"])},function(u,A,E){var C=E(3),F=E(4),D=E(5),B=E(6).camelCase;u.exports={createClass:function(u,A,E){function t(u){e[u]=function(){return this.state.chart[u].apply(this.state.chart,arguments)}}var e={displayName:u+"Chart",getInitialState:function(){return{}},render:function(){var u={ref:"canvass"};for(var A in this.props)this.props.hasOwnProperty(A)&&"data"!==A&&"options"!==A&&(u[A]=this.props[A]);return C.createElement("canvas",u)}},r=["clear","stop","resize","toBase64Image","generateLegend","update","addData","removeData"];e.componentDidMount=function(){this.initializeChart(this.props)},e.componentWillUnmount=function(){var u=this.state.chart;u.destroy()},e.componentWillReceiveProps=function(u){var A=this.state.chart;u.redraw?(A.destroy(),this.initializeChart(u)):(u.data.datasets.forEach(function(u,E){var C=A.data.datasets[E];for(var F in u)u.hasOwnProperty(F)&&(C[F]=u[F])}),A.data.labels=u.data.labels,A.update())},e.initializeChart=function(A){var E=F.findDOMNode(this),C=E.getContext("2d"),t=B(u);this.state.chart=new D(C,{type:t,data:A.data,options:A.options})},e.getChart=function(){return this.state.chart},e.getCanvass=function(){return this.refs.canvass},e.getCanvas=e.getCanvass;var n;for(n=0;n