@ -129,6 +129,7 @@
_ _data _labels = getConfig ( [ 'data' , 'labels' ] , { } ) ,
_ _data _order = getConfig ( [ 'data' , 'order' ] ) ,
_ _data _regions = getConfig ( [ 'data' , 'regions' ] , { } ) ,
_ _data _color = getConfig ( [ 'data' , 'color' ] ) ,
_ _data _colors = getConfig ( [ 'data' , 'colors' ] , { } ) ,
_ _data _selection _enabled = getConfig ( [ 'data' , 'selection' , 'enabled' ] , false ) ,
_ _data _selection _grouped = getConfig ( [ 'data' , 'selection' , 'grouped' ] , false ) ,
@ -273,7 +274,8 @@
var dragStart = null , dragging = false , cancelClick = false , mouseover = false ;
var color = generateColor ( _ _data _colors , _ _color _pattern ) ;
var defaultColorPattern = [ '#1f77b4' , '#ff7f0e' , '#2ca02c' , '#d62728' , '#9467bd' , '#8c564b' , '#e377c2' , '#7f7f7f' , '#bcbd22' , '#17becf' ] , //same as d3.scale.category10()
color = generateColor ( _ _data _colors , notEmpty ( _ _color _pattern ) ? _ _color _pattern : defaultColorPattern , _ _data _color ) ;
var defaultTimeFormat = ( function ( ) {
var formats = [
@ -1920,25 +1922,26 @@
//-- Color --//
function generateColor ( _colors , _pattern ) {
var ids = [ ] ,
colors = _colors ,
pattern = notEmpty ( _pattern ) ? _pattern : [ '#1f77b4' , '#ff7f0e' , '#2ca02c' , '#d62728' , '#9467bd' , '#8c564b' , '#e377c2' , '#7f7f7f' , '#bcbd22' , '#17becf' ] ; //same as d3.scale.category10()
function generateColor ( colors , pattern , callback ) {
var ids = [ ] ;
return function ( d ) {
var id = d . id || d ;
var id = d . id || d , color ;
// if callback function is provided
if ( colors [ id ] instanceof Function ) { return colors [ id ] ( d ) ; }
if ( colors [ id ] instanceof Function ) {
color = colors [ id ] ( d ) ;
}
// if specified, choose that color
if ( id in colors ) { return colors [ id ] ; }
else if ( id in colors ) {
color = colors [ id ] ;
}
// if not specified, choose from pattern
if ( ids . indexOf ( id ) === - 1 ) {
ids . push ( id ) ;
else {
if ( ids . indexOf ( id ) < 0 ) { ids . push ( id ) ; }
color = pattern [ ids . indexOf ( id ) % pattern . length ] ;
}
return pattern [ ids . indexOf ( id ) % pattern . length ] ;
return callback instanceof Function ? callback ( color , d ) : color ;
} ;
}