tmp image show
Browse files- plots/clusters.png +0 -0
- src/clusters.js +17 -1
plots/clusters.png
ADDED
src/clusters.js
CHANGED
@@ -108,8 +108,24 @@ const readData = async () => {
|
|
108 |
}));
|
109 |
}
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
async function plotClusters() {
|
112 |
const parent = document.getElementById('clusters-plot');
|
|
|
|
|
113 |
const data = await readData();
|
114 |
const traces = [{
|
115 |
type: 'scatter',
|
@@ -169,6 +185,7 @@ async function plotClusters() {
|
|
169 |
},
|
170 |
};
|
171 |
|
|
|
172 |
Plotly.newPlot(parent, traces, layout);
|
173 |
|
174 |
parent.on('plotly_relayout', (eventdata) => {
|
@@ -218,6 +235,5 @@ const getColor = (i, opacity) => {
|
|
218 |
if (i < 0) {
|
219 |
i = i * -1
|
220 |
}
|
221 |
-
console.log(COLORS[i % COLORS.length])
|
222 |
return `rgba(${COLORS[i % COLORS.length].join(',')}, ${opacity})`
|
223 |
}
|
|
|
108 |
}));
|
109 |
}
|
110 |
|
111 |
+
|
112 |
+
const showImage = (parent) => {
|
113 |
+
// create the image
|
114 |
+
const img = document.createElement('img');
|
115 |
+
img.src = 'plots/clusters.png';
|
116 |
+
img.alt = 'Clusters';
|
117 |
+
parent.appendChild(img);
|
118 |
+
}
|
119 |
+
|
120 |
+
const destroyImage = (parent) => {
|
121 |
+
const img = parent.querySelector('img');
|
122 |
+
img.remove();
|
123 |
+
}
|
124 |
+
|
125 |
async function plotClusters() {
|
126 |
const parent = document.getElementById('clusters-plot');
|
127 |
+
// We do a little trolling on users and pretend that we already donwloaded the data by simply showing uniteractive image :)
|
128 |
+
showImage(parent);
|
129 |
const data = await readData();
|
130 |
const traces = [{
|
131 |
type: 'scatter',
|
|
|
185 |
},
|
186 |
};
|
187 |
|
188 |
+
destroyImage(parent);
|
189 |
Plotly.newPlot(parent, traces, layout);
|
190 |
|
191 |
parent.on('plotly_relayout', (eventdata) => {
|
|
|
235 |
if (i < 0) {
|
236 |
i = i * -1
|
237 |
}
|
|
|
238 |
return `rgba(${COLORS[i % COLORS.length].join(',')}, ${opacity})`
|
239 |
}
|