Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
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;
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;
discontinuousTimeScaleProvider.setLocale = function(locale, formatters = null) {
if (locale) {
timeFormatDefaultLocale(locale);
}
if (formatters) {
currentFormatters = formatters;
}
return discontinuousTimeScaleProvider;
};
public onTimeFormatLocaleChanged(newLocale) {
try {
timeFormatDefaultLocale(newLocale);
if (this.timeFormat) {
this.onTimeFormatChanged(this.timeFormat);
}
} catch (e) {
throw new Error('Invalid time format.');
}
}
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();
const setupLocale = lang => {
timeFormatDefaultLocale(D3_LOCALES_MAP[lang] || D3_LOCALES_MAP.en)
}