Skip to content

[TSVB] Show an indicator when using Last Value mode#91977

Merged
stratoula merged 30 commits intoelastic:masterfrom
DianaDerevyankina:issues/90248
Mar 30, 2021
Merged

[TSVB] Show an indicator when using Last Value mode#91977
stratoula merged 30 commits intoelastic:masterfrom
DianaDerevyankina:issues/90248

Conversation

@DianaDerevyankina
Copy link
Copy Markdown
Contributor

@DianaDerevyankina DianaDerevyankina commented Feb 19, 2021

Closes #90248

Summary

Put "Last value" badge to all TSVB panel types except timeseries

image

Added a tooltip with last bucket date and interval information (was moved here from the editor)

image

Checklist

For maintainers

@DianaDerevyankina DianaDerevyankina added Feature:TSVB TSVB (Time Series Visual Builder) Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// v8.0.0 v7.13.0 labels Feb 19, 2021
@DianaDerevyankina DianaDerevyankina self-assigned this Feb 19, 2021
const interval = convertIntervalIntoUnit(this.state.panelInterval, false);

return interval ? `${interval.unitValue}${interval.unitString}` : null;
return [
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: I see you renamed that method to isAnyPanelTypeExceptTimeseries maybe in that case instead of

 [	
        PANEL_TYPES.METRIC,	
        PANEL_TYPES.TOP_N,	
        PANEL_TYPES.GAUGE,	
        PANEL_TYPES.MARKDOWN,	
        PANEL_TYPES.TABLE,	
      ].includes(type) &&

we can writee just type !== PANEL_TYPES.TIMESERIES

@alexwizp
Copy link
Copy Markdown
Contributor

Broken case:

  1. Open TSVB and open any sample data
  2. Set 1 second as a value for global timeeframe
  3. Refresh visualization and see next screen
    image

import { TIME_RANGE_DATA_MODES } from '../../../common/timerange_data_modes';

const lastValueFormattedMessage = (
<FormattedMessage
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.

use i18n.translate for non-JSX translations

);

interface DataTimeRangeModeLabelProps {
seriesData: Array<Array<number | null>>;
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.

is it PanelData['data'] ?

export const convertIntervalIntoUnit = (interval: number, hasTranslateUnitString = true) => {
// Iterate units from biggest to smallest
const units = Object.keys(unitLookup).reverse();
const units = Object.keys(unitLookup).reverse() as TimeUnits;
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 if we reefactor it to:

type TimeUnit = keyof typeof unitLookup;
const units = Object.keys(unitLookup).reverse() as TimeUnit[];

export const getInterval = (visData: TimeseriesVisData, model: TimeseriesVisParams) => {
const series = get(
visData,
model?.type === 'table' ? `series[0].series` : `${model.id}.series`,
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.

please replace 'table' to PANEL_TYPES.TABLE

export const isAutoInterval = (interval: string) => !interval || interval === AUTO_INTERVAL;

interface ValidationResult {
errorMessage: string;
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.

looks like errorMessage should be optional

@alexwizp
Copy link
Copy Markdown
Contributor

@elasticmachine merge upstream

modelInterval,
modelTimeRangeMode,
}: DataTimeRangeModeLabelProps) => {
const hasShowPanelIntervalValue = () =>
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 see you usee that method only for getting value for getFormattedPanelInterval. Maybe we can move isAutoInterval(modelInterval) || isGteInterval(modelInterval) directly to getFormattedPanelInterval

};

const getLastValueLabelWithTooltip = () => {
const dateFormat = getUISettings().get('dateFormat');
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.

please move it up to don't calculate dateFormat and scaledDataFormat on each time

filters,
};
return getVisData(requestContext, rawRequest, options);
return getVisData(requestContext, rawRequest, options) as Promise<InfraTSVBResponse>;
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.

could you please explain why it wass changed?

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.

@dziyanadzeraviankina could you please try to export right types from TSVB plugin and replace InfraTSVBResponse to it? I see in infra plugin some types which can be probably safely removed
image

@alexwizp
Copy link
Copy Markdown
Contributor

@VladLasitsa @sulemanof please have a look

@alexwizp alexwizp requested a review from stratoula February 23, 2021 08:12
return false;
},
execute: async () => {},
});
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.

@streamich could you please take a look?
during the discussion, it's been decided to add an indicator on top of the embeddable to indicate if visualization is using last value mode
so what do you think about this solution? would appreciate any comments or other ideas how to implement that

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 am missing some context, what is this supposed to do ? action without execute ? or is this work in progress ?

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.

so after being explained what we need i think we should try to put the message inside TSVB (instead of panel header).
currently panel headers are showing things that are common for all the embeddables and i think it should stay that way.

if we really wanted to show some indication like this inside the panel header we need to expand the embeddable API to support this, which will take some time as we'll want to take it thru planning, rfc and arch review.

import { PANEL_TYPES } from '../../common/panel_types';
import { Vis } from '../../../visualizations/public';

const LAST_VALUE_MODE = 'lastValueMode';
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.

Why do not you use constants from here src\plugins\vis_type_timeseries\common\timerange_data_modes.ts?

@@ -87,18 +98,43 @@ function TimeseriesVisualization({

const VisComponent = TimeseriesVisTypes[model.type];
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.

Could you please check, I18nProvider should be already provided here

@stratoula
Copy link
Copy Markdown
Contributor

@dziyanadzeraviankina this works great. Maybe it would make sense to display the gear only when the last value is selected. wdyt?

@wylieconlon do you want to have another look?

@DianaDerevyankina
Copy link
Copy Markdown
Contributor Author

Maybe it would make sense to display the gear only when the last value is selected

nice idea, added a condition for that 👍

@stratoula
Copy link
Copy Markdown
Contributor

Thank you Diana, it works fine 🙂

image

@gchaps do you have any suggestions for the popover text above?
If the toggle is on, the last value grey badge will appear on the visualization and dashboard, otherwise will not. I think I prefer something shorter. Something like:
Title: Last value options
Text: Display last value indicator. (I don't like the word indicator tbh, maybe badge? label?)

image

@wylieconlon
Copy link
Copy Markdown
Contributor

I think this is working very well! I like all the new tweaks. I have comments that shouldn't block merging:

  1. This new indicator is on by default for Last Value visualizations, even ones that I created before this change. This seems good to me, but raising it to everyone's attention.

  2. I found this indicator confusing when using the Markdown visualization, because Markdown gives full access to the data, even when using Last Value mode. I don't think you need to change anything since there is a way to disable this. For example:

Screen Shot 2021-03-26 at 10 58 11 AM

@gchaps
Copy link
Copy Markdown
Contributor

gchaps commented Mar 26, 2021

@stratoula, I discussed the text with @wylieconlon. Here is a suggestion:

Title: Last value options
Text: Show label when using Last value mode

@stratoula
Copy link
Copy Markdown
Contributor

I love it! Thank you both 🙂

Copy link
Copy Markdown
Contributor

@ppisljar ppisljar left a comment

Choose a reason for hiding this comment

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

LGTM

… is empty, create migration script to hide last value label for previously created visualizations and a test for that
@kibanamachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
visTypeTimeseries 485 505 +20

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
visTypeTimeseries 1.6MB 1.6MB +9.5KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
visTypeTimeseries 126.8KB 127.7KB +883.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @dziyanadzeraviankina

Copy link
Copy Markdown
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

I haven't tested it again but it seems fine to me. To wrap up we decided to hide the label for old TSVB visualizations and we applied a new text to the Last value options

@stratoula
Copy link
Copy Markdown
Contributor

@elasticmachine run elasticsearch-ci/docs

@simianhacker simianhacker self-requested a review March 30, 2021 15:22
Copy link
Copy Markdown
Member

@simianhacker simianhacker left a comment

Choose a reason for hiding this comment

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

LGTM

@stratoula stratoula merged commit 78b16fd into elastic:master Mar 30, 2021
stratoula pushed a commit to stratoula/kibana that referenced this pull request Mar 30, 2021
* [TSVB] Show an indicator when using Last Value mode

* Extended some TSVB types, remove unused translations and do some refactoring

* Fix some functional tests and label displaying for Last value

* Fix some functional tests and label displaying for Last value

* Refactor data_time_range_mode_label and change some types

* fix CI

* Refactor timeseries_visualization seriesData

* Remove unused re export

* Replace "href" prop with "onClick" in EuiLink and refactor tooltip content

* Change link to text and add pointer style to it

* FIx import in kibana_framework_adapter

* Remove label for entire time range mode and add an icon for last value mode label

* Add action to show last value label for TSVB embeddables

* Fix TimeseriesVisParams import

* Revert "Add action to show last value label for TSVB embeddables"

This reverts commit 15f16d6.

* Put the "Last value" badge on the top of visualization and add an option to hide it

* Fix failing _tsvb_markdown test and refactor timeseries_visualization

* Move I18nProvider frim timeseries_visualization to timeseries_vis_renderer

* Add condition to hide gear button when entire time range mode is enabled, fix gauge scroll issue

* Change text in the popover, add condition to indicator if series data is empty, create migration script to hide last value label for previously created visualizations and a test for that

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Alexey Antonov <alexwizp@gmail.com>
stratoula added a commit that referenced this pull request Mar 30, 2021
* [TSVB] Show an indicator when using Last Value mode

* Extended some TSVB types, remove unused translations and do some refactoring

* Fix some functional tests and label displaying for Last value

* Fix some functional tests and label displaying for Last value

* Refactor data_time_range_mode_label and change some types

* fix CI

* Refactor timeseries_visualization seriesData

* Remove unused re export

* Replace "href" prop with "onClick" in EuiLink and refactor tooltip content

* Change link to text and add pointer style to it

* FIx import in kibana_framework_adapter

* Remove label for entire time range mode and add an icon for last value mode label

* Add action to show last value label for TSVB embeddables

* Fix TimeseriesVisParams import

* Revert "Add action to show last value label for TSVB embeddables"

This reverts commit 15f16d6.

* Put the "Last value" badge on the top of visualization and add an option to hide it

* Fix failing _tsvb_markdown test and refactor timeseries_visualization

* Move I18nProvider frim timeseries_visualization to timeseries_vis_renderer

* Add condition to hide gear button when entire time range mode is enabled, fix gauge scroll issue

* Change text in the popover, add condition to indicator if series data is empty, create migration script to hide last value label for previously created visualizations and a test for that

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Alexey Antonov <alexwizp@gmail.com>

Co-authored-by: Diana Derevyankina <54894989+DziyanaDzeraviankina@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Alexey Antonov <alexwizp@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:TSVB TSVB (Time Series Visual Builder) release_note:enhancement Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// v7.13.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TSVB] Show an indicator when using Last Value mode