Skip to content

Commit 29fd9d3

Browse files
authored
Set default auto period to minimum 100 datapoints (as it was in the readme) (#235)
1 parent 2c324ca commit 29fd9d3

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

readme.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ See also: [Custom buttons](https://github.com/dbuezas/lovelace-plotly-graph-card
130130
131131
![btns](https://user-images.githubusercontent.com/777196/216764329-94b9cd7e-fee9-439b-9134-95b7be626592.gif)
132132
133-
134133
## Features
135134
136135
- Anything you can do with in plotlyjs except maps
@@ -210,8 +209,6 @@ entities:
210209
period: 5minute # `5minute`, `hour`, `day`, `week`, `month`, `auto` # `auto` varies the period depending on the zoom level
211210
```
212211
213-
The option `auto` makes the period relative to the currently visible time range. It picks the longest period, such that there are at least 100 datapoints in screen.
214-
215212
#### for entities with state_class=total (such as utility meters)
216213
217214
```yaml
@@ -224,7 +221,7 @@ entities:
224221
225222
#### automatic period
226223
227-
The period will automatically adapt to the visible range.
224+
The option `auto` makes the period relative to the currently visible time range. It picks the longest period, such that there are at least 100 datapoints in screen.
228225

229226
```yaml
230227
type: custom:plotly-graph
@@ -234,15 +231,20 @@ entities:
234231
period: auto
235232
```
236233

237-
equivalent to:
234+
It is equivalent to writing:
238235

239236
```yaml
240-
period:
241-
0s: 5minute
242-
1d: hour
243-
7d: day
244-
28d: week
245-
12M: month # note uppercase M
237+
type: custom:plotly-graph
238+
entities:
239+
- entity: sensor.temperature
240+
statistic: mean
241+
period:
242+
0m: 5minute
243+
100h: hour
244+
100d: day
245+
100w: week
246+
100M: month # note uppercase M for month. Lowercase are minutes
247+
};
246248
```
247249

248250
#### step function for auto period

src/duration/duration.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ export const isRelativeTime = (str: any) => {
113113
parseRelativeTime(str);
114114
return true;
115115
} catch (e) {
116-
console.log(e);
117116
return false;
118117
}
119118
};

src/parse-config/defaults.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ const defaultYamlOptional: {
8787
displaylogo: false,
8888
scrollZoom: true,
8989
modeBarButtonsToRemove: ["resetScale2d", "toImage", "lasso2d", "select2d"],
90+
// @ts-expect-error expects a string, not a function
9091
locale: ({ hass }) => hass.locale?.language,
9192
},
9293
layout: {

src/parse-config/parse-statistics.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ export function parseStatistics(
4040
if (period === "auto") {
4141
period = {
4242
"0": "5minute",
43-
"1d": "hour",
44-
"7d": "day",
45-
"28d": "week",
46-
"12M": "month",
43+
"100h": "hour",
44+
"100d": "day",
45+
"100w": "week",
46+
"100M": "month",
4747
};
4848
}
4949
if (getIsAutoPeriodConfig(period)) {

0 commit comments

Comments
 (0)