Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(declarative charts): Add check in Date parsing method #33674

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,21 @@ interface ISecondaryYAxisValues {
secondaryYScaleOptions?: { yMinValue?: number; yMaxValue?: number };
}

const isDate = (value: any): boolean => {
const parsedDate = new Date(Date.parse(value));
if (isNaN(parsedDate.getTime())) {
Anush2303 marked this conversation as resolved.
Show resolved Hide resolved
return false;
}
const parsedYear = parsedDate.getFullYear();
const yearInString = /\b\d{4}\b/.test(value);
if (!yearInString && (parsedYear === 2000 || parsedYear === 2001)) {
return false;
}
return true;
};
const SUPPORTED_PLOT_TYPES = ['pie', 'bar', 'scatter', 'heatmap', 'sankey', 'indicator', 'histogram'];

const isDate = (value: any): boolean => !isNaN(Date.parse(value));
const isNumber = (value: any): boolean => !isNaN(parseFloat(value)) && isFinite(value);

// const isDate = (datum: any): datum is Date => {
// return datum instanceof Date;
// };

const isMonth = (possiblyMonthValue: any, presentYear: number): boolean => {
return isDate(`${possiblyMonthValue} 01, ${presentYear}`);
};
Expand Down
Loading