forked from almende/vis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Functional, not bug-free version which works with locale aware week n…
…umbers.
- Loading branch information
Showing
3 changed files
with
84 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,70 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<title>Timeline | Grid styling</title> | ||
|
||
<script src="../../../dist/vis.js"></script> | ||
<link href="../../../dist/vis-timeline-graph2d.min.css" rel="stylesheet" type="text/css" /> | ||
|
||
<style type="text/css"> | ||
body, html { | ||
font-family: sans-serif; | ||
} | ||
|
||
/* alternating column backgrounds */ | ||
.vis-time-axis .vis-grid.vis-odd { | ||
background: #f5f5f5; | ||
} | ||
|
||
/* gray background in weekends, white text color */ | ||
.vis-time-axis .vis-grid.vis-saturday, | ||
.vis-time-axis .vis-grid.vis-sunday { | ||
background: gray; | ||
} | ||
.vis-time-axis .vis-text.vis-saturday, | ||
.vis-time-axis .vis-text.vis-sunday { | ||
color: white; | ||
} | ||
</style> | ||
|
||
<title>Timeline | Grid styling</title> | ||
|
||
<script src="../../../dist/vis.js"></script> | ||
<link href="../../../dist/vis-timeline-graph2d.min.css" rel="stylesheet" type="text/css"/> | ||
|
||
<style type="text/css"> | ||
body, html { | ||
font-family: sans-serif; | ||
} | ||
|
||
/* alternating column backgrounds */ | ||
.vis-time-axis .vis-grid.vis-odd { | ||
background: #f5f5f5; | ||
} | ||
|
||
/* gray background in weekends, white text color */ | ||
.vis-time-axis .vis-grid.vis-saturday, | ||
.vis-time-axis .vis-grid.vis-sunday { | ||
background: gray; | ||
} | ||
|
||
.vis-time-axis .vis-text.vis-saturday, | ||
.vis-time-axis .vis-text.vis-sunday { | ||
color: white; | ||
} | ||
</style> | ||
|
||
</head> | ||
<body> | ||
<div id="visualization"></div> | ||
|
||
<script type="text/javascript"> | ||
// DOM element where the Timeline will be attached | ||
var container = document.getElementById('visualization'); | ||
|
||
// Create a DataSet (allows two way data-binding) | ||
var items = new vis.DataSet([ | ||
{id: 1, content: 'ISO week 10 in 2017', start: '2017-03-06', end: '2017-03-12'}, | ||
{id: 2, content: 'ISO week 11 in 2017', start: '2017-03-13', end: '2017-03-19'}, | ||
{id: 3, content: 'ISO week 12 in 2017', start: '2017-03-20', end: '2017-03-26'}, | ||
{id: 4, content: 'ISO week 13 in 2017', start: '2017-03-27', end: '2017-04-02'}, | ||
{id: 5, content: 'US week 10 in 2017', start: '2017-03-05', end: '2017-03-11'}, | ||
{id: 6, content: 'US week 11 in 2017', start: '2017-03-12', end: '2017-03-18'}, | ||
{id: 7, content: 'US week 12 in 2017', start: '2017-03-19', end: '2017-03-25'}, | ||
{id: 8, content: 'US week 13 in 2017', start: '2017-03-26', end: '2017-04-02'} | ||
]); | ||
|
||
// Configuration for the Timeline | ||
var options = {timeAxis: {scale: 'week', step: 1}}; | ||
|
||
// Create a Timeline | ||
var timeline = new vis.Timeline(container, items, options); | ||
// DOM element where the Timeline will be attached | ||
var container = document.getElementById('visualization'); | ||
|
||
// just a group for the effects | ||
var groups = new vis.DataSet(); | ||
groups.add([{id: 1, content: "ISO Weeks"}, {id: 2, content: "US Weeks"}]); | ||
|
||
// Create a DataSet (allows two way data-binding) | ||
var items = new vis.DataSet([ | ||
{id: 1, group: 1, content: 'ISO week 51 in 2016', start: '2016-12-19 00:00:00', end: '2016-12-25 23:59:59'}, | ||
{id: 2, group: 1, content: 'ISO week 52 in 2016', start: '2016-12-26 00:00:00', end: '2017-01-01 23:59:59'}, | ||
{id: 3, group: 1, content: 'ISO week 01 in 2017', start: '2017-01-02 00:00:00', end: '2017-01-08 23:59:59'}, | ||
{id: 4, group: 1, content: 'ISO week 02 in 2017', start: '2017-01-09 00:00:00', end: '2017-01-15 23:59:59'}, | ||
{id: 5, group: 2, content: 'US week 52 in 2017', start: '2016-12-18 00:00:00', end: '2016-12-24 23:59:59'}, | ||
{id: 6, group: 2, content: 'US week 53 in 2017', start: '2016-12-25 00:00:00', end: '2016-12-31 23:59:59'}, | ||
{id: 7, group: 2, content: 'US week 01 in 2017', start: '2017-01-01 00:00:00', end: '2017-01-07 23:59:59'}, | ||
{id: 8, group: 2, content: 'US week 02 in 2017', start: '2017-01-08 00:00:00', end: '2017-01-14 23:59:59'}, | ||
{id: 9, group: 1, content: 'ISO week 10 in 2017', start: '2017-03-06 00:00:00', end: '2017-03-12 23:59:59'}, | ||
{id: 10, group: 1, content: 'ISO week 11 in 2017', start: '2017-03-13 00:00:00', end: '2017-03-19 23:59:59'}, | ||
{id: 11, group: 1, content: 'ISO week 12 in 2017', start: '2017-03-20 00:00:00', end: '2017-03-26 23:59:59'}, | ||
{id: 12, group: 1, content: 'ISO week 13 in 2017', start: '2017-03-27 00:00:00', end: '2017-04-02 23:59:59'}, | ||
{id: 13, group: 2, content: 'US week 10 in 2017', start: '2017-03-05 00:00:00', end: '2017-03-11 23:59:59'}, | ||
{id: 14, group: 2, content: 'US week 11 in 2017', start: '2017-03-12 00:00:00', end: '2017-03-18 23:59:59'}, | ||
{id: 15, group: 2, content: 'US week 12 in 2017', start: '2017-03-19 00:00:00', end: '2017-03-25 23:59:59'}, | ||
{id: 16, group: 2, content: 'US week 13 in 2017', start: '2017-03-26 00:00:00', end: '2017-04-01 23:59:59'} | ||
]); | ||
|
||
// Configuration for the Timeline | ||
var options = {timeAxis: {scale: 'week', step: 1}}; | ||
|
||
// Create a Timeline | ||
var timeline = new vis.Timeline(container, items, options); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There's maybe a small problem here, with vis-even/vis-odd classes, or maybe not. :)
In the last/first week of the year, you might end up with 2 columns one after another with the same class.. not exactly sure how to solve it though.