Changeset 3ac70ca in OpenWorkouts-current for ow/static/js/ow.js
- Timestamp:
- Mar 12, 2019, 9:29:22 PM (5 years ago)
- Branches:
- current
- Children:
- 39dc0a6
- Parents:
- f2c9e20
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.