How to use the d3-time-format.timeFormatDefaultLocale function in d3-time-format

To help you get started, we’ve selected a few d3-time-format 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 carbon-design-system / carbon-charts / packages / core / src / components / axes / axis.ts View on Github external
case AxisPositions.BOTTOM:
				axisFunction = axisBottom;
				break;
			case AxisPositions.RIGHT:
				axisFunction = axisRight;
				break;
			case AxisPositions.TOP:
				axisFunction = axisTop;
				break;
		}

		// Set the date/time locale
		if (this.scaleType === ScaleTypes.TIME) {
			const timeLocale = Tools.getProperty(options, "locale", "time");
			if (timeLocale) {
				timeFormatDefaultLocale(timeLocale);
			}
		}

		// Initialize axis object
		const axis = axisFunction(scale)
			.tickSizeOuter(0)
			.tickFormat(Tools.getProperty(axisOptions, "ticks", "formatter"));

		if (scale.ticks) {
			const numberOfTicks = Tools.getProperty(axisOptions, "ticks", "number") || Configuration.axis.ticks.number;
			axis.ticks(numberOfTicks);

			if (this.scaleType === ScaleTypes.TIME) {
				let tickValues = scale.ticks(numberOfTicks).concat(scale.domain())
					.map(date => +date).sort();
				tickValues = Tools.removeArrayDuplicates(tickValues);
github DefinitelyTyped / DefinitelyTyped / types / d3-time-format / d3-time-format-tests.ts View on Github external
let shortMonths: [string, string, string, string, string, string, string, string, string, string, string, string] = localeDef.shortMonths;

localeDef = {
    dateTime: '%a %b %e %X %Y',
    date: '%m/%d/%Y',
    time: '%H:%M:%S',
    periods: ['Vormittag', 'Nachmittag'],
    days: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Sonnabend'],
    shortDays: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
    months: ['Januar', 'Februar', 'Maerz', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
    shortMonths: ['Jan', 'Feb', 'Mrz', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez']
};

localeObj = d3TimeFormat.timeFormatLocale(localeDef);

localeObj = d3TimeFormat.timeFormatDefaultLocale(localeDef);

let formatFactory: (specifier: string) => ((date: Date) => string) = localeObj.format;
let parseFactory: (specifier: string) => ((dateString: string) => Date) = localeObj.parse;

formatFactory = localeObj.utcFormat;
parseFactory = localeObj.utcParse;
github DefinitelyTyped / DefinitelyTyped / d3-time-format / d3-time-format-tests.ts View on Github external
let shortMonths: [string, string, string, string, string, string, string, string, string, string, string, string] = localeDef.shortMonths;

localeDef = {
    dateTime: '%a %b %e %X %Y',
    date: '%m/%d/%Y',
    time: '%H:%M:%S',
    periods: ['Vormittag', 'Nachmittag'],
    days: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Sonnabend'],
    shortDays: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
    months: ['Januar', 'Februar', 'Maerz', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
    shortMonths: ['Jan', 'Feb', 'Mrz', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez']
};

localeObj = d3TimeFormat.timeFormatLocale(localeDef);

localeObj = d3TimeFormat.timeFormatDefaultLocale(localeDef);

let formatFactory: (specifier: string) => ((date: Date) => string) = localeObj.format;
let parseFactory: (specifier: string) => ((dateString: string) => Date) = localeObj.parse;

formatFactory = localeObj.utcFormat;
parseFactory = localeObj.utcParse;
github rrag / react-stockcharts / src / lib / scale / discontinuousTimeScaleProvider.js View on Github external
discontinuousTimeScaleProvider.setLocale = function(locale, formatters = null) {
		if (locale) {
			timeFormatDefaultLocale(locale);
		}
		if (formatters) {
			currentFormatters = formatters;
		}
		return discontinuousTimeScaleProvider;
	};
github CartoDB / airship / packages / components / src / components / as-time-series-widget / as-time-series-widget.tsx View on Github external
public onTimeFormatLocaleChanged(newLocale) {
    try {
      timeFormatDefaultLocale(newLocale);

      if (this.timeFormat) {
        this.onTimeFormatChanged(this.timeFormat);
      }
    } catch (e) {
      throw new Error('Invalid time format.');
    }

  }
github CartoDB / airship / packages / components / src / components / as-time-series-widget / as-time-series-widget.tsx View on Github external
public async componentDidLoad() {
    if (this.timeFormatLocale) {
      timeFormatDefaultLocale(this.timeFormatLocale);
    }

    this._formatter = timeFormat(this.timeFormat);

    this.histogram.addEventListener('selectionInput', (evt: CustomEvent) => {
      if (evt.detail === null) {
        this._selection = null;
      } else {
        this._selection = evt.detail.selection;
      }

      this._render();
    });

    this.histogram.addEventListener('selectionChanged', (evt: CustomEvent) => {
      evt.stopPropagation();
github cozy / cozy.github.io / en / cozy-banks / src / utils / d3.js View on Github external
const setupLocale = lang => {
  timeFormatDefaultLocale(D3_LOCALES_MAP[lang] || D3_LOCALES_MAP.en)
}