[TSVB] Show an indicator when using Last Value mode#91977
[TSVB] Show an indicator when using Last Value mode#91977stratoula merged 30 commits intoelastic:masterfrom
Conversation
| const interval = convertIntervalIntoUnit(this.state.panelInterval, false); | ||
|
|
||
| return interval ? `${interval.unitValue}${interval.unitString}` : null; | ||
| return [ |
There was a problem hiding this comment.
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
| import { TIME_RANGE_DATA_MODES } from '../../../common/timerange_data_modes'; | ||
|
|
||
| const lastValueFormattedMessage = ( | ||
| <FormattedMessage |
There was a problem hiding this comment.
use i18n.translate for non-JSX translations
| ); | ||
|
|
||
| interface DataTimeRangeModeLabelProps { | ||
| seriesData: Array<Array<number | null>>; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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`, |
There was a problem hiding this comment.
please replace 'table' to PANEL_TYPES.TABLE
| export const isAutoInterval = (interval: string) => !interval || interval === AUTO_INTERVAL; | ||
|
|
||
| interface ValidationResult { | ||
| errorMessage: string; |
There was a problem hiding this comment.
looks like errorMessage should be optional
|
@elasticmachine merge upstream |
| modelInterval, | ||
| modelTimeRangeMode, | ||
| }: DataTimeRangeModeLabelProps) => { | ||
| const hasShowPanelIntervalValue = () => |
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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>; |
There was a problem hiding this comment.
could you please explain why it wass changed?
There was a problem hiding this comment.
@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

|
@VladLasitsa @sulemanof please have a look |
| return false; | ||
| }, | ||
| execute: async () => {}, | ||
| }); |
There was a problem hiding this comment.
@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
There was a problem hiding this comment.
i am missing some context, what is this supposed to do ? action without execute ? or is this work in progress ?
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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]; | |||
There was a problem hiding this comment.
Could you please check, I18nProvider should be already provided here
|
@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? |
…led, fix gauge scroll issue
nice idea, added a condition for that 👍 |
|
Thank you Diana, it works fine 🙂 @gchaps do you have any suggestions for the popover text above? |
|
I think this is working very well! I like all the new tweaks. I have comments that shouldn't block merging:
|
|
@stratoula, I discussed the text with @wylieconlon. Here is a suggestion: Title: Last value options |
|
I love it! Thank you both 🙂 |
… is empty, create migration script to hide last value label for previously created visualizations and a test for that
💚 Build SucceededMetrics [docs]Module Count
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
stratoula
left a comment
There was a problem hiding this comment.
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
|
@elasticmachine run elasticsearch-ci/docs |
* [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>
* [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>




Closes #90248
Summary
Put "Last value" badge to all TSVB panel types except timeseries
Added a tooltip with last bucket date and interval information (was moved here from the editor)
Checklist
For maintainers