多色进度条插件 jQuery Multibar.js

  • 源码大小:29.27KB
  • 所需积分:1积分
  • 源码编号:19JP-3127
  • 浏览次数:729次
  • 最后更新:2023年05月08日
  • 所属栏目:图表
本站默认解压密码:19jp.com 或 19jp_com

简介

Multibar.js是一个简单但完全可定制的jQuery插件,用于创建多色(分段)进度条,以表示各种数据范围、完成级别或任何其他需要可视化的指标

它支持一个或多个标记,这些标记清楚地指示进度条中的特定点或里程碑。此外,该插件允许您根据进度值生成图例,使用户能够轻松解释所呈现的数据。

参见:

  • JavaScript和CSS中的10个最佳进度条(线性)组件

如何使用它:

1.将jQuery库和Multibar.js插件的文件添加到页面中。

  1. <!-- jQuery is required -->
  2. <script src="/path/to/cdn/jquery.slim.min.js"></script>
  3.  
  4. <!-- jQuery Multibar.js -->
  5. <link rel="stylesheet" href="multibar.css">
  6. <script src="multibar.js"></script>

2.为进度条创建一个空的DIV。

  1. <div id="example"></div>

3.初始化插件并在进度条中添加一个标记。

  1. var bar = $('#example').multibar({
  2. initValue: [3],
  3. });
  4.  
  5. // OR
  6. bar.multibar("setValue",[3]);

4.自定义标记。

  1. var bar = $('#example').multibar({
  2.  
  3. // or "inside"
  4. posMarker: "outside",
  5.  
  6. // custom icon class
  7. iconMarker: "arrow-down",
  8. });

5.设置最小/最大值。

  1. var bar = $('#example').multibar({
  2. min: 0,
  3. max: 10,
  4. });

6.自定义进度条每个部分的样式。

  1. var bar = $('#example').multibar({
  2.  
  3. multiBarValue:[
  4. {
  5. visibility:"visible",
  6. val:2,
  7. bgColor:"green"
  8. },
  9. {
  10. visibility:"visible",
  11. val:4,
  12. bgColor:"yellow"
  13. },
  14. {
  15. visibility:"visible",
  16. val:6,
  17. bgColor:"orange"
  18. },
  19. {
  20. visibility:"visible",
  21. val:8,
  22. bgColor:"red"
  23. },
  24. {
  25. visibility:"visible",
  26. val:10,
  27. bgColor:"purple"
  28. }
  29. ],
  30.  
  31. });

7.自定义图例。

  1. var bar = $('#example').multibar({
  2.  
  3. legend:{
  4. show: true,
  5. title: "My Item",
  6. titleClass: "titleLegend",
  7. itemClass: "itemLegend"
  8. }
  9.  
  10. });

8.更多插件选项。

  1. var bar = $('#example').multibar({
  2.  
  3. // 'hot', 'cold'
  4. type: "normal",
  5.  
  6. // enable Multi Bar Thermometer
  7. thermometer: false,
  8.  
  9. // reverse the progress bar
  10. reverse: false,
  11.  
  12. // set the visibility of values
  13. multiBarValueVisibility: "visible",
  14.  
  15. // set the position of the box-shadow
  16. // e.g. 'top_right'
  17. shadow: false
  18.  
  19. });

预览截图