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

Time series specific visualization controls #986

Merged
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
more robust number range formatter
adrianmroz-allegro committed Dec 6, 2022
commit e886ed880a58e061358dbaca071073b10adac425
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
* limitations under the License.
*/

import { Dataset, Datum, NumberRange, Range, TimeRange } from "plywood";
import { Dataset, Datum, NumberRange, TimeRange } from "plywood";
import { Split } from "../../../../../common/models/split/split";
import { Binary, cons, replaceAt, Unary } from "../../../../../common/utils/functional/functional";
import { SPLIT } from "../../../../config/constants";
9 changes: 8 additions & 1 deletion src/common/utils/formatter/formatter.ts
Original file line number Diff line number Diff line change
@@ -31,10 +31,17 @@ import {
TimeFilterClause,
TimeFilterPeriod
} from "../../models/filter-clause/filter-clause";
import { isNil } from "../general/general";
import { formatStartOfTimeRange, formatTimeRange } from "../time/time";

function safeFormatNumber(value: number): string {
return isNil(value) ? "any" : value.toString(10);
}

export function formatNumberRange(value: NumberRange) {
return `${formatValue(value.start || "any")} to ${formatValue(value.end || "any")}`;
const start = safeFormatNumber(value.start);
const end = safeFormatNumber(value.end);
return `${start} to ${end}`;
}

export function formatValue(value: any, timezone?: Timezone): string {