Skip to content

adding watch visualization#35404

Merged
bmcconaghy merged 6 commits intoelastic:watcher-portfrom
bmcconaghy:watcher-port
Apr 23, 2019
Merged

adding watch visualization#35404
bmcconaghy merged 6 commits intoelastic:watcher-portfrom
bmcconaghy:watcher-port

Conversation

@bmcconaghy
Copy link
Copy Markdown
Contributor

This PR adds a visualization when the threshold watch conditions are valid.
image
A couple of things need to get figured out:

  • The size of the visualization is currently hardcoded, should probably be dynamic based on viewport of browser
  • The old implementation refreshed the visualization every 60 seconds. This seems like a bad idea to me, so I left that out. We might want to add a refresh visualization button so the user could do this manually if she wishes.

@elasticmachine
Copy link
Copy Markdown
Contributor

💔 Build Failed

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

@cjcenizal cjcenizal added Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more t// Feature:Watcher non-issue Indicates to automation that a pull request should not appear in the release notes labels Apr 22, 2019
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/es-ui

Copy link
Copy Markdown
Contributor

@alisonelizabeth alisonelizabeth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bmcconaghy nice work!

I tested locally. Not sure if I hit all the possible scenarios, but here are a couple things I noticed:

  • Tooltip missing when you hover over data points.

  • What do you think about having a chart loading state? Without it, I noticed the EuiCallOut sometimes appears briefly when changing field values.

  • In the old UI, when you select Grouped over, it looks like the UI switches to a slider-type presentation and multiple charts are rendered. I don’t think there’s support for that yet here, so instead the EuiCallOut message renders.

Old UI:
Screen Shot 2019-04-22 at 2 27 28 PM

colorValues: [],
specId: getSpecId('threshold'),
};
thresholdCustomSeriesColors.set(thresholdDataSeriesColorValues, 'red');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we use the hex from the eui color pallete? it's #BD271E

https://elastic.github.io/eui/#/guidelines/colors

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, done

/>
</Chart>
) : (
<EuiCallOut title="No data" color="warning">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i18n for title here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, added

Copy link
Copy Markdown
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just had a couple suggestions and a question.

return detectedTimezone;
}

const tzOffset = moment().format('Z');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do? Could we add a comment explaining the intention behind this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a comment

specId: getSpecId('threshold'),
};
thresholdCustomSeriesColors.set(thresholdDataSeriesColorValues, 'red');
const theme = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make this work with dark theme, I think we should import DARK_THEME from the charts lib and extract this out into a helper function near the top of the file:

const getChartTheme = () => {
  const isDarkTheme = chrome.getUiSettingsClient().get('theme:darkMode');
  const baseTheme = isDarkTheme ? DARK_THEME : LIGHT_THEME;

  return {
    ...baseTheme,
    lineSeriesStyle: {
      ...baseTheme.lineSeriesStyle,
      line: {
        ...baseTheme.lineSeriesStyle.line,
        strokeWidth: 3,
      },
      point: {
        ...baseTheme.lineSeriesStyle.point,
        visible: false,
      },
    },
  };
};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, forgot about dark mode, done


const WatchVisualizationUi = () => {
const { watch } = useContext(WatchContext);
const [watchVisualizationData, setWatchVisualizationData] = useState<number[][]>([]);
Copy link
Copy Markdown
Contributor

@cjcenizal cjcenizal Apr 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't have a functional impact, but in case you find it cleaner you could also extract this and the effect on line 95 into a custom hook:

const useWatchVisualizationData = watch => {
  const [watchVisualizationData, setWatchVisualizationData] = useState<number[][]>([]);

  useEffect(
    () => {
      loadWatchVisualizationData(watch, setWatchVisualizationData);
    },
    [watch]
  );

  return watchVisualizationData;
}

Then consuming it would look like this:

const WatchVisualizationUi = () => {
  const { watch } = useContext(WatchContext);
  const watchVisualizationData = useWatchVisualizationData(watch);
  /* ... */
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it prefer it in this way personally.

@bmcconaghy
Copy link
Copy Markdown
Contributor Author

@alisonelizabeth the tooltip missing is a bug in EUI charts. If the data is continuous, they appear, if not, not. Chart loading state makes sense, but maybe that can be done in a separate PR. The paged charts thing just got implemented as a chart with multiple lines. This works pretty well for lower values of top N, but is obviously not great with higher values. Will probably need a revisit to sort out the proper UI here.

@elasticmachine
Copy link
Copy Markdown
Contributor

💔 Build Failed

import { aggTypes } from '../../../models/watch/agg_types';
const getChartTheme = () => {
const isDarkTheme = chrome.getUiSettingsClient().get('theme:darkMode');
const baseTheme = isDarkTheme ? DARK_THEME : LIGHT_THEME;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to import DARK_THEME from @elastic/charts

@alisonelizabeth
Copy link
Copy Markdown
Contributor

alisonelizabeth commented Apr 22, 2019

@bmcconaghy thanks for making the changes!

I'm getting an error with the latest. Do you think you could take a look?

Version: 8.0.0
Build: 9007199254740991
Error: Uncaught TypeError: (0 , _charts.getSpecId) is not a function (http://localhost:5601/fca/bundles/kibana.bundle.js:130939)
    at push../src/legacy/ui/public/notify/notify.js.window.onerror (http://localhost:5601/fca/bundles/commons.bundle.js:135703:32)
    at Object.invokeGuardedCallbackDev (webpack://%5Bname%5D/./node_modules/react-dom/cjs/react-dom.development.js?:199:16)
    at invokeGuardedCallback (webpack://%5Bname%5D/./node_modules/react-dom/cjs/react-dom.development.js?:256:31)
    at replayUnitOfWork (webpack://%5Bname%5D/./node_modules/react-dom/cjs/react-dom.development.js?:18372:5)
    at renderRoot (webpack://%5Bname%5D/./node_modules/react-dom/cjs/react-dom.development.js?:19262:13)
    at performWorkOnRoot (webpack://%5Bname%5D/./node_modules/react-dom/cjs/react-dom.development.js?:20136:7)
    at performWork (webpack://%5Bname%5D/./node_modules/react-dom/cjs/react-dom.development.js?:20048:7)
    at performSyncWork (webpack://%5Bname%5D/./node_modules/react-dom/cjs/react-dom.development.js?:20022:3)
    at batchedUpdates$1 (webpack://%5Bname%5D/./node_modules/react-dom/cjs/react-dom.development.js?:20237:7)
    at batchedUpdates (webpack://%5Bname%5D/./node_modules/react-dom/cjs/react-dom.development.js?:2151:12)

@bmcconaghy
Copy link
Copy Markdown
Contributor Author

@alisonelizabeth not able to reproduce that error, maybe we can pair and you can show it to me? I did find a React warning (missing key on array) that I pushed a fix for.

@elasticmachine
Copy link
Copy Markdown
Contributor

💔 Build Failed

@alisonelizabeth
Copy link
Copy Markdown
Contributor

@bmcconaghy thanks for looking into it. i believe the error is something with my local dev env. latest changes LGTM.

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

@bmcconaghy bmcconaghy merged commit 5faec7b into elastic:watcher-port Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:Watcher non-issue Indicates to automation that a pull request should not appear in the release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more t//

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants