-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhc-iron-gauge-temperature.html
124 lines (121 loc) · 3.4 KB
/
hc-iron-gauge-temperature.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<link rel="import" href="hc-chart-behaviours.html"/>
<dom-module id="hc-iron-gauge-temperature">
<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="tempcontainer" class="chart-container"></div>
</template>
<script>
Polymer({
is: "hc-iron-gauge-temperature",
// 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.$.tempcontainer,
height: 150,
width: 150
},
title: {
text: ''
},
pane: {
startAngle: -150,
endAngle: 150,
background: [{
backgroundColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
stops: [
[0, '#FFF'],
[1, '#333']
]
},
borderWidth: 0,
outerRadius: '109%'
}, {
backgroundColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
stops: [
[0, '#333'],
[1, '#FFF']
]
},
borderWidth: 1,
outerRadius: '107%'
}, {
// default background
}, {
backgroundColor: '#DDD',
borderWidth: 0,
outerRadius: '105%',
innerRadius: '103%'
}]
},
// the value axis
yAxis: {
min: 0,
max: 50,
minorTickInterval: 'auto',
minorTickWidth: 1,
minorTickLength: 10,
minorTickPosition: 'inside',
minorTickColor: '#666',
tickPixelInterval: 30,
tickWidth: 2,
tickPosition: 'inside',
tickLength: 10,
tickColor: '#666',
labels: {
step: 2,
rotation: 'auto'
},
plotBands: [{
from: 0,
to: 35,
color: '#55BF3B' // green
}, {
from: 35,
to: 40,
color: '#DDDF0D' // yellow
}, {
from: 40,
to: 50,
color: '#DF5353' // red
}]
},
credits: {
enabled: false
},
exporting: {
enabled: false
},
series: [{
animation: false,
type: 'gauge',
name: 'Temperature',
visible: true,
data: [data.temperature.current_val],
dataLabels: {
enabled: false,
}
}]
});
}
});
</script>
</dom-module>