Skip to content

Commit 00c478a

Browse files
committedApr 18, 2020
[Issue] Fix values to 5 decimals (#4)
1 parent 419ec48 commit 00c478a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed
 

‎pvpc-hourly-pricing-card.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class PVPCHourlyPricingCard extends Polymer.Element {
4242
<template is="dom-if" if="[[getTariffStatusIcon(pvpcHourlyPricingObj.attributes.tariff)]]">
4343
<ha-icon icon="[[getTariffStatusIcon(pvpcHourlyPricingObj.attributes.tariff)]]"></ha-icon>
4444
</template>
45-
<div on-click="_pvpcHourlyPricingAttr">[[pvpcHourlyPricingObj.state]]<sup>[[pvpcHourlyPricingObj.attributes.unit_of_measurement]]</sup></div>
45+
<div on-click="_pvpcHourlyPricingAttr">[[getFixedFloat(pvpcHourlyPricingObj.state)]]<sup>[[pvpcHourlyPricingObj.attributes.unit_of_measurement]]</sup></div>
4646
</div>
4747
<ha-chart-base data="[[ChartData]]"></ha-chart-base>
4848
<template is="dom-repeat" items="[[data]]"></template>
@@ -93,6 +93,10 @@ class PVPCHourlyPricingCard extends Polymer.Element {
9393
getCardSize() {
9494
return 4;
9595
}
96+
97+
getFixedFloat(number){
98+
return parseFloat(number).toFixed(5);
99+
}
96100

97101
getTariffStatusIcon(tariff) {
98102
var icon;
@@ -343,7 +347,7 @@ class PVPCHourlyPricingCard extends Polymer.Element {
343347
}
344348

345349
var labelTitle = data.datasets[tooltipItems.datasetIndex].label || '';
346-
var label = labelTitle + ': ' + tooltipItems.value + ' ' + energyUnit + ' ';
350+
var label = labelTitle + ': ' + parseFloat(tooltipItems.value).toFixed(5) + ' ' + energyUnit + ' ';
347351

348352
return icon ? label + icon : label;
349353
},

0 commit comments

Comments
 (0)
Please sign in to comment.