@ -115,7 +115,7 @@
checkConfig ( 'data' , 'data is required in config' ) ;
var _ _data _x = getConfig ( [ 'data' , 'x' ] ) ,
_ _data _xs = getConfig ( [ 'data' , 'xs' ] ) ,
_ _data _xs = getConfig ( [ 'data' , 'xs' ] , { } ) ,
_ _data _x _format = getConfig ( [ 'data' , 'x_format' ] , '%Y-%m-%d' ) ,
_ _data _id _converter = getConfig ( [ 'data' , 'id_converter' ] , function ( id ) { return id ; } ) ,
_ _data _names = getConfig ( [ 'data' , 'names' ] , { } ) ,
@ -142,7 +142,7 @@
_ _subchart _size _height = _ _subchart _show ? getConfig ( [ 'subchart' , 'size' , 'height' ] , 60 ) : 0 ;
// color
var _ _color _pattern = getConfig ( [ 'color' , 'pattern' ] ) ;
var _ _color _pattern = getConfig ( [ 'color' , 'pattern' ] , [ ] ) ;
// legend
var _ _legend _show = getConfig ( [ 'legend' , 'show' ] , true ) ,
@ -258,7 +258,7 @@
var isTimeSeries = ( _ _axis _x _type === 'timeseries' ) ,
isCategorized = ( _ _axis _x _type === 'categorized' ) ,
isCustomX = ! isTimeSeries && ( _ _data _x || _ _data _xs ) ;
isCustomX = ! isTimeSeries && ( _ _data _x || ! isEmpty ( _ _data _xs ) ) ;
var dragStart = null , dragging = false , cancelClick = false ;
@ -1190,13 +1190,13 @@
//-- Data --//
function isX ( key ) {
return ( _ _data _x && key === _ _data _x ) || ( _ _data _xs && hasValue ( _ _data _xs , key ) ) ;
return ( _ _data _x && key === _ _data _x ) || ( ! isEmpty ( _ _data _xs ) && hasValue ( _ _data _xs , key ) ) ;
}
function isNotX ( key ) {
return ! isX ( key ) ;
}
function getXKey ( id ) {
return _ _data _x ? _ _data _x : _ _data _xs ? _ _data _xs [ id ] : null ;
return _ _data _x ? _ _data _x : ! isEmpty ( _ _data _xs ) ? _ _data _xs [ id ] : null ;
}
function getXValue ( id , i ) {
return id in c3 . data . x && c3 . data . x [ id ] && c3 . data . x [ id ] [ i ] ? c3 . data . x [ id ] [ i ] : i ;
@ -1784,7 +1784,7 @@
function generateColor ( _colors , _pattern ) {
var ids = [ ] ,
colors = _colors ,
pattern = _pattern ? _pattern : [ '#1f77b4' , '#ff7f0e' , '#2ca02c' , '#d62728' , '#9467bd' , '#8c564b' , '#e377c2' , '#7f7f7f' , '#bcbd22' , '#17becf' ] ; //same as d3.scale.category10()
pattern = ! isEmpty ( _pattern ) ? _pattern : [ '#1f77b4' , '#ff7f0e' , '#2ca02c' , '#d62728' , '#9467bd' , '#8c564b' , '#e377c2' , '#7f7f7f' , '#bcbd22' , '#17becf' ] ; //same as d3.scale.category10()
return function ( id ) {
// if specified, choose that color
@ -1829,6 +1829,9 @@
return false ;
}
function isEmpty ( dict ) {
return Object . keys ( dict ) . length === 0 ;
}
function hasValue ( dict , value ) {
var found = false ;
Object . keys ( dict ) . forEach ( function ( key ) {
@ -2341,7 +2344,7 @@
if ( _ _zoom _enabled ) { // TODO: __zoom_privileged here?
// if zoom privileged, insert rect to forefront
main . insert ( 'rect' , _ _zoom _privileged ? null : 'g.grid ' )
main . insert ( 'rect' , _ _zoom _privileged ? null : 'g.' + CLASS . grid )
. attr ( 'class' , CLASS . zoomRect )
. attr ( 'width' , width )
. attr ( 'height' , height )
@ -3012,7 +3015,7 @@
. attr ( "cy" , _ _axis _rotated ? circleX : circleY ) ;
// rect for mouseover
if ( _ _data _xs ) {
if ( ! isEmpty ( _ _data _xs ) ) {
eventRectUpdate = main . select ( '.' + CLASS . eventRects ) . selectAll ( '.' + CLASS . eventRect )
. data ( [ 0 ] ) ;
// enter : only one rect will be added