From fb610334212287aacfdc933aca27c8f572ed7979 Mon Sep 17 00:00:00 2001 From: Henri Bergius Date: Tue, 28 Nov 2017 22:46:49 +0100 Subject: [PATCH] Fix defaults handling --- elements/heatmap.js | 10 ++++++---- elements/polar.js | 10 ++++++---- screens/test.html | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/elements/heatmap.js b/elements/heatmap.js index 76a2573..339c2e8 100644 --- a/elements/heatmap.js +++ b/elements/heatmap.js @@ -6,9 +6,7 @@ const Component = withComponent(); class Heatmap extends Component { static props = { timeseries: props.string, - days: props.number({ - default: 7, - }), + days: props.number, interpolate: props.boolean, accumulate: props.boolean, }; @@ -22,6 +20,10 @@ class Heatmap extends Component { } render({ timeseries, interpolate, accumulate, days }) { + let daySlots = days; + if (!daySlots) { + daySlots = 7; + } const el = document.createElement('div'); if (!this.enableFetch) { // Not yet connected @@ -31,7 +33,7 @@ class Heatmap extends Component { // We're re-rendering, cancel previous this.ts.canceled = true; } - const ts = new Timeseries(timeseries, new Date(), days); + const ts = new Timeseries(timeseries, new Date(), daySlots); const data = [{ x: ts.getSlotLabels(), y: ts.getDayLabels(), diff --git a/elements/polar.js b/elements/polar.js index 18bcc64..716bc3c 100644 --- a/elements/polar.js +++ b/elements/polar.js @@ -6,9 +6,7 @@ const Component = withComponent(); class Polar extends Component { static props = { timeseries: props.string, - days: props.number({ - default: 7, - }), + days: props.number, interpolate: props.boolean, accumulate: props.boolean, percentage: props.boolean, @@ -25,6 +23,10 @@ class Polar extends Component { } render({ timeseries, interpolate, accumulate, percentage, days }) { + let daySlots = days; + if (!daySlots) { + daySlots = 7; + } const el = document.createElement('div'); if (!this.enableFetch) { // Not yet connected @@ -34,7 +36,7 @@ class Polar extends Component { // We're re-rendering, cancel previous this.ts.canceled = true; } - const ts = new Timeseries(timeseries, new Date(), days); + const ts = new Timeseries(timeseries, new Date(), daySlots); const layout = { orientation: 270, direction: 'clockwise', diff --git a/screens/test.html b/screens/test.html index 4732999..0da6d8d 100644 --- a/screens/test.html +++ b/screens/test.html @@ -26,7 +26,7 @@
- +