forked from MasterMaps/d3-slider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
executable file
·120 lines (88 loc) · 3.28 KB
/
index.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>D3.js Slider Examples</title>
<link rel="stylesheet" href="d3.slider.css" />
<style>
body {
font-family: Verdana,Arial,sans-serif;
}
h2 {
font-size: 1.2em;
margin: 60px 0 5px 0;
}
.wrapper {
width: 800px;
margin-left: auto;
margin-right: auto;
}
.wrapper > div {
margin: 35px 0;
}
#slider8 {
height: 250px;
}
#slider9 {
height: 250px;
}
</style>
</head>
<body>
<div class="wrapper">
<h1>D3.js Slider Examples</h1>
<p><a href="http://github.com/turban/d3.slider">http://github.com/turban/d3.slider</a></p>
<h2>Default slider</h2>
<code>d3.slider()</code>
<div id="slider1"></div>
<h2>Range Slider</h2>
<code>d3.slider().value([10, 25 ])</code>
<div id="slider2"></div>
<h2>Range Slider with event, values: <span id="slider3textmin">10</span>, <span id="slider3textmax">25</span></h2>
<code>d3.select('#slider3').call(d3.slider().axis(true).value( [ 10, 25 ] ).on("slide", function(evt, value) {<br>
d3.select('#slider3textmin').text(value[ 0 ]);<br />
d3.select('#slider3textmax').text(value[ 1 ]);<br>
})</code>
<div id="slider3"></div>
<h2>Slider with slide event: <span id="slider4text">0</span></h2>
<code>d3.slider().on("slide", function(evt, value) {<br>
d3.select('#slider3text').text(value);<br>
})</code>
<div id="slider4"></div>
<h2>Slider with default axis</h2>
<code>d3.slider().axis(true)</code>
<div id="slider5"></div>
<h2>Slider with custom axis</h2>
<code>d3.slider().axis( d3.svg.axis().orient("top").ticks(6) )</code>
<div id="slider6"></div>
<h2>Slider with min, max and step values</h2>
<code>d3.slider().axis(true).min(2000).max(2100).step(5)</code>
<div id="slider7"></div>
<h2>Vertical slider</h2>
<code>d3.slider().value(50).orientation("vertical")</code>
<div id="slider8"></div>
<h2>Vertical range slider</h2>
<code>d3.slider().value([10, 45 ]).orientation("vertical")</code>
<div id="slider9"></div>
</div>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="d3.slider.js"></script>
<script>
d3.select('#slider1').call(d3.slider());
d3.select('#slider2').call(d3.slider().value( [ 10, 25 ] ));
d3.select('#slider3').call(d3.slider().axis(true).value( [ 10, 25 ] ).on("slide", function(evt, value) {
d3.select('#slider3textmin').text(value[ 0 ]);
d3.select('#slider3textmax').text(value[ 1 ]);
}));
d3.select('#slider4').call(d3.slider().on("slide", function(evt, value) {
d3.select('#slider4text').text(value);
}));
d3.select('#slider5').call(d3.slider().axis(true));
var axis = d3.svg.axis().orient("top").ticks(4);
d3.select('#slider6').call(d3.slider().axis(axis));
d3.select('#slider7').call(d3.slider().axis(true).min(2000).max(2100).step(5));
d3.select('#slider8').call(d3.slider().value(50).orientation("vertical"));
d3.select('#slider9').call(d3.slider().value( [10, 30] ).orientation("vertical"));
</script>
</body>
</html>