Skip to content

Commit bce5fc2

Browse files
committed
Experiment with timeline on the page.
1 parent 0ed7815 commit bce5fc2

File tree

5 files changed

+89
-0
lines changed

5 files changed

+89
-0
lines changed

_posts/2009-02-02-timeline.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
bg: 'white'
3+
fa-icon: calendar
4+
---
5+
6+
# Projects Timeline
7+
8+
<div id="visualization"></div>
9+

_posts/2010-01-04-sign.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: sign
33
fa-icon: pencil
4+
bg: lightgray
45
---
56

67
# Sign the pledge

combo.css

+14
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,17 @@
33
{% include css/base.css %}
44
{% include css/skeleton.css %}
55
{% include css/main.css %}
6+
7+
.vis-item.py2 {
8+
background-color: greenyellow;
9+
border-color: green;
10+
}
11+
12+
/* create a custom sized dot at the bottom of the red item */
13+
.vis-item.red {
14+
background-color: red;
15+
border-color: darkred;
16+
color: white;
17+
font-family: monospace;
18+
box-shadow: 0 0 10px gray;
19+
}

index.html

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
<link rel="stylesheet" href="combo.css">
1212
<link href='http://fonts.googleapis.com/css?family=Raleway:400,300,700' rel='stylesheet' type='text/css'>
1313
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
14+
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/vis/4.16.1/vis.min.css">
15+
<script src="//cdnjs.cloudflare.com/ajax/libs/vis/4.16.1/vis.min.js"></script>
1416
{% if site.favicon %}<link rel="shortcut icon" href="{{ site.favicon }}" type="image/x-icon">{% endif %}
1517
{% if site.touch_icon %}<link rel="apple-touch-icon" href="{{ site.touch_icon }}">{% endif %}
1618
</head>

site.js

+63
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,68 @@ $(document).ready(function (){
9191
}
9292
});
9393

94+
// DOM element where the Timeline will be attached
95+
var container = document.getElementById('visualization');
96+
97+
var data = {
98+
'cpython':[
99+
{content:'Remaining Python 2.7 support', start: Date.now(), end: '2020-01-01'},
100+
],
101+
'ipython':[
102+
{content: 'ipython 5.x LTS', start: '2016-06-01', end:'2019-06-01', py2:true},
103+
{content: 'ipython 6.x', start: '2017-01-01', end:'2018-01-01'},
104+
{content: 'ipython 7.x', start: '2018-01-01', end:'2019-06-12'},
105+
{content: 'ipython 8.x', start: '2019-06-12', end:'2020-06-01'},
106+
],
107+
'matplotlib':[
108+
{content: 'matplotlib 2.x', start: '2015-06-01', end:'2018-06-01', py2:true},
109+
{content: 'matplotlib 3.x', start: '2018-6-12', end:'2019-12-01'},
110+
],
111+
'scikit-bio':[
112+
{content: '0.18', start: '2016-05-01', end:'2016-11-01', py2:true},
113+
{content: '0.19', start: '2016-11-02', end:'2017-12-01'},
114+
]
115+
116+
117+
}
118+
119+
// Create a DataSet (allows two way data-binding)
120+
var items = new vis.DataSet([
121+
]);
122+
123+
124+
125+
var groups = new vis.DataSet();
126+
g=0;
127+
i=0;
128+
for (var gname in data) {
129+
g++;
130+
groups.add({id: g, content: gname});
131+
gr = data[gname];
132+
for(var k in gr){
133+
i++;
134+
gr[k].id = i;
135+
gr[k].group = g;
136+
if(gr[k].py2) gr[k].className ='py2'
137+
items.add(gr[k])
138+
}
139+
}
140+
141+
// Configuration for the Timeline
142+
var options = {};
143+
144+
var options = {
145+
groupOrder: 'group' // groupOrder can be a property name or a sorting function
146+
};
147+
148+
// Create a Timeline
149+
var timeline = new vis.Timeline(container, items, options);
150+
timeline.setGroups(groups);
151+
timeline.setItems(items);
152+
timeline.addCustomTime(Date.parse('2020-01-01'))
153+
window.groups = groups;
154+
window.items = items;
155+
window.timeline = timeline;
156+
94157
});
95158

0 commit comments

Comments
 (0)