Progress 进度条

基本用法

  1. {
  2. "type": "page",
  3. "body": {
  4. "type": "progress",
  5. "value": 60
  6. }
  7. }

颜色映射

可以配置map为单独颜色,例如:#F96D3E

若配置为字符串数组,指定颜色映射,例如,默认的 map 配置为:['bg-danger', 'bg-warning', 'bg-info', 'bg-success', 'bg-success']

它意味着将进度条分成了 5 份,前20%将会添加bg-danger css 类名到进度条上,20%~40%,将会添加bg-warning,以此类推,你可以自定义map来配置想要的进度效果

若配置为[{value: 30, color: "#007bff"}, {value: 60, color: "#F96D3E"}], 表示为 value 小于等于30的区间显示#007bff, 大于30则显示#F96D3E

  1. {
  2. "type": "page",
  3. "body": [
  4. {
  5. "type": "progress",
  6. "value": 40,
  7. "map": "#F96D3E"
  8. },
  9. {
  10. "type": "divider"
  11. },
  12. {
  13. "type": "progress",
  14. "value": 60,
  15. "map": ["bg-danger", "bg-success"]
  16. },
  17. {
  18. "type": "divider"
  19. },
  20. {
  21. "type": "progress",
  22. "value": 20,
  23. "map": [{
  24. value: 30,
  25. color: "#007bff"
  26. },
  27. {
  28. value: 60,
  29. color: "#fad733"
  30. }],
  31. "mode": "circle"
  32. },
  33. {
  34. "type": "divider"
  35. },
  36. {
  37. "type": "progress",
  38. "value": 50,
  39. "map": [{
  40. value: 50,
  41. color: "#007bff"
  42. },
  43. {
  44. value: 60,
  45. color: "#fad733"
  46. }],
  47. "mode": "circle"
  48. }
  49. ]
  50. }

用作 Field 时

当用在 Table 的列配置 Column、List 的内容、Card 卡片的内容和表单的 Static-XXX 中时,可以设置name属性,映射同名变量

Table 中的列类型

```schema: scope=”body” { “type”: “table”, “data”: { “items”: [ { “id”: “1”, “progress”: 20 }, { “id”: “2”, “progress”: 40 }, { “id”: “3”, “progress”: 60 } ] }, “columns”: [ { “name”: “id”, “label”: “Id” },

  1. {
  2. "name": "progress",
  3. "label": "进度",
  4. "type": "progress"
  5. }
  6. ]

}

  1. List 的内容、Card 卡片的内容配置同上
  2. ### Form 中静态展示
  3. ```schema: scope="body"
  4. {
  5. "type": "form",
  6. "data": {
  7. "progress": 60
  8. },
  9. "body": [
  10. {
  11. "type": "static-progress",
  12. "name": "progress",
  13. "label": "进度"
  14. }
  15. ]
  16. }

显示背景间隔

  1. {
  2. "type": "page",
  3. "body": {
  4. "type": "progress",
  5. "stripe": true,
  6. "value": 60
  7. }
  8. }

显示动画

需要条形进度条才生效

  1. {
  2. "type": "page",
  3. "body": [
  4. {
  5. "type": "progress",
  6. "animate": true,
  7. "value": 60
  8. },
  9. {
  10. "type": "divider"
  11. },
  12. {
  13. "type": "progress",
  14. "animate": true,
  15. "value": 60,
  16. "stripe": true
  17. }
  18. ]
  19. }

圆形进度条

  1. {
  2. "type": "page",
  3. "body": {
  4. "type": "progress",
  5. "value": 60,
  6. "mode": "circle"
  7. }
  8. }

仪表盘进度条

可设置缺口位置和缺口角度

  1. {
  2. "type": "page",
  3. "body": {
  4. "type": "progress",
  5. "value": 60,
  6. "mode": "dashboard",
  7. "gapDegree": 22,
  8. "gapPosition": "bottom"
  9. }
  10. }

圆形进度条设置线条宽度

可设置 strokeWidth 调整线条宽度

  1. {
  2. "type": "page",
  3. "body": {
  4. "type": "progress",
  5. "value": 60,
  6. "mode": "dashboard",
  7. "strokeWidth": 3
  8. }
  9. }

自定义格式输出内容

  1. {
  2. "type": "page",
  3. "body": {
  4. "type": "progress",
  5. "mode": "circle",
  6. "value": 60,
  7. "valueTpl": "${value}个"
  8. }
  9. }

属性表

属性名 类型 默认值 说明
type string 如果在 Form 中用作静态展示,为"static-progress"
mode string line 进度「条」的类型,可选line circle dashboard
className string 外层 CSS 类名
value string 进度值
placeholder string - 占位文本
showLabel boolean true 是否展示进度文本
stripe boolean false 背景是否显示条纹
animate boolean false type 为 line,可支持动画
map `string \ Array \ Array<{value:number, color:string}>` ['bg-danger', 'bg-warning', 'bg-info', 'bg-success', 'bg-success'] 进度颜色映射
valueTpl string ${value}% 自定义格式化内容
strokeWidth number line 类型为10,circle、dashboard 类型为6 进度条线宽度
gapDegree number 75 仪表盘缺角角度,可取值 0 ~ 295
gapPosition string bottom 仪表盘进度条缺口位置,可选top bottom left right