(days, data)
| 735 | } |
| 736 | |
| 737 | createLineChartPoints (days, data) { |
| 738 | let i, point |
| 739 | let points = [] |
| 740 | for (i = 0; i < data.length; i++) { |
| 741 | const entry = data[i] |
| 742 | points.push({ |
| 743 | day: entry.day, |
| 744 | y: entry.value |
| 745 | }) |
| 746 | } |
| 747 | |
| 748 | // Trim points preceding days |
| 749 | if (points.length && days.length && (points[0].day.localeCompare(days[0]) < 0)) { |
| 750 | if (points[points.length - 1].day.localeCompare(days[0]) < 0) { |
| 751 | points = [] |
| 752 | } else { |
| 753 | for (i = 0; i < points.length; i++) { |
| 754 | point = points[i] |
| 755 | if (point.day.localeCompare(days[0]) >= 0) { |
| 756 | points.splice(0, i) |
| 757 | break |
| 758 | } |
| 759 | } |
| 760 | } |
| 761 | } |
| 762 | |
| 763 | // Trim points following days |
| 764 | if (points.length && days.length && (points[points.length - 1].day.localeCompare(days[days.length - 1]) > 0)) { |
| 765 | if (points[0].day.localeCompare(days[days.length - 1]) > 0) { |
| 766 | points = [] |
| 767 | } else { |
| 768 | let asc, start |
| 769 | for (start = points.length - 1, i = start, asc = start <= 0; asc ? i <= 0 : i >= 0; asc ? i++ : i--) { |
| 770 | point = points[i] |
| 771 | if (point.day.localeCompare(days[days.length - 1]) <= 0) { |
| 772 | points.splice(i) |
| 773 | break |
| 774 | } |
| 775 | } |
| 776 | } |
| 777 | } |
| 778 | |
| 779 | // Ensure points for each day |
| 780 | for (i = 0; i < days.length; i++) { |
| 781 | const day = days[i] |
| 782 | if ((points.length <= i) || ((points[i] != null ? points[i].day : undefined) !== day)) { |
| 783 | const prevY = i > 0 ? points[i - 1].y : 0.0 |
| 784 | points.splice(i, 0, { |
| 785 | day, |
| 786 | y: prevY |
| 787 | } |
| 788 | ) |
| 789 | } |
| 790 | if (isNaN(points[i].y)) { points[i].y = 0.0 } |
| 791 | points[i].x = i |
| 792 | } |
| 793 | |
| 794 | if (points.length > days.length) { points.splice(0, points.length - days.length) } |
no outgoing calls
no test coverage detected