Youen Toupin
3 years ago
7 changed files with 75 additions and 23 deletions
@ -0,0 +1,27 @@
|
||||
import m from 'mithril'; |
||||
import { GaugeLinear } from 'components/widgets/gauge-linear'; |
||||
|
||||
export class GaugeBattery extends GaugeLinear { |
||||
constructor(vnode: any) { |
||||
super(vnode); |
||||
this.svgPaddingTop = 0.06; |
||||
} |
||||
|
||||
createSvg(svgElement: SVGElement) { |
||||
super.createSvg(svgElement); |
||||
|
||||
let w = Math.round(svgElement.clientWidth); |
||||
let h = Math.round(svgElement.clientHeight); |
||||
let paddingTop = Math.round(svgElement.clientHeight * this.svgPaddingTop); |
||||
|
||||
const batteryTopWidth = 0.5; |
||||
|
||||
let batteryTop = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); |
||||
batteryTop.setAttribute('width', (w * batteryTopWidth).toFixed(1)); |
||||
batteryTop.setAttribute('height', (paddingTop).toString()); |
||||
batteryTop.setAttribute('x', (w * (1.0 - batteryTopWidth)*0.5).toFixed(1)); |
||||
batteryTop.setAttribute('y', '0'); |
||||
batteryTop.classList.add('gauge-bg'); |
||||
svgElement.append(batteryTop); |
||||
} |
||||
} |
@ -0,0 +1,9 @@
|
||||
div.gauge svg.gauge-circular path.gauge-bg-outline { |
||||
stroke: rgb(0,0,0); |
||||
fill: none; |
||||
} |
||||
|
||||
div.gauge svg.gauge-circular path.gauge-bg { |
||||
stroke: rgb(255,255,255); |
||||
fill: none; |
||||
} |
Loading…
Reference in new issue