How to use the d3-time.timeWeek.count function in d3-time

To help you get started, we’ve selected a few d3-time examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github plouc / nivo / packages / calendar / src / compute.js View on Github external
const monthPathAndBBox = ({
    date,
    cellSize,
    yearIndex,
    yearSpacing,
    daySpacing,
    direction,
    originX,
    originY,
}) => {
    // first day of next month
    const t1 = new Date(date.getFullYear(), date.getMonth() + 1, 0)

    // ranges
    const firstWeek = timeWeek.count(timeYear(date), date)
    const lastWeek = timeWeek.count(timeYear(t1), t1)
    const firstDay = date.getDay()
    const lastDay = t1.getDay()

    // offset according to year index
    let xO = originX
    let yO = originY
    const yearOffset = yearIndex * (7 * (cellSize + daySpacing) + yearSpacing)
    if (direction === 'horizontal') {
        yO += yearOffset
    } else {
        xO += yearOffset
    }

    let path
    let bbox = { x: xO, y: yO, width: 0, height: 0 }
    if (direction === 'horizontal') {
github plouc / nivo / packages / calendar / src / compute.js View on Github external
const monthPathAndBBox = ({
    date,
    cellSize,
    yearIndex,
    yearSpacing,
    daySpacing,
    direction,
    originX,
    originY,
}) => {
    // first day of next month
    const t1 = new Date(date.getFullYear(), date.getMonth() + 1, 0)

    // ranges
    const firstWeek = timeWeek.count(timeYear(date), date)
    const lastWeek = timeWeek.count(timeYear(t1), t1)
    const firstDay = date.getDay()
    const lastDay = t1.getDay()

    // offset according to year index
    let xO = originX
    let yO = originY
    const yearOffset = yearIndex * (7 * (cellSize + daySpacing) + yearSpacing)
    if (direction === 'horizontal') {
        yO += yearOffset
    } else {
        xO += yearOffset
    }

    let path
    let bbox = { x: xO, y: yO, width: 0, height: 0 }
github hpcc-systems / Visualization / packages / other / src / CalendarHeatMap.ts View on Github external
function calcMonthPath(t0) {
            const t1 = new Date(t0.getFullYear(), t0.getMonth() + 1, 0);
            const d0 = t0.getDay();
            const w0 = d3TimeWeek.count(d3TimeYear(t0), t0);
            const d1 = t1.getDay();
            const w1 = d3TimeWeek.count(d3TimeYear(t1), t1);
            return "M" + (w0 + 1) * cellSize + "," + d0 * cellSize +
                "H" + w0 * cellSize + "V" + 7 * cellSize +
                "H" + w1 * cellSize + "V" + (d1 + 1) * cellSize +
                "H" + (w1 + 1) * cellSize + "V" + 0 +
                "H" + (w0 + 1) * cellSize + "Z";
        }
    }
github hpcc-systems / Visualization / packages / other / src / CalendarHeatMap.ts View on Github external
function calcMonthPath(t0) {
            const t1 = new Date(t0.getFullYear(), t0.getMonth() + 1, 0);
            const d0 = t0.getDay();
            const w0 = d3TimeWeek.count(d3TimeYear(t0), t0);
            const d1 = t1.getDay();
            const w1 = d3TimeWeek.count(d3TimeYear(t1), t1);
            return "M" + (w0 + 1) * cellSize + "," + d0 * cellSize +
                "H" + w0 * cellSize + "V" + 7 * cellSize +
                "H" + w1 * cellSize + "V" + (d1 + 1) * cellSize +
                "H" + (w1 + 1) * cellSize + "V" + 0 +
                "H" + (w0 + 1) * cellSize + "Z";
        }
    }
github plouc / nivo / packages / calendar / src / compute.js View on Github external
return (originX, originY, d, yearIndex) => {
        const weekOfYear = timeWeek.count(timeYear(d), d)

        return {
            x:
                originX +
                d.getDay() * (cellSize + daySpacing) +
                daySpacing / 2 +
                yearIndex * (yearSpacing + 7 * (cellSize + daySpacing)),
            y: originY + weekOfYear * (cellSize + daySpacing) + daySpacing / 2,
        }
    }
}
github hpcc-systems / Visualization / packages / other / src / CalendarHeatMap.ts View on Github external
            .attr("x", function (d) { return d3TimeWeek.count(d3TimeYear(d), d) * cellSize; })
            .attr("y", function (d) { return d.getDay() * cellSize; })