Gauge - 图1

Gauge Svelte Component

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

Gauge Components

There are following components included:

  • 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)
bgColorstringtransparentGauge background color. Can be any valid color string, e.g. #ff00ff, rgb(0,0,255), etc.
borderBgColorstring#eeeeeeMain border/stroke background color
borderColorstring#000000Main border/stroke color
borderWidthstring10Main border/stroke width
valueTextstringnullGauge value text (large text in the center of gauge)
valueTextColorstring#000000Value text color
valueFontSizestring31Value text font size
valueFontWeightstring500Value text font weight
labelTextstringnullGauge additional label text
labelTextColorstring#888888Label text color
labelFontSizestring14Label text font size
labelFontWeightstring400Label text font weight

Examples

  1. <Page>
  2. <Navbar title="Gauge"></Navbar>
  3. <Block strong>
  4. <p>Framework7 comes with Gauge component. It produces nice looking fully responsive SVG gauges.</p>
  5. </Block>
  6. <Block strong class="text-align-center">
  7. <Gauge
  8. type="circle"
  9. value={gaugeValue}
  10. size={250}
  11. borderColor="#2196f3"
  12. borderWidth={10}
  13. valueText={`${gaugeValue * 100}%`}
  14. valueFontSize={41}
  15. valueTextColor="#2196f3"
  16. labelText="amount of something"
  17. />
  18. <Segmented tag="p" raised>
  19. <Button onClick={() => gaugeValue = 0 }>0%</Button>
  20. <Button onClick={() => gaugeValue = 0.25 }>25%</Button>
  21. <Button onClick={() => gaugeValue = 0.5 }>50%</Button>
  22. <Button onClick={() => gaugeValue = 0.75 }>75%</Button>
  23. <Button onClick={() => gaugeValue = 1 }>100%</Button>
  24. </Segmented>
  25. </Block>
  26. <BlockTitle>Circle Gauges</BlockTitle>
  27. <Block strong>
  28. <Row>
  29. <Col class="text-align-center">
  30. <Gauge
  31. type="circle"
  32. value={0.44}
  33. valueText="44%"
  34. valueTextColor="#ff9800"
  35. borderColor="#ff9800"
  36. />
  37. </Col>
  38. <Col class="text-align-center">
  39. <Gauge
  40. type="circle"
  41. value={0.12}
  42. valueText="$120"
  43. valueTextColor="#4caf50"
  44. borderColor="#4caf50"
  45. labelText="of $1000 budget"
  46. labelTextColor="#f44336"
  47. labelFontWeight={700}
  48. />
  49. </Col>
  50. </Row>
  51. </Block>
  52. <BlockTitle>Semicircle Gauges</BlockTitle>
  53. <Block strong>
  54. <Row>
  55. <Col class="text-align-center">
  56. <Gauge
  57. type="semicircle"
  58. value={0.3}
  59. valueText="30%"
  60. valueTextColor="#f44336"
  61. borderColor="#f44336"
  62. />
  63. </Col>
  64. <Col class="text-align-center">
  65. <Gauge
  66. type="semicircle"
  67. value={0.5}
  68. valueText="30kg"
  69. valueTextColor="#e91e63"
  70. borderColor="#e91e63"
  71. labelText="of 60kg total"
  72. labelTextColor="#333"
  73. />
  74. </Col>
  75. </Row>
  76. </Block>
  77. <BlockTitle>Customization</BlockTitle>
  78. <Block strong>
  79. <Row>
  80. <Col class="text-align-center">
  81. <Gauge
  82. type="circle"
  83. value={0.35}
  84. valueText="35%"
  85. valueTextColor="#4caf50"
  86. valueFontSize={51}
  87. valueFontWeight={700}
  88. borderWidth={20}
  89. borderColor="#4caf50"
  90. borderBgColor="#ffeb3b"
  91. bgColor="#ffeb3b"
  92. />
  93. </Col>
  94. <Col class="text-align-center">
  95. <Gauge
  96. type="circle"
  97. value={0.67}
  98. valueText="$670"
  99. valueTextColor="#000"
  100. borderColor="#ff9800"
  101. labelText="of $1000 spent"
  102. labelTextColor="#4caf50"
  103. labelFontWeight={800}
  104. labelFontSize={12}
  105. borderWidth={30}
  106. />
  107. </Col>
  108. </Row>
  109. <br />
  110. <Row>
  111. <Col class="text-align-center">
  112. <Gauge
  113. type="semicircle"
  114. value={0.5}
  115. valueText="50%"
  116. valueTextColor="#ffeb3b"
  117. valueFontSize={41}
  118. valueFontWeight={700}
  119. borderWidth={10}
  120. borderColor="#ffeb3b"
  121. borderBgColor="transparent"
  122. />
  123. </Col>
  124. <Col class="text-align-center">
  125. <Gauge
  126. type="semicircle"
  127. value={0.77}
  128. borderColor="#ff9800"
  129. labelText="$770 spent so far"
  130. labelTextColor="#ff9800"
  131. labelFontWeight={800}
  132. labelFontSize={12}
  133. borderWidth={10}
  134. />
  135. </Col>
  136. </Row>
  137. </Block>
  138. </Page>
  139. <script>
  140. import {Page, Navbar, Block, Gauge, Segmented, Button, BlockTitle, Row, Col} from 'framework7-svelte';
  141. let gaugeValue = 0.5;
  142. </script>

← Floating Action Button / FAB

Grid / Layout Grid →