-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbonus.js
62 lines (58 loc) · 1.85 KB
/
bonus.js
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
function guage(wash_freq){
// Enter a speed between 0 and 180
var level = wash_freq*20;
// Trig to calc meter point
var degrees = 180 - level,
radius = .5;
var radians = degrees * Math.PI / 180;
var x = radius * Math.cos(radians);
var y = radius * Math.sin(radians);
var path1 = (degrees < 45 || degrees > 135) ? 'M -0.0 -0.025 L 0.0 0.025 L ' : 'M -0.025 -0.0 L 0.025 0.0 L ';
// Path: may have to change to create a better triangle
var mainPath = path1,
pathX = String(x),
space = ' ',
pathY = String(y),
pathEnd = ' Z';
var path = mainPath.concat(pathX,space,pathY,pathEnd);
var data = [{ type: 'scatter',
x: [0], y:[0],
marker: {size: 14, color:'850000'},
showlegend: false,
name: ' Wash per Week',
text: wash_freq,
hoverinfo: 'text+name'},
{ values: [1,1,1,1,1,1,1,1,1,9],
rotation: 90,
text: ['8-9', '7-8', '6-7', '5-6', '4-5', '3-4', '2-3', '1-2', '0-1', ''],
textinfo: 'text',
textposition:'inside',
marker: {colors:['#83b588', '#88bc8d', '#8ac085', '#b7cd8f', '#d5e59a', '#e5e8b1', '#e9e7c9',
'#f4f1e4', '#f8f3ec', '#ffffff']},
hoverinfo: 'text',
hole: .5,
type: 'pie',
showlegend: false
}];
var layout = {
title: '<b>Belly Button Wash Frequency</b> <br> Scrubs per Week',
"titlefont": {
"size": 16,
},
shapes:[{
type: 'path',
path: path,
fillcolor: '850000',
line: {
color: '850000'
}
}],
height: 400,
width: 400,
xaxis: {zeroline:false, showticklabels:false,
showgrid: false, range: [-1, 1]},
yaxis: {zeroline:false, showticklabels:false,
showgrid: false, range: [-1, 1]}
};
Plotly.newPlot('gauge', data, layout);
};