How to use the d3-time.timeYear 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 facette / facette / ui / src / components / chart / chart.vue View on Github external
format: (date: Date): string => {
                                const format: (specifier: string) => (date: Date) => string = timezoneUTC.value
                                    ? utcFormat
                                    : timeFormat;

                                return (timeSecond(date) < date
                                    ? format(".%L")
                                    : timeMinute(date) < date
                                    ? format(":%S")
                                    : timeHour(date) < date
                                    ? format("%H:%M")
                                    : timeDay(date) < date
                                    ? format("%H:00")
                                    : timeMonth(date) < date
                                    ? format("%a %d")
                                    : timeYear(date) < date
                                    ? format("%B")
                                    : timeFormat("%Y"))(date);
                            },
                        },
github vega / vega-tooltip / src / formatFieldValue.ts View on Github external
export function autoTimeFormat(date: Date) {
  const formatMillisecond = timeFormat('.%L'),
    formatSecond = timeFormat(':%S'),
    formatMinute = timeFormat('%I:%M'),
    formatHour = timeFormat('%I %p'),
    formatDay = timeFormat('%a %d'),
    formatWeek = timeFormat('%b %d'),
    formatMonth = timeFormat('%B'),
    formatYear = timeFormat('%Y');

  return (timeSecond(date) < date ? formatMillisecond
    : timeMinute(date) < date ? formatSecond
      : timeHour(date) < date ? formatMinute
        : timeDay(date) < date ? formatHour
          : timeMonth(date) < date ? (timeWeek(date) < date ? formatDay : formatWeek)
            : timeYear(date) < date ? formatMonth
              : formatYear)(date);
}
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 + weekOfYear * (cellSize + daySpacing) + daySpacing / 2,
            y:
                originY +
                d.getDay() * (cellSize + daySpacing) +
                daySpacing / 2 +
                yearIndex * (yearSpacing + 7 * (cellSize + daySpacing)),
        }
    }
}
github sourcecred / sourcecred / src / explorer / TimelineCredChart.js View on Github external
function multiFormat(dateMs) {
      const date = new Date(dateMs);
      return timeYear(date) < date ? formatMonth(date) : formatYear(date);
    }