-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
adds metric_vis_renderer #57694
adds metric_vis_renderer #57694
Conversation
a02c601
to
9556e8d
Compare
Pinging @elastic/kibana-app-arch (Team:AppArch) |
9556e8d
to
b260b95
Compare
Finally got around to looking through this....
I think these ideas make the most sense for the unanswered items. One thing I'm not sure about is how/if to deal with non-React scenarios. We could provide helpers or HOCs to decorate React components, but that doesn't help folks using other rendering technologies. I wonder if there'd be a way to consolidate all of this into some sort of visualizationRenderWrapper(
domNode: HTMLElement;
config: { visData, visConfig };
renderFn: (domNode) => render(<MyApp />, domNode);
); Then in
This is mostly a brain dump - I haven't thought too much about the details on this, so there's likely something I'm overlooking. Edit: Come to think of it, I'm not sure the wrapper idea works entirely. Because we don't always know the shape of the data that a given visualization function provides to a renderer. hmm |
@elasticmachine merge upstream |
src/plugins/vis_type_metric/public/components/metric_vis_component.tsx
Outdated
Show resolved
Hide resolved
745b52d
to
035cf70
Compare
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.
Wondering if as a part of this we should also be adding a toExpression
function on the metric vis and removing the metric vis function from build_pipeline
? That would help validate that this works and demonstrate the whole workflow for creating a vis.
Edit: Also I just realized that build_pipeline
is calling toExpression
whereas the vis object has toAST
defined... I'm guessing that's a bug we hadn't noticed yet?
@@ -54,7 +54,7 @@ export class BaseVisType { | |||
stage: 'experimental' | 'beta' | 'production'; | |||
isExperimental: boolean; | |||
options: Record<string, any>; | |||
visualization: VisualizationControllerConstructor; | |||
visualization: VisualizationControllerConstructor | undefined; |
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.
nit: Maybe you could do visualization?: VisualizationControllerConstructor;
instead of adding undefined
?
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.
yeah i tried that, but it gets into some ts errors so i went with this
src/plugins/visualizations/public/components/visualization_container.tsx
Outdated
Show resolved
Hide resolved
@elasticmachine merge upstream |
941ccc6
to
fc9b5a0
Compare
@elasticmachine merge upstream |
1523ca0
to
acf2ed1
Compare
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 LGTM now, added a few final comments which are mostly nits.
// request handler | ||
if (vis.type.requestHandler === 'courier') { | ||
pipeline += `esaggs | ||
if (vis.type.toAST) { |
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 always forget what naming convention we decided on for these. toAST
? toExpression
? toExpressionAst
?
I think it's all over the place now, but might be good to choose something we are okay with applying everywhere before all of the vis renderers get written.
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 agree, you are using toExpressionAst
?
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.
aggs are using toExpressionAst
} | ||
|
||
// @ts-ignore | ||
const metricVis = buildExpressionFunction<MetricVisExpressionFunctionDefinition>('metricVis', { |
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.
curious, what does TS not like about the usage with buildExpressionFunction
here? wondering if it's something fixable in the function builder
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.
we need to cleanup the types i think, we need a separation between argumnent types (arguments user is providing) and argument types (arguments as received inside fn function .... with defaults injected) which we currently don't have.
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.
ah, yeah so right now this is a tradeoff between losing type safety when using the expression builder, or having a worse DX when writing the expression function.
you wouldn't need to ignore this if the typings for metric_vis_fn
args reflected the actual function definition configuration (that is, args which are optional are typed as optional, args which are required are typed as required).
in that case this would work, but it would mean inside the function implementation itself you would need to assert that you know something exists:
colorRange: args.colorRange!,
percentageMode: args.percentageMode!,
...etc
i think there are a couple ways to solve this which we could discuss -- for now i've pushed an update to this PR to switch out the ts-ignore
with ts-expect-error
so that we remember to remove it later when we fix this
679240c
to
f907fb5
Compare
f907fb5
to
b22e91a
Compare
ea762e1
to
3cc385f
Compare
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. We should sort out the issue with expression definition typings and how they are used in the function builder, but can discuss that separately as it's orthogonal to this effort.
@elasticmachine merge upstream |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
💚 Build SucceededBuild metrics@kbn/optimizer bundle module count
page load bundle size
History
To update your PR or re-run it, just comment with: |
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.
Tested locally on Chrome, for a quick sanity check of the functionality of metric vis.
Kibana App code LGTM!
Summary
adds renderer for
metric_vis
(so it doesn't need to use visualization renderer anymore)no-result
messagetoAST()
function to produce expression out of vis configurationChecklist
Delete any items that are not applicable to this PR.
For maintainers