Skip to content

Commit

Permalink
feat(statistics): add weekly statistics period (#680)
Browse files Browse the repository at this point in the history
Co-authored-by: Jérôme W <jerome@wnetworks.org>
  • Loading branch information
tefracky and RomRider committed Jul 4, 2024
1 parent 608fbe5 commit e923126
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ series:
| Name | Type | Default | Since | Description |
| ---- | :--: | :-----: | :---: | ----------- |
| `type` | string | `mean` | v2.0.0 | Type of long term statistic to pull. Can be one of `min`, `max`, `mean`, `sum` `state` or `change` |
| `period` | string | `hour` | v2.0.0 | Period of statistics to pull. Can be one of `5minute`, `hour`, `day` or `month` |
| `period` | string | `hour` | v2.0.0 | Period of statistics to pull. Can be one of `5minute`, `hour`, `day`, `week` or `month` |
| `align` | string | `middle` | v2.0.0 | Align the data points to the `start`, `end` or `middle` of the period of the statistics |

### Main `show` Options
Expand Down
2 changes: 2 additions & 0 deletions src/graphEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ export default class GraphEntry {
displayDate = new Date(startDate.getTime() + 1800000); // 30min
} else if (this._config.statistics.period === 'day') {
displayDate = new Date(startDate.getTime() + 43200000); // 12h
} else if (this._config.statistics.period === 'week') {
displayDate = new Date(startDate.getTime() + 259200000); // 3.5d
} else {
displayDate = new Date(startDate.getTime() + 1296000000); // 15d
}
Expand Down
2 changes: 1 addition & 1 deletion src/types-config-ti.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const ChartCardSpanExtConfig = t.iface([], {

export const ChartCardStartEnd = t.union(t.lit('minute'), t.lit('hour'), t.lit('day'), t.lit('week'), t.lit('month'), t.lit('year'), t.lit('isoWeek'));

export const StatisticsPeriod = t.union(t.lit('5minute'), t.lit('hour'), t.lit('day'), t.lit('month'));
export const StatisticsPeriod = t.union(t.lit('5minute'), t.lit('hour'), t.lit('day'), t.lit('week'), t.lit('month'));

export const ChartCardAllSeriesExternalConfig = t.iface([], {
"entity": t.opt("string"),
Expand Down
2 changes: 1 addition & 1 deletion src/types-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export interface ChartCardSpanExtConfig {

export type ChartCardStartEnd = 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year' | 'isoWeek';

export type StatisticsPeriod = '5minute' | 'hour' | 'day' | 'month';
export type StatisticsPeriod = '5minute' | 'hour' | 'day' | 'week' | 'month';

export interface ChartCardAllSeriesExternalConfig {
entity?: string;
Expand Down

0 comments on commit e923126

Please sign in to comment.