another attempt at fixing review graph

This should correctly show today count in the 1 month/3 month graphs.
1+ year will have a very tiny bar, but the today count is not so
important at that range. I experimented with shifting the numbers
by one at the gathering stage (so -1 = today) - that makes today fit
in the previous bin, but means the bars no longer match the ticks.
This commit is contained in:
Damien Elmes 2020-07-08 13:31:09 +10:00
parent 93425be839
commit 7a08970bf7

View file

@ -139,6 +139,8 @@ export function renderReviews(
const desiredBars = Math.min(70, Math.abs(xMin!)); const desiredBars = Math.min(70, Math.abs(xMin!));
const x = scaleLinear().domain([xMin!, xMax]).nice(desiredBars); const x = scaleLinear().domain([xMin!, xMax]).nice(desiredBars);
x.domain([x.domain()[0], xMax]);
const sourceMap = showTime ? sourceData.reviewTime : sourceData.reviewCount; const sourceMap = showTime ? sourceData.reviewTime : sourceData.reviewCount;
const bins = histogram() const bins = histogram()
.value((m) => { .value((m) => {
@ -347,10 +349,6 @@ export function renderReviews(
.attr("height", () => y(0) - y(yMax!)) .attr("height", () => y(0) - y(yMax!))
.on("mousemove", function (this: any, d: any, idx) { .on("mousemove", function (this: any, d: any, idx) {
const [x, y] = mouse(document.body); const [x, y] = mouse(document.body);
if (d.x0! >= 0) {
// don't show 'in x days' at the end of the graph
return;
}
showTooltip(tooltipText(d, areaData[idx + 1]), x, y); showTooltip(tooltipText(d, areaData[idx + 1]), x, y);
}) })
.on("mouseout", hideTooltip); .on("mouseout", hideTooltip);