Skip to content

Feature/flag to stop needle at max for percentage above 100#40

Open
eirikaho wants to merge 9 commits into
Martin36:masterfrom
eirikaho:feature/flag-to-stop-needle-at-max-for-percentage-above-100
Open

Feature/flag to stop needle at max for percentage above 100#40
eirikaho wants to merge 9 commits into
Martin36:masterfrom
eirikaho:feature/flag-to-stop-needle-at-max-for-percentage-above-100

Conversation

@eirikaho
Copy link
Copy Markdown

added 'stopNeedleAtMax' prop to flag that the needle should stop just above max for percentages above 1.0.

stopNeedleAtMax={true}
image

stopNeedleAtMax={false}
image

@Martin36
Copy link
Copy Markdown
Owner

There are some merge conflicts. Could you merge your local branch with the latest master and fix them?

eah added 3 commits April 15, 2020 08:37
…p-needle-at-max-for-percentage-above-100

# Conflicts:
#	package-lock.json
#	src/lib/GaugeChart/index.js
@eirikaho
Copy link
Copy Markdown
Author

There are some merge conflicts. Could you merge your local branch with the latest master and fix them?

done ✔️

@Martin36
Copy link
Copy Markdown
Owner

@eirikaho It looks great. I was just thinking, maybe the stop at 100% prop should be set default to true? For me it seems like the most logical behavior for the chart. Or it could even be something that is not a optional thing. What do you think?

@eirikaho
Copy link
Copy Markdown
Author

@Martin36 I agree, it could definitely be the default behaviour and not even an optional prop. Should I update the PR with that change?

@Martin36
Copy link
Copy Markdown
Owner

Martin36 commented Nov 5, 2020

@eirikaho Sorry for the late reply, but you can do that

@rebase
Copy link
Copy Markdown

rebase commented Apr 4, 2023

I solved this problem in the following way.

const newPercent = Math.min(percent, 1);

<GaugeChart
  percent={newPercent}
  formatTextValue={value => (percent > 1 ? `${(percent * 100).toFixed(0)}%` : `${value}%`)}
/>;

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants