forked from apache/echarts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheatmap-large.html
102 lines (96 loc) · 3.62 KB
/
heatmap-large.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<html>
<head>
<meta charset="utf-8">
<script src="esl.js"></script>
<script src="config.js"></script>
<script src="lib/perlin.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<style>
html, body, #main {
width: 100%;
height: 100%;
margin: 0;
}
</style>
<div id="main"></div>
<script>
require([
'echarts',
'echarts/chart/heatmap',
'echarts/chart/scatter',
'echarts/component/legend',
'echarts/component/visualMap',
'echarts/component/grid',
'echarts/component/polar',
'echarts/component/tooltip'
], function (echarts) {
var chart = echarts.init(document.getElementById('main'));
// function normalDist(theta, x) {
// return 1 / (theta * Math.sqrt(2 * Math.PI)) * Math.exp(- x * x / 2 / theta / theta);
// }
var xData = [];
var yData = [];
noise.seed(Math.random());
function generateData(theta, min, max) {
var data = [];
for (var i = 0; i <= 100; i++) {
for (var j = 0; j <= 100; j++) {
// var x = (max - min) * i / 200 + min;
// var y = (max - min) * j / 100 + min;
data.push([i, j, noise.perlin2(i / 40, j / 20) + 0.5]);
// data.push([i, j, normalDist(theta, x) * normalDist(theta, y)]);
}
yData.push(i);
xData.push(i);
}
return data;
}
var data = generateData(2, -5, 5);
// console.profile('render');
console.time('render');
chart.setOption({
tooltip: {},
xAxis: {
type: 'category',
data: xData
},
yAxis: {
type: 'category',
data: yData
},
visualMap: {
// type: 'piecewise',
min: 0,
max: 1,
calculable: true,
realtime: false,
splitNumber: 8,
inRange: {
color: ['#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf', '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026']
}
},
series: [{
name: 'Gaussian',
type: 'heatmap',
data: data,
itemStyle: {
emphasis: {
borderColor: '#333',
borderWidth: 2
}
},
progressive: 1000,
// silent: true,
// progressive: 0,
// progressiveThreshold: 30000,
animation: false
}]
});
console.timeEnd('render');
// console.profileEnd('render');
});
</script>
</body>
</html>