Skip to content

Commit

Permalink
Merge branch 'master' into master-dist
Browse files Browse the repository at this point in the history
  • Loading branch information
patternfly-build committed Sep 29, 2016
2 parents d0ef6b8 + 7a0d91c commit 4f0180b
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 13 deletions.
3 changes: 2 additions & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/c3/0.4.11/c3.min.css" media="all">
<link rel="stylesheet" href="../dist/timeline.css">
<link rel="stylesheet" href="../demo/style.css">
<title>Patternfly timeline test page</title>
</head>

<body>
Expand Down Expand Up @@ -47,7 +48,7 @@
</div>
</div>
<div class="form-group">
<button class="btn btn-default" id="reset-button" type="button">reset zoom</button>
<button class="btn btn-default" id="reset-button" type="button">Reset Zoom</button>
</div>
</form>
</div>
Expand Down
21 changes: 18 additions & 3 deletions demo/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,29 @@ var timeline = d3.chart.timeline()
var table = '<table class="table table-striped table-bordered">';
if(el.hasOwnProperty("events")) {
table = table + '<thead>This is a group of ' + el.events.length + ' events starting on '+ el.date + '</thead><tbody>';
table = table + '<tr><th>Date</th><th>Event</th><th>Object</th></tr>'
table = table + '<tr><th>Date</th><th>Event</th><th>Object</th></tr>';
for (var i = 0; i < el.events.length; i++) {
table = table + '<tr><td>' + el.events[i].date + ' </td> ';
for (var j in el.events[i].details) {
table = table +'<td> ' + el.events[i].details[j] + ' </td> ';
}
table = table + '</tr>'
table = table + '</tr>';
}
table = table + '</tbody>';
} else {
table = table + 'Date: ' + el.date + '<br>';
for (var i in el.details) {
for (i in el.details) {
table = table + i.charAt(0).toUpperCase() + i.slice(1) + ': ' + el.details[i] + '<br>';
}
}
$('#legend').html(table);

});
if(countNames(data) <= 0) {
timeline.labelWidth(60);
}



var element = d3.select('#pf-timeline').append('div').datum(data.filter(function(eventGroup) {
return eventGroup.display === true;
Expand Down Expand Up @@ -107,6 +112,16 @@ $( document.body ).on( 'click', '.dropdown-menu li', function( event ) {

});

function countNames(data) {
var count = 0;
for (var i = 0; i < data.length; i++) {
if (data[i].name !== undefined && data[i].name !=='') {
count++;
}
}
return count;
}

function zoomFilter() {
var range = $('#range-dropdown').find('[data-bind="label"]' ).text(),
position = $('#position-dropdown').find('[data-bind="label"]' ).text(),
Expand Down
2 changes: 1 addition & 1 deletion dist/timeline.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/timeline.js.map

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ const config = {
[':%S', (d) => d.getSeconds()],
['%I:%M', (d) => d.getMinutes()],
['%I %p', (d) => d.getHours()],
['%a %d', (d) => d.getDay() && d.getDate() !== 1],
['%b %d', (d) => d.getDate() !== 1],
['%B', (d) => d.getMonth()],
['%b %d', (d) => d.getMonth() && d.getDate()],
['%b', (d) => d.getMonth()],
['%Y', () => true]
],
eventHover: null,
Expand Down Expand Up @@ -71,6 +70,6 @@ const config = {
eventGrouping: 60000, //one minute
};

config.dateFormat = config.locale ? config.locale.timeFormat('%x %I:%M %p') : d3.time.format('%x %I:%M %p');
config.dateFormat = config.locale ? config.locale.timeFormat('%a %x %I:%M %p') : d3.time.format('%a %x %I:%M %p');

module.exports = config;
4 changes: 3 additions & 1 deletion src/drawer/labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export default (container, scales, config) => data => {
}
const text = d => {
const count = countEvents(d.data);
if (d.name === undefined || d.name ===''){
return `${count} Events`;
}
return d.name + (count >= 0 ? ` (${count})` : '');
};

Expand All @@ -22,7 +25,6 @@ export default (container, scales, config) => data => {
labels.enter()
.append('text')
.classed('label', true)
// .attr('x', 180)
.attr('transform', (d, idx) => `translate(${config.labelWidth - 20} ${scales.y(idx) + (config.lineHeight/2)})`)
.attr('dominant-baseline', 'central')
.attr('text-anchor', 'end')
Expand Down
4 changes: 2 additions & 2 deletions src/drawer/marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default (gridContainer, stampContainer, scales, dimensions, dateFormat) =

var timeBox = stampContainer.append('rect')
.attr('height', '24')
.attr('width', '130')
.attr('width', '150')
.style('display', 'none');

var timeStamp = stampContainer.append('text')
Expand All @@ -37,7 +37,7 @@ export default (gridContainer, stampContainer, scales, dimensions, dateFormat) =
function moveMarker() {
var pos = d3.mouse(gridContainer[0][0])[0]
marker.attr('transform', `translate(${pos})`);
timeBox.attr('transform', `translate(${pos - 65}, -25)`);
timeBox.attr('transform', `translate(${pos - 75}, -25)`);
timeStamp.attr('transform', `translate(${pos}, -9)`)
.text(dateFormat(scales.x.invert(pos)));

Expand Down

0 comments on commit 4f0180b

Please sign in to comment.