-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhc-iron-gauge-humidity.html
110 lines (109 loc) · 2.93 KB
/
hc-iron-gauge-humidity.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<link rel="import" href="hc-chart-behaviours.html"/>
<dom-module id="hc-iron-gauge-humidity">
<style>
.chart-container {
width: 100%; margin: 0 auto; margin-bottom: 0rem; margin-top: 0rem; height: 100%;
}
</style>
<template>
<!-- Iron Ajax -->
<iron-ajax id="ajax" url="{{url}}" last-response="{{data}}" debounce-duration="300"></iron-ajax>
<!--Gauges-->
<div id="humidContainer" class="chart-container"></div>
</template>
<script>
Polymer({
is: "hc-iron-gauge-humidity",
// fetch hc-iron-charts behaviours
/*
* @ fetch common properties from hc-iron-charts and setup custom highchart options using hc-iron-gauge
* @ alternatively, you can use hc-iron-gauge for single gauges with different datasets
*
*/
behaviors: [HCProperties],
// Humidity Gauge
_chartData: function (data) {
new Highcharts.Chart({
colors: this.createSeriesColorsArray(this.dataVisColors, this.seriesColorOrder),
chart: {
inverted: false,
renderTo: this.$.humidContainer,
height: 150,
width: 150
},
title: {
text: '',
verticalAlign: 'bottom',
style: {
fontWeight: 'normal',
fontSize: "12px"
}
},
xAxis: {
title: {
text: null
},
minRange: 30,
min: -15,
max: 60
},
exporting: {
enabled: false
},
yAxis: [{
min: 0,
max: 70,
tickPosition: 'outside',
lineWidth: 2,
minorTickPosition: 'outside',
tickLength: 5,
minorTickWidth: 1,
minorTickLength: 3,
labels: {
distance: 12,
rotation: 'auto'
},
tickInterval: 10,
offset: -20,
endOnTick: false,
showFirstLabel: false
}],
tooltip: {
valueSuffix: ''
},
plotOptions: {
gauge: {
dataLabels: {
enabled: false
}
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -40,
y: 80,
floating: true,
borderWidth: 1,
backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'),
shadow: true
},
credits: {
enabled: false
},
series: [{
animation: false,
type: 'gauge',
name: 'Humidity',
visible: true,
data: [data.humidity.current_val],
dataLabels: {
enabled: false,
}
}]
});
}
});
</script>
</dom-module>