@onetype/framework 2.0.26 → 2.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/addons/core/assets/back/functions/utils/transform.js +1 -1
- package/addons/render/directives/front/js/functions/process/data.js +0 -1
- package/addons/render/transforms/addon.js +2 -0
- package/addons/render/transforms/functions/data.js +21 -0
- package/addons/render/transforms/functions/run.js +11 -0
- package/addons/render/transforms/item/functions/load.js +55 -0
- package/addons/render/transforms/item/functions/run.js +12 -0
- package/addons/render/transforms/items/directives/transform.js +15 -18
- package/lib/items/elements/global/heading/heading.css +1 -1
- package/lib/items/elements/global/markdown/markdown.js +207 -3
- package/lib/items/elements/{sections → navigation}/navbar/navbar.css +9 -9
- package/lib/items/elements/{sections → navigation}/navbar/navbar.js +2 -2
- package/lib/items/elements/navigation/sidebar/sidebar.css +101 -0
- package/lib/items/elements/navigation/sidebar/sidebar.js +56 -0
- package/lib/items/elements/{global → navigation}/tabs/tabs.css +6 -6
- package/lib/items/elements/{global → navigation}/tabs/tabs.js +2 -2
- package/lib/items/elements/sections/pricing/pricing.css +148 -0
- package/lib/items/elements/sections/pricing/pricing.js +76 -0
- package/lib/items/transforms/accordion/accordion.js +139 -141
- package/lib/items/transforms/chart/area.js +130 -133
- package/lib/items/transforms/chart/bar.js +116 -119
- package/lib/items/transforms/chart/bubble.js +142 -145
- package/lib/items/transforms/chart/doughnut.js +104 -107
- package/lib/items/transforms/chart/line.js +127 -130
- package/lib/items/transforms/chart/pie.js +102 -105
- package/lib/items/transforms/chart/radar.js +134 -137
- package/lib/items/transforms/chart/scatter.js +127 -130
- package/lib/items/transforms/codeflask/codeflask.js +10 -12
- package/lib/items/transforms/codemirror/codemirror.js +186 -189
- package/lib/items/transforms/comparison/comparison.js +130 -133
- package/lib/items/transforms/heatmap/heatmap.js +406 -407
- package/lib/items/transforms/interact/interact.js +240 -241
- package/lib/items/transforms/particles/particles.js +282 -283
- package/lib/items/transforms/sparkline/sparkline.js +207 -208
- package/lib/items/transforms/swiper/swiper.js +115 -118
- package/lib/items/transforms/tabs/tabs.js +383 -384
- package/lib/items/transforms/typed/typed.js +146 -147
- package/lib/load.js +8 -16
- package/lib/src/mixins/addons.js +10 -10
- package/lib/styles/variables.css +1 -1
- package/package.json +1 -1
- package/addons/render/transforms/functions/load/assets.js +0 -49
- /package/{addons/render/directives/front/js/items → lib/items/directives}/100-if.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/1000-render.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/110-show.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/160-slot.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/200-for.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-blur.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-change.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-click-outside.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-click.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-double-click.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-focus.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-input.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-keydown.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-keyup.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-mouse-enter.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-mouse-leave.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-mouse-move.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-scroll.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-submit.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/650-fetch.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/660-form.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/700-text.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/750-html.js +0 -0
|
@@ -1,494 +1,493 @@
|
|
|
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
|
-
|
|
1
|
+
transforms.ItemAdd({
|
|
2
|
+
id: 'heatmap',
|
|
3
|
+
icon: 'gradient',
|
|
4
|
+
name: 'Heatmap',
|
|
5
|
+
description: 'Visual heatmap data representation. Display data density with color-coded intensity maps.',
|
|
6
|
+
js: [
|
|
7
|
+
'https://cdn.jsdelivr.net/npm/heatmap.js@2.0.5/build/heatmap.min.js'
|
|
8
|
+
],
|
|
9
|
+
config: {
|
|
10
|
+
'data': ['array', []],
|
|
11
|
+
'max-value': ['number', 100],
|
|
12
|
+
'min-opacity': ['number', 0],
|
|
13
|
+
'max-opacity': ['number', 0.6],
|
|
14
|
+
'radius': ['number', 40],
|
|
15
|
+
'blur': ['number', 0.75],
|
|
16
|
+
'gradient': ['object', {}],
|
|
17
|
+
'container-height': ['number', 400],
|
|
18
|
+
'background-color': ['string', 'transparent'],
|
|
19
|
+
'background-image': ['string', ''],
|
|
20
|
+
'click-tracking': ['boolean', false],
|
|
21
|
+
'move-tracking': ['boolean', false],
|
|
22
|
+
'scroll-tracking': ['boolean', false],
|
|
23
|
+
'touch-tracking': ['boolean', false],
|
|
24
|
+
'auto-resize': ['boolean', true],
|
|
25
|
+
'show-tooltip': ['boolean', false],
|
|
26
|
+
'show-legend': ['boolean', false],
|
|
27
|
+
'legend-position': ['string', 'br'], // tl, tr, bl, br
|
|
28
|
+
'debug': ['boolean', false]
|
|
29
|
+
},
|
|
30
|
+
code: function(data, node, transformer)
|
|
31
|
+
{
|
|
32
|
+
const id = 'heatmap-' + onetype.Generate(8);
|
|
33
|
+
|
|
34
|
+
this.setup = () =>
|
|
33
35
|
{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
node.classList.add('heatmap');
|
|
37
|
-
node.classList.add('heatmap-' + identifier);
|
|
36
|
+
node.classList.add('heatmap');
|
|
37
|
+
node.classList.add(id);
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
// Set container styles
|
|
40
|
+
node.style.position = 'relative';
|
|
41
|
+
node.style.height = data['container-height'] + 'px';
|
|
42
|
+
node.style.backgroundColor = data['background-color'];
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
if(data['background-image'])
|
|
45
|
+
{
|
|
46
|
+
node.style.backgroundImage = `url(${data['background-image']})`;
|
|
47
|
+
node.style.backgroundSize = 'cover';
|
|
48
|
+
node.style.backgroundPosition = 'center';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Create heatmap container
|
|
52
|
+
const heatmapContainer = document.createElement('div');
|
|
53
|
+
heatmapContainer.className = 'heatmap-container';
|
|
54
|
+
heatmapContainer.style.position = 'absolute';
|
|
55
|
+
heatmapContainer.style.top = '0';
|
|
56
|
+
heatmapContainer.style.left = '0';
|
|
57
|
+
heatmapContainer.style.width = '100%';
|
|
58
|
+
heatmapContainer.style.height = '100%';
|
|
59
|
+
|
|
60
|
+
// Preserve existing content if any
|
|
61
|
+
const children = Array.from(node.children);
|
|
62
|
+
if(children.length > 0)
|
|
63
|
+
{
|
|
64
|
+
const contentWrapper = document.createElement('div');
|
|
65
|
+
contentWrapper.className = 'heatmap-content';
|
|
66
|
+
contentWrapper.style.position = 'relative';
|
|
67
|
+
contentWrapper.style.zIndex = '2';
|
|
50
68
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
heatmapContainer.style.position = 'absolute';
|
|
55
|
-
heatmapContainer.style.top = '0';
|
|
56
|
-
heatmapContainer.style.left = '0';
|
|
57
|
-
heatmapContainer.style.width = '100%';
|
|
58
|
-
heatmapContainer.style.height = '100%';
|
|
59
|
-
|
|
60
|
-
// Preserve existing content if any
|
|
61
|
-
const children = Array.from(node.children);
|
|
62
|
-
if(children.length > 0)
|
|
63
|
-
{
|
|
64
|
-
const contentWrapper = document.createElement('div');
|
|
65
|
-
contentWrapper.className = 'heatmap-content';
|
|
66
|
-
contentWrapper.style.position = 'relative';
|
|
67
|
-
contentWrapper.style.zIndex = '2';
|
|
69
|
+
children.forEach(child => contentWrapper.appendChild(child));
|
|
70
|
+
node.appendChild(contentWrapper);
|
|
71
|
+
}
|
|
68
72
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
node.insertBefore(heatmapContainer, node.firstChild);
|
|
74
|
+
this.container = heatmapContainer;
|
|
75
|
+
};
|
|
72
76
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
this.gradient = () =>
|
|
78
|
+
{
|
|
79
|
+
const customGradient = data['gradient'];
|
|
76
80
|
|
|
77
|
-
|
|
81
|
+
// Default gradients based on use case
|
|
82
|
+
if(Object.keys(customGradient).length === 0)
|
|
78
83
|
{
|
|
79
|
-
|
|
84
|
+
return {
|
|
85
|
+
'.00': 'rgb(0,0,255)',
|
|
86
|
+
'.25': 'rgb(0,255,255)',
|
|
87
|
+
'.50': 'rgb(0,255,0)',
|
|
88
|
+
'.75': 'rgb(255,255,0)',
|
|
89
|
+
'1.0': 'rgb(255,0,0)'
|
|
90
|
+
};
|
|
91
|
+
}
|
|
80
92
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
{
|
|
84
|
-
return {
|
|
85
|
-
'.00': 'rgb(0,0,255)',
|
|
86
|
-
'.25': 'rgb(0,255,255)',
|
|
87
|
-
'.50': 'rgb(0,255,0)',
|
|
88
|
-
'.75': 'rgb(255,255,0)',
|
|
89
|
-
'1.0': 'rgb(255,0,0)'
|
|
90
|
-
};
|
|
91
|
-
}
|
|
93
|
+
return customGradient;
|
|
94
|
+
};
|
|
92
95
|
|
|
93
|
-
|
|
96
|
+
this.config = () =>
|
|
97
|
+
{
|
|
98
|
+
return {
|
|
99
|
+
container: this.container,
|
|
100
|
+
radius: data['radius'],
|
|
101
|
+
maxOpacity: data['max-opacity'],
|
|
102
|
+
minOpacity: data['min-opacity'],
|
|
103
|
+
blur: data['blur'],
|
|
104
|
+
gradient: this.gradient()
|
|
94
105
|
};
|
|
106
|
+
};
|
|
95
107
|
|
|
96
|
-
|
|
108
|
+
this.sampleData = () =>
|
|
109
|
+
{
|
|
110
|
+
// Generate sample data if none provided
|
|
111
|
+
const width = node.offsetWidth;
|
|
112
|
+
const height = node.offsetHeight;
|
|
113
|
+
const points = [];
|
|
114
|
+
|
|
115
|
+
// Create interesting sample pattern
|
|
116
|
+
for(let i = 0; i < 50; i++)
|
|
97
117
|
{
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
gradient: this.gradient()
|
|
105
|
-
};
|
|
106
|
-
};
|
|
118
|
+
points.push({
|
|
119
|
+
x: Math.floor(Math.random() * width),
|
|
120
|
+
y: Math.floor(Math.random() * height),
|
|
121
|
+
value: Math.floor(Math.random() * 100)
|
|
122
|
+
});
|
|
123
|
+
}
|
|
107
124
|
|
|
108
|
-
|
|
125
|
+
// Add some hotspots
|
|
126
|
+
for(let i = 0; i < 5; i++)
|
|
109
127
|
{
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
const height = node.offsetHeight;
|
|
113
|
-
const points = [];
|
|
128
|
+
const x = Math.floor(Math.random() * width);
|
|
129
|
+
const y = Math.floor(Math.random() * height);
|
|
114
130
|
|
|
115
|
-
|
|
116
|
-
for(let i = 0; i < 50; i++)
|
|
131
|
+
for(let j = 0; j < 20; j++)
|
|
117
132
|
{
|
|
118
133
|
points.push({
|
|
119
|
-
x:
|
|
120
|
-
y:
|
|
121
|
-
value: Math.floor(Math.random() *
|
|
134
|
+
x: x + (Math.random() - 0.5) * 100,
|
|
135
|
+
y: y + (Math.random() - 0.5) * 100,
|
|
136
|
+
value: 80 + Math.floor(Math.random() * 20)
|
|
122
137
|
});
|
|
123
138
|
}
|
|
139
|
+
}
|
|
124
140
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
{
|
|
128
|
-
const x = Math.floor(Math.random() * width);
|
|
129
|
-
const y = Math.floor(Math.random() * height);
|
|
130
|
-
|
|
131
|
-
for(let j = 0; j < 20; j++)
|
|
132
|
-
{
|
|
133
|
-
points.push({
|
|
134
|
-
x: x + (Math.random() - 0.5) * 100,
|
|
135
|
-
y: y + (Math.random() - 0.5) * 100,
|
|
136
|
-
value: 80 + Math.floor(Math.random() * 20)
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
}
|
|
141
|
+
return points;
|
|
142
|
+
};
|
|
140
143
|
|
|
141
|
-
|
|
142
|
-
|
|
144
|
+
this.processData = () =>
|
|
145
|
+
{
|
|
146
|
+
const inputData = data['data'];
|
|
143
147
|
|
|
144
|
-
|
|
148
|
+
if(!inputData || inputData.length === 0)
|
|
145
149
|
{
|
|
146
|
-
const inputData = data['data'].value;
|
|
147
|
-
|
|
148
|
-
if(!inputData || inputData.length === 0)
|
|
149
|
-
{
|
|
150
|
-
return {
|
|
151
|
-
max: data['max-value'].value,
|
|
152
|
-
data: this.sampleData()
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// Ensure data points have correct format
|
|
157
|
-
const processedData = inputData.map(point => ({
|
|
158
|
-
x: parseInt(point.x || 0),
|
|
159
|
-
y: parseInt(point.y || 0),
|
|
160
|
-
value: parseInt(point.value || 1)
|
|
161
|
-
}));
|
|
162
|
-
|
|
163
150
|
return {
|
|
164
|
-
max: data['max-value']
|
|
165
|
-
data:
|
|
151
|
+
max: data['max-value'],
|
|
152
|
+
data: this.sampleData()
|
|
166
153
|
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Ensure data points have correct format
|
|
157
|
+
const processedData = inputData.map(point => ({
|
|
158
|
+
x: parseInt(point.x || 0),
|
|
159
|
+
y: parseInt(point.y || 0),
|
|
160
|
+
value: parseInt(point.value || 1)
|
|
161
|
+
}));
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
max: data['max-value'],
|
|
165
|
+
data: processedData
|
|
167
166
|
};
|
|
167
|
+
};
|
|
168
168
|
|
|
169
|
-
|
|
169
|
+
this.tooltip = () =>
|
|
170
|
+
{
|
|
171
|
+
if(!data['show-tooltip'])
|
|
170
172
|
{
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
node.
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
const x = e.clientX - rect.left;
|
|
197
|
-
const y = e.clientY - rect.top;
|
|
198
|
-
|
|
199
|
-
const value = this.instance.getValueAt({
|
|
200
|
-
x: Math.floor(x),
|
|
201
|
-
y: Math.floor(y)
|
|
202
|
-
});
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const tooltip = document.createElement('div');
|
|
177
|
+
tooltip.className = 'heatmap-tooltip';
|
|
178
|
+
tooltip.style.cssText = `
|
|
179
|
+
position: absolute;
|
|
180
|
+
background: rgba(0, 0, 0, 0.8);
|
|
181
|
+
color: white;
|
|
182
|
+
padding: 5px 10px;
|
|
183
|
+
border-radius: 4px;
|
|
184
|
+
font-size: 12px;
|
|
185
|
+
pointer-events: none;
|
|
186
|
+
display: none;
|
|
187
|
+
z-index: 1000;
|
|
188
|
+
`;
|
|
189
|
+
|
|
190
|
+
node.appendChild(tooltip);
|
|
191
|
+
this.tooltip = tooltip;
|
|
192
|
+
|
|
193
|
+
node.addEventListener('mousemove', (e) =>
|
|
194
|
+
{
|
|
195
|
+
const rect = node.getBoundingClientRect();
|
|
196
|
+
const x = e.clientX - rect.left;
|
|
197
|
+
const y = e.clientY - rect.top;
|
|
203
198
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
tooltip.style.left = (x + 10) + 'px';
|
|
208
|
-
tooltip.style.top = (y - 30) + 'px';
|
|
209
|
-
tooltip.style.display = 'block';
|
|
210
|
-
}
|
|
211
|
-
else
|
|
212
|
-
{
|
|
213
|
-
tooltip.style.display = 'none';
|
|
214
|
-
}
|
|
199
|
+
const value = this.instance.getValueAt({
|
|
200
|
+
x: Math.floor(x),
|
|
201
|
+
y: Math.floor(y)
|
|
215
202
|
});
|
|
216
203
|
|
|
217
|
-
|
|
204
|
+
if(value > 0)
|
|
218
205
|
{
|
|
219
|
-
tooltip.
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
if(!data['show-legend'].value)
|
|
206
|
+
tooltip.textContent = `Value: ${value}`;
|
|
207
|
+
tooltip.style.left = (x + 10) + 'px';
|
|
208
|
+
tooltip.style.top = (y - 30) + 'px';
|
|
209
|
+
tooltip.style.display = 'block';
|
|
210
|
+
}
|
|
211
|
+
else
|
|
226
212
|
{
|
|
227
|
-
|
|
213
|
+
tooltip.style.display = 'none';
|
|
228
214
|
}
|
|
215
|
+
});
|
|
229
216
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
'tl': 'top: 10px; left: 10px;',
|
|
236
|
-
'tr': 'top: 10px; right: 10px;',
|
|
237
|
-
'bl': 'bottom: 10px; left: 10px;',
|
|
238
|
-
'br': 'bottom: 10px; right: 10px;'
|
|
239
|
-
};
|
|
217
|
+
node.addEventListener('mouseleave', () =>
|
|
218
|
+
{
|
|
219
|
+
tooltip.style.display = 'none';
|
|
220
|
+
});
|
|
221
|
+
};
|
|
240
222
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
rgb(0,255,255),
|
|
258
|
-
rgb(0,255,0),
|
|
259
|
-
rgb(255,255,0),
|
|
260
|
-
rgb(255,0,0)
|
|
261
|
-
);
|
|
262
|
-
border-radius: 2px;
|
|
263
|
-
margin-bottom: 5px;
|
|
264
|
-
`;
|
|
265
|
-
|
|
266
|
-
const labels = document.createElement('div');
|
|
267
|
-
labels.style.cssText = `
|
|
268
|
-
display: flex;
|
|
269
|
-
justify-content: space-between;
|
|
270
|
-
font-size: 11px;
|
|
271
|
-
color: #333;
|
|
272
|
-
`;
|
|
273
|
-
labels.innerHTML = `<span>0</span><span>${data['max-value'].value}</span>`;
|
|
274
|
-
|
|
275
|
-
legend.appendChild(gradientBar);
|
|
276
|
-
legend.appendChild(labels);
|
|
277
|
-
node.appendChild(legend);
|
|
223
|
+
this.legend = () =>
|
|
224
|
+
{
|
|
225
|
+
if(!data['show-legend'])
|
|
226
|
+
{
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const position = data['legend-position'];
|
|
231
|
+
const legend = document.createElement('div');
|
|
232
|
+
legend.className = 'heatmap-legend';
|
|
233
|
+
|
|
234
|
+
const positions = {
|
|
235
|
+
'tl': 'top: 10px; left: 10px;',
|
|
236
|
+
'tr': 'top: 10px; right: 10px;',
|
|
237
|
+
'bl': 'bottom: 10px; left: 10px;',
|
|
238
|
+
'br': 'bottom: 10px; right: 10px;'
|
|
278
239
|
};
|
|
279
240
|
|
|
280
|
-
|
|
241
|
+
legend.style.cssText = `
|
|
242
|
+
position: absolute;
|
|
243
|
+
${positions[position]}
|
|
244
|
+
background: rgba(255, 255, 255, 0.9);
|
|
245
|
+
padding: 10px;
|
|
246
|
+
border-radius: 4px;
|
|
247
|
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
248
|
+
z-index: 10;
|
|
249
|
+
`;
|
|
250
|
+
|
|
251
|
+
const gradientBar = document.createElement('div');
|
|
252
|
+
gradientBar.style.cssText = `
|
|
253
|
+
width: 150px;
|
|
254
|
+
height: 20px;
|
|
255
|
+
background: linear-gradient(to right,
|
|
256
|
+
rgb(0,0,255),
|
|
257
|
+
rgb(0,255,255),
|
|
258
|
+
rgb(0,255,0),
|
|
259
|
+
rgb(255,255,0),
|
|
260
|
+
rgb(255,0,0)
|
|
261
|
+
);
|
|
262
|
+
border-radius: 2px;
|
|
263
|
+
margin-bottom: 5px;
|
|
264
|
+
`;
|
|
265
|
+
|
|
266
|
+
const labels = document.createElement('div');
|
|
267
|
+
labels.style.cssText = `
|
|
268
|
+
display: flex;
|
|
269
|
+
justify-content: space-between;
|
|
270
|
+
font-size: 11px;
|
|
271
|
+
color: #333;
|
|
272
|
+
`;
|
|
273
|
+
labels.innerHTML = `<span>0</span><span>${data['max-value']}</span>`;
|
|
274
|
+
|
|
275
|
+
legend.appendChild(gradientBar);
|
|
276
|
+
legend.appendChild(labels);
|
|
277
|
+
node.appendChild(legend);
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
this.tracking = () =>
|
|
281
|
+
{
|
|
282
|
+
const trackedData = [];
|
|
283
|
+
let tracking = false;
|
|
284
|
+
|
|
285
|
+
const addPoint = (e, multiplier = 1) =>
|
|
281
286
|
{
|
|
282
|
-
const
|
|
283
|
-
|
|
287
|
+
const rect = node.getBoundingClientRect();
|
|
288
|
+
const x = e.clientX - rect.left;
|
|
289
|
+
const y = e.clientY - rect.top;
|
|
284
290
|
|
|
285
|
-
|
|
291
|
+
if(x >= 0 && x <= rect.width && y >= 0 && y <= rect.height)
|
|
286
292
|
{
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
{
|
|
293
|
-
const point = {
|
|
294
|
-
x: Math.floor(x),
|
|
295
|
-
y: Math.floor(y),
|
|
296
|
-
value: 10 * multiplier
|
|
297
|
-
};
|
|
293
|
+
const point = {
|
|
294
|
+
x: Math.floor(x),
|
|
295
|
+
y: Math.floor(y),
|
|
296
|
+
value: 10 * multiplier
|
|
297
|
+
};
|
|
298
298
|
|
|
299
|
-
|
|
300
|
-
|
|
299
|
+
trackedData.push(point);
|
|
300
|
+
this.instance.addData(point);
|
|
301
301
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
302
|
+
if(data['debug'])
|
|
303
|
+
{
|
|
304
|
+
console.log('Heatmap point added:', point);
|
|
306
305
|
}
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
if(data['click-tracking'].value)
|
|
310
|
-
{
|
|
311
|
-
node.addEventListener('click', (e) => addPoint(e, 5));
|
|
312
306
|
}
|
|
307
|
+
};
|
|
313
308
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
if(Math.random() > 0.95) // Sample 5% of movements
|
|
319
|
-
{
|
|
320
|
-
addPoint(e, 1);
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
}
|
|
309
|
+
if(data['click-tracking'])
|
|
310
|
+
{
|
|
311
|
+
node.addEventListener('click', (e) => addPoint(e, 5));
|
|
312
|
+
}
|
|
324
313
|
|
|
325
|
-
|
|
314
|
+
if(data['move-tracking'])
|
|
315
|
+
{
|
|
316
|
+
node.addEventListener('mousemove', (e) =>
|
|
326
317
|
{
|
|
327
|
-
|
|
328
|
-
node.addEventListener('scroll', (e) =>
|
|
318
|
+
if(Math.random() > 0.95) // Sample 5% of movements
|
|
329
319
|
{
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
const centerX = rect.width / 2;
|
|
335
|
-
const centerY = rect.height / 2 + node.scrollTop;
|
|
336
|
-
|
|
337
|
-
const point = {
|
|
338
|
-
x: Math.floor(centerX),
|
|
339
|
-
y: Math.floor(centerY),
|
|
340
|
-
value: 20
|
|
341
|
-
};
|
|
342
|
-
|
|
343
|
-
this.instance.addData(point);
|
|
344
|
-
}, 100);
|
|
345
|
-
});
|
|
346
|
-
}
|
|
320
|
+
addPoint(e, 1);
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
}
|
|
347
324
|
|
|
348
|
-
|
|
325
|
+
if(data['scroll-tracking'])
|
|
326
|
+
{
|
|
327
|
+
let scrollTimer;
|
|
328
|
+
node.addEventListener('scroll', (e) =>
|
|
349
329
|
{
|
|
350
|
-
|
|
330
|
+
clearTimeout(scrollTimer);
|
|
331
|
+
scrollTimer = setTimeout(() =>
|
|
351
332
|
{
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
|
|
333
|
+
const rect = node.getBoundingClientRect();
|
|
334
|
+
const centerX = rect.width / 2;
|
|
335
|
+
const centerY = rect.height / 2 + node.scrollTop;
|
|
355
336
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
addPoint(touch, 1);
|
|
362
|
-
}
|
|
363
|
-
});
|
|
364
|
-
}
|
|
337
|
+
const point = {
|
|
338
|
+
x: Math.floor(centerX),
|
|
339
|
+
y: Math.floor(centerY),
|
|
340
|
+
value: 20
|
|
341
|
+
};
|
|
365
342
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
343
|
+
this.instance.addData(point);
|
|
344
|
+
}, 100);
|
|
345
|
+
});
|
|
346
|
+
}
|
|
369
347
|
|
|
370
|
-
|
|
348
|
+
if(data['touch-tracking'])
|
|
371
349
|
{
|
|
372
|
-
|
|
350
|
+
node.addEventListener('touchstart', (e) =>
|
|
373
351
|
{
|
|
374
|
-
|
|
375
|
-
|
|
352
|
+
const touch = e.touches[0];
|
|
353
|
+
addPoint(touch, 3);
|
|
354
|
+
});
|
|
376
355
|
|
|
377
|
-
|
|
378
|
-
const resizeObserver = new ResizeObserver(() =>
|
|
356
|
+
node.addEventListener('touchmove', (e) =>
|
|
379
357
|
{
|
|
380
|
-
|
|
381
|
-
resizeTimer = setTimeout(() =>
|
|
358
|
+
if(Math.random() > 0.9) // Sample 10% of touch movements
|
|
382
359
|
{
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
this.instance.setData(currentData);
|
|
387
|
-
}
|
|
388
|
-
}, 250);
|
|
360
|
+
const touch = e.touches[0];
|
|
361
|
+
addPoint(touch, 1);
|
|
362
|
+
}
|
|
389
363
|
});
|
|
364
|
+
}
|
|
390
365
|
|
|
391
|
-
|
|
392
|
-
|
|
366
|
+
// Store tracked data for export
|
|
367
|
+
node.heatmapData = trackedData;
|
|
368
|
+
};
|
|
393
369
|
|
|
394
|
-
|
|
370
|
+
this.resize = () =>
|
|
371
|
+
{
|
|
372
|
+
if(!data['auto-resize'])
|
|
395
373
|
{
|
|
396
|
-
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
397
376
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
position: relative;
|
|
401
|
-
overflow: hidden;
|
|
402
|
-
}
|
|
403
|
-
.heatmap-${identifier} canvas {
|
|
404
|
-
position: absolute;
|
|
405
|
-
top: 0;
|
|
406
|
-
left: 0;
|
|
407
|
-
pointer-events: ${(data['click-tracking'].value || data['move-tracking'].value) ? 'auto' : 'none'};
|
|
408
|
-
}
|
|
409
|
-
`;
|
|
410
|
-
|
|
411
|
-
document.head.appendChild(style);
|
|
412
|
-
};
|
|
413
|
-
|
|
414
|
-
this.initialize = () =>
|
|
377
|
+
let resizeTimer;
|
|
378
|
+
const resizeObserver = new ResizeObserver(() =>
|
|
415
379
|
{
|
|
416
|
-
|
|
380
|
+
clearTimeout(resizeTimer);
|
|
381
|
+
resizeTimer = setTimeout(() =>
|
|
417
382
|
{
|
|
418
|
-
if(
|
|
383
|
+
if(this.instance)
|
|
419
384
|
{
|
|
420
|
-
|
|
421
|
-
|
|
385
|
+
const currentData = this.instance.getData();
|
|
386
|
+
this.instance.setData(currentData);
|
|
422
387
|
}
|
|
388
|
+
}, 250);
|
|
389
|
+
});
|
|
423
390
|
|
|
424
|
-
|
|
425
|
-
|
|
391
|
+
resizeObserver.observe(node);
|
|
392
|
+
};
|
|
426
393
|
|
|
427
|
-
|
|
428
|
-
|
|
394
|
+
this.styles = () =>
|
|
395
|
+
{
|
|
396
|
+
const style = document.createElement('style');
|
|
429
397
|
|
|
430
|
-
|
|
431
|
-
|
|
398
|
+
style.textContent = `
|
|
399
|
+
.heatmap-${id} {
|
|
400
|
+
position: relative;
|
|
401
|
+
overflow: hidden;
|
|
402
|
+
}
|
|
403
|
+
.heatmap-${id} canvas {
|
|
404
|
+
position: absolute;
|
|
405
|
+
top: 0;
|
|
406
|
+
left: 0;
|
|
407
|
+
pointer-events: ${(data['click-tracking'] || data['move-tracking']) ? 'auto' : 'none'};
|
|
408
|
+
}
|
|
409
|
+
`;
|
|
432
410
|
|
|
433
|
-
|
|
434
|
-
|
|
411
|
+
document.head.appendChild(style);
|
|
412
|
+
};
|
|
435
413
|
|
|
436
|
-
|
|
437
|
-
|
|
414
|
+
this.initialize = () =>
|
|
415
|
+
{
|
|
416
|
+
setTimeout(() =>
|
|
417
|
+
{
|
|
418
|
+
if(typeof h337 === 'undefined')
|
|
419
|
+
{
|
|
420
|
+
console.error('Heatmap.js library not loaded');
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
438
423
|
|
|
439
|
-
|
|
440
|
-
|
|
424
|
+
// Create heatmap instance
|
|
425
|
+
this.instance = h337.create(this.config());
|
|
441
426
|
|
|
442
|
-
|
|
443
|
-
|
|
427
|
+
// Set initial data
|
|
428
|
+
this.instance.setData(this.processData());
|
|
444
429
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
{
|
|
448
|
-
if(this.instance)
|
|
449
|
-
{
|
|
450
|
-
this.instance.setData({
|
|
451
|
-
max: data['max-value'].value,
|
|
452
|
-
data: newData
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
};
|
|
430
|
+
// Add tooltip
|
|
431
|
+
this.tooltip();
|
|
456
432
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
}
|
|
463
|
-
};
|
|
433
|
+
// Add legend
|
|
434
|
+
this.legend();
|
|
435
|
+
|
|
436
|
+
// Setup tracking
|
|
437
|
+
this.tracking();
|
|
464
438
|
|
|
465
|
-
|
|
439
|
+
// Setup resize handler
|
|
440
|
+
this.resize();
|
|
441
|
+
|
|
442
|
+
// Expose instance and methods
|
|
443
|
+
node.heatmap = this.instance;
|
|
444
|
+
|
|
445
|
+
// Add utility methods
|
|
446
|
+
node.setHeatmapData = (newData) =>
|
|
447
|
+
{
|
|
448
|
+
if(this.instance)
|
|
466
449
|
{
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
}
|
|
471
|
-
}
|
|
450
|
+
this.instance.setData({
|
|
451
|
+
max: data['max-value'],
|
|
452
|
+
data: newData
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
};
|
|
472
456
|
|
|
473
|
-
|
|
457
|
+
node.addHeatmapPoint = (point) =>
|
|
458
|
+
{
|
|
459
|
+
if(this.instance)
|
|
474
460
|
{
|
|
475
|
-
|
|
476
|
-
}
|
|
461
|
+
this.instance.addData(point);
|
|
462
|
+
}
|
|
463
|
+
};
|
|
477
464
|
|
|
478
|
-
|
|
465
|
+
node.clearHeatmap = () =>
|
|
466
|
+
{
|
|
467
|
+
if(this.instance)
|
|
479
468
|
{
|
|
480
|
-
|
|
481
|
-
id: identifier,
|
|
482
|
-
config: this.config(),
|
|
483
|
-
data: this.processData()
|
|
484
|
-
});
|
|
469
|
+
this.instance.setData({max: 1, data: []});
|
|
485
470
|
}
|
|
486
|
-
}
|
|
487
|
-
};
|
|
471
|
+
};
|
|
488
472
|
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
473
|
+
node.exportHeatmapData = () =>
|
|
474
|
+
{
|
|
475
|
+
return this.instance ? this.instance.getData() : null;
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
if(data['debug'])
|
|
479
|
+
{
|
|
480
|
+
console.log('Heatmap initialized:', {
|
|
481
|
+
id: identifier,
|
|
482
|
+
config: this.config(),
|
|
483
|
+
data: this.processData()
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
}, 100);
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
this.setup();
|
|
490
|
+
this.styles();
|
|
491
|
+
this.initialize();
|
|
492
|
+
}
|
|
493
|
+
});
|