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

Commit ca1825d

Browse files
committed
initial commit
1 parent 9b5d365 commit ca1825d

12 files changed

Lines changed: 317 additions & 0 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ node_modules
2626

2727
# Users Environment Variables
2828
.lock-wscript
29+
30+
.DS_Store
31+
showcase

bar.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var vars = require('./vars');
2+
3+
module.exports = vars.createClass('Bar', ['getBarsAtEvent']);

doughnut.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var vars = require('./vars');
2+
3+
module.exports = vars.createClass('Doughnut', ['getSegmentsAtEvent']);

index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Chart.React = {
2+
Bar: require('./bar'),
3+
Doughnut: require('./doughnut'),
4+
Line: require('./line'),
5+
Pie: require('./pie'),
6+
PolarArea: require('./polar-area'),
7+
Radar: require('./radar')
8+
};
9+
10+
11+

line.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var vars = require('./vars');
2+
3+
module.exports = vars.createClass('Line', ['getPointsAtEvent']);

package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "react-charts",
3+
"version": "0.0.1",
4+
"description": "react charting components",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "mocha"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "https://github.com/jhudson8/react-charts"
12+
},
13+
"keywords": [
14+
"react",
15+
"react-component"
16+
],
17+
"author": "Joe Hudson",
18+
"license": "MIT",
19+
"bugs": {
20+
"url": "https://github.com/jhudson8/react-charts/issues"
21+
},
22+
"homepage": "https://github.com/jhudson8/react-charts",
23+
"devDependencies": {
24+
"webpack": "^1.4.14"
25+
}
26+
}

pie.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var vars = require('./vars');
2+
3+
module.exports = vars.createClass('Pie', ['getSegmentsAtEvent']);

polar-area.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var vars = require('./vars');
2+
3+
module.exports = vars.createClass('PolarArea', ['getSegmentsAtEvent']);

radar.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var vars = require('./vars');
2+
3+
module.exports = vars.createClass('Radar', ['getPointsAtEvent']);

react-charts.js

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
/******/ (function(modules) { // webpackBootstrap
2+
/******/ // The module cache
3+
/******/ var installedModules = {};
4+
/******/
5+
/******/ // The require function
6+
/******/ function __webpack_require__(moduleId) {
7+
/******/
8+
/******/ // Check if module is in cache
9+
/******/ if(installedModules[moduleId])
10+
/******/ return installedModules[moduleId].exports;
11+
/******/
12+
/******/ // Create a new module (and put it into the cache)
13+
/******/ var module = installedModules[moduleId] = {
14+
/******/ exports: {},
15+
/******/ id: moduleId,
16+
/******/ loaded: false
17+
/******/ };
18+
/******/
19+
/******/ // Execute the module function
20+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21+
/******/
22+
/******/ // Flag the module as loaded
23+
/******/ module.loaded = true;
24+
/******/
25+
/******/ // Return the exports of the module
26+
/******/ return module.exports;
27+
/******/ }
28+
/******/
29+
/******/
30+
/******/ // expose the modules object (__webpack_modules__)
31+
/******/ __webpack_require__.m = modules;
32+
/******/
33+
/******/ // expose the module cache
34+
/******/ __webpack_require__.c = installedModules;
35+
/******/
36+
/******/ // __webpack_public_path__
37+
/******/ __webpack_require__.p = "";
38+
/******/
39+
/******/ // Load entry module and return exports
40+
/******/ return __webpack_require__(0);
41+
/******/ })
42+
/************************************************************************/
43+
/******/ ([
44+
/* 0 */
45+
/***/ function(module, exports, __webpack_require__) {
46+
47+
Chart.React = {
48+
Bar: __webpack_require__(1),
49+
Doughnut: __webpack_require__(2),
50+
Line: __webpack_require__(3),
51+
Pie: __webpack_require__(4),
52+
PolarArea: __webpack_require__(5),
53+
Radar: __webpack_require__(6)
54+
};
55+
56+
57+
58+
59+
60+
/***/ },
61+
/* 1 */
62+
/***/ function(module, exports, __webpack_require__) {
63+
64+
var vars = __webpack_require__(7);
65+
66+
module.exports = vars.createClass('Bar', ['getBarsAtEvent']);
67+
68+
69+
/***/ },
70+
/* 2 */
71+
/***/ function(module, exports, __webpack_require__) {
72+
73+
var vars = __webpack_require__(7);
74+
75+
module.exports = vars.createClass('Doughnut', ['getSegmentsAtEvent']);
76+
77+
78+
/***/ },
79+
/* 3 */
80+
/***/ function(module, exports, __webpack_require__) {
81+
82+
var vars = __webpack_require__(7);
83+
84+
module.exports = vars.createClass('Line', ['getPointsAtEvent']);
85+
86+
87+
/***/ },
88+
/* 4 */
89+
/***/ function(module, exports, __webpack_require__) {
90+
91+
var vars = __webpack_require__(7);
92+
93+
module.exports = vars.createClass('Pie', ['getSegmentsAtEvent']);
94+
95+
96+
/***/ },
97+
/* 5 */
98+
/***/ function(module, exports, __webpack_require__) {
99+
100+
var vars = __webpack_require__(7);
101+
102+
module.exports = vars.createClass('PolarArea', ['getSegmentsAtEvent']);
103+
104+
105+
/***/ },
106+
/* 6 */
107+
/***/ function(module, exports, __webpack_require__) {
108+
109+
var vars = __webpack_require__(7);
110+
111+
module.exports = vars.createClass('Radar', ['getPointsAtEvent']);
112+
113+
114+
/***/ },
115+
/* 7 */
116+
/***/ function(module, exports, __webpack_require__) {
117+
118+
/* WEBPACK VAR INJECTION */(function(global) {module.exports = {
119+
createClass: function(chartType, methodNames) {
120+
var classData = {
121+
displayName: chartType + 'Chart',
122+
getInitialState: function() { return {}; },
123+
render: function() {
124+
var _props = {};
125+
for (var name in this.props) {
126+
if (this.props.hasOwnProperty(name)) {
127+
if (name !== 'data' && name !== 'options') {
128+
_props[name] = this.props[name];
129+
}
130+
}
131+
}
132+
return React.createElement('canvas', _props);
133+
}
134+
};
135+
136+
var extras = ['clear', 'stop', 'resize', 'toBase64Image', 'generateLegend', 'update', 'addData', 'removeData'];
137+
function extra(type) {
138+
classData[type] = function() {
139+
this.state.chart[name].apply(this.state.chart, arguments);
140+
};
141+
}
142+
143+
if (global.Chart) {
144+
classData.componentDidMount = function() {
145+
this.initializeChart(this.props);
146+
};
147+
148+
classData.componentWillUnmount = function() {
149+
var chart = this.state.chart;
150+
chart.destroy();
151+
};
152+
153+
classData.componentWillReceiveProps = function(props) {
154+
var chart = this.state.chart;
155+
chart.destroy();
156+
this.initializeChart(props);
157+
};
158+
159+
classData.initializeChart = function(props) {
160+
var el = this.getDOMNode();
161+
var ctx = el.getContext("2d");
162+
var chart = new Chart(ctx)[chartType](this.props.data, this.props.options || {});
163+
this.state.chart = chart;
164+
};
165+
166+
var i;
167+
for (i=0; i<extras.length; i++) {
168+
extra(extras[i]);
169+
}
170+
for (i=0; i<methodNames.length; i++) {
171+
extra(methodNames[i]);
172+
}
173+
}
174+
175+
var React = this.React || global.React;
176+
if (!React) {
177+
throw new Error("The charts were not initialized with the React instance");
178+
}
179+
180+
return React.createClass(classData);
181+
}
182+
};
183+
184+
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
185+
186+
/***/ }
187+
/******/ ])

0 commit comments

Comments
 (0)