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

Commit 7b30e1b

Browse files
committed
add AMD docs
1 parent d9aadcc commit 7b30e1b

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,30 @@ Installation
1616
------------
1717
### Browser
1818
```
19+
<!-- chart.js must be loaded before react-chartjs -->
1920
<script src="path/to/chart.js"></script>
2021
<script src="path/to/react-chartjs.js"></script>
2122
```
2223

2324
### CommonJS
2425
```
25-
// allow the components to use the React object
26+
// initialize ReactChartjs
2627
require('react-chartjs/vars').React = React;
2728
```
2829

30+
### AMD
31+
```
32+
define('path/to/chart.js', 'react-chartjs', function(Chart, ReactChart) {
33+
// initialize ReactChartjs
34+
ReactChart(Chart);
35+
/// now you can refer to React charts as Chart.React.*
36+
});
37+
```
38+
2939
Example Usage
3040
-------------
3141
```
32-
var LineChart = Chart.React.Line; // for browser include
42+
var LineChart = Chart.React.Line; // for browser or AMD (using define('path/to/chart.js'))
3343
var LineChart = require("react-chartjs/line"); // for commonJS
3444
3545
var MyComponent = React.createClass({

0 commit comments

Comments
 (0)