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

Support decimal values in table progress cell type #824

Closed
vopani opened this issue May 19, 2021 · 6 comments · Fixed by #2329 · May be fixed by #2226
Closed

Support decimal values in table progress cell type #824

vopani opened this issue May 19, 2021 · 6 comments · Fixed by #2329 · May be fixed by #2226
Labels
feature Feature request good first issue Contributions welcome! ui Related to UI

Comments

@vopani
Copy link
Contributor

vopani commented May 19, 2021

Is your feature request related to a problem? Please describe

I am using a ui.progress_table_cell_type to show some statistics in a table that has need for displaying decimal values.

Describe the solution you'd like

Support for showing additional decimals instead of rounding to an integer.
Or
Support some other cell type that is suitable to decimal stats.

Comments

It should be optional / configurable of course, in most other cases I think rounding works great.

@vopani vopani added the feature Feature request label May 19, 2021
@mturoci mturoci added the ui Related to UI label May 19, 2021
@mturoci
Copy link
Collaborator

mturoci commented May 19, 2021

Thanks for the issue @vopani. Just to clarify, do you need to to show also the progress arc or just a standalone value?

@vopani
Copy link
Contributor Author

vopani commented May 19, 2021

The progress arc looks very attractive in a table and hence I've been using that.
If it's just a standalone value I could just use a numeric column, right?

But, if there could be some 'other' cell_type that could be useful for decimal values then that would be good but maybe the easier solution now is to allow decimals in the value with the arc if that's feasible.

@mturoci
Copy link
Collaborator

mturoci commented May 19, 2021

If it's just a standalone value I could just use a numeric column, right?
yes, exactly

Theoretically, there is a bit of space for 2 decimal places
image
vs
image

@lo5 @shanaka-rajitha wdyt? Should we add decimals attr into existing progress_cell_type or create a new cell type?

@mturoci
Copy link
Collaborator

mturoci commented Sep 13, 2023

Let's go with updating the existing progress_cell_type.

@mturoci mturoci added the good first issue Contributions welcome! label Sep 13, 2023
@arshar2411
Copy link

Hi, can I work on this issue?

@dbranley
Copy link
Contributor

Hello Wave,

I have a solution for this issue to support decimal values in table progress cell type.

As explained in the issue, the table progress cell currently rounds values to whole numbers when diplaying them as a percentage. With this change, the percentage will now render with up to 2 decimal places. This is accomplished by using toFixed(2) and parseFloat() together to ensure data is rounded properly and then trailing zeros are removed. The code change in ui/src/progress_table_cell_type.tsx looks like this:

<div className={css.percent}>{`${Number.parseFloat((progress * 100).toFixed(2))}%`}</div>

Here is a partial screen shot of the Table example where you can see the progress data now being displayed with up to 2 decimal places:

output_example_issue_824

There is a new test case in progress_table_cell_type.test.tsx. The test rerenders the XProgressTableCellType component in a loop to make sure that the component is rendering the following input decimal values correctly:

  progressValues = [
    {input: 0.88, output: '88%'},
    {input: 0.888, output: '88.8%'},
    {input: 0.8888, output: '88.88%'},
    {input: 0.88888, output: '88.89%'},
    {input: 0.88899, output: '88.9%'},
    {input: 0.88999, output: '89%'},]

I have a branch in my fork of the project and will be submitting a PR later today. Let me know if this looks ok. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request good first issue Contributions welcome! ui Related to UI
Projects
None yet
4 participants