How to use d3-time - 10 common examples

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 DefinitelyTyped / DefinitelyTyped / d3-time / d3-time-tests.ts View on Github external
resultDate = simpleI.floor(inBetween);
resultDate = simpleI.round(inBetween);
resultDate = simpleI.ceil(inBetween);
resultDate = simpleI.ceil(inBetween);
resultDate = simpleI.offset(inBetween);
resultDate = simpleI.offset(inBetween, 3);
simpleI = simpleI.filter((d: Date) => { return d.getMonth() === 2; });

// count = simpleI.count(start, end); // Test fails, since .count(...) is not defined on Interval
// simpleI = simpleI.every(10); // Test fails, since .every(...) is not defined on Interval

// Test built-in factories and date array creator definitions ------------------

countableI = d3Time.timeMillisecond;
dateArray = d3Time.timeMilliseconds(start, end);
dateArray = d3Time.timeMilliseconds(start, end, 60000);

countableI = d3Time.timeSecond;
dateArray = d3Time.timeSeconds(start, end);
dateArray = d3Time.timeSeconds(start, end, 120);

countableI = d3Time.timeMinute;
dateArray = d3Time.timeMinutes(start, end);
dateArray = d3Time.timeMinutes(start, end, 5);

countableI = d3Time.timeHour;
dateArray = d3Time.timeHours(start, end);
dateArray = d3Time.timeHours(start, end, 2);

countableI = d3Time.timeDay;
dateArray = d3Time.timeDays(start, end);
github DefinitelyTyped / DefinitelyTyped / types / d3-time / d3-time-tests.ts View on Github external
resultDate = simpleI.floor(inBetween);
resultDate = simpleI.round(inBetween);
resultDate = simpleI.ceil(inBetween);
resultDate = simpleI.ceil(inBetween);
resultDate = simpleI.offset(inBetween);
resultDate = simpleI.offset(inBetween, 3);
simpleI = simpleI.filter((d: Date) => d.getMonth() === 2);

// count = simpleI.count(start, end); // Test fails, since .count(...) is not defined on Interval
// simpleI = simpleI.every(10); // Test fails, since .every(...) is not defined on Interval

// Test built-in factories and date array creator definitions ------------------

countableI = d3Time.timeMillisecond;
dateArray = d3Time.timeMilliseconds(start, end);
dateArray = d3Time.timeMilliseconds(start, end, 60000);

countableI = d3Time.timeSecond;
dateArray = d3Time.timeSeconds(start, end);
dateArray = d3Time.timeSeconds(start, end, 120);

countableI = d3Time.timeMinute;
dateArray = d3Time.timeMinutes(start, end);
dateArray = d3Time.timeMinutes(start, end, 5);

countableI = d3Time.timeHour;
dateArray = d3Time.timeHours(start, end);
dateArray = d3Time.timeHours(start, end, 2);

countableI = d3Time.timeDay;
dateArray = d3Time.timeDays(start, end);
github DefinitelyTyped / DefinitelyTyped / types / d3-time / d3-time-tests.ts View on Github external
resultDate = simpleI.floor(inBetween);
resultDate = simpleI.round(inBetween);
resultDate = simpleI.ceil(inBetween);
resultDate = simpleI.ceil(inBetween);
resultDate = simpleI.offset(inBetween);
resultDate = simpleI.offset(inBetween, 3);
simpleI = simpleI.filter((d: Date) => d.getMonth() === 2);

// count = simpleI.count(start, end); // Test fails, since .count(...) is not defined on Interval
// simpleI = simpleI.every(10); // Test fails, since .every(...) is not defined on Interval

// Test built-in factories and date array creator definitions ------------------

countableI = d3Time.timeMillisecond;
dateArray = d3Time.timeMilliseconds(start, end);
dateArray = d3Time.timeMilliseconds(start, end, 60000);

countableI = d3Time.timeSecond;
dateArray = d3Time.timeSeconds(start, end);
dateArray = d3Time.timeSeconds(start, end, 120);

countableI = d3Time.timeMinute;
dateArray = d3Time.timeMinutes(start, end);
dateArray = d3Time.timeMinutes(start, end, 5);

countableI = d3Time.timeHour;
dateArray = d3Time.timeHours(start, end);
dateArray = d3Time.timeHours(start, end, 2);

countableI = d3Time.timeDay;
dateArray = d3Time.timeDays(start, end);
dateArray = d3Time.timeDays(start, end, 2);
github DefinitelyTyped / DefinitelyTyped / d3-time / d3-time-tests.ts View on Github external
resultDate = simpleI.floor(inBetween);
resultDate = simpleI.round(inBetween);
resultDate = simpleI.ceil(inBetween);
resultDate = simpleI.ceil(inBetween);
resultDate = simpleI.offset(inBetween);
resultDate = simpleI.offset(inBetween, 3);
simpleI = simpleI.filter((d: Date) => { return d.getMonth() === 2; });

// count = simpleI.count(start, end); // Test fails, since .count(...) is not defined on Interval
// simpleI = simpleI.every(10); // Test fails, since .every(...) is not defined on Interval

// Test built-in factories and date array creator definitions ------------------

countableI = d3Time.timeMillisecond;
dateArray = d3Time.timeMilliseconds(start, end);
dateArray = d3Time.timeMilliseconds(start, end, 60000);

countableI = d3Time.timeSecond;
dateArray = d3Time.timeSeconds(start, end);
dateArray = d3Time.timeSeconds(start, end, 120);

countableI = d3Time.timeMinute;
dateArray = d3Time.timeMinutes(start, end);
dateArray = d3Time.timeMinutes(start, end, 5);

countableI = d3Time.timeHour;
dateArray = d3Time.timeHours(start, end);
dateArray = d3Time.timeHours(start, end, 2);

countableI = d3Time.timeDay;
dateArray = d3Time.timeDays(start, end);
dateArray = d3Time.timeDays(start, end, 2);
github cityofasheville / simplicity2 / src / app / development / volume / TimeSlider.js View on Github external
);
  }
}

TimeSlider.propTypes = {
  // defaultBrushExtent: PropTypes.arrayOf(PropTypes.number),
  onBrushEnd: PropTypes.func,
  xSpan: PropTypes.number,
};

TimeSlider.defaultProps = {
  defaultBrushExtent: [
    timeWeek.offset(timeDay.floor(new Date()), -1).getTime(),
    timeDay.floor(new Date()).getTime(),
  ], // today and today minus thirty-one days
  onBrushEnd: newExtent => console.log(newExtent),
  xSpan: 2, // in years
};

export default TimeSlider;
github cityofasheville / simplicity2 / src / app / development / volume / TimeSlider.js View on Github external
/>}
        
      
    );
  }
}

TimeSlider.propTypes = {
  // defaultBrushExtent: PropTypes.arrayOf(PropTypes.number),
  onBrushEnd: PropTypes.func,
  xSpan: PropTypes.number,
};

TimeSlider.defaultProps = {
  defaultBrushExtent: [
    timeWeek.offset(timeDay.floor(new Date()), -1).getTime(),
    timeDay.floor(new Date()).getTime(),
  ], // today and today minus thirty-one days
  onBrushEnd: newExtent => console.log(newExtent),
  xSpan: 2, // in years
};

export default TimeSlider;
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 orbiting / crowdfunding-frontend / components / Status / index.js View on Github external
render () {
    if (!this.props.crowdfunding) {
      return null
    }

    const {crowdfunding: {goals, status, endDate}, t} = this.props
    const now = new Date()
    const nextMinute = timeMinute.ceil(new Date())

    // end date is expected to be an exact minute
    // timeMinute.round is used to ensure that and
    // support end dates like '2017-05-31 19:59:59.999+02'
    const end = timeMinute.round(new Date(endDate))

    const totalMinutes = timeMinute.count(nextMinute, end)
    const minutes = totalMinutes % 60
    const hours = Math.floor(totalMinutes / 60) % 24
    const days = Math.floor(totalMinutes / 60 / 24)

    if (!goals.length) {
      return
    }

    const goalsByPeople = [].concat(goals)
      .sort((a, b) => ascending(a.people, b.people))
    const goal = goalsByPeople[goalsByPeople.length - 1]

    const peopleLabel = t.elements('status/goal/people', {
      count: (
        <a> {</a>
github orbiting / republik-frontend / components / CrowdfundingStatus / index.js View on Github external
crowdfundingName,
      crowdfunding: { goals, status },
      t,
      money,
      people,
      memberships
    } = this.props
    const now = new Date()
    const nextMinute = timeMinute.ceil(new Date())

    // end date is expected to be an exact minute
    // timeMinute.round is used to ensure that and
    // support end dates like '2017-05-31 19:59:59.999+02'
    const end = timeMinute.round(new Date(endDate))

    const totalMinutes = timeMinute.count(nextMinute, end)
    const minutes = totalMinutes % 60
    const hours = Math.floor(totalMinutes / 60) % 24
    const days = Math.floor(totalMinutes / 60 / 24)

    if (!goals.length) {
      return null
    }

    const goalsByPeople = []
      .concat(goals)
      .sort((a, b) =&gt; ascending(a.people, b.people))
    const goal = goalsByPeople[goalsByPeople.length - 1]

    const createHoverGoalCount = (format, value) =&gt; (