File tree Expand file tree Collapse file tree 4 files changed +24
-2
lines changed
Expand file tree Collapse file tree 4 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -124,16 +124,24 @@ class HuiHistoryChartCardFeature
124124 }
125125
126126 const hourToShow = this . _config . hours_to_show ?? DEFAULT_HOURS_TO_SHOW ;
127+ const detail = this . _config . detail !== false ; // default to true (high detail)
127128
128129 return subscribeHistoryStatesTimeWindow (
129130 this . hass ! ,
130131 ( historyStates ) => {
132+ // sample to 1 point per hour for low detail or 1 point per 5 pixels for high detail
133+ const maxDetails = detail
134+ ? Math . max ( 10 , this . clientWidth / 5 , hourToShow )
135+ : Math . max ( 10 , hourToShow ) ;
136+ const useMean = ! detail ;
131137 const { points, yAxisOrigin } =
132138 coordinatesMinimalResponseCompressedState (
133139 historyStates [ this . context ! . entity_id ! ] ,
134140 this . clientWidth ,
135141 this . clientHeight ,
136- this . clientWidth / 5 // sample to 1 point per 5 pixels
142+ maxDetails ,
143+ undefined ,
144+ useMean
137145 ) ;
138146 this . _coordinates = points ;
139147 this . _yAxisOrigin = yAxisOrigin ;
Original file line number Diff line number Diff line change @@ -199,6 +199,7 @@ export interface UpdateActionsCardFeatureConfig {
199199export interface TrendGraphCardFeatureConfig {
200200 type : "trend-graph" ;
201201 hours_to_show ?: number ;
202+ detail ?: boolean ;
202203}
203204
204205export const AREA_CONTROLS = [
Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ const SCHEMA = [
2020 default : DEFAULT_HOURS_TO_SHOW ,
2121 selector : { number : { min : 1 , mode : "box" } } ,
2222 } ,
23+ {
24+ name : "detail" ,
25+ selector : { boolean : { } } ,
26+ } ,
2327] as const satisfies HaFormSchema [ ] ;
2428
2529@customElement ( "hui-trend-graph-card-feature-editor" )
@@ -48,6 +52,10 @@ export class HuiTrendGraphCardFeatureEditor
4852 data . hours_to_show = DEFAULT_HOURS_TO_SHOW ;
4953 }
5054
55+ if ( this . _config . detail === undefined ) {
56+ data . detail = true ;
57+ }
58+
5159 return html `
5260 < ha-form
5361 .hass =${ this . hass }
@@ -69,6 +77,10 @@ export class HuiTrendGraphCardFeatureEditor
6977 return this . hass ! . localize (
7078 `ui.panel.lovelace.editor.card.generic.${ schema . name } `
7179 ) ;
80+ case "detail" :
81+ return this . hass ! . localize (
82+ "ui.panel.lovelace.editor.features.types.trend-graph.detail"
83+ ) ;
7284 default :
7385 return "" ;
7486 }
Original file line number Diff line number Diff line change 84348434 "max": "Maximum value"
84358435 },
84368436 "trend-graph": {
8437- "label": "Trend graph"
8437+ "label": "Trend graph",
8438+ "detail": "Show more detail"
84388439 }
84398440 }
84408441 },
You can’t perform that action at this time.
0 commit comments