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