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

feat: new chart error panel #1850

Merged
merged 10 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
43 changes: 25 additions & 18 deletions packages/chart/src/Chart.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { Component, ReactElement, RefObject } from 'react';
import deepEqual from 'deep-equal';
import memoize from 'memoize-one';
import { CopyButton, Popper } from '@deephaven/components';
import {
vsLoading,
dhGraphLineDown,
Expand Down Expand Up @@ -33,6 +32,7 @@ import { bindAllMethods } from '@deephaven/utils';
import createPlotlyComponent from './plotly/createPlotlyComponent';
import Plotly from './plotly/Plotly';
import ChartModel from './ChartModel';
import ChartErrorOverlay from './ChartErrorOverlay';
import { ChartTheme } from './ChartTheme';
import ChartUtils, { ChartModelSettings } from './ChartUtils';
import './Chart.scss';
Expand Down Expand Up @@ -415,6 +415,10 @@ class Chart extends Component<ChartProps, ChartState> {
this.setState({ shownError: null });
}

handleDownsampleErrorClose(): void {
this.setState({ downsamplingError: null });
}

handleModelEvent(event: CustomEvent): void {
const { type, detail } = event;
log.debug2('Received data update', type, detail);
Expand Down Expand Up @@ -704,23 +708,26 @@ class Chart extends Component<ChartProps, ChartState> {
style={{ height: '100%', width: '100%' }}
/>
)}
<Popper
className="chart-error-popper"
options={{ placement: 'top' }}
isShown={shownError != null}
onExited={this.handleErrorClose}
closeOnBlur
interactive
>
{shownError != null && (
<>
<div className="chart-error">{shownError}</div>
<CopyButton tooltip="Copy Error" copy={shownError}>
Copy Error
</CopyButton>
</>
)}
</Popper>
{downsamplingError != null && shownError == null && (
<ChartErrorOverlay
errorMessage={`${downsamplingError}`}
onDiscard={() => {
this.handleDownsampleErrorClose();
}}
onConfirm={() => {
this.handleDownsampleErrorClose();
this.handleDownsampleClick();
}}
/>
)}
{shownError != null && (
<ChartErrorOverlay
errorMessage={`${shownError}`}
onDiscard={() => {
this.handleErrorClose();
}}
/>
)}
</div>
);
}
Expand Down
14 changes: 14 additions & 0 deletions packages/chart/src/ChartErrorOverlay.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@import '@deephaven/components/scss/custom.scss';

.chart-error-overlay {
.chart-error-overlay-content {
.btn {
margin-top: $spacer-3;
margin-right: $spacer-3;
}
.info-message,
.waiting-filter-list {
text-align: left;
}
}
}
59 changes: 59 additions & 0 deletions packages/chart/src/ChartErrorOverlay.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { ReactElement } from 'react';
import { CopyButton, Button } from '@deephaven/components';
import './ChartErrorOverlay.scss';

interface ChartErrorOverlayProps {
errorMessage: string;
onDiscard?: () => void;
onCancel?: () => void;
onConfirm?: () => void;
'data-testid'?: string;
}

function ChartErrorOverlay({
errorMessage,
onDiscard,
onConfirm,
onCancel,
'data-testid': dataTestId,
}: ChartErrorOverlayProps): ReactElement {
const messageTestId =
dataTestId != null ? `${dataTestId}-message` : undefined;

// TODO: DHC #5220 to detect slow performance and show this message

const undismissableError =
errorMessage === 'Too many items to disable downsampling';
mofojed marked this conversation as resolved.
Show resolved Hide resolved

return (
<div className="chart-panel-overlay chart-error-overlay">
<div className="chart-panel-overlay-content chart-error-overlay-content">
<div className="info-message" data-testid={messageTestId}>
{errorMessage}
<CopyButton copy={errorMessage} style={{ margin: '0' }} />
</div>
{/* {!undismissableError && ( */}
mofojed marked this conversation as resolved.
Show resolved Hide resolved
<div>
{onCancel && (
<Button onClick={onCancel} kind="secondary">
Cancel
</Button>
)}
{onDiscard && (
<Button onClick={onDiscard} kind="secondary">
Dismiss
</Button>
)}
{onConfirm && !undismissableError && (
<Button onClick={onConfirm} kind="primary">
Continue
</Button>
)}
</div>
{/* )} */}
mofojed marked this conversation as resolved.
Show resolved Hide resolved
</div>
</div>
);
}

export default ChartErrorOverlay;
Loading