Changeset 3ac70ca in OpenWorkouts-current
- Timestamp:
- Mar 12, 2019, 9:29:22 PM (5 years ago)
- Branches:
- current
- Children:
- 39dc0a6
- Parents:
- f2c9e20
- Location:
- ow
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
ow/static/css/main.css
rf2c9e20 r3ac70ca 1575 1575 stroke-width: 2; 1576 1576 } 1577 .calendar-heatmap-tooltip { 1578 width: 20%; 1579 } 1577 1580 .verify-account-content { 1578 1581 background-position: center; -
ow/static/js/ow.js
rf2c9e20 r3ac70ca 489 489 the chart 490 490 */ 491 492 // Hide the tooltip 493 $('.js-calendar-heatmap-tooltip').hide() 494 491 495 var chart = d3.select(chart_selector); 492 496 … … 541 545 rows = calendar_rows(max_date); 542 546 547 var find_day = function(day) { 548 var found = data.find(function(d) { 549 return d.day == day; 550 }); 551 return found; 552 } 553 543 554 // Build the svg image where the chart will be 544 555 var svg = chart.selectAll("svg") … … 582 593 .on("mouseover", function(d) { 583 594 d3.select(this).classed('hover', true); 595 var day = find_day(d); 596 $('.js-ch-tooltip-date').html(titleFormat(new Date(d))); 597 if (day != undefined) { 598 $('.js-ch-tooltip-workouts').html(day.workouts); 599 $('.js-ch-tooltip-time').html(day.time_formatted); 600 $('.js-ch-tooltip-distance').html(day.distance_formatted); 601 $('.js-ch-tooltip-elevation').html(day.elevation_formatted); 602 } 603 else { 604 $('.js-ch-tooltip-workouts').html(' - '); 605 $('.js-ch-tooltip-time').html(' - '); 606 $('.js-ch-tooltip-distance').html(' - '); 607 $('.js-ch-tooltip-elevation').html(' - '); 608 } 609 $('.js-calendar-heatmap-tooltip').fadeIn('fast'); 584 610 }) 585 611 .on("mouseout", function(d) { 586 612 d3.select(this).classed('hover', false); 613 $('.js-calendar-heatmap-tooltip').fadeOut('fast'); 587 614 }) 588 615 .datum(format); … … 608 635 }); 609 636 610 var find_day = function(day) {611 var found = data.find(function(d) {612 return d.day == day;613 });614 return found;615 }616 617 637 var lookup = d3.nest() 618 638 .key(function(d) { … … 655 675 // doSomething(); 656 676 }) 657 .select("title")658 .text(function(d) {659 // Update the title adding some more info660 var day = find_day(d);661 return titleFormat(new Date(d)) + ": " + day.time_formatted; });662 677 }); 663 678 -
ow/static/less/pages/profile.less
rf2c9e20 r3ac70ca 181 181 } 182 182 } 183 184 .calendar-heatmap-tooltip { 185 width: 20%; 186 } -
ow/templates/profile.pt
rf2c9e20 r3ac70ca 53 53 <div class="calendar-heatmap js-calendar-heatmap"> 54 54 </div> 55 <div class="calendar-heatmap-tooltip js-calendar-heatmap-tooltip"> 56 <ul class="profile-data"> 57 <li> 58 <span class="js-ch-tooltip-date"></span> 59 </li> 60 <li> 61 <span><tal:t i18n:translate="">Workouts:</tal:t></span> 62 <span class="js-ch-tooltip-workouts"></span> 63 </li> 64 <li> 65 <span><tal:t i18n:translate="">Time:</tal:t></span> 66 <span class="js-ch-tooltip-time"></span> 67 </li> 68 <li> 69 <span><tal:t i18n:translate="">Distance:</tal:t></span> 70 <span class="js-ch-tooltip-distance"></span> 71 </li> 72 <li> 73 <span><tal:t i18n:translate="">Elevation:</tal:t></span> 74 <span class="js-ch-tooltip-elevation"></span> 75 </li> 76 </ul> 77 </div> 55 78 </div> 56 79 -
ow/views/user.py
rf2c9e20 r3ac70ca 466 466 'distance': 0, # kilometers 467 467 'elevation': 0, # meters 468 'workouts': 0, 469 'sports': {}, 468 470 } 469 471 duration = getattr(workout, 'duration', None) or timedelta(0) … … 473 475 elevation = getattr(workout, 'uphill', None) or 0 474 476 stats[start]['elevation'] += int(elevation) 477 stats[start]['workouts'] += 1 478 if workout.sport not in stats[start]['sports'].keys(): 479 stats[start]['sports'][workout.sport] = 0 480 stats[start]['sports'][workout.sport] += 1 475 481 476 482 json_stats = [] … … 484 490 str(hms[1]).zfill(2), localizer.translate(_('min.')) 485 491 ]) 492 distance_formatted = str(round(stats[day]['distance'])) + ' km' 493 elevation_formatted = str(round(stats[day]['elevation'])) + ' m' 486 494 json_stats.append({ 487 495 'day': day, … … 489 497 'time_formatted': time_formatted, 490 498 'distance': stats[day]['distance'], 491 'elevation': stats[day]['elevation'] 499 'distance_formatted': distance_formatted, 500 'elevation': stats[day]['elevation'], 501 'elevation_formatted': elevation_formatted, 502 'workouts': stats[day]['workouts'], 503 'sports': stats[day]['sports'] 492 504 }) 493 505
Note: See TracChangeset
for help on using the changeset viewer.