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

Dashboard style progress bar #49

Closed
nbruno opened this issue Mar 15, 2018 · 10 comments
Closed

Dashboard style progress bar #49

nbruno opened this issue Mar 15, 2018 · 10 comments

Comments

@nbruno
Copy link

nbruno commented Mar 15, 2018

Is there any way to customize the display of the progress bar to display like a "dashboard" progress indicator, similar to the dashboard progress bar from ant design https://ant.design/components/progress/

screen shot 2018-03-15 at 7 24 06 pm

@kevinsqi
Copy link
Owner

There isn't right now. It seems reasonable to add a prop to configure the proportion of the diameter the path/trail takes up, and combine that with path/trail rotation to achieve this.

I'll take a look at doing that at some point, but not sure exactly when. Thanks for the suggestion!

@jeremywho
Copy link
Contributor

I added support for this here:
https://github.com/jeremywho/react-circular-progressbar/pull/1

I'm not submitting a PR at the moment as counterClockwise is broken.

If you have a suggestion for getting that to work, let me know, I'll update and add unit tests and PR.

@kevinsqi
Copy link
Owner

@jeremywho that looks neat - sorry I haven't had time to dig in yet.

@lchandramohan
Copy link

any update on this?

@kevinsqi
Copy link
Owner

Not yet. I'd like to take a pass at it soon, though.

@kevinsqi
Copy link
Owner

kevinsqi commented Apr 29, 2019

This is now possible in v1.2.0 with the circleRatio prop and CSS rotation, based on @jeremywho's helpful initial PR which I fleshed out in #80 (thanks jeremy!)

To do this:

Screen Shot 2019-04-28 at 9 21 08 PM

You'd write:

          <CircularProgressbar
            percentage={66}
            text={`${66}%`}
            circleRatio={0.75}  /* Make the circle only 0.75 of the full diameter */
            styles={{
              trail: {
                strokeLinecap: 'butt',
                transform: 'rotate(-135deg)',
                transformOrigin: 'center center',
              },
              path: {
                strokeLinecap: 'butt',
                transform: 'rotate(-135deg)',
                transformOrigin: 'center center',
              },
            }}
          />

Right now it's slightly cumbersome because you have to adjust transform: rotate whenever you change circleRatio. I'm planning to add some abstractions to make this easier in the future.

cc @nbruno @jeremywho @lchandramohan

@kevinsqi
Copy link
Owner

kevinsqi commented Jun 5, 2019

The syntax is now somewhat nicer in v2.0.0 with buildStyles, e.g.:

const value = 66;

<CircularProgressbar
  value={value}
  text={`${value}%`}
  circleRatio={0.75}
  styles={buildStyles({
    rotation: 1 / 2 + 1 / 8,
    strokeLinecap: "butt",
    trailColor: "#eee"
  })}
/>

Repository owner deleted a comment from aaron170 Jun 19, 2019
@garrettg123
Copy link

Follow-up question: how would one adjust the height of the SVG based on this circleRatio so there's no empty space at the bottom?

      <CircularProgressbar
        value={fill}
        circleRatio={0.5}
        styles={buildStyles({
          rotation: 3 / 4,
          strokeLinecap: 'butt',
          trailColor: COLOR.PURPLE,
          textColor: COLOR.WHITE,
        })}
      />

I've tried margin-bottom: -50% but that's not working.

@HoussemDjeghri
Copy link

@garrett-gottlieb you can add a parent div on top of the CircularProgressbar that has the height you want and with the property overflow:clip to cut the unwanted space.
progressContainer:{ width: 200, height:150, overflow: "clip" }

@ViniTeider
Copy link

@HoussemDjeghri this doesnt work since the progress bar resizes to fit the div, did any one find another solution?

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

No branches or pull requests

7 participants