Commit 990a9752e987edbdb9dec6f534d1beb5fab0cc33

Authored by Antoine Goutenoir
1 parent de597abb
Exists in master

feat: clean the histogram

Showing 1 changed file with 18 additions and 16 deletions   Show diff stats
flaskr/static/js/plots/emissions-per-distance.js
... ... @@ -49,7 +49,7 @@ function draw_emissions_per_distance(containerSelector, csvUrl) {
49 49  
50 50 vertical.style("left", x + "px");
51 51 rightArea.style("left", x + "px");
52   - rightArea.style("width", (width+margin.left-x) + "px");
  52 + rightArea.style("width", (width + margin.left - x) + "px");
53 53 tooltip.style("left", (x + 10) + "px");
54 54 tooltip.style("top", (y - 20) + "px");
55 55  
... ... @@ -76,7 +76,7 @@ function draw_emissions_per_distance(containerSelector, csvUrl) {
76 76 tooltip.style("display", "inherit");
77 77 }
78 78  
79   - tooltip.text((((attendeePercent<10)?'0':'') + attendeePercent) + "% of attendees");
  79 + tooltip.text((((attendeePercent < 10) ? '0' : '') + attendeePercent) + "% of attendees");
80 80 }
81 81  
82 82 function addVerticalLineAndListenCursor(xScale, attendeeNumberPerGroup, attendeeSum) {
... ... @@ -197,7 +197,7 @@ function draw_emissions_per_distance(containerSelector, csvUrl) {
197 197 // Title
198 198 svg.append("text")
199 199 .attr("transform",
200   - "translate(" + (0) + ", "+ (-18) +")")
  200 + "translate(" + (0) + ", " + (-18) + ")")
201 201 .style("font-weight", "bold")
202 202 .style("font-size", "130%")
203 203 .text("Emissions per distance");
... ... @@ -271,19 +271,21 @@ function draw_emissions_per_distance(containerSelector, csvUrl) {
271 271 // console.log(histolol);
272 272 let barSettings = [];
273 273 emissionsPerGroup.forEach((element, index) => {
274   - barSettings[index] =
275   - {
276   - height: element,
277   - leftBorder: histolol[index].x0,
278   - rightBorder: histolol[index].x1,
279   - };
280   - svg.append("text")
281   - .attr("transform", "translate(" + ((x(histolol[index].x0) + x(histolol[index].x1))/2) + margin.left + ", " + ( yl(element) - 20) + ")")
282   - .attr("y", 0)
283   - .attr("x", 0 )
284   - .attr("dy", "1em")
285   - .style("text-anchor", "middle")
286   - .text(attendeeNumberPerGroup[index]);
  274 + barSettings[index] = {
  275 + height: element,
  276 + leftBorder: histolol[index].x0,
  277 + rightBorder: histolol[index].x1,
  278 + };
  279 + if (attendeeNumberPerGroup[index] > 0) {
  280 + svg.append("text")
  281 + .attr("transform", "translate(" + ((x(histolol[index].x0) + x(histolol[index].x1)) / 2) + margin.left + ", " + (yl(element) - 15) + ")")
  282 + .attr("y", 0)
  283 + .attr("x", 0)
  284 + .attr("dy", "1em")
  285 + .style("text-anchor", "middle")
  286 + .style("font-size", "0.618em")
  287 + .text(attendeeNumberPerGroup[index] + "👱");
  288 + }
287 289 // console.log(index);
288 290 // console.log(barSettings[index]);
289 291 });
... ...