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

[TSVB] Filter by clicking on the timeseries chart #97426

Merged
merged 20 commits into from
May 12, 2021

Conversation

stratoula
Copy link
Contributor

@stratoula stratoula commented Apr 19, 2021

Summary

Closes #83892

Adds support to create filters by clicking on a TSVB timeseries chart when is embedded on a dashboard. When the user edits/creates the visualization and clicks the chart, no filter is applied as the filter bar is not rendered.

As a bonus, the URL and dashboard drilldowns for click events are now supported 🎉

Filter by click on a dashboard:
image

Dasboard drilldowns - click event:
image

Checklist

Delete any items that are not applicable to this PR.

@stratoula stratoula changed the title Tsvb click filter [TSVB] Filter by clicking on the timeseries chart Apr 19, 2021
@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@stratoula stratoula added the release_note:feature Makes this part of the condensed release notes label May 10, 2021
@stratoula stratoula added enhancement New value added to drive a business result release_note:enhancement Feature:TSVB TSVB (Time Series Visual Builder) v7.14.0 v8.0.0 and removed release_note:feature Makes this part of the condensed release notes enhancement New value added to drive a business result labels May 10, 2021
@stratoula stratoula marked this pull request as ready for review May 10, 2021 11:58
@stratoula stratoula requested a review from a team May 10, 2021 11:58
@stratoula stratoula added the Team:Visualizations Visualization editors, elastic-charts and infrastructure label May 10, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

Found some nits but overall it's working great

id,
name: layer.metrics[0].field || seriesPerLayer[0].splitByLabel,
isMetric: true,
type: layer.metrics[0].type,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain why this is necessary? As there can be multiple metrics and the first one might not even be used, I'm not sure whether it would work in all cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes you are right, I changed it to the latest metric in the list. If I don't miss anything this is always the active one per layer on TSVB.
eb75702

const table = tables[termArray[0]];

const layer = model.series.filter(({ id }) => id === termArray[0]);
let splitLabel = termArray.length > 1 ? termArray[1] : undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Can you extract termArray.length > 1 into a constant like hasSplit or something similar? I tripped over this a few times.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it to const [layerId, splitLabel] = specId.split(':');
and used the splitLabel instead. Are you ok with it?

eb75702

}

export const addMetaToColumns = (
columns: TSVBColumns[],
indexPattern: IndexPattern,
metricsType: string
indexPattern: IndexPattern
): DatatableColumn[] => {
return columns.map((column) => {
const field = indexPattern.getFieldByName(column.name);
const type = (field?.spec.type as DatatableColumnType) || 'number';
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure whether it matters, but this isn't correct for filters - it will assume type as number because there is no field in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@flash1293 this is now the case on viz, here is the example of the meta on a filters column (taken by xy axis)
image

type === number

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, guess we should fix this on esaggs side as well. Anyway, for consistency reasons it makes sense to keep it for now 👍

};
if (column.type === BUCKET_TYPES.FILTERS && column.params) {
const filters = column.params.map((col) => ({
input: col.filter,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think if you add label: col.label in here, it will pick it up as custom label for the filter pill (this is what happens for Lens/Visualize as well)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are absolutely right
image

Fixed eb75702

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
visTypeTimeseries 503 504 +1

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.7MB 1.7MB +2.9KB
visualizations 101.1KB 101.2KB +92.0B
total +3.0KB

Page load bundle

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

id before after diff
visTypeTimeseries 27.4KB 27.5KB +82.0B
Unknown metric groups

References to deprecated APIs

id before after diff
globalSearch 4 2 -2
indexManagement 12 7 -5
infra 5 3 -2
licensing 18 15 -3
monitoring 109 56 -53
total -65

History

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

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

Tested and works as expected - LGTM

@stratoula stratoula merged commit a900110 into elastic:master May 12, 2021
stratoula added a commit to stratoula/kibana that referenced this pull request May 12, 2021
* WIP TSVB filter by click

* Disable filter click when showBar is set to false

* Exclude metric columns as they are not filtered

* Allow filters group by filter click event

* Fix CI and unit tests

* Add some comments

* Move to separate function for easier testing

* Add more unit tests

* Add a functional test

* Improve types

* Fix bug with group by filters and user applies custom labels

* fix time filter bug

* Address PR comments

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
stratoula added a commit that referenced this pull request May 12, 2021
* WIP TSVB filter by click

* Disable filter click when showBar is set to false

* Exclude metric columns as they are not filtered

* Allow filters group by filter click event

* Fix CI and unit tests

* Add some comments

* Move to separate function for easier testing

* Add more unit tests

* Add a functional test

* Improve types

* Fix bug with group by filters and user applies custom labels

* fix time filter bug

* Address PR comments

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

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.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 Visualization editors, elastic-charts and infrastructure v7.14.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to add a dashboard filter by clicking a TSVB dataset
4 participants