|
2 | 2 | <html> |
3 | 3 |
|
4 | 4 | <head> |
5 | | - <title>Chats Protocols - AIL</title> |
| 5 | + <title>Chat - AIL</title> |
6 | 6 | <link rel="icon" href="{{ url_for('static', filename='image/ail-icon.png') }}"> |
7 | 7 |
|
8 | 8 | <!-- Core CSS --> |
|
18 | 18 | <script src="{{ url_for('static', filename='js/dataTables.bootstrap.min.js')}}"></script> |
19 | 19 | <script src="{{ url_for('static', filename='js/d3.min.js')}}"></script> |
20 | 20 | <script src="{{ url_for('static', filename='js/d3/heatmap_week_hour.js')}}"></script> |
| 21 | + <script src="{{ url_for('static', filename='js/echarts.min.js')}}"></script> |
21 | 22 |
|
22 | 23 | <style> |
23 | 24 | .chat-message-left, |
@@ -112,6 +113,9 @@ <h5 class="mx-5 text-secondary">This week:</h5> |
112 | 113 | <div id="heatmapweekhour"></div> |
113 | 114 | {% endif %} |
114 | 115 |
|
| 116 | + <h5>Messages by year:</h5> |
| 117 | + <div id="heatmapyear" style="width: 100%;height: 300px;"></div> |
| 118 | + |
115 | 119 | {% with translate_url=url_for('chats_explorer.chats_explorer_chat', subtype=chat['subtype']), obj_id=chat['id'], pagination=chat['pagination'] %} |
116 | 120 | {% include 'chats_explorer/block_translation.html' %} |
117 | 121 | {% endwith %} |
@@ -218,109 +222,56 @@ <h5 class="mx-5 text-secondary">This week:</h5> |
218 | 222 | }) |
219 | 223 | {% endif %} |
220 | 224 |
|
221 | | -/* |
222 | | -
|
223 | | -// set the dimensions and margins of the graph |
224 | | -const margin = {top: 30, right: 30, bottom: 30, left: 30}, |
225 | | - width = 450 - margin.left - margin.right, |
226 | | - height = 450 - margin.top - margin.bottom; |
227 | | -
|
228 | | -// append the svg object to the body of the page |
229 | | -const svg = d3.select("#my_dataviz") |
230 | | -.append("svg") |
231 | | - .attr("width", width + margin.left + margin.right) |
232 | | - .attr("height", height + margin.top + margin.bottom) |
233 | | -.append("g") |
234 | | - .attr("transform", `translate(${margin.left},${margin.top})`); |
235 | | -
|
236 | | -// Labels of row and columns |
237 | | -const myGroups = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"] |
238 | | -const myVars = ["v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10"] |
239 | | -
|
240 | | -//Read the data |
241 | | -d3.csv("").then( function(data) { |
242 | | -
|
243 | | - // Labels of row and columns -> unique identifier of the column called 'group' and 'variable' |
244 | | - const myGroups = Array.from(new Set(data.map(d => d.group))) |
245 | | - const myVars = Array.from(new Set(data.map(d => d.variable))) |
246 | | -
|
247 | | - // Build X scales and axis: |
248 | | - const x = d3.scaleBand() |
249 | | - .range([ 0, width ]) |
250 | | - .domain(myGroups) |
251 | | - .padding(0.05); |
252 | | - svg.append("g") |
253 | | - .style("font-size", 15) |
254 | | - .attr("transform", `translate(0, ${height})`) |
255 | | - .call(d3.axisBottom(x).tickSize(0)) |
256 | | - .select(".domain").remove() |
257 | | -
|
258 | | - // Build Y scales and axis: |
259 | | - const y = d3.scaleBand() |
260 | | - .range([ height, 0 ]) |
261 | | - .domain(myVars) |
262 | | - .padding(0.01); |
263 | | - svg.append("g") |
264 | | - .style("font-size", 15) |
265 | | - .call(d3.axisLeft(y).tickSize(0)) |
266 | | - .select(".domain").remove() |
267 | | -
|
268 | | - // Build color scale |
269 | | - const myColor = d3.scaleSequential() |
270 | | - .interpolator(d3.interpolateInferno) |
271 | | - .domain([1,100]) |
272 | | -
|
273 | | - // create a tooltip |
274 | | - const tooltip = d3.select("#my_dataviz") |
275 | | - .append("div") |
276 | | - .style("opacity", 0) |
277 | | - .attr("class", "tooltip") |
278 | | - .style("background-color", "white") |
279 | | - .style("border", "solid") |
280 | | - .style("border-width", "2px") |
281 | | - .style("border-radius", "5px") |
282 | | - .style("padding", "5px") |
283 | | -
|
284 | | - // Three function that change the tooltip when user hover / move / leave a cell |
285 | | - const mouseover = function(event,d) { |
286 | | - tooltip.style("opacity", 1) |
287 | | - d3.select(this) |
288 | | - .style("stroke", "black") |
289 | | - .style("opacity", 1) |
290 | | - } |
291 | | - const mousemove = function(event,d) { |
292 | | - tooltip.html("The exact value of<br>this cell is: " + d) |
293 | | - .style("left", (event.x)/2 + "px") |
294 | | - .style("top", (event.y)/2 + "px") |
295 | | - } |
296 | | - const mouseleave = function(d) { |
297 | | - tooltip.style("opacity", 0) |
298 | | - d3.select(this) |
299 | | - .style("stroke", "none") |
300 | | - .style("opacity", 0.8) |
301 | | - } |
302 | 225 |
|
| 226 | +var heatyearChart = echarts.init(document.getElementById('heatmapyear')); |
| 227 | +window.addEventListener('resize', function() { |
| 228 | + heatyearChart.resize(); |
| 229 | +}); |
| 230 | +var optionheatmap; |
303 | 231 |
|
304 | | - svg.selectAll() |
305 | | - .data(data, function(d) {return d.group+':'+d.variable;}) |
306 | | - .join("rect") |
307 | | - .attr("x", function(d) { return x(d.group) }) |
308 | | - .attr("y", function(d) { return y(d.variable) }) |
309 | | - .attr("rx", 4) |
310 | | - .attr("ry", 4) |
311 | | - .attr("width", x.bandwidth() ) |
312 | | - .attr("height", y.bandwidth() ) |
313 | | - .style("fill", function(d) { return myColor(d.value)} ) |
314 | | - .style("stroke-width", 4) |
315 | | - .style("stroke", "none") |
316 | | - .style("opacity", 0.8) |
317 | | - .on("mouseover", mouseover) |
318 | | - .on("mousemove", mousemove) |
319 | | - .on("mouseleave", mouseleave) |
| 232 | +optionheatmap = { |
| 233 | + tooltip: { |
| 234 | + position: 'top', |
| 235 | + formatter: function (p) { |
| 236 | + //const format = echarts.time.format(p.data[0], '{yyyy}-{MM}-{dd}', false); |
| 237 | + return p.data[0] + ': ' + p.data[1]; |
| 238 | + } |
| 239 | + }, |
| 240 | + visualMap: { |
| 241 | + min: 0, |
| 242 | + max: 100, |
| 243 | + calculable: true, |
| 244 | + orient: 'horizontal', |
| 245 | + left: '500', |
| 246 | + top: '-10' |
| 247 | + }, |
| 248 | + calendar: [ |
| 249 | + { |
| 250 | + orient: 'horizontal', |
| 251 | + //range: new Date().getFullYear(), |
| 252 | + range: '2024', |
| 253 | + }, |
| 254 | + ], |
| 255 | + series: [ |
| 256 | + { |
| 257 | + type: 'heatmap', |
| 258 | + coordinateSystem: 'calendar', |
| 259 | + data: [] |
| 260 | + }, |
| 261 | + |
| 262 | + ] |
| 263 | +}; |
| 264 | +heatyearChart.setOption(optionheatmap); |
| 265 | + |
| 266 | +$.getJSON("{{ url_for('chats_explorer.chats_explorer_messages_stats_year') }}?type=chat&subtype={{ chat['subtype'] }}&id={{ chat['id'] }}") |
| 267 | + .done(function(data) { |
| 268 | + optionheatmap['visualMap']['max'] = data['max'] |
| 269 | + optionheatmap['series'][0]['data'] = data['nb'] |
| 270 | + heatyearChart.setOption(optionheatmap) |
320 | 271 |
|
321 | | -}) |
| 272 | + } |
| 273 | +); |
322 | 274 |
|
323 | | - */ |
324 | 275 | </script> |
325 | 276 |
|
326 | 277 |
|
|
0 commit comments