-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Conversation
@elasticmachine merge upstream |
@elasticmachine merge upstream |
Pinging @elastic/kibana-app (Team:KibanaApp) |
@elasticmachine merge upstream |
There was a problem hiding this 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/expression_functions/category_axis.ts
Outdated
Show resolved
Hide resolved
src/plugins/vis_type_xy/public/expression_functions/category_axis.ts
Outdated
Show resolved
Hide resolved
src/plugins/vis_type_xy/public/expression_functions/category_axis.ts
Outdated
Show resolved
Hide resolved
src/plugins/vis_type_xy/public/expression_functions/series_param.ts
Outdated
Show resolved
Hide resolved
src/plugins/vis_type_xy/public/expression_functions/vis_scale.ts
Outdated
Show resolved
Hide resolved
src/plugins/vis_type_xy/public/expression_functions/vis_scale.ts
Outdated
Show resolved
Hide resolved
@nickofthyme do you want to also have a look? As you know this plugin better ❤️ |
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? |
There was a problem hiding this 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.
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), |
There was a problem hiding this comment.
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[]; |
There was a problem hiding this comment.
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 }; |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
@elasticmachine merge upstream |
@elasticmachine merge upstream |
@@ -6,52 +6,43 @@ | |||
* Side Public License, v 1. | |||
*/ | |||
|
|||
import { $Values } from '@kbn/utility-types'; | |||
|
|||
export const ChartMode = Object.freeze({ |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Tested locally
There was a problem hiding this 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
There was a problem hiding this 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
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Module Count
Async chunks
Page load bundle
Unknown metric groupsReferences to deprecated APIs
History
To update your PR or re-run it, just comment with: cc @VladLasitsa |
@elasticmachine run elasticsearch-ci/docs |
* 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]>
* 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]>
* 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]>
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.