|
|
|
@ -49,27 +49,38 @@ export class GaugeCircular extends Gauge {
|
|
|
|
|
bg.classList.add('gauge-bg'); |
|
|
|
|
svgElement.append(bg); |
|
|
|
|
|
|
|
|
|
let barHeight = 15; |
|
|
|
|
let barHeight = 12; |
|
|
|
|
const barGap = barHeight * 0.2; |
|
|
|
|
let numBars = Math.round(h / (barHeight + barGap)); |
|
|
|
|
let numBars = Math.round(arcLength / (barHeight + barGap)); |
|
|
|
|
|
|
|
|
|
let bh = (h - (numBars+1)*barGap) / numBars; |
|
|
|
|
barHeight = Math.round(bh); |
|
|
|
|
barHeight = (arcLength - (numBars+1)*barGap) / numBars; |
|
|
|
|
|
|
|
|
|
/*for(let barIdx = 0; barIdx < numBars; ++barIdx) { |
|
|
|
|
let bar = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); |
|
|
|
|
bar.setAttribute('width', (w - barGap * 2).toString()); |
|
|
|
|
bar.setAttribute('height', barHeight.toString()); |
|
|
|
|
let computeCircleCoords = function(d: number, r: number, out: {x: number, y: number}) { |
|
|
|
|
let a = outlineOpeningHalfAngle + (2.0 * Math.PI - outlineOpeningHalfAngle * 2.0) * (d / arcLength); |
|
|
|
|
out.x = svgRound(cx - Math.sin(a) * r); |
|
|
|
|
out.y = svgRound(cy + Math.cos(a) * r); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
let points: {x: number, y: number}[] = []; |
|
|
|
|
for(let idx = 0; idx < 4; ++idx) { points[idx] = {x: 0, y: 0}; } |
|
|
|
|
for(let barIdx = 0; barIdx < numBars; ++barIdx) { |
|
|
|
|
let bar = document.createElementNS('http://www.w3.org/2000/svg', 'path'); |
|
|
|
|
bar.classList.add('gauge-bar'); |
|
|
|
|
bar.classList.toggle('lit', false); |
|
|
|
|
|
|
|
|
|
bar.setAttribute('x', barGap.toString()); |
|
|
|
|
bar.setAttribute('y', (h - barIdx * (bh+barGap) - barGap - barHeight).toString()); |
|
|
|
|
let barStartLen = barGap + barIdx * (barHeight + barGap); |
|
|
|
|
let barEndLen = barStartLen + barHeight; |
|
|
|
|
computeCircleCoords(barStartLen, gaugeRadius - gaugeWidth*0.5 + barGap, points[0]); |
|
|
|
|
computeCircleCoords(barStartLen, gaugeRadius + gaugeWidth*0.5 - barGap, points[1]); |
|
|
|
|
computeCircleCoords(barEndLen, gaugeRadius + gaugeWidth*0.5 - barGap, points[2]); |
|
|
|
|
computeCircleCoords(barEndLen, gaugeRadius - gaugeWidth*0.5 + barGap, points[3]); |
|
|
|
|
|
|
|
|
|
bar.setAttribute('d', 'M'+points[0].x+' '+points[0].y+' L'+points[1].x+' '+points[1].y+' L'+points[2].x+' '+points[2].y+' L'+points[3].x+' '+points[3].y+' Z'); |
|
|
|
|
|
|
|
|
|
svgElement.append(bar); |
|
|
|
|
|
|
|
|
|
this.bars.push(bar); |
|
|
|
|
}*/ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
oncreate(vnode: any) { |
|
|
|
|