Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pathMonth for Calendar View to D3 #170

Open
curran opened this issue Nov 2, 2020 · 3 comments
Open

Add pathMonth for Calendar View to D3 #170

curran opened this issue Nov 2, 2020 · 3 comments

Comments

@curran
Copy link
Contributor

curran commented Nov 2, 2020

This little snippet appears in calendar view visualizations, but I don't believe it's part of D3 itself.

function pathMonth(t) {
  const n = weekday === "weekday" ? 5 : 7;
  const d = Math.max(0, Math.min(n, countDay(t.getUTCDay())));
  const w = timeWeek.count(d3.utcYear(t), t);
  return `${d === 0 ? `M${w * cellSize},0`
      : d === n ? `M${(w + 1) * cellSize},0`
      : `M${(w + 1) * cellSize},0V${d * cellSize}H${w * cellSize}`}V${n * cellSize}`;
}

(from https://observablehq.com/@d3/calendar-view)

Might it make sense to add this to d3-shape? Or maybe as a separate D3 package?

@mbostock
Copy link
Member

mbostock commented Nov 2, 2020

Previously d3/d3#449.

@curran
Copy link
Contributor Author

curran commented Nov 2, 2020

Ah yes! Also d3/d3#2851

@curran
Copy link
Contributor Author

curran commented Aug 12, 2024

Here's the latest implementation, from https://observablehq.com/@d3/calendar/2

  // A function that draws a thin white line to the left of each month.
  function pathMonth(t) {
    const d = Math.max(0, Math.min(5, countDay(t.getUTCDay())));
    const w = timeWeek.count(d3.utcYear(t), t);
    return `${d === 0 ? `M${w * cellSize},0`
        : d === 5 ? `M${(w + 1) * cellSize},0`
        : `M${(w + 1) * cellSize},0V${d * cellSize}H${w * cellSize}`}V${5 * cellSize}`;
  }

@curran curran changed the title pathMonth? Add pathMonth for Calendar View to D3 Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants