Added decimals on month plot if number under 10. Also added mouse-over with better precision

This commit is contained in:
Gunnar Skjold
2023-05-02 10:40:53 +02:00
parent eea1782280
commit 13dda2bb19
9 changed files with 41 additions and 18 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -14,7 +14,8 @@
function point(v) {
return {
label: fmtnum(v) +'A',
label: fmtnum(v) + 'A',
title: v.toFixed(1) + ' A',
value: isNaN(v) ? 0 : v,
color: ampcol(v ? (v)/(max)*100 : 0)
};

View File

@@ -61,6 +61,7 @@
<g class='bars'>
{#each config.points as point, i}
<g>
{#if point.value !== undefined}
<rect
x="{xScale(i) + 2}"
@@ -79,9 +80,15 @@
text-anchor="{barWidth < 25 ? 'left' : 'middle'}"
fill="{yScale(point.value) > yScale(0)-labelOffset ? point.color : 'white'}"
transform="rotate({barWidth < 25 ? 90 : 0}, {xScale(i) + (barWidth/2)}, {yScale(point.value) > yScale(0)-labelOffset ? yScale(point.value) - labelOffset : yScale(point.value)+9})"
>{point.label}</text>
{#if point.title}
<title>{point.title}</title>
{/if}
{/if}
{/if}
</g>
<g>
{#if point.value2 > 0.0001}
<rect
x="{xScale(i) + 2}"
@@ -100,8 +107,12 @@
fill="{yScale(-point.value2) < yScale(0)+12 ? point.color : 'white'}"
transform="rotate({barWidth < 25 ? 90 : 0}, {xScale(i) + (barWidth/2)}, {yScale(point.value2 - config.y.min) > yScale(0)-12 ? yScale(point.value2 - config.y.min) - 12 : yScale(point.value2 - config.y.min)+9})"
>{point.label2}</text>
{#if point.title2}
<title>{point.title2}</title>
{/if}
{/if}
{/if}
</g>
{/each}
</g>
</svg>

View File

@@ -26,8 +26,10 @@
});
points.push({
label: imp.toFixed(1),
title: imp.toFixed(2) + ' kWh',
value: imp*10,
label2: exp.toFixed(1),
title2: exp.toFixed(2) + ' kWh',
value2: exp*10,
color: '#7c3aed'
});
@@ -46,8 +48,10 @@
});
points.push({
label: imp.toFixed(1),
title: imp.toFixed(2) + ' kWh',
value: imp*10,
label2: exp.toFixed(1),
title2: exp.toFixed(2) + ' kWh',
value2: exp*10,
color: '#7c3aed'
});

View File

@@ -27,9 +27,11 @@
label: zeropad(i)
});
points.push({
label: imp.toFixed(0),
label: imp.toFixed(imp < 10 ? 1 : 0),
title: imp.toFixed(2) + ' kWh',
value: imp,
label2: exp.toFixed(0),
label2: exp.toFixed(exp < 10 ? 1 : 0),
title2: exp.toFixed(2) + ' kWh',
value2: exp,
color: '#7c3aed'
});
@@ -46,9 +48,11 @@
label: zeropad(i)
});
points.push({
label: imp.toFixed(0),
label: imp.toFixed(imp < 10 ? 1 : 0),
title: imp.toFixed(2) + ' kWh',
value: imp,
label2: exp.toFixed(0),
label2: exp.toFixed(exp < 10 ? 1 : 0),
title2: exp.toFixed(2) + ' kWh',
value2: exp,
color: '#7c3aed'
});

View File

@@ -26,8 +26,10 @@
});
points.push({
label: val > 0 ? val.toFixed(d) : '',
title: val > 0 ? val.toFixed(2) + ' ' + json.currency : '',
value: val > 0 ? Math.abs(val*100) : 0,
label2: val < 0 ? val.toFixed(d) : '',
title2: val < 0 ? val.toFixed(2) + ' ' + json.currency : '',
value2: val < 0 ? Math.abs(val*100) : 0,
color: '#7c3aed'
});

View File

@@ -22,7 +22,7 @@
label: name.slice(-4)
});
points.push({
label: val.toFixed(1),
label: val.toFixed(1),
value: val,
color: '#7c3aed'
});

View File

@@ -12,6 +12,7 @@
function point(v) {
return {
label: fmtnum(v) + 'V',
title: v.toFixed(1) + ' V',
value: isNaN(v) ? 0 : v,
color: voltcol(v ? v : 0)
};