mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-09 10:26:35 +00:00
Multiple weather card graphs (#181)
* Set different id for each weather card * Style fixes * Changed id interpolation * Use same function both for generating and finding chart id * Fix line too long
This commit is contained in:
parent
26c7cc38ca
commit
fa68419f77
@ -21,7 +21,7 @@
|
|||||||
<google-legacy-loader on-api-load='googleApiLoaded'></google-legacy-loader>
|
<google-legacy-loader on-api-load='googleApiLoaded'></google-legacy-loader>
|
||||||
<ha-card header='[[computeTitle(stateObj)]]'>
|
<ha-card header='[[computeTitle(stateObj)]]'>
|
||||||
<div class='content'>
|
<div class='content'>
|
||||||
<div id='chart_area'></div>
|
<div id$='[[computeChartId(stateObj)]]'></div>
|
||||||
<ha-attributes state-obj='[[stateObj]]' extra-filters='forecast'></ha-attributes>
|
<ha-attributes state-obj='[[stateObj]]' extra-filters='forecast'></ha-attributes>
|
||||||
</div>
|
</div>
|
||||||
</ha-card>
|
</ha-card>
|
||||||
@ -50,6 +50,10 @@
|
|||||||
return stateObj.attributes.friendly_name;
|
return stateObj.attributes.friendly_name;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
computeChartId: function (stateObj) {
|
||||||
|
return 'chart_area_' + stateObj.id;
|
||||||
|
},
|
||||||
|
|
||||||
getDataArray: function () {
|
getDataArray: function () {
|
||||||
var dataArray = [];
|
var dataArray = [];
|
||||||
var data = this.stateObj.attributes.forecast;
|
var data = this.stateObj.attributes.forecast;
|
||||||
@ -79,7 +83,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this.chartEngine) {
|
if (!this.chartEngine) {
|
||||||
this.chartEngine = new window.google.visualization.LineChart(document.getElementById('chart_area'));
|
this.chartEngine = new window.google.visualization.LineChart(
|
||||||
|
document.getElementById(this.computeChartId(this.stateObj)));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.drawChart();
|
this.drawChart();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user