|
730 | 730 | } |
731 | 731 | } |
732 | 732 |
|
| 733 | + var _shareEntries = entries; |
| 734 | + var _shareMinerAddr = (share && share.share_data) ? share.share_data.payout_address : ''; |
| 735 | + function renderSharePPLNS() { |
733 | 736 | var w = grid.clientWidth; |
734 | 737 | var vh = window.innerHeight || document.documentElement.clientHeight; |
735 | | - var h = Math.max(400, Math.min(w * 0.5, vh * 0.7)); |
| 738 | + var h = Math.max(vh * 0.75, Math.min(w * 0.55, vh * 0.85)); |
736 | 739 | grid.style.height = h + 'px'; |
| 740 | + grid.innerHTML = ''; |
737 | 741 |
|
738 | | - var rects = pplnsTreemap(entries, 0, 0, w, h); |
739 | | - var minerAddr = (share && share.share_data) ? share.share_data.payout_address : ''; |
| 742 | + var rects = pplnsTreemap(_shareEntries, 0, 0, w, h); |
| 743 | + var minerAddr = _shareMinerAddr; |
740 | 744 | var addrPrefix = ci.address_explorer_url_prefix || 'https://blockchair.com/litecoin/address/'; |
741 | 745 |
|
742 | 746 | rects.forEach(function(r) { |
|
876 | 880 | tooltip.style.display = 'block'; |
877 | 881 | }); |
878 | 882 | cell.addEventListener('mousemove', function(ev) { |
879 | | - tooltip.style.left = (ev.clientX + 14) + 'px'; |
880 | | - tooltip.style.top = (ev.clientY + 14) + 'px'; |
| 883 | + var tw = tooltip.offsetWidth || 320; |
| 884 | + var th = tooltip.offsetHeight || 120; |
| 885 | + var tx = ev.clientX + 14; |
| 886 | + var ty = ev.clientY + 14; |
| 887 | + if (tx + tw > window.innerWidth - 8) tx = ev.clientX - tw - 14; |
| 888 | + if (ty + th > window.innerHeight - 8) ty = ev.clientY - th - 14; |
| 889 | + if (tx < 8) tx = 8; |
| 890 | + if (ty < 8) ty = 8; |
| 891 | + tooltip.style.left = tx + 'px'; |
| 892 | + tooltip.style.top = ty + 'px'; |
881 | 893 | }); |
882 | 894 | cell.addEventListener('mouseleave', function() { |
883 | 895 | tooltip.style.display = 'none'; |
884 | 896 | }); |
885 | 897 |
|
886 | 898 | grid.appendChild(cell); |
887 | 899 | }); |
| 900 | + } // end renderSharePPLNS |
| 901 | + renderSharePPLNS(); |
| 902 | + // Resize handler |
| 903 | + var _resizeTimer; |
| 904 | + window.addEventListener('resize', function() { |
| 905 | + clearTimeout(_resizeTimer); |
| 906 | + _resizeTimer = setTimeout(renderSharePPLNS, 200); |
| 907 | + }); |
888 | 908 | }); // end d3.json sharechain/window |
889 | 909 | } |
890 | 910 |
|
|
0 commit comments