-
Notifications
You must be signed in to change notification settings - Fork 88
Feature/flag to stop needle at max for percentage above 100 #40
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
base: master
Are you sure you want to change the base?
Feature/flag to stop needle at max for percentage above 100 #40
Conversation
|
There are some merge conflicts. Could you merge your local branch with the latest master and fix them? |
…p-needle-at-max-for-percentage-above-100 # Conflicts: # package-lock.json # src/lib/GaugeChart/index.js
done ✔️ |
|
@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? |
|
@Martin36 I agree, it could definitely be the default behaviour and not even an optional prop. Should I update the PR with that change? |
|
@eirikaho Sorry for the late reply, but you can do that |
|
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}%`)}
/>; |
added 'stopNeedleAtMax' prop to flag that the needle should stop just above max for percentages above 1.0.
stopNeedleAtMax={true}

stopNeedleAtMax={false}
