@ -1909,8 +1909,12 @@
function parseDate ( date ) {
var parsedDate ;
if ( ! date ) { throw Error ( date + " can not be parsed as d3.time with format " + _ _data _x _format + ". Maybe 'x' of this data is not defined. See data.x or data.xs option." ) ; }
parsedDate = _ _data _x _format ? d3 . time . format ( _ _data _x _format ) . parse ( date ) : new Date ( date ) ;
if ( ! parsedDate ) { throw Error ( "Failed to parse '" + date + "' with format " + _ _data _x _format ) ; }
try {
parsedDate = _ _data _x _format ? d3 . time . format ( _ _data _x _format ) . parse ( date ) : new Date ( date ) ;
} catch ( e ) {
parsedDate = undefined ;
}
if ( ! parsedDate ) { window . console . error ( "Failed to parse x '" + date + "' to Date with format " + _ _data _x _format ) ; }
return parsedDate ;
}
@ -2837,7 +2841,7 @@
var hideAxis = hasArcType ( c3 . data . targets ) ;
var drawBar , drawBarOnSub , xForText , yForText ;
var duration , durationForExit , durationForAxis ;
var targetsToShow = filterTargetsToShow ( c3 . data . targets ) , uniqueXs ;
var targetsToShow = filterTargetsToShow ( c3 . data . targets ) , uniqueXs , i , intervalForCulling ;
// abort if no targets to show
if ( targetsToShow . length === 0 ) {
@ -2879,10 +2883,19 @@
y2 . domain ( getYDomain ( targetsToShow , 'y2' ) ) ;
// Fix tick position to data
if ( _ _axis _x _tick _fit ) {
if ( _ _axis _x _tick _fit ) { // MEMO: supposed to be non categorized axis
uniqueXs = mapTargetsToUniqueXs ( targetsToShow ) ;
xAxis . tickValues ( uniqueXs ) ;
subXAxis . tickValues ( uniqueXs ) ;
// compute interval for culling if needed
if ( _ _axis _x _tick _culling ) {
for ( i = 1 ; i < uniqueXs . length ; i ++ ) {
if ( uniqueXs . length / i < _ _axis _x _tick _count ) {
intervalForCulling = i ;
break ;
}
}
}
}
// axis
@ -2890,6 +2903,13 @@
main . select ( '.' + CLASS . axisY ) . style ( "opacity" , hideAxis ? 0 : 1 ) . transition ( ) . duration ( durationForAxis ) . call ( yAxis ) ;
main . select ( '.' + CLASS . axisY2 ) . style ( "opacity" , hideAxis ? 0 : 1 ) . transition ( ) . duration ( durationForAxis ) . call ( yAxis2 ) ;
// show/hide if manual culling needed
if ( _ _axis _x _tick _fit && _ _axis _x _tick _culling ) {
d3 . selectAll ( '.' + CLASS . axisX + ' .tick text' ) . each ( function ( e , i ) {
d3 . select ( this ) . style ( 'display' , i % intervalForCulling ? 'none' : 'block' ) ;
} ) ;
}
// setup drawer - MEMO: these must be called after axis updated
drawBar = generateDrawBar ( barIndices ) ;
xForText = generateXYForText ( barIndices , true ) ;