Render gauge value in component

pull/10616/head
Alex P 2017-11-16 10:52:15 -08:00
parent 39bc8a21b5
commit 6f112a4e35
1 changed files with 13 additions and 0 deletions

View File

@ -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