52
rated 0 times
[
53]
[
1]
/ answers: 1 / hits: 5276
/ 5 Years ago, fri, october 18, 2019, 12:00:00
I'm having a js file that draw heatmap based on the points given .I want the same work to be done with reactjs .How can i do this ?
heatmap.html :
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<title>Heatmap Test Code</title>
<script src='http://www.patrick-wied.at/static/heatmapjs/assets/js/heatmap.min.js'></script>
</head>
<body>
<div id='heatMap' style=height: 742px>
<canvas width=1024 height=742 style=position:absolute; left: 0; top: 0></canvas>
</div>
</body>
<script>
var heatmapInstance = h337.create({
container: document.getElementById('heatMap')
});
var testData = {
min: 0,
max: 100,
data: [{'x': 948, 'y': 71, 'value': 1}, {'x': 949, 'y': 70, 'value': 1}, {'x': 948, 'y': 69, 'value': 1}, {'x': 946, 'y': 67, 'value': 1}, {'x': 390, 'y': 39, 'value': 1}, {'x': 376, 'y': 39, 'value': 1}, {'x': 288, 'y': 16, 'value': 1}, {'x': 200, 'y': 12, 'value': 1}, {'x': 134, 'y': 12, 'value': 1}, {'x': 96, 'y': 12, 'value': 1}, {'x': 80, 'y': 12, 'value': 1}, {'x': 69, 'y': 15, 'value': 1}, {'x': 65, 'y': 17, 'value': 1}]
};
heatmapInstance.setData(testData);
</script>
</html>
I tried the following in reactjs :
In index.html :
included the script in index.html (<script src=heatmap.min.js ></script>)
In heat.js :
export function heat(){
//code to draw heatmap
}
In app.js :
import {heat} from './heat';
class App extends Component {
componentWillMount(){
heat();
}
When i run the code in reactjs ,it throws h337 is not defined error .What was the mistake i have done ?
More From » html