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

[ML] Single Metric Viewer: Fix focus chart updating. #45146

Merged
merged 1 commit into from
Sep 10, 2019
Merged
Show file tree
Hide file tree
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 @@ -103,6 +103,7 @@ const TimeseriesChartIntl = injectI18n(class TimeseriesChart extends React.Compo
focusAnnotationData: PropTypes.array,
focusChartData: PropTypes.array,
focusForecastData: PropTypes.array,
loading: PropTypes.bool.isRequired,
modelPlotEnabled: PropTypes.bool.isRequired,
renderFocusChartOnly: PropTypes.bool.isRequired,
selectedJob: PropTypes.object,
Expand Down Expand Up @@ -202,6 +203,10 @@ const TimeseriesChartIntl = injectI18n(class TimeseriesChart extends React.Compo
}

componentDidUpdate() {
if (this.props.loading) {
return;
}

if (this.props.renderFocusChartOnly === false) {
this.renderChart();
this.drawContextChartSelection();
Expand Down Expand Up @@ -1063,6 +1068,15 @@ const TimeseriesChartIntl = injectI18n(class TimeseriesChart extends React.Compo
const selectionMin = selectedBounds[0].getTime();
const selectionMax = selectedBounds[1].getTime();

// Avoid triggering an update if bounds haven't changed
if (
that.selectedBounds !== undefined &&
that.selectedBounds.min.valueOf() === selectionMin &&
that.selectedBounds.max.valueOf() === selectionMax
) {
return;
}

// Set the color of the swimlane cells according to whether they are inside the selection.
contextGroup.selectAll('.swimlane-cell')
.style('fill', (d) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const TimeSeriesExplorerPage = ({ children, jobSelectorProps, loading, resizeRef
{loading && (<EuiProgress className="mlTimeSeriesExplorerProgress" color="primary" size="xs" />)}
{/* Show a progress bar with progress 0% when not loading.
If we'd just show no progress bar when not loading it would result in a flickering height effect. */}
{!loading && (<EuiProgress className="mlTimeSeriesExplorerProgress" value="0" max="100" color="primary" size="xs" />)}
{!loading && (<EuiProgress className="mlTimeSeriesExplorerProgress" value={0} max={100} color="primary" size="xs" />)}
<JobSelector {...jobSelectorProps} />
<div className="ml-time-series-explorer" ref={resizeRef} >
{children}
Expand Down Expand Up @@ -294,6 +294,11 @@ export class TimeSeriesExplorer extends React.Component {
modelPlotEnabled,
} = this.state;

this.setState({
loading: true,
fullRefresh: false,
});

getFocusData(
criteriaFields,
+detectorId,
Expand Down Expand Up @@ -969,6 +974,7 @@ export class TimeSeriesExplorer extends React.Component {
focusChartData,
focusForecastData,
focusAggregationInterval,
loading,
svgWidth,
zoomFrom,
zoomTo,
Expand Down