Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let localeObj: d3TimeFormat.TimeLocaleObject;
// ----------------------------------------------------------------------
// Test Formating and Parsing
// ----------------------------------------------------------------------
// local time -----------------------------------------------------------
formatFn = d3TimeFormat.timeFormat('.%L');
parseFn = d3TimeFormat.timeParse('.%L');
// utc ------------------------------------------------------------------
formatFn = d3TimeFormat.utcFormat('.%L');
parseFn = d3TimeFormat.utcParse('.%L');
// iso ------------------------------------------------------------------
let dateString: string = d3TimeFormat.isoFormat(new Date(2016, 6, 6));
let date: Date = d3TimeFormat.isoParse('2016-07-08T14:06:41.386Z');
// ----------------------------------------------------------------------
// Test Locale Definition
// ----------------------------------------------------------------------
let dateTimeSpecifier: string = localeDef.dateTime;
let dateSpecifier: string = localeDef.date;
let timeSpecifier: string = localeDef.time;
let periods: [string, string] = localeDef.periods;
let days: [string, string, string, string, string, string, string] = localeDef.days;
let shortDays: [string, string, string, string, string, string, string] = localeDef.shortDays;
let localeObj: d3TimeFormat.TimeLocaleObject;
// ----------------------------------------------------------------------
// Test Formating and Parsing
// ----------------------------------------------------------------------
// local time -----------------------------------------------------------
formatFn = d3TimeFormat.timeFormat('.%L');
parseFn = d3TimeFormat.timeParse('.%L');
// utc ------------------------------------------------------------------
formatFn = d3TimeFormat.utcFormat('.%L');
parseFn = d3TimeFormat.utcParse('.%L');
// iso ------------------------------------------------------------------
let dateString: string = d3TimeFormat.isoFormat(new Date(2016, 6, 6));
let date: Date = d3TimeFormat.isoParse('2016-07-08T14:06:41.386Z');
// ----------------------------------------------------------------------
// Test Locale Definition
// ----------------------------------------------------------------------
let dateTimeSpecifier: string = localeDef.dateTime;
let dateSpecifier: string = localeDef.date;
let timeSpecifier: string = localeDef.time;
let periods: [string, string] = localeDef.periods;
let days: [string, string, string, string, string, string, string] = localeDef.days;
let shortDays: [string, string, string, string, string, string, string] = localeDef.shortDays;
dates = dates.map(d => utcParse('%Y-%m-%dT%H:%M:%S.%LZ')(d));
const dates = data.map((d) => utcParse('%Y-%m-%dT%H:%M:%S.%LZ')(d.date));
export const createDateNormalizer = ({
format = 'native',
precision = 'millisecond',
useUTC = true,
}) => {
const precisionFn = createPrecisionMethod(precision)
if (format === 'native') return v => precisionFn(v)
const parseTime = useUTC ? utcParse(format) : timeParse(format)
return v => precisionFn(parseTime(v))
}
const dates = data.map((d) => utcParse('%Y-%m-%dT%H:%M:%S.%LZ')(d.date));
const { BarSeries, LineSeries } = series
const { discontinuousTimeScaleProvider } = scale
const {
CrossHairCursor,
MouseCoordinateX,
MouseCoordinateY,
CurrentCoordinate,
EdgeIndicator
} = coordinates
const { ClickCallback } = interactive
const { XAxis, YAxis } = axes
const { fitWidth } = helper
const parseDatetime = utcParse('%Y-%m-%dT%H:%M:%S.%LZ')
formatDefaultLocale({
decimal: '.',
thousands: ',',
grouping: [3],
currency: ['£', '']
})
class SymbolChart extends React.Component {
constructor(props) {
super(props)
const { trades, minDatetime, maxDatetime, maxVolume } = this.parseData(this.props.trades)
this.state = {
trades,
maxVolume,
initialMinDatetime: minDatetime,
async function getLatestDscovrDate(imageType: ImageType) {
const raw = await fetch(`${DSCOVR_BASE_URL}api/${imageType === DSCOVR_EPIC_ENHANCED ? "enhanced" : "natural"}`);
const data: {date: string; image: string}[] = await raw.json();
if (data.length === 0) { return null; }
const latest = data[data.length - 1];
return {
date: utcParse("%Y-%m-%d %H:%M:%S")(latest.date),
image: latest.image,
}
}
this.rawData.buckets.forEach((bucket, i) => {
let obj = {
date: utcParse("%Y-%m-%d")(bucket)
};
this.rawData.series.forEach(series => {
obj[series.name] = series.values[i];
if (_keys.indexOf(series.name) < 0) {
_keys.push(series.name);
}
});
_data.push(obj);
});
async function getLatestSliderDate(imageType: ImageType) {
const which = {
GOES_16: 16,
GOES_16_NATURAL: 16,
GOES_17: 17,
}[imageType];
const raw = await fetch(`${SLIDER_BASE_URL}json/goes-${which}/full_disk/geocolor/latest_times.json`);
const data: {timestamps_int: string[]} = await raw.json();
return utcParse("%Y%m%d%H%M%S")(data.timestamps_int[0]);
}