HTMLcopy
1
<div id="container"></div>
CSScopy
6
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
3
// create data
4
var data = [92];
5
6
// set the gauge type
7
var gauge = anychart.gauges.thermometer();
8
9
// set the data for the gauge
10
gauge.data(data);
11
12
// set the title of the gauge
13
gauge.title('Thermometer with Fahrenheit and Celsius Scales');
14
15
// add a thermometer pointer
16
gauge.addPointer(0);
17
18
// use the primary scale a Fahrenheit scale
19
var fScale = gauge.scale();
20
21
// set the minimum and maximum values of the Fahrenheit scale
22
fScale.minimum(-40);
23
fScale.maximum(122);
24
25
// set the intervals of major and minor ticks on the Fahrenheit scale
26
fScale.ticks().interval(10);
27
fScale.minorTicks().interval(2);
28
29
// add an axis on the left side of the gauge
30
var axisLeft = gauge.axis(0);
31
32
// configure minor ticks on the left axis
33
axisLeft.minorTicks(true)
34
axisLeft.minorTicks().stroke('#cecece');
35
36
// set the width of the left axis
37
axisLeft.width('0');
38
39
// set the offset of the left axis (as a percentage of the gauge width)
40
axisLeft.offset('-0.18%');
41
42
// bind the left axis to the Fahrenheit scale
43
axisLeft.scale(fScale);
44
45
// configure a Celsius scale
46
var cScale = anychart.scales.linear();
47
cScale.minimum(-40);
48
cScale.maximum(50);
49
cScale.ticks().interval(10);
50
cScale.minorTicks().interval(1);
51
52
// configure an axis on the right side of the gauge
53
var axisRight = gauge.axis(1);
54
axisRight.minorTicks(true);
55
axisRight.minorTicks().stroke('#cecece');
56
axisRight.width('0');
57
axisRight.offset('3.15%');
58
axisRight.orientation('right');
59
60
// bind the right axis to the Celsius scale
61
axisRight.scale(cScale);
62
63
// set the container id
64
gauge.container('container');
65
66
// initiate drawing the gauge
67
gauge.draw();
68
});