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

[XY axis] Improve expression with explicit params #98897

Merged
merged 15 commits into from
May 18, 2021

Conversation

VladLasitsa
Copy link
Contributor

Closes: #97247

Summary

Right now the vis_type_xy is using a JSON visConfig which is not ideal for other teams to reuse it.
We should remove the JSON blob and use explicit params instead. In this PR I removed visConfig and use all params from visConfig as args in expression function defenition for xy plugin. Also I wrote some new expression function defenition for params which have complex object structure.

@VladLasitsa VladLasitsa requested a review from alexwizp April 30, 2021 10:55
@VladLasitsa
Copy link
Contributor Author

@elasticmachine merge upstream

@VladLasitsa
Copy link
Contributor Author

@elasticmachine merge upstream

@VladLasitsa VladLasitsa requested a review from stratoula May 12, 2021 07:55
@VladLasitsa VladLasitsa self-assigned this May 12, 2021
@VladLasitsa VladLasitsa added Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.14.0 v8.0.0 release_note:skip Skip the PR/issue when compiling release notes labels May 12, 2021
@VladLasitsa VladLasitsa marked this pull request as ready for review May 12, 2021 08:00
@VladLasitsa VladLasitsa requested a review from a team May 12, 2021 08:00
@elasticmachine
Copy link
Contributor

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

@stratoula stratoula added the Feature:XYAxis XY-Axis charts (bar, area, line) label May 13, 2021
@stratoula
Copy link
Contributor

@elasticmachine merge upstream

Copy link
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.

@VladLasitsa this looks pretty good. Just some comments to make our params more understandable

src/plugins/vis_type_xy/public/xy_vis_fn.ts Outdated Show resolved Hide resolved
src/plugins/vis_type_xy/public/xy_vis_fn.ts Outdated Show resolved Hide resolved
src/plugins/vis_type_xy/public/xy_vis_fn.ts Outdated Show resolved Hide resolved
@stratoula
Copy link
Contributor

@nickofthyme do you want to also have a look? As you know this plugin better ❤️

@stratoula stratoula requested a review from nickofthyme May 13, 2021 10:11
@stratoula
Copy link
Contributor

Another thing that concerns me is why the bundle size has been increased by +20.3KB. It seems quite big for this change. Can you look into it?

Copy link
Contributor

@nickofthyme nickofthyme left a comment

Choose a reason for hiding this comment

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

This is a great refactor. I haven't run locally but all the code changes LGTM.

Comment on lines 189 to +216
const visTypeXy = buildExpressionFunction<VisTypeXyExpressionFunctionDefinition>(visName, {
type: vis.type.name as XyVisType,
visConfig: JSON.stringify(visConfig),
chartType: vis.params.type,
addTimeMarker: vis.params.addTimeMarker,
addLegend: vis.params.addLegend,
addTooltip: vis.params.addTooltip,
legendPosition: vis.params.legendPosition,
orderBucketsBySum: vis.params.orderBucketsBySum,
categoryAxes: vis.params.categoryAxes.map(prepareCategoryAxis),
valueAxes: vis.params.valueAxes.map(prepareValueAxis),
seriesParams: vis.params.seriesParams.map(prepareSeriesParam),
labels: prepareLabel(vis.params.labels),
thresholdLine: prepareThresholdLine(vis.params.thresholdLine),
gridCategoryLines: vis.params.grid.categoryLines,
gridValueAxis: vis.params.grid.valueAxis,
radiusRatio: vis.params.radiusRatio,
isVislibVis: vis.params.isVislibVis,
detailedTooltip: vis.params.detailedTooltip,
fittingFunction: vis.params.fittingFunction,
times: vis.params.times.map(prepareTimeMarker),
palette: vis.params.palette.name,
xDimension: dimensions.x ? prepareXYDimension(dimensions.x) : null,
yDimension: dimensions.y.map(prepareXYDimension),
zDimension: dimensions.z?.map(prepareXYDimension),
widthDimension: dimensions.width?.map(prepareXYDimension),
seriesDimension: dimensions.series?.map(prepareXYDimension),
splitRowDimension: dimensions.splitRow?.map(prepareXYDimension),
splitColumnDimension: dimensions.splitColumn?.map(prepareXYDimension),
Copy link
Contributor

Choose a reason for hiding this comment

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

This is great, love the flatter version.

@@ -116,7 +123,7 @@ export interface Dimensions {
y: Dimension[];
z?: Dimension[];
width?: Dimension[];
series?: Dimension | Dimension[];
series?: Dimension[];
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice 👍

@@ -62,15 +171,13 @@ export const toExpressionAst: VisToExpressionAst<VisParams> = async (vis, params
}
}

const visConfig = { ...vis.params };
Copy link
Contributor

Choose a reason for hiding this comment

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

This was to prevent an infinite update loop, particularly with date histogram charts. I think this should be fixed with these changes but could you play around with the date histogram visualization just updating the config and see if it hangs. Thanks!

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 haven't find any problems with date histograms now. I guess you a re right and my PR fixed it.

@VladLasitsa
Copy link
Contributor Author

@elasticmachine merge upstream

@alexwizp
Copy link
Contributor

@elasticmachine merge upstream

@@ -6,52 +6,43 @@
* Side Public License, v 1.
*/

import { $Values } from '@kbn/utility-types';

export const ChartMode = Object.freeze({
Copy link
Contributor

@alexwizp alexwizp May 17, 2021

Choose a reason for hiding this comment

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

@nickofthyme it like an enum. What do you think about replacing this code with a clearer definition?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's fine to change it back I just don't think babel does a great job transpiling them rn. See #53536 (comment)

@alexwizp
Copy link
Contributor

@elasticmachine merge upstream

Copy link
Contributor

@alexwizp alexwizp left a comment

Choose a reason for hiding this comment

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

LGTM! Tested locally

Copy link
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.

Thanx for the changes Vlad, a final small change on one description and it will be fine

Copy link
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.

LGTM, tested it locally and works fine

@VladLasitsa
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
visTypeXy 91 99 +8

Async chunks

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

id before after diff
visTypeXy 111.6KB 111.6KB +20.0B

Page load bundle

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

id before after diff
visTypeXy 43.4KB 62.7KB +19.4KB
Unknown metric groups

References to deprecated APIs

id before after diff
canvas 29 25 -4
crossClusterReplication 8 6 -2
fleet 22 20 -2
globalSearch 4 2 -2
indexManagement 12 7 -5
infra 261 149 -112
lens 67 45 -22
licensing 18 15 -3
maps 286 208 -78
ml 121 115 -6
monitoring 109 56 -53
stackAlerts 101 95 -6
total -295

History

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

cc @VladLasitsa

@timroes
Copy link
Contributor

timroes commented May 18, 2021

@elasticmachine run elasticsearch-ci/docs

@VladLasitsa VladLasitsa merged commit 5c3527d into elastic:master May 18, 2021
VladLasitsa added a commit to VladLasitsa/kibana that referenced this pull request May 18, 2021
* Removed visconfig and using explicit params instead in xy_plugin

* Fix CI

* Fix i18n

* Fix unit test

* Fix some remarks

* move expressions into separate chunk

* fix CI

* Update label.ts

Co-authored-by: Kibana Machine <[email protected]>
Co-authored-by: Alexey Antonov <[email protected]>
VladLasitsa added a commit that referenced this pull request May 18, 2021
* Removed visconfig and using explicit params instead in xy_plugin

* Fix CI

* Fix i18n

* Fix unit test

* Fix some remarks

* move expressions into separate chunk

* fix CI

* Update label.ts

Co-authored-by: Kibana Machine <[email protected]>
Co-authored-by: Alexey Antonov <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
Co-authored-by: Alexey Antonov <[email protected]>
yctercero pushed a commit to yctercero/kibana that referenced this pull request May 25, 2021
* Removed visconfig and using explicit params instead in xy_plugin

* Fix CI

* Fix i18n

* Fix unit test

* Fix some remarks

* move expressions into separate chunk

* fix CI

* Update label.ts

Co-authored-by: Kibana Machine <[email protected]>
Co-authored-by: Alexey Antonov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:XYAxis XY-Axis charts (bar, area, line) release_note:skip Skip the PR/issue when compiling release notes 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.

[XY axis] Improve expression with explicit params
7 participants