Sensor Stroke Width Fix (#4916)

* Sensor width fix

* Const
This commit is contained in:
Zack Arnett 2020-02-18 23:20:32 -05:00 committed by GitHub
parent 0a41a4f066
commit 2c58a9f802
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,6 +27,8 @@ import { SensorCardConfig } from "./types";
import { hasConfigOrEntityChanged } from "../common/has-changed"; import { hasConfigOrEntityChanged } from "../common/has-changed";
import { actionHandler } from "../common/directives/action-handler-directive"; import { actionHandler } from "../common/directives/action-handler-directive";
const strokeWidth = 5;
const average = (items): number => { const average = (items): number => {
return ( return (
items.reduce((sum, entry) => sum + parseFloat(entry.state), 0) / items.reduce((sum, entry) => sum + parseFloat(entry.state), 0) /
@ -101,7 +103,8 @@ const calcPoints = (
if (item) { if (item) {
last = [average(item), lastValue(item)]; last = [average(item), lastValue(item)];
} }
const y = height - ((item ? last[0] : last[1]) - min) / yRatio; const y =
height + strokeWidth / 2 - ((item ? last[0] : last[1]) - min) / yRatio;
return coords.push([x, y]); return coords.push([x, y]);
}; };
@ -257,7 +260,7 @@ class HuiSensorCard extends LitElement implements LovelaceCard {
<path <path
fill="none" fill="none"
stroke="var(--accent-color)" stroke="var(--accent-color)"
stroke-width="5" stroke-width="${strokeWidth}"
stroke-linecap="round" stroke-linecap="round"
stroke-linejoin="round" stroke-linejoin="round"
d=${this._history} d=${this._history}