Added month select component.

This commit is contained in:
Mike Cao 2023-08-16 10:50:28 -07:00
parent 6ef1f2e9f9
commit c548267d91
16 changed files with 169 additions and 71 deletions

View file

@ -1,5 +1,5 @@
import { StatusLight } from 'react-basics';
import { dateFormat } from 'lib/date';
import { formatDate } from 'lib/date';
import { formatLongNumber } from 'lib/format';
export function renderNumberLabels(label) {
@ -12,15 +12,15 @@ export function renderDateLabels(unit, locale) {
switch (unit) {
case 'minute':
return dateFormat(d, 'h:mm', locale);
return formatDate(d, 'h:mm', locale);
case 'hour':
return dateFormat(d, 'p', locale);
return formatDate(d, 'p', locale);
case 'day':
return dateFormat(d, 'MMM d', locale);
return formatDate(d, 'MMM d', locale);
case 'month':
return dateFormat(d, 'MMM', locale);
return formatDate(d, 'MMM', locale);
case 'year':
return dateFormat(d, 'YYY', locale);
return formatDate(d, 'YYY', locale);
default:
return label;
}
@ -50,7 +50,7 @@ export function renderStatusTooltipPopup(unit, locale) {
setTooltipPopup(
<>
<div>{dateFormat(new Date(dataPoints[0].raw.x), formats[unit], locale)}</div>
<div>{formatDate(new Date(dataPoints[0].raw.x), formats[unit], locale)}</div>
<div>
<StatusLight color={labelColors?.[0]?.backgroundColor}>
{formatLongNumber(dataPoints[0].raw.y)} {dataPoints[0].dataset.label}

View file

@ -63,12 +63,12 @@ function getDateFormat(date) {
return `'${dateFormat(date, 'UTC:yyyy-mm-dd HH:MM:ss')}'`;
}
function mapFilter(column, operator, name) {
function mapFilter(column, operator, name, type = 'String') {
switch (operator) {
case OPERATORS.equals:
return `${column} = {${name}:String}`;
return `${column} = {${name}:${type}`;
case OPERATORS.notEquals:
return `${column} != {${name}:String}`;
return `${column} != {${name}:${type}}`;
default:
return '';
}

View file

@ -249,7 +249,7 @@ export const customFormats = {
},
};
export function dateFormat(date, str, locale = 'en-US') {
export function formatDate(date, str, locale = 'en-US') {
return format(
typeof date === 'string' ? new Date(date) : date,
customFormats?.[locale]?.[str] || str,

View file

@ -67,12 +67,12 @@ function getTimestampIntervalQuery(field: string): string {
}
}
function mapFilter(column, operator, name) {
function mapFilter(column, operator, name, type = 'String') {
switch (operator) {
case OPERATORS.equals:
return `${column} = {{${name}}}`;
return `${column} = {${name}:${type}`;
case OPERATORS.notEquals:
return `${column} != {{${name}}}`;
return `${column} != {${name}:${type}}`;
default:
return '';
}