Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/app/stats/page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,20 @@ describe("Stats page, Visitors view", () => {

fireEvent.blur(month);
});

it("lists the higher series first in the tooltip, like the lines on the chart", () => {
openVisitors();

const month = screen.getByRole("img", { name: /November 2026: 1,743 visitors/ });
fireEvent.focus(month);
const chart = screen.getByRole("group", { name: "Visitors and page views per month" });
const tooltip = chart.querySelector('[aria-hidden="true"].bg-popover');
expect(tooltip).not.toBeNull();
const text = tooltip!.textContent ?? "";
// Page views are always at least visitors, so they come first and visitors sit below.
expect(text.indexOf("Page views")).toBeGreaterThan(-1);
expect(text.indexOf("Page views")).toBeLessThan(text.indexOf("Visitors"));

fireEvent.blur(month);
});
});
3 changes: 2 additions & 1 deletion src/components/traffic/traffic-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,8 @@ export function TrafficChart({ rows, metrics, kind, valueLabel }: TrafficChartPr
{valueLabel ? `, ${valueLabel.toLowerCase()}` : ""}
</p>
<div className="mt-1.5 flex flex-col gap-1">
{series.map((s) => (
{/* Highest value first, so the rows sit in the same order as the lines on the chart. */}
{[...series].sort((a, b) => activeRow[b.key] - activeRow[a.key]).map((s) => (
<div key={s.key} className="flex items-center gap-2">
<span
className="inline-block h-0.5 w-3 rounded-full"
Expand Down
Loading