Skip to content

Commit 54c7cf4

Browse files
committed
update code and readme
1 parent a99c0af commit 54c7cf4

File tree

2 files changed

+37
-22
lines changed

2 files changed

+37
-22
lines changed

README.md

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,39 @@ import React from 'react';
99
import ReactDom from 'react-dom';
1010
import ReactHeatmap from 'react-heatmap';
1111

12-
class ReactHeatmapExample extends React.Component {
12+
class ReactHeatmapExample extends React.PureComponent {
1313
render() {
14-
var points = [];
15-
var max = 0;
16-
var width = 840;
17-
var height = 400;
18-
var len = 300;
14+
const config = {
15+
radius: 10,
16+
maxOpacity: 0.5,
17+
minOpacity: 0,
18+
blur: 0.75
19+
};
20+
const points = [];
21+
const width = 840;
22+
const height = 400;
23+
let max = 0;
24+
let len = 300;
1925

2026
while (len--) {
21-
var val = Math.floor(Math.random() * 100);
27+
const val = Math.floor(Math.random() * 100);
2228
// now also with custom radius
23-
var radius = Math.floor(Math.random() * 70);
29+
const radius = Math.floor(Math.random() * 70);
2430

2531
max = Math.max(max, val);
26-
var point = {
32+
const point = {
2733
x: Math.floor(Math.random() * width),
2834
y: Math.floor(Math.random() * height),
2935
value: val,
3036
// radius configuration on point basis
31-
radius: radius
37+
radius
3238
};
3339
points.push(point);
3440
}
3541

3642
return (
3743
<div style={{ width: '840px', height: '400px' }}>
38-
< ReactHeatmap max= { max } data= { points } unit= "notPercent" />
44+
<ReactHeatmap configObject={config} max={max} data={points} />
3945
</div >
4046
);
4147
}
@@ -44,3 +50,6 @@ class ReactHeatmapExample extends React.Component {
4450
ReactDom.render(<ReactHeatmapExample />, document.querySelector('#app'));
4551

4652
```
53+
For more configuration, take [docs.html][747485cf] as reference.
54+
55+
[747485cf]: https://www.patrick-wied.at/static/heatmapjs/docs.html "docs.html"

example/index.jsx

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,39 @@ import React from 'react';
22
import ReactDom from 'react-dom';
33
import ReactHeatmap from 'react-heatmap';
44

5-
class ReactHeatmapExample extends React.Component {
5+
class ReactHeatmapExample extends React.PureComponent {
66
render() {
7-
var points = [];
8-
var max = 0;
9-
var width = 840;
10-
var height = 400;
11-
var len = 300;
7+
const config = {
8+
radius: 10,
9+
maxOpacity: 0.5,
10+
minOpacity: 0,
11+
blur: 0.75
12+
};
13+
const points = [];
14+
const width = 840;
15+
const height = 400;
16+
let max = 0;
17+
let len = 300;
1218

1319
while (len--) {
14-
var val = Math.floor(Math.random() * 100);
20+
const val = Math.floor(Math.random() * 100);
1521
// now also with custom radius
16-
var radius = Math.floor(Math.random() * 70);
22+
const radius = Math.floor(Math.random() * 70);
1723

1824
max = Math.max(max, val);
19-
var point = {
25+
const point = {
2026
x: Math.floor(Math.random() * width),
2127
y: Math.floor(Math.random() * height),
2228
value: val,
2329
// radius configuration on point basis
24-
radius: radius
30+
radius
2531
};
2632
points.push(point);
2733
}
2834

2935
return (
3036
<div style={{ width: '840px', height: '400px' }}>
31-
< ReactHeatmap max= { max } data= { points } unit= "notPercent" />
37+
<ReactHeatmap configObject={config} max={max} data={points} />
3238
</div >
3339
);
3440
}

0 commit comments

Comments
 (0)