Gauge - 图1

Gauge Vue Component

Framework7 comes with Gauge component. It produces nice looking fully responsive SVG gauges.

Gauge Components

There are following components included:

  • **f7-gauge**

Gauge Properties

PropTypeDefaultDescription
idstringGauge element ID attribute
typestringcircleGauge type. Can be circle or semicircle
valuenumber0Gauge value/percentage. Must be a number between 0 and 1
sizenumber200Generated SVG image size (in px)
bg-colorstringtransparentGauge background color. Can be any valid color string, e.g. #ff00ff, rgb(0,0,255), etc.
border-bg-colorstring#eeeeeeMain border/stroke background color
border-colorstring#000000Main border/stroke color
border-widthstring10Main border/stroke width
value-textstringnullGauge value text (large text in the center of gauge)
value-text-colorstring#000000Value text color
value-font-sizestring31Value text font size
value-font-weightstring500Value text font weight
label-textstringnullGauge additional label text
label-text-colorstring#888888Label text color
label-font-sizestring14Label text font size
label-font-weightstring400Label text font weight

Examples

  1. <template>
  2. <f7-page>
  3. <f7-navbar title="Gauge"></f7-navbar>
  4. <f7-block strong class="text-align-center">
  5. <f7-gauge
  6. type="circle"
  7. :value="gaugeValue"
  8. :size="250"
  9. border-color="#2196f3"
  10. :border-width="10"
  11. :value-text="`${gaugeValue * 100}%`"
  12. :value-font-size="41"
  13. value-text-color="#2196f3"
  14. label-text="amount of something"
  15. ></f7-gauge>
  16. <f7-segmented tag="p" raised>
  17. <f7-button @click="() => gaugeValue = 0">0%</f7-button>
  18. <f7-button @click="() => gaugeValue = 0.25">25%</f7-button>
  19. <f7-button @click="() => gaugeValue = 0.5">50%</f7-button>
  20. <f7-button @click="() => gaugeValue = 0.75">75%</f7-button>
  21. <f7-button @click="() => gaugeValue = 1">100%</f7-button>
  22. </f7-segmented>
  23. </f7-block>
  24. <f7-block-title>Circle Gauges</f7-block-title>
  25. <f7-block strong>
  26. <f7-row>
  27. <f7-col class="text-align-center">
  28. <f7-gauge
  29. type="circle"
  30. :value="0.44"
  31. value-text="44%"
  32. value-text-color="#ff9800"
  33. border-color="#ff9800"
  34. ></f7-gauge>
  35. </f7-col>
  36. <f7-col class="text-align-center">
  37. <f7-gauge
  38. type="circle"
  39. :value="0.12"
  40. value-text="$120"
  41. value-text-color="#4caf50"
  42. border-color="#4caf50"
  43. label-text="of $1000 budget"
  44. label-text-color="#f44336"
  45. :label-font-weight="700"
  46. ></f7-gauge>
  47. </f7-col>
  48. </f7-row>
  49. </f7-block>
  50. <f7-block-title>Semicircle Gauges</f7-block-title>
  51. <f7-block strong>
  52. <f7-row>
  53. <f7-col class="text-align-center">
  54. <f7-gauge
  55. type="semicircle"
  56. :value="0.3"
  57. value-text="30%"
  58. value-text-color="#f44336"
  59. border-color="#f44336"
  60. ></f7-gauge>
  61. </f7-col>
  62. <f7-col class="text-align-center">
  63. <f7-gauge
  64. type="semicircle"
  65. :value="0.5"
  66. value-text="30kg"
  67. value-text-color="#e91e63"
  68. border-color="#e91e63"
  69. label-text="of 60kg total"
  70. label-text-color="#333"
  71. ></f7-gauge>
  72. </f7-col>
  73. </f7-row>
  74. </f7-block>
  75. <f7-block-title>Customization</f7-block-title>
  76. <f7-block strong>
  77. <f7-row>
  78. <f7-col class="text-align-center">
  79. <f7-gauge
  80. type="circle"
  81. :value="0.35"
  82. value-text="35%"
  83. value-text-color="#4caf50"
  84. :valueFontSize="51"
  85. :valueFontWeight="700"
  86. :border-width="20"
  87. border-color="#4caf50"
  88. border-bg-color="#ffeb3b"
  89. bg-color="#ffeb3b"
  90. ></f7-gauge>
  91. </f7-col>
  92. <f7-col class="text-align-center">
  93. <f7-gauge
  94. type="circle"
  95. :value="0.67"
  96. value-text="$670"
  97. value-text-color="#000"
  98. border-color="#ff9800"
  99. label-text="of $1000 spent"
  100. label-text-color="#4caf50"
  101. :label-font-weight="800"
  102. :label-font-size="12"
  103. :border-width="30"
  104. ></f7-gauge>
  105. </f7-col>
  106. </f7-row>
  107. <br />
  108. <f7-row>
  109. <f7-col class="text-align-center">
  110. <f7-gauge
  111. type="semicircle"
  112. :value="0.5"
  113. value-text="50%"
  114. value-text-color="#ffeb3b"
  115. :valueFontSize="41"
  116. :valueFontWeight="700"
  117. :border-width="10"
  118. border-color="#ffeb3b"
  119. border-bg-color="transparent"
  120. ></f7-gauge>
  121. </f7-col>
  122. <f7-col class="text-align-center">
  123. <f7-gauge
  124. type="semicircle"
  125. :value="0.77"
  126. border-color="#ff9800"
  127. label-text="$770 spent so far"
  128. label-text-color="#ff9800"
  129. :label-font-weight="800"
  130. :label-font-size="12"
  131. :border-width="10"
  132. ></f7-gauge>
  133. </f7-col>
  134. </f7-row>
  135. </f7-block>
  136. </f7-page>
  137. </template>
  138. <script>
  139. export default {
  140. data() {
  141. return {
  142. gaugeValue: 0.5,
  143. };
  144. },
  145. };
  146. </script>