diff --git a/.eslintrc-hound.json b/.eslintrc-hound.json
index dc053e517d..3361247052 100644
--- a/.eslintrc-hound.json
+++ b/.eslintrc-hound.json
@@ -16,6 +16,7 @@
"__DEMO__": false,
"__BUILD__": false,
"__VERSION__": false,
+ "__ROOT__": false,
"Polymer": true,
"webkitSpeechRecognition": false,
"ResizeObserver": false
diff --git a/.eslintrc.json b/.eslintrc.json
index e0c225a1f1..9954ffbaba 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -8,6 +8,7 @@
"browser": true
},
"rules": {
- "import/no-unresolved": 2
+ "import/no-unresolved": 2,
+ "linebreak-style": 0
}
}
diff --git a/bower.json b/bower.json
index 41c13814f1..50eb05342b 100644
--- a/bower.json
+++ b/bower.json
@@ -55,7 +55,10 @@
"vaadin-combo-box": "vaadin/vaadin-combo-box#^3.0.2",
"vaadin-date-picker": "vaadin/vaadin-date-picker#^2.0.0",
"web-animations-js": "^2.2.5",
- "webcomponentsjs": "^1.0.10"
+ "webcomponentsjs": "^1.0.10",
+ "chart.js": "~2.7.1",
+ "moment": "^2.20.0",
+ "chartjs-chart-timeline": "fanthos/chartjs-chart-timeline#^0.1.3"
},
"devDependencies": {
"web-component-tester": "^6.3.0"
diff --git a/gulp/tasks/build.js b/gulp/tasks/build.js
index cbd546755c..396a72fb37 100644
--- a/gulp/tasks/build.js
+++ b/gulp/tasks/build.js
@@ -36,6 +36,7 @@ function build(es6) {
stripImportsStrategy([
'bower_components/font-roboto/roboto.html',
'bower_components/paper-styles/color.html',
+ 'src/resources/ha-chart-scripts.html',
]),
stripAllButEntrypointStrategy('panels/hassio/ha-panel-hassio.html')
]);
diff --git a/gulp/tasks/rollup.js b/gulp/tasks/rollup.js
index 16f6803208..07d3c5ee16 100644
--- a/gulp/tasks/rollup.js
+++ b/gulp/tasks/rollup.js
@@ -58,6 +58,7 @@ function getRollupInputOptions(es6) {
__DEMO__: JSON.stringify(DEMO),
__BUILD__: JSON.stringify(es6 ? 'latest' : 'es5'),
__VERSION__: JSON.stringify(VERSION),
+ __ROOT__: JSON.stringify(es6 ? 'frontend_latest' : 'frontend_es5'),
},
}),
],
diff --git a/js/core.js b/js/core.js
index 31a0434dd4..9367a03597 100644
--- a/js/core.js
+++ b/js/core.js
@@ -5,6 +5,7 @@ window.HASS_DEMO = __DEMO__;
window.HASS_DEV = __DEV__;
window.HASS_BUILD = __BUILD__;
window.HASS_VERSION = __VERSION__;
+window.HASS_ROOT = __ROOT__;
const init = window.createHassConnection = function (password) {
const proto = window.location.protocol === 'https:' ? 'wss' : 'ws';
diff --git a/panels/history/ha-panel-history.html b/panels/history/ha-panel-history.html
index ea6a4703e6..0931617998 100644
--- a/panels/history/ha-panel-history.html
+++ b/panels/history/ha-panel-history.html
@@ -82,9 +82,11 @@
+ end-time="[[endTime]]"
+ no-single>
diff --git a/polymer.json b/polymer.json
index eb40c8d42e..f6339c29e7 100644
--- a/polymer.json
+++ b/polymer.json
@@ -16,7 +16,8 @@
"panels/logbook/ha-panel-logbook.html",
"panels/map/ha-panel-map.html",
"panels/shopping-list/ha-panel-shopping-list.html",
- "panels/mailbox/ha-panel-mailbox.html"
+ "panels/mailbox/ha-panel-mailbox.html",
+ "src/resources/ha-chart-scripts.html"
],
"sources": [
"src/**/*",
diff --git a/script/build_frontend b/script/build_frontend
index 047cd11d0c..afb778d8f2 100755
--- a/script/build_frontend
+++ b/script/build_frontend
@@ -27,6 +27,10 @@ cp build/panels/*.html $OUTPUT_DIR/panels
mkdir $OUTPUT_DIR_ES5/panels
cp build-es5/panels/*.html $OUTPUT_DIR_ES5/panels
+# Chart code
+cp build/src/resources/ha-chart-scripts.html $OUTPUT_DIR
+cp build-es5/src/resources/ha-chart-scripts.html $OUTPUT_DIR_ES5
+
# Translations
cp -r build-translations/output $OUTPUT_DIR/translations
diff --git a/src/components/entity/ha-chart-base.html b/src/components/entity/ha-chart-base.html
new file mode 100644
index 0000000000..4e7b55da31
--- /dev/null
+++ b/src/components/entity/ha-chart-base.html
@@ -0,0 +1,484 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/state-history-chart-line.html b/src/components/state-history-chart-line.html
index 313d95cb25..551f9b89ba 100644
--- a/src/components/state-history-chart-line.html
+++ b/src/components/state-history-chart-line.html
@@ -1,299 +1,274 @@
-
+
+
+
+
+
+
+
diff --git a/src/components/state-history-chart-timeline.html b/src/components/state-history-chart-timeline.html
index 15c5f3b9a2..30e87580c8 100644
--- a/src/components/state-history-chart-timeline.html
+++ b/src/components/state-history-chart-timeline.html
@@ -1,13 +1,25 @@
-
+
+
+
+
+
+
+
diff --git a/src/components/state-history-charts.html b/src/components/state-history-charts.html
index 315960ebc2..576f6c16c5 100644
--- a/src/components/state-history-charts.html
+++ b/src/components/state-history-charts.html
@@ -1,27 +1,16 @@
-
-
-
-
-
-
-
+
+ No state history found.
-
-
- No state history found.
-
-
+
+
-
-
-
-
+
+
+
@@ -69,6 +50,9 @@ class StateHistoryCharts extends Polymer.Element {
static get is() { return 'state-history-charts'; }
static get properties() {
return {
+ hass: {
+ type: Object
+ },
historyData: {
type: Object,
value: null,
@@ -85,35 +69,11 @@ class StateHistoryCharts extends Polymer.Element {
upToNow: Boolean,
noSingle: Boolean,
-
- _apiLoaded: {
- type: Boolean,
- value: false,
- },
-
- _isLoading: {
- type: Boolean,
- computed: '_computeIsLoading(isLoadingData, _apiLoaded)',
- },
};
}
- _computeIsSingleLineChart(historyData, noSingle) {
- return !noSingle && historyData && historyData.line.length === 1;
- }
-
- _googleApiLoaded() {
- window.google.load('visualization', '1', {
- packages: ['timeline', 'corechart'],
- language: navigator.language,
- callback: function () {
- this._apiLoaded = true;
- }.bind(this),
- });
- }
-
- _computeIsLoading(_isLoadingData, _apiLoaded) {
- return _isLoadingData || !_apiLoaded;
+ _computeIsSingleLineChart(data, noSingle) {
+ return !noSingle && data && data.length === 1;
}
_computeIsEmpty(historyData) {
diff --git a/src/data/ha-state-history-data.html b/src/data/ha-state-history-data.html
index d188a6161c..a2ef584741 100644
--- a/src/data/ha-state-history-data.html
+++ b/src/data/ha-state-history-data.html
@@ -35,7 +35,8 @@
entity_id: stateInfo[0].entity_id,
data: stateInfo
.map(state => ({
- state: window.hassUtil.computeStateDisplay(localize, state, language),
+ state_localize: window.hassUtil.computeStateDisplay(localize, state, language),
+ state: state.state,
last_changed: state.last_changed,
}))
.filter((element, index, arr) => {
@@ -140,7 +141,7 @@
super.connectedCallback();
this.filterChanged(
this.filterType, this.entityId, this.startTime, this.endTime,
- this.cacheConfig, this.localize, this.language
+ this.cacheConfig
);
}
@@ -164,6 +165,7 @@
filterChanged(filterType, entityId, startTime, endTime, cacheConfig, localize, language) {
if (!this.hass) return;
if (cacheConfig && !cacheConfig.cacheKey) return;
+ if (!localize || !language) return;
this._madeFirstCall = true;
let data;
diff --git a/src/resources/ha-chart-scripts.html b/src/resources/ha-chart-scripts.html
new file mode 100644
index 0000000000..4e0acacd16
--- /dev/null
+++ b/src/resources/ha-chart-scripts.html
@@ -0,0 +1,74 @@
+
+
+
+
\ No newline at end of file