function formatTooltipAsHours(value, ratio, id, index)
{
return value.toFixed(2) + ' h';
}
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 c3arg = {
onrendered: updateFrameHeight,
data: chartData,
grid: {
y: {
show: true
},
x: {
show: true
}
},
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: chartData.ytype
}
}
};
if (chartData.custom && chartData.custom.tooltip)
{
var tooltipFunction = eval(chartData.custom.tooltip);
c3arg.tooltip = {
format: {
value: tooltipFunction
}
};
}
if ( chartData.custom && chartData.custom.gauge_max)
{
c3arg.gauge = {
max: parseFloat(chartData.custom.gauge_max)
};
}
c3.generate(c3arg); |