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

Agg configs should support formatting options or field formatters #57154

Closed
wylieconlon opened this issue Feb 7, 2020 · 9 comments
Closed

Agg configs should support formatting options or field formatters #57154

wylieconlon opened this issue Feb 7, 2020 · 9 comments
Labels
Feature:FieldFormatters Feature:Visualizations Generic visualization features (in case no more specific feature label is available)

Comments

@wylieconlon
Copy link
Contributor

Agg configs already have the ability to have formatting based on their configuration, but this isn't exposed in a way that can be used programmatically or in any UI. This prevents our users from setting per-visualization formatters. We are working around this limitation in Lens by using Expression datatable formatting hints with a format selector that uses a new function to change datatable.formatHint to whatever we want it to be.

This level of control over formatting seems like something that should be brought into agg configs, potentially as another param. The basic requirement is that a format parameter can be set for a specific aggregation in the esaggs expression function, which would be used by visLib and Lens.

cc @ppisljar

@wylieconlon wylieconlon added Feature:Visualizations Generic visualization features (in case no more specific feature label is available) Team:AppArch Feature:FieldFormatters labels Feb 7, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch (Team:AppArch)

@ppisljar
Copy link
Member

ppisljar commented Feb 10, 2020

per visualization formatting should be applied to the visualization function rather than aggConfigs which is used in the data fetching. This way its possible to configure formatting for visualizations no matter where they get their data from. kibana charts already have this option thru setting format on the dimension parameters (like metric or buckets)

For example the tag_cloud function has a metric parameter which is of the vis_dimension type.

vis_dimension has an

  • accessor property (which tells it which column in the datatable to use),
  • format (custom formatter than can be applied)
  • ``formatOptions` parameters for the formatter

to get the serialized version of fieldFormat you can use the createFormat utility currently in ui/visualize/loader/pipeline_helpers. and to get from serialized version to field format instance you can use getFormat utility in that same folder.

@wylieconlon
Copy link
Contributor Author

@ppisljar Agg configs is already using index pattern information to find the formatter, and is already passing the formatter information to the visualization. It seems like making this the responsibility of the visualization will introduce even more inconsistency, as there are more visualizations than there are data sources.

@ppisljar
Copy link
Member

ppisljar commented Feb 10, 2020

visualization is not provided aggconfig information (at least not for visualize visualizations) as that is query specific information, and actual visualizations could receive its data from other sources (for example demodata function), but rather figures out what formater to use based on the information passed on the dimension
tag_cloud metric={vis_dimension accessor=2 format='number'}

visualize editor (or rather visualize embeddable) makes sure that the format is set correctly according to the information provided off index pattern (that currently happens in buildPipeline utility function) , but that also gives it the ability to customize/override specific formaters on per-visualization basis.

@wylieconlon
Copy link
Contributor Author

I think your comment is explaining how it currently works, but what is your proposal for doing per-visualization formatting?

@ppisljar
Copy link
Member

i suggest that in case visualizations want to override the format, they pass custom format information to vis_dimension function. i think it would also be nice to change vis_dimension function so that the format parameter is optional, and if it's not provided meta information provided on table columns is used instead (if available). this way build_pipeline function doesn't need to add it to the expression (unless we are working with visualization that overrided the format)

@ppisljar
Copy link
Member

ppisljar commented Mar 9, 2020

closing this for now as lens is continuing with alternate approach

@ppisljar ppisljar closed this as completed Mar 9, 2020
@wylieconlon
Copy link
Contributor Author

@ppisljar this is not about Lens, this is about the default visualize apps

@wylieconlon wylieconlon reopened this Mar 9, 2020
@ppisljar
Copy link
Member

there even more, we will not be providing formatting overrides on the aggconfigs, they can already be provided on each visualize chart function (or if in some its missing it can be added to those)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:FieldFormatters Feature:Visualizations Generic visualization features (in case no more specific feature label is available)
Projects
None yet
Development

No branches or pull requests

3 participants