-
Notifications
You must be signed in to change notification settings - Fork 117
/
index.html
executable file
·139 lines (101 loc) · 4.48 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!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>
<h2>Slider with dates</h2>
<code>d3.slider().scale(d3.time.scale().domain([new Date(1984,1,1), new Date(2014,1,1)])).axis(d3.svg.axis())</code>
<div id="slider10"></div>
<h2>Slider with snapping to ticks</h2>
<code>d3.slider().scale(d3.time.scale().domain([new Date(1984,1,1), new Date(2014,1,1)])).axis( d3.svg.axis() ).snap(true).value(new Date(2000,1,1))</code>
<div id="slider11"></div>
<h2>Slider with ordinal scales (categories)</h2>
<code>d3.slider().scale(d3.scale.ordinal().domain(["Gecko", "Webkit", "Blink", "Trident"]).rangePoints([0, 1], 0.5)).axis( d3.svg.axis() ).snap(true).value("Gecko")</code>
<div id="slider12"></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"));
d3.select('#slider10').call(d3.slider().scale(d3.time.scale().domain([new Date(1984,1,1), new Date(2014,1,1)])).axis(d3.svg.axis()));
d3.select('#slider11').call(d3.slider().scale(d3.time.scale().domain([new Date(1984,1,1), new Date(2014,1,1)])).axis(d3.svg.axis()).snap(true).value(new Date(2000,1,1)));
essai = d3.slider().scale(d3.scale.ordinal().domain(["Gecko", "Webkit", "Blink", "Trident"]).rangePoints([0, 1], 0.5)).axis(d3.svg.axis()).snap(true).value("Gecko");
d3.select('#slider12').call(essai);
</script>
</body>
</html>