forked from flrs/visavail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_daterange.htm
92 lines (79 loc) · 2.87 KB
/
example_daterange.htm
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Visavail.js Example: DateRange</title>
<!-- Visavail.js style -->
<link href='https://fonts.googleapis.com/css?family=Muli' rel='stylesheet' type='text/css'>
<link href='../visavail/css/visavail.css' rel='stylesheet' type='text/css'>
<!-- font-awesome -->
<script src="https://use.fontawesome.com/8321cacbf6.js"></script>
<!--
Note: This should be replaced by
<link href='./vendors/font-awesome/css/font-awesome.min.css' rel='stylesheet' type='text/css'>
when implemented in your project.
-->
<!-- body style for this example -->
<style>
body {
font-family: "Muli", "Helvetica", Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Visavail.js DateRange Example</h1>
<p>This example demonstrates the use of <a href="http://www.github.com/flrs/visavail"
target="_blank">Visavail.js</a> for displaying a fixed period of time.
While your data might contain data outside of a given date-range, it shows only the specified period.</p>
<p id="example"><!-- Visavail.js chart will be placed here --></p>
<!-- Visavail.js scripts -->
<script src="../vendors/moment/moment-with-locales.min.js" type="text/javascript"></script>
<script>
moment.locale('en');
</script>
<script src="../vendors/d3/d3.min.js" charset="utf-8"></script>
<script type="text/javascript">
var dataset = [{
"measure": "Balance Sheet",
"data": [
["2015-03-31", 0, "2015-04-15"],
["2015-06-30", 1, "2015-07-15"],
["2015-09-30", 1, "2015-10-15"],
["2015-12-31", 1, "2016-01-15"],
["2016-01-15", 1, "2016-01-22"],
["2016-03-31", 1, "2016-04-15"],
["2016-06-30", 1, "2016-07-15"],
["2016-09-30", 1, "2016-10-15"],
["2016-12-25", 1, "2017-01-15"],
["2017-03-31", 0, "2017-04-15"],
["2017-06-30", 1, "2017-07-15"],
["2017-09-30", 1, "2017-10-15"],
["2017-12-31", 1, "2018-01-15"],
["2018-03-31", 1, "2018-04-15"],
["2018-06-30", 1, "2018-07-15"],
["2018-09-30", 1, "2018-10-15"]
]
}, {
"measure": "Annual Report",
"data": [
["2015-01-01", 0, "2015-06-01"],
["2016-01-01", 1, "2016-03-15"],
["2017-01-01", 1, "2017-10-10"],
["2018-01-01", 1, "2018-02-20"]
]
}];
</script>
<script src="../visavail/js/visavail.js"></script>
<script>
// draw Visavail.js chart
var parseDate = d3.time.format('%Y-%m-%d');
var chart = visavailChart().width(800).displayDateRange([
parseDate.parse('2016-01-01'),
parseDate.parse('2016-12-31')
])
d3.select("#example")
.datum(dataset)
.call(chart);
</script>
</body>
</html>