function formatQuarter(d)
{
if (d instanceof Date)
{
var q = d.getMonth();
q = parseInt(q / 3) + 1;
return 'Q' + q;
}
return '';
}
function formatHalfyear(d)
{
if (d instanceof Date)
{
var q = d.getMonth();
q = parseInt(q / 6) + 1;
return 'H' + q;
}
return '';
}
var formatDate = d3.time.format("%Y.%m.%d");
var formatDateNice = d3.time.format("%d.%m.%Y");
var node = document.createElement("STYLE")
var textnode = document.createTextNode('body { font-family: Arial,sans-serif; }\ntd { white-space: no-wrap; font-size: 12px}\nth { white-space: no-wrap; font-size: 12px}\ng.today line { stroke:red; }\n')
node.appendChild(textnode)
document.body.appendChild(node)
c3.generate({
data: chartData,
grid: {
y: {
show: true
},
x: {
show: true,
lines: [
{value: new Date(), text: 'today',class: 'today'}
]
}
},
zoom: {
enabled: true
},
tooltip: {
grouped: true,
contents: function (d, defaultTitleFormat, defaultValueFormat, color) {
return '<div id="superdupertt" style="border: thin solid black; background-color:white; padding: 3px; white-space: nowrap !important;">'+
'<table>'+
'<tr>'+
'<th colspan="2" style="border-bottom: black thin solid;">' + formatDateNice(d[0].x) + '</th>'+
'</tr>' +
chartData.custom.versions[formatDate(d[0].x)] +
'</table>'+
'</div>';
}
},
axis: {
x: {
type: 'timeseries',
label: {
text: chartData.custom.xLabel,
position: 'outer-left'
},
tick: {
format: eval(chartData.custom.xTickFormat),
culling: {
max: 25
},
fit: true,
multiline: false
}
},
y: {
label: 'Versions'
}
}
}) |