Progress

antd Progress进度圆环图 https://ant.design/components/progress-cn

  1. import React, { memo } from 'react'
  2. import PropTypes from 'prop-types'
  3. import { Progress } from 'antd'
  4. CircleRing.propTypes = {
  5. value: PropTypes.number,
  6. color: PropTypes.string,
  7. }
  8. /**
  9. * @param { value, color } props
  10. * @description 圆环图参数
  11. */
  12. function CircleRing(props) {
  13. const { value, color } = props
  14. return (
  15. <Progress
  16. strokeLinecap="square"
  17. type="circle"
  18. width={80}
  19. strokeWidth={16}
  20. showInfo={false}
  21. percent={value}
  22. strokeColor={color}
  23. />
  24. )
  25. }
  26. export default memo(CircleRing)

progress-se.jpg

Progress-circle.jpg

react-circle

在线demo https://zzarcon.github.io/react-circle
github 文档 https://github.com/zzarcon/react-circle

  1. yarn add react-circle
  2. npm install react-circle

使用

  1. import Circle from 'react-circle'
  2. <Circle
  3. animate={true}
  4. animationDuration="1s"
  5. responsive={false}
  6. size="100"
  7. lineWidth="40"
  8. progress="36"
  9. progressColor="rgb(76, 154, 255)"
  10. bgColor="#ecedf0"
  11. textColor="#6b778c"
  12. percentSpacing={10}
  13. roundedStroke={false}
  14. showPercentage={true}
  15. showPercentageSymbol={true}
  16. />

react-circle参数说明

  1. // All avaliable props for customization(illustrated by default values):
  2. // Details are ordered as: `<Type>: <Description>`
  3. <Circle
  4. animate={true} // Boolean: Animated/Static progress
  5. animationDuration="1s" // String: Length of animation
  6. responsive={false} // Boolean: Make SVG adapt to parent size
  7. size="100" // String: Defines the size of the circle.
  8. lineWidth="25" // String: Defines the thickness of the circle's stroke.
  9. progress="0" // String: Update to change the progress and percentage.
  10. progressColor="rgb(76, 154, 255)" // String: Color of "progress" portion of circle.
  11. bgColor="#ecedf0" // String: Color of "empty" portion of circle.
  12. textColor="#6b778c" // String: Color of percentage text color.
  13. textStyle={{
  14. font: 'bold 4rem Helvetica, Arial, sans-serif' // CSSProperties: Custom styling for percentage.
  15. }}
  16. percentSpacing={10} // Number: Adjust spacing of "%" symbol and number.
  17. roundedStroke={false} // Boolean: Rounded/Flat line ends
  18. showPercentage={true} // Boolean: Show/hide percentage.
  19. showPercentageSymbol={true} // Boolean: Show/hide only the "%" symbol.
  20. />

svg边缘被剪切bug

设置 svg的 overflow: visible
svg.jpg

  1. svg {
  2. overflow: visible;
  3. }
  4. /* 默认的样式 */
  5. svg:not(:root) {
  6. overflow: hidden;
  7. }

SVG溢出

SVG视图溢出:隐藏/裁剪
让viewBox外的任何东西都不可见