function formatTooltipAsHours(value, ratio, id, index)
{
return value.toFixed(2) + ' h';
}
function formatTooltipAsHoursWithDays(value, ratio, id, index)
{
var hours = parseInt(value);
var days = parseInt(hours / 24);
value = value - days * 24;
if (days > 0)
{
return days + 'd, ' + value.toFixed(2) + ' h';
}
return value.toFixed(2) + ' h';
}
var c3arg = {
onrendered: updateFrameHeight,
data: chartData,
axis: {
x: {
type: 'category', // this is needed to load string x value
label: {
text: chartData.custom.xLabel,
position: 'outer-left'
}
},
y: {
label: chartData.ytype
}
}
};
if (chartData.custom && chartData.custom.tooltip)
{
var tooltipFunction = eval(chartData.custom.tooltip);
c3arg.tooltip = {
format: {
value: tooltipFunction
}
};
}
c3.generate(c3arg); |