@ -78,9 +78,11 @@
}
function getConfig ( keys , defaultValue ) {
var target = config ;
for ( var i = 0 ; i < keys . length ; i ++ ) {
if ( ! ( keys [ i ] in target ) ) { return defaultValue ; }
var i , target = config , isDefaultObject = typeof defaultValue === 'object' ;
for ( i = 0 ; i < keys . length ; i ++ ) {
if ( ! ( keys [ i ] in target ) || ( i === keys . length - 1 && ! isDefaultObject && typeof target [ keys [ i ] ] === 'object' ) ) {
return defaultValue ;
}
target = target [ keys [ i ] ] ;
}
return target ;
@ -89,14 +91,14 @@
// bindto - id to bind the chart
var _ _bindto = getConfig ( [ 'bindto' ] , '#chart' ) ;
var _ _size _width = getConfig ( [ 'size' , 'width' ] , null ) ,
_ _size _height = getConfig ( [ 'size' , 'height' ] , null ) ;
var _ _size _width = getConfig ( [ 'size' , 'width' ] ) ,
_ _size _height = getConfig ( [ 'size' , 'height' ] ) ;
var _ _padding _left = getConfig ( [ 'padding' , 'left' ] , null ) ,
_ _padding _right = getConfig ( [ 'padding' , 'right' ] , null ) ;
var _ _padding _left = getConfig ( [ 'padding' , 'left' ] ) ,
_ _padding _right = getConfig ( [ 'padding' , 'right' ] ) ;
var _ _zoom _enabled = getConfig ( [ 'zoom' , 'enabled' ] , false ) ,
_ _zoom _extent = getConfig ( [ 'zoom' , 'extent' ] , null ) ,
_ _zoom _extent = getConfig ( [ 'zoom' , 'extent' ] ) ,
_ _zoom _privileged = getConfig ( [ 'zoom' , 'privileged' ] , false ) ;
var _ _onenter = getConfig ( [ 'onenter' ] , function ( ) { } ) ,
@ -107,17 +109,17 @@
// data - data configuration
checkConfig ( 'data' , 'data is required in config' ) ;
var _ _data _x = getConfig ( [ 'data' , 'x' ] , null ) ,
_ _data _xs = getConfig ( [ 'data' , 'xs' ] , null ) ,
var _ _data _x = getConfig ( [ 'data' , 'x' ] ) ,
_ _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' ] , { } ) ,
_ _data _groups = getConfig ( [ 'data' , 'groups' ] , [ ] ) ,
_ _data _axes = getConfig ( [ 'data' , 'axes' ] , { } ) ,
_ _data _type = getConfig ( [ 'data' , 'type' ] , null ) ,
_ _data _type = getConfig ( [ 'data' , 'type' ] ) ,
_ _data _types = getConfig ( [ 'data' , 'types' ] , { } ) ,
_ _data _labels = getConfig ( [ 'data' , 'labels' ] , { } ) ,
_ _data _order = getConfig ( [ 'data' , 'order' ] , null ) ,
_ _data _order = getConfig ( [ 'data' , 'order' ] ) ,
_ _data _regions = getConfig ( [ 'data' , 'regions' ] , { } ) ,
_ _data _colors = getConfig ( [ 'data' , 'colors' ] , { } ) ,
_ _data _selection _enabled = getConfig ( [ 'data' , 'selection' , 'enabled' ] , false ) ,
@ -135,7 +137,7 @@
_ _subchart _size _height = _ _subchart _show ? getConfig ( [ 'subchart' , 'size' , 'height' ] , 60 ) : 0 ;
// color
var _ _color _pattern = getConfig ( [ 'color' , 'pattern' ] , null ) ;
var _ _color _pattern = getConfig ( [ 'color' , 'pattern' ] ) ;
// legend
var _ _legend _show = getConfig ( [ 'legend' , 'show' ] , true ) ,
@ -148,40 +150,40 @@
_ _axis _x _type = getConfig ( [ 'axis' , 'x' , 'type' ] , 'indexed' ) ,
_ _axis _x _categories = getConfig ( [ 'axis' , 'x' , 'categories' ] , [ ] ) ,
_ _axis _x _tick _centered = getConfig ( [ 'axis' , 'x' , 'tick' , 'centered' ] , false ) ,
_ _axis _x _tick _format = getConfig ( [ 'axis' , 'x' , 'tick' , 'format' ] , null ) ,
_ _axis _x _tick _format = getConfig ( [ 'axis' , 'x' , 'tick' , 'format' ] ) ,
_ _axis _x _tick _culling = getConfig ( [ 'axis' , 'x' , 'tick' , 'culling' ] , _ _axis _x _type === 'categorized' ? false : true ) ,
_ _axis _x _tick _count = getConfig ( [ 'axis' , 'x' , 'tick' , 'count' ] , 10 ) ,
_ _axis _x _max = getConfig ( [ 'axis' , 'x' , 'max' ] , null ) ,
_ _axis _x _min = getConfig ( [ 'axis' , 'x' , 'min' ] , null ) ,
_ _axis _x _default = getConfig ( [ 'axis' , 'x' , 'default' ] , null ) ,
_ _axis _x _label = getConfig ( [ 'axis' , 'x' , 'label' ] , null ) ,
_ _axis _x _max = getConfig ( [ 'axis' , 'x' , 'max' ] ) ,
_ _axis _x _min = getConfig ( [ 'axis' , 'x' , 'min' ] ) ,
_ _axis _x _default = getConfig ( [ 'axis' , 'x' , 'default' ] ) ,
_ _axis _x _label = getConfig ( [ 'axis' , 'x' , 'label' ] , { } ) ,
_ _axis _y _show = getConfig ( [ 'axis' , 'y' , 'show' ] , true ) ,
_ _axis _y _max = getConfig ( [ 'axis' , 'y' , 'max' ] , null ) ,
_ _axis _y _min = getConfig ( [ 'axis' , 'y' , 'min' ] , null ) ,
_ _axis _y _center = getConfig ( [ 'axis' , 'y' , 'center' ] , null ) ,
_ _axis _y _label = getConfig ( [ 'axis' , 'y' , 'label' ] , null ) ,
_ _axis _y _max = getConfig ( [ 'axis' , 'y' , 'max' ] ) ,
_ _axis _y _min = getConfig ( [ 'axis' , 'y' , 'min' ] ) ,
_ _axis _y _center = getConfig ( [ 'axis' , 'y' , 'center' ] ) ,
_ _axis _y _label = getConfig ( [ 'axis' , 'y' , 'label' ] , { } ) ,
_ _axis _y _inner = getConfig ( [ 'axis' , 'y' , 'inner' ] , false ) ,
_ _axis _y _tick _format = getConfig ( [ 'axis' , 'y' , 'tick' , 'format' ] , null ) ,
_ _axis _y _padding = getConfig ( [ 'axis' , 'y' , 'padding' ] , null ) ,
_ _axis _y _tick _format = getConfig ( [ 'axis' , 'y' , 'tick' , 'format' ] ) ,
_ _axis _y _padding = getConfig ( [ 'axis' , 'y' , 'padding' ] ) ,
_ _axis _y _ticks = getConfig ( [ 'axis' , 'y' , 'ticks' ] , 10 ) ,
_ _axis _y2 _show = getConfig ( [ 'axis' , 'y2' , 'show' ] , false ) ,
_ _axis _y2 _max = getConfig ( [ 'axis' , 'y2' , 'max' ] , null ) ,
_ _axis _y2 _min = getConfig ( [ 'axis' , 'y2' , 'min' ] , null ) ,
_ _axis _y2 _center = getConfig ( [ 'axis' , 'y2' , 'center' ] , null ) ,
_ _axis _y2 _label = getConfig ( [ 'axis' , 'y2' , 'label' ] , null ) ,
_ _axis _y2 _max = getConfig ( [ 'axis' , 'y2' , 'max' ] ) ,
_ _axis _y2 _min = getConfig ( [ 'axis' , 'y2' , 'min' ] ) ,
_ _axis _y2 _center = getConfig ( [ 'axis' , 'y2' , 'center' ] ) ,
_ _axis _y2 _label = getConfig ( [ 'axis' , 'y2' , 'label' ] ) ,
_ _axis _y2 _inner = getConfig ( [ 'axis' , 'y2' , 'inner' ] , false ) ,
_ _axis _y2 _tick _format = getConfig ( [ 'axis' , 'y2' , 'tick' , 'format' ] , null ) ,
_ _axis _y2 _padding = getConfig ( [ 'axis' , 'y2' , 'padding' ] , null ) ,
_ _axis _y2 _tick _format = getConfig ( [ 'axis' , 'y2' , 'tick' , 'format' ] ) ,
_ _axis _y2 _padding = getConfig ( [ 'axis' , 'y2' , 'padding' ] ) ,
_ _axis _y2 _ticks = getConfig ( [ 'axis' , 'y2' , 'ticks' ] , 10 ) ;
// grid
var _ _grid _x _show = getConfig ( [ 'grid' , 'x' , 'show' ] , false ) ,
_ _grid _x _type = getConfig ( [ 'grid' , 'x' , 'type' ] , 'tick' ) ,
_ _grid _x _lines = getConfig ( [ 'grid' , 'x' , 'lines' ] , null ) ,
_ _grid _x _lines = getConfig ( [ 'grid' , 'x' , 'lines' ] ) ,
_ _grid _y _show = getConfig ( [ 'grid' , 'y' , 'show' ] , false ) ,
// not used
// __grid_y_type = getConfig(['grid', 'y', 'type'], 'tick'),
_ _grid _y _lines = getConfig ( [ 'grid' , 'y' , 'lines' ] , null ) ,
_ _grid _y _lines = getConfig ( [ 'grid' , 'y' , 'lines' ] ) ,
_ _grid _y _ticks = getConfig ( [ 'grid' , 'y' , 'ticks' ] , 10 ) ;
// point - point of each data
@ -194,14 +196,14 @@
// pie
var _ _pie _label _show = getConfig ( [ 'pie' , 'label' , 'show' ] , true ) ,
_ _pie _label _format = getConfig ( [ 'pie' , 'label' , 'format' ] , null ) ,
_ _pie _label _format = getConfig ( [ 'pie' , 'label' , 'format' ] ) ,
_ _pie _onclick = getConfig ( [ 'pie' , 'onclick' ] , function ( ) { } ) ,
_ _pie _onmouseover = getConfig ( [ 'pie' , 'onmouseover' ] , function ( ) { } ) ,
_ _pie _onmouseout = getConfig ( [ 'pie' , 'onmouseout' ] , function ( ) { } ) ;
// donut
var _ _donut _label _show = getConfig ( [ 'donut' , 'label' , 'show' ] , true ) ,
_ _donut _label _format = getConfig ( [ 'donut' , 'label' , 'format' ] , null ) ,
_ _donut _label _format = getConfig ( [ 'donut' , 'label' , 'format' ] ) ,
_ _donut _title = getConfig ( [ 'donut' , 'title' ] , "" ) ,
_ _donut _onclick = getConfig ( [ 'donut' , 'onclick' ] , function ( ) { } ) ,
_ _donut _onmouseover = getConfig ( [ 'donut' , 'onmouseover' ] , function ( ) { } ) ,
@ -212,8 +214,8 @@
// tooltip - show when mouseover on each data
var _ _tooltip _show = getConfig ( [ 'tooltip' , 'show' ] , true ) ,
_ _tooltip _format _title = getConfig ( [ 'tooltip' , 'format' , 'title' ] , null ) ,
_ _tooltip _format _value = getConfig ( [ 'tooltip' , 'format' , 'value' ] , null ) ,
_ _tooltip _format _title = getConfig ( [ 'tooltip' , 'format' , 'title' ] ) ,
_ _tooltip _format _value = getConfig ( [ 'tooltip' , 'format' , 'value' ] ) ,
_ _tooltip _contents = getConfig ( [ 'tooltip' , 'contents' ] , function ( d , defaultTitleFormat , defaultValueFormat , color ) {
var titleFormat = _ _tooltip _format _title ? _ _tooltip _format _title : defaultTitleFormat ,
valueFormat = _ _tooltip _format _value ? _ _tooltip _format _value : defaultValueFormat ,
@ -1773,7 +1775,7 @@
function generateColor ( _colors , _pattern ) {
var ids = [ ] ,
colors = _colors ,
pattern = ( _pattern !== null ) ? _pattern : [ '#1f77b4' , '#ff7f0e' , '#2ca02c' , '#d62728' , '#9467bd' , '#8c564b' , '#e377c2' , '#7f7f7f' , '#bcbd22' , '#17becf' ] ; //same as d3.scale.category10()
pattern = _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
@ -2340,7 +2342,7 @@
}
// Set default extent if defined
if ( _ _axis _x _default !== null ) {
if ( _ _axis _x _default ) {
brush . extent ( typeof _ _axis _x _default !== 'function' ? _ _axis _x _default : _ _axis _x _default ( getXDomain ( ) ) ) ;
}