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

Field.display:DisplayProcessor ignored by displayProcessor.ts or the documentation of Field is wrong. (code or doc bug). #37237

Closed
JoeNemo opened this issue Jul 27, 2021 · 4 comments

Comments

@JoeNemo
Copy link

JoeNemo commented Jul 27, 2021

I am defining a DataSource and I wanted to build a custom formatting of some values of some fields. I read the documentation at https://grafana.com/docs/grafana/latest/packages_api/data/field/ is implying that if a DisplayProcessor is placed in the optional display property of Field, that it will be used to convert a raw value to a DisplayValue. However, I find no path in the code from the Table UI Panel component that actually uses the function that is in field.display. It seems that unconditional that a function returned from getDisplayProcessor in packages/data/src/field/displayProcessor.ts is used as the displayProcessor. The field's display property is not referenced. I apologize if I have misunderstood the intention of the design.

Thanks,
Joe

@zuchka zuchka added the bot/question Bot will close with standard question comment and add label type/question label Jul 27, 2021
@grafanabot
Copy link
Contributor

Please ask your question on community.grafana.com/. To avoid having your issue closed in the future, please read our CONTRIBUTING guidelines.

Happy graphing!

@grafanabot grafanabot removed the bot/question Bot will close with standard question comment and add label type/question label Jul 27, 2021
@JoeNemo
Copy link
Author

JoeNemo commented Jul 27, 2021

It's sort of weird that this is labelled this as a question, I was trying to be polite. I am pretty sure that this is either a code bug or incorrect documentation. That is, if this field is not used, then the doc should say so.

This is not a Grafana user question, but a plugin development question.

Matt, if you still are seeing this, I cannot see a place on community.grafana.com where plugin developers talk. I may have missed something.

@JoeNemo JoeNemo changed the title Is Field.display:DisplayProcessor really used? Field.display:DisplayProcessor ignored by displayProcessor.ts or the documentation of Field is wrong. (code or doc bug). Jul 27, 2021
@torkelo
Copy link
Member

torkelo commented Jul 27, 2021

It is used by almost all panels, and is set in the data frame processing in applyFieldOverrides , so returning this from the data source might not work / is not supported.

@JoeNemo
Copy link
Author

JoeNemo commented Jul 27, 2021

So is the is disposition of this issue that it is a doc bug then? If it is indeed optional that a Panel component may or may not use it DisplayProcessors, that should be documented. Or should there be a bug on Table that it does not follow the correct pattern. Can I can contribute a fix?

EDIT: I just looked again at applyFieldOverrides(), and I don't see Field.display being referenced or used. I see it being set unconditionally to the returned value (a function) of getDisplayProcessor() which never uses Field.display. I think having a datasource being able to provide a display processor is a great feature, and the documetation at https://grafana.com/docs/grafana/latest/packages_api/data/field/ implies that this should work. That is, DataSources define fields, and fields have DisplayProcessors, so it really looks like it's supported. And since you say it's not supported, shouldn't the doc just say "Do not store anything here in Field.display, it's an internal member that is built that is wholly owned by FieldOverrides.ts".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants