Skip to content

[FEATURE] - DataTable Formatters #13685

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

Merged
merged 18 commits into from
Feb 16, 2024
Merged

Conversation

thomktz
Copy link
Member

@thomktz thomktz commented Feb 9, 2024

Still have to discuss whether this approach is worth finishing, and then make the other Formatters compatible.

Copy link

codecov bot commented Feb 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (afdab54) 92.59% compared to head (76184c7) 92.58%.
Report is 12 commits behind head on branch-3.4.

Additional details and impacted files
@@              Coverage Diff               @@
##           branch-3.4   #13685      +/-   ##
==============================================
- Coverage       92.59%   92.58%   -0.01%     
==============================================
  Files             323      325       +2     
  Lines           20575    20728     +153     
==============================================
+ Hits            19051    19191     +140     
- Misses           1524     1537      +13     

@thomktz thomktz requested a review from bryevdv February 11, 2024 00:26
@bryevdv bryevdv added this to the 3.4 milestone Feb 11, 2024
@bryevdv bryevdv requested a review from mattpap February 11, 2024 02:41
@bryevdv
Copy link
Member

bryevdv commented Feb 11, 2024

@thomktz I've left a few comments, I've also added @mattpap for review since he is most heavily involved in BokehJS development these days. He may have some suggestions and guidance for adding other kinds of tests, or details of the implementation.

Some other things that might also be nice, depending on your availability to devote more time:

  • apply this new feature to some of the existing examples that use data tables, especially any already in the gallery
  • find somewhere in the user guide to make mention of this capability cc @tcmetzger for thoughts

We can make issues for follow-on if you don't have bandwidth for these.

Lastly @thomktz would you like to be added to @bokeh/dev ? This is really a terrific first PR for diving in to BokehJS, and certainly reason to add you in case you'd are able to continue being involved.

This is going to be a great feature to show off in a release blog!

@thomktz
Copy link
Member Author

thomktz commented Feb 11, 2024

I do have some time to make thorough examples, docs and tests for this, with guidance.
Thanks @bryevdv, I'd love to join :) Mostly to continue working on tables, for now

Regarding examples, I have modified these two:

integration/widgets/data_table_customization.py old/new
image

interaction/tools/point_draw.py old/new
image

resolvedFontStyle = font_style.value
} else if (isField(font_style)) {
resolvedFontStyle = _dataContext[font_style.field]
}
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 unfortunate, because this should be deferred to vectorized properties to figure out how to resolve this. Especially to handle ndarrays properly, among other issues. Having access to the data source, we could write something like this:

this.properties.font_style.uniform(data_source).get(index)

though this would need to be precomputed, perhaps as some kind of virtual column in table's data provider.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will probably need guidance on this - not sure where/when to precompute. Are we doing something similar somewhere else in the code I can use for inspiration ?

Copy link
Member

Choose a reason for hiding this comment

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

@mattpap is this something we could merge as-is for now with a follow-up issue to improve later?

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 definitely not ideal and compiles only because it's mostly dynamically typed code, but given the proper solution is non-trivial and that this isn't critical code path in bokehjs, then yes we can proceed with this and improve later.

@mattpap mattpap self-requested a review February 15, 2024 12:42
@thomktz thomktz requested review from mosc9575 and bryevdv February 15, 2024 20:08
@bryevdv
Copy link
Member

bryevdv commented Feb 15, 2024

@thomktz this LGTM but let's wait for @mattpap to chime in about the one remaining question (i.e. change here with guidance, or make an issue for follow-up later)

} else if (isField(background_color)) {
if (background_color.transform != null && background_color.transform instanceof ColorMapper) {
const rgbaArray = background_color.transform.rgba_mapper.v_compute([_dataContext[background_color.field]])
const [r, g, b, a] = rgbaArray
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 a bit confusing at the first glance, but given that v_compute returns a flat array (technically an ndarray), then this is indeed correct. Sadly there is no scalar variant in ColorMapper, so we will have to keep this as-is.

Copy link
Contributor

@mattpap mattpap left a comment

Choose a reason for hiding this comment

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

Not ideal, but it works and we can improve this later. Please address the remaining comments, especially about missing color2css().

@mattpap mattpap merged commit a9b4d0f into bokeh:branch-3.4 Feb 16, 2024
@bryevdv
Copy link
Member

bryevdv commented Feb 16, 2024

Thanks @thomktz ! 🎉

Chiemezuo pushed a commit to Chiemezuo/bokeh that referenced this pull request Aug 27, 2024
* Revamp StringFormatter

* Remove dev script

* fix examples

* isort

* No need for 'normal' style

* Use existing Specs

* Working colormaps

* Increase size from 350 to 450

* Ruff & isort

* Update import path for ColorMapper in cell_formatters.ts and adjust size limit for bokeh-tables.min.js

* point_draw and data_table_customization examples revamp

* isort

* Add luminance, use isExpr

* ESLint

* Add test for luminance calculation in RGB class

* Update luminance test precision

* Remove extra variables

* PR comments
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] - DataTable - Conditional Formatting
4 participants