Render gauge value in component
parent
39bc8a21b5
commit
6f112a4e35
|
@ -41,6 +41,7 @@ class Gauge extends Component {
|
|||
// The following functions must be called in the specified order
|
||||
this.drawGaugeLines(ctx, centerX, centerY, radius, gradientThickness)
|
||||
this.drawGaugeLabels(ctx, centerX, centerY, radius, gradientThickness)
|
||||
this.drawGaugeValue(ctx, radius)
|
||||
this.drawNeedle(ctx, radius)
|
||||
}
|
||||
|
||||
|
@ -203,6 +204,18 @@ class Gauge extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
drawGaugeValue = (ctx, radius) => {
|
||||
const {gaugePosition} = this.props
|
||||
|
||||
ctx.font = '40px Roboto'
|
||||
ctx.fillStyle = '#ffffff'
|
||||
ctx.textBaseline = 'middle'
|
||||
ctx.textAlign = 'center'
|
||||
|
||||
const textY = radius * 0.75
|
||||
ctx.fillText(gaugePosition.toString(), 0, textY)
|
||||
}
|
||||
|
||||
drawNeedle = (ctx, radius) => {
|
||||
const {maxValue, gaugePosition} = this.props
|
||||
const {degree} = GAUGE_SPECS
|
||||
|
|
Loading…
Reference in New Issue