@ -17,9 +17,9 @@
chartArc : 'c3-chart-arc' ,
chartArc : 'c3-chart-arc' ,
chartArcs : 'c3-chart-arcs' ,
chartArcs : 'c3-chart-arcs' ,
chartArcsTitle : 'c3-chart-arcs-title' ,
chartArcsTitle : 'c3-chart-arcs-title' ,
// gauge: 'c3-gauge',
gaugeArc : 'c3-gauge-arc' ,
// gaugeDial: 'c3-gauge-dial',
gaugeArcs : 'c3-gauge-arcs' ,
// gaugeTitle: 'c3-gauge-title',
gaugeArcsTitle : 'c3-gauge-arcs-title' ,
selectedCircle : 'c3-selected-circle' ,
selectedCircle : 'c3-selected-circle' ,
selectedCircles : 'c3-selected-circles' ,
selectedCircles : 'c3-selected-circles' ,
eventRect : 'c3-event-rect' ,
eventRect : 'c3-event-rect' ,
@ -158,7 +158,8 @@
// color
// color
var _ _color _pattern = getConfig ( [ 'color' , 'pattern' ] , [ ] ) ,
var _ _color _pattern = getConfig ( [ 'color' , 'pattern' ] , [ ] ) ,
_ _color _opacity = getConfig ( [ 'color' , 'opacity' ] , null ) ;
_ _color _opacity = getConfig ( [ 'color' , 'opacity' ] , null ) ,
_ _color _values = getConfig ( [ 'color' , 'values' ] , [ ] ) ;
// legend
// legend
var _ _legend _show = getConfig ( [ 'legend' , 'show' ] , true ) ,
var _ _legend _show = getConfig ( [ 'legend' , 'show' ] , true ) ,
@ -230,6 +231,19 @@
_ _pie _onmouseover = getConfig ( [ 'pie' , 'onmouseover' ] , function ( ) { } ) ,
_ _pie _onmouseover = getConfig ( [ 'pie' , 'onmouseover' ] , function ( ) { } ) ,
_ _pie _onmouseout = getConfig ( [ 'pie' , 'onmouseout' ] , function ( ) { } ) ;
_ _pie _onmouseout = getConfig ( [ 'pie' , 'onmouseout' ] , function ( ) { } ) ;
// gauge
var _ _gauge _color = getConfig ( [ 'gauge' , 'color' ] , "#e0e0e0" ) ,
_ _gauge _label _show = getConfig ( [ 'gauge' , 'label' , 'show' ] , true ) ,
_ _gauge _label _format = getConfig ( [ 'gauge' , 'label' , 'format' ] ) ,
_ _gauge _max = getConfig ( [ 'gauge' , 'max' ] ) ,
_ _gauge _min = getConfig ( [ 'gauge' , 'min' ] ) ,
_ _gauge _onclick = getConfig ( [ 'gauge' , 'onclick' ] , function ( ) { } ) ,
_ _gauge _onmouseover = getConfig ( [ 'gauge' , 'onmouseover' ] , function ( ) { } ) ,
_ _gauge _onmouseout = getConfig ( [ 'gauge' , 'onmouseout' ] , function ( ) { } ) ,
_ _gauge _style = getConfig ( [ 'gauge' , 'style' ] ) ,
_ _gauge _units = getConfig ( [ 'gauge' , 'units' ] ) ,
_ _gauge _width = getConfig ( [ 'gauge' , 'width' ] , false ) ;
// donut
// donut
var _ _donut _label _show = getConfig ( [ 'donut' , 'label' , 'show' ] , true ) ,
var _ _donut _label _show = getConfig ( [ 'donut' , 'label' , 'show' ] , true ) ,
_ _donut _label _format = getConfig ( [ 'donut' , 'label' , 'format' ] ) ,
_ _donut _label _format = getConfig ( [ 'donut' , 'label' , 'format' ] ) ,
@ -238,11 +252,6 @@
_ _donut _onmouseover = getConfig ( [ 'donut' , 'onmouseover' ] , function ( ) { } ) ,
_ _donut _onmouseover = getConfig ( [ 'donut' , 'onmouseover' ] , function ( ) { } ) ,
_ _donut _onmouseout = getConfig ( [ 'donut' , 'onmouseout' ] , function ( ) { } ) ;
_ _donut _onmouseout = getConfig ( [ 'donut' , 'onmouseout' ] , function ( ) { } ) ;
// var __gauge_label_show = getConfig(['gauge', 'label', 'show'], true),
// __gauge_label_format = getConfig(['gauge', 'label', 'format']),
// __gauge_title = getConfig(['gauge', 'title'], ""),
// __gauge_onclick = getConfig(['gauge', 'onclick'], function () {});
// region - region to change style
// region - region to change style
var _ _regions = getConfig ( [ 'regions' ] , [ ] ) ;
var _ _regions = getConfig ( [ 'regions' ] , [ ] ) ;
@ -253,7 +262,7 @@
_ _tooltip _contents = getConfig ( [ 'tooltip' , 'contents' ] , function ( d , defaultTitleFormat , defaultValueFormat , color ) {
_ _tooltip _contents = getConfig ( [ 'tooltip' , 'contents' ] , function ( d , defaultTitleFormat , defaultValueFormat , color ) {
var titleFormat = _ _tooltip _format _title ? _ _tooltip _format _title : defaultTitleFormat ,
var titleFormat = _ _tooltip _format _title ? _ _tooltip _format _title : defaultTitleFormat ,
valueFormat = _ _tooltip _format _value ? _ _tooltip _format _value : defaultValueFormat ,
valueFormat = _ _tooltip _format _value ? _ _tooltip _format _value : defaultValueFormat ,
text , i , title , value , name ;
text , i , title , value , name , bgcolor ;
for ( i = 0 ; i < d . length ; i ++ ) {
for ( i = 0 ; i < d . length ; i ++ ) {
if ( ! ( d [ i ] && ( d [ i ] . value || d [ i ] . value === 0 ) ) ) { continue ; }
if ( ! ( d [ i ] && ( d [ i ] . value || d [ i ] . value === 0 ) ) ) { continue ; }
@ -264,9 +273,10 @@
name = d [ i ] . name ;
name = d [ i ] . name ;
value = valueFormat ( d [ i ] . value , d [ i ] . ratio ) ;
value = valueFormat ( d [ i ] . value , d [ i ] . ratio ) ;
bgcolor = ( _ _color _values ) ? levelColor ( d [ i ] . value ) : color ( d [ i ] . id ) ;
text += "<tr class='" + CLASS . tooltipName + "-" + d [ i ] . id + "'>" ;
text += "<tr class='" + CLASS . tooltipName + "-" + d [ i ] . id + "'>" ;
text += "<td class='name'><span style='background-color:" + color ( d [ i ] . id ) + "'></span>" + name + "</td>" ;
text += "<td class='name'><span style='background-color:" + bg color + "'></span>" + name + "</td>" ;
text += "<td class='value'>" + value + "</td>" ;
text += "<td class='value'>" + value + "</td>" ;
text += "</tr>" ;
text += "</tr>" ;
}
}
@ -293,6 +303,8 @@
var color = generateColor ( _ _data _colors , _ _color _pattern ) ;
var color = generateColor ( _ _data _colors , _ _color _pattern ) ;
var levelColor = generateLevelColor ( _ _color _pattern , _ _color _values ) ;
var defaultTimeFormat = ( function ( ) {
var defaultTimeFormat = ( function ( ) {
var formats = [
var formats = [
[ d3 . time . format ( "%Y/%-m/%-d" ) , function ( ) { return true ; } ] ,
[ d3 . time . format ( "%Y/%-m/%-d" ) , function ( ) { return true ; } ] ,
@ -423,7 +435,8 @@
function updateRadius ( ) {
function updateRadius ( ) {
radiusExpanded = height / 2 ;
radiusExpanded = height / 2 ;
radius = radiusExpanded * 0.95 ;
radius = radiusExpanded * 0.95 ;
innerRadius = hasDonutType ( c3 . data . targets ) ? radius * 0.6 : 0 ;
var innerRadiusRatio = _ _gauge _width ? ( ( radius - _ _gauge _width ) / radius ) : 0.6 ;
innerRadius = hasDonutType ( c3 . data . targets ) || hasGaugeType ( c3 . data . targets ) ? radius * innerRadiusRatio : 0 ;
}
}
function getSvgLeft ( ) {
function getSvgLeft ( ) {
var leftAxisClass = _ _axis _rotated ? CLASS . axisX : CLASS . axisY ,
var leftAxisClass = _ _axis _rotated ? CLASS . axisX : CLASS . axisY ,
@ -991,6 +1004,15 @@
return ;
return ;
}
}
} ) ;
} ) ;
if ( isNaN ( d . endAngle ) ) d . endAngle = d . startAngle ;
if ( isGaugeType ( d . data ) ) {
var sA = d . startAngle , eA = d . endAngle ;
var gMin = _ _gauge _min , gMax = _ _gauge _max ,
gF = Math . abs ( gMin ) + gMax , fA = Math . abs ( sA ) + eA ,
aTic = ( Math . PI ) / gF ;
d . startAngle = ( - 1 * ( Math . PI / 2 ) ) + ( aTic * Math . abs ( gMin ) ) ;
d . endAngle = d . startAngle + ( aTic * d . value ) ;
}
return found ? d : null ;
return found ? d : null ;
}
}
@ -1021,12 +1043,13 @@
if ( updated ) {
if ( updated ) {
c = svgArc . centroid ( updated ) ;
c = svgArc . centroid ( updated ) ;
x = c [ 0 ] , y = c [ 1 ] , h = Math . sqrt ( x * x + y * y ) ;
x = c [ 0 ] , y = c [ 1 ] , h = Math . sqrt ( x * x + y * y ) ;
translate = "translate(" + ( ( x / h ) * radius * 0.8 ) + ',' + ( ( y / h ) * radius * 0.8 ) + ")" ;
translate = _ _gauge _style == 'arc' ? "translate(1,1)" : "translate(" + ( ( x / h ) * radius * 0.8 ) + ',' + ( ( y / h ) * radius * 0.8 ) + ")" ;
}
}
return translate ;
return translate ;
}
}
function getArcRatio ( d ) {
function getArcRatio ( d ) {
return d ? ( d . endAngle - d . startAngle ) / ( Math . PI * 2 ) : null ;
var whole = _ _gauge _style == 'arc' ? Math . PI : ( Math . PI * 2 ) ;
return d ? ( d . endAngle - d . startAngle ) / whole : null ;
}
}
function convertToArcData ( d ) {
function convertToArcData ( d ) {
return addName ( {
return addName ( {
@ -1047,7 +1070,7 @@
function expandArc ( id , withoutFadeOut ) {
function expandArc ( id , withoutFadeOut ) {
var target = svg . selectAll ( '.' + CLASS . chartArc + selectorTarget ( id ) ) ,
var target = svg . selectAll ( '.' + CLASS . chartArc + selectorTarget ( id ) ) ,
noneTargets = svg . selectAll ( '.' + CLASS . arc ) . filter ( function ( data ) { return data . data . id !== id ; } ) ;
noneTargets = svg . selectAll ( '.' + CLASS . arc ) . filter ( function ( data ) { return data . data . id !== id ; } ) ;
target . selectAll ( 'path' )
target . selectAll ( 'path.c3-arc ' )
. transition ( ) . duration ( 50 )
. transition ( ) . duration ( 50 )
. attr ( "d" , svgArcExpanded )
. attr ( "d" , svgArcExpanded )
. transition ( ) . duration ( 100 )
. transition ( ) . duration ( 100 )
@ -1063,30 +1086,45 @@
}
}
function unexpandArc ( id ) {
function unexpandArc ( id ) {
var target = svg . selectAll ( '.' + CLASS . chartArc + selectorTarget ( id ) ) ;
var target = svg . selectAll ( '.' + CLASS . chartArc + selectorTarget ( id ) ) ;
target . selectAll ( 'path' )
target . selectAll ( 'path.c3-arc ' )
. transition ( ) . duration ( 50 )
. transition ( ) . duration ( 50 )
. attr ( "d" , svgArc ) ;
. attr ( "d" , svgArc ) ;
svg . selectAll ( '.' + CLASS . arc )
svg . selectAll ( '.' + CLASS . arc )
. style ( "opacity" , ( _ _color _opacity ) ? _ _color _opacity : 1 ) ;
. style ( "opacity" , ( _ _color _opacity ) ? _ _color _opacity : 1 ) ;
}
}
function shouldShowArcLable ( ) {
function shouldShowArcLable ( ) {
if ( hasGaugeType ( c3 . data . targets ) ) {
return true ;
}
return hasDonutType ( c3 . data . targets ) ? _ _donut _label _show : _ _pie _label _show ;
return hasDonutType ( c3 . data . targets ) ? _ _donut _label _show : _ _pie _label _show ;
}
}
function getArcLabelFormat ( ) {
function getArcLabelFormat ( ) {
if ( hasGaugeType ( c3 . data . targets ) ) {
return _ _gauge _label _format ;
}
return hasDonutType ( c3 . data . targets ) ? _ _donut _label _format : _ _pie _label _format ;
return hasDonutType ( c3 . data . targets ) ? _ _donut _label _format : _ _pie _label _format ;
}
}
function getArcTitle ( ) {
function getArcTitle ( ) {
return hasDonutType ( c3 . data . targets ) ? _ _donut _title : "" ;
return hasDonutType ( c3 . data . targets ) ? _ _donut _title : "" ;
}
}
function getArcOnClick ( ) {
function getArcOnClick ( ) {
if ( hasGaugeType ( c3 . data . targets ) ) {
return typeof _ _gauge _onclick === 'function' ? _ _gauge _onclick : function ( ) { } ;
}
var callback = hasDonutType ( c3 . data . targets ) ? _ _donut _onclick : _ _pie _onclick ;
var callback = hasDonutType ( c3 . data . targets ) ? _ _donut _onclick : _ _pie _onclick ;
return typeof callback === 'function' ? callback : function ( ) { } ;
return typeof callback === 'function' ? callback : function ( ) { } ;
}
}
function getArcOnMouseOver ( ) {
function getArcOnMouseOver ( ) {
if ( hasGaugeType ( c3 . data . targets ) ) {
return typeof _ _gauge _onmouseover === 'function' ? _ _gauge _onmouseover : function ( ) { } ;
}
var callback = hasDonutType ( c3 . data . targets ) ? _ _donut _onmouseover : _ _pie _onmouseover ;
var callback = hasDonutType ( c3 . data . targets ) ? _ _donut _onmouseover : _ _pie _onmouseover ;
return typeof callback === 'function' ? callback : function ( ) { } ;
return typeof callback === 'function' ? callback : function ( ) { } ;
}
}
function getArcOnMouseOut ( ) {
function getArcOnMouseOut ( ) {
if ( hasGaugeType ( c3 . data . targets ) ) {
return typeof _ _gauge _onmouseout === 'function' ? _ _gauge _onmouseout : function ( ) { } ;
}
var callback = hasDonutType ( c3 . data . targets ) ? _ _donut _onmouseout : _ _pie _onmouseout ;
var callback = hasDonutType ( c3 . data . targets ) ? _ _donut _onmouseout : _ _pie _onmouseout ;
return typeof callback === 'function' ? callback : function ( ) { } ;
return typeof callback === 'function' ? callback : function ( ) { } ;
}
}
@ -1740,7 +1778,7 @@
var tWidth , tHeight ;
var tWidth , tHeight ;
var svgLeft , tooltipLeft , tooltipRight , tooltipTop , chartRight ;
var svgLeft , tooltipLeft , tooltipRight , tooltipTop , chartRight ;
var forArc = hasArcType ( c3 . data . targets ) ;
var forArc = hasArcType ( c3 . data . targets ) ;
var valueFormat = forArc ? defaultArcValueFormat : defaultValueFormat ;
var valueFormat = forArc && ! hasGaugeType ( c3 . data . targets ) ? defaultArcValueFormat : defaultValueFormat ;
var dataToShow = selectedData . filter ( function ( d ) { return d && isValue ( d . value ) ; } ) ;
var dataToShow = selectedData . filter ( function ( d ) { return d && isValue ( d . value ) ; } ) ;
if ( ! _ _tooltip _show ) { return ; }
if ( ! _ _tooltip _show ) { return ; }
// don't show tooltip when no data
// don't show tooltip when no data
@ -1991,14 +2029,14 @@
function hasPieType ( targets ) {
function hasPieType ( targets ) {
return hasType ( targets , 'pie' ) ;
return hasType ( targets , 'pie' ) ;
}
}
function hasGaugeType ( targets ) {
return hasType ( targets , 'gauge' ) ;
}
function hasDonutType ( targets ) {
function hasDonutType ( targets ) {
return hasType ( targets , 'donut' ) ;
return hasType ( targets , 'donut' ) ;
}
}
// function hasGaugeType(targets) {
// return hasType(targets, 'gauge') || hasType(targets, 'google-gauge');
// }
function hasArcType ( targets ) {
function hasArcType ( targets ) {
return hasPieType ( targets ) || hasDonutType ( targets ) ; // || hasGaugeType(targets);
return hasPieType ( targets ) || hasDonutType ( targets ) || hasGaugeType ( targets ) ;
}
}
function isLineType ( d ) {
function isLineType ( d ) {
var id = ( typeof d === 'string' ) ? d : d . id ;
var id = ( typeof d === 'string' ) ? d : d . id ;
@ -2028,16 +2066,16 @@
var id = ( typeof d === 'string' ) ? d : d . id ;
var id = ( typeof d === 'string' ) ? d : d . id ;
return _ _data _types [ id ] === 'pie' ;
return _ _data _types [ id ] === 'pie' ;
}
}
function isGaugeType ( d ) {
var id = ( typeof d === 'string' ) ? d : d . id ;
return _ _data _types [ id ] === 'gauge' ;
}
function isDonutType ( d ) {
function isDonutType ( d ) {
var id = ( typeof d === 'string' ) ? d : d . id ;
var id = ( typeof d === 'string' ) ? d : d . id ;
return _ _data _types [ id ] === 'donut' ;
return _ _data _types [ id ] === 'donut' ;
}
}
// function isGaugeType(d) {
// var id = (typeof d === 'string') ? d : d.id;
// return __data_types[id] === 'gauge' || __data_types[id] === 'google-gauge'
// }
function isArcType ( d ) {
function isArcType ( d ) {
return isPieType ( d ) || isDonutType ( d ) ; // || isGaugeType(d);
return isPieType ( d ) || isDonutType ( d ) || isGaugeType ( d ) ;
}
}
/ * n o t u s e d
/ * n o t u s e d
function lineData ( d ) {
function lineData ( d ) {
@ -2076,6 +2114,23 @@
} ;
} ;
}
}
function generateLevelColor ( _colors , _values ) {
var colors = _colors ,
levels = _values ;
return function ( value ) {
for ( var a = 1 ; a < levels . length ; a ++ ) {
if ( levels [ 0 ] === 'percentage' && ( ( value / _ _gauge _max ) * 100 ) < levels [ a ] ) {
return colors [ a - 1 ] ;
}
if ( levels [ 0 ] === 'whole' && value < levels [ a ] ) {
return colors [ a - 1 ] ;
}
}
return colors [ colors . length - 1 ] ;
} ;
}
//-- Date --//
//-- Date --//
function parseDate ( date ) {
function parseDate ( date ) {
@ -2247,7 +2302,7 @@
isSplineType ( d ) ? area . interpolate ( "cardinal" ) : area . interpolate ( "linear" ) ;
isSplineType ( d ) ? area . interpolate ( "cardinal" ) : area . interpolate ( "linear" ) ;
return area ( data ) ;
return area ( data ) ;
} else if ( hasType ( [ d ] , 'area-step' ) ) {
} else if ( hasType ( [ d ] , 'area-step' ) ) {
isStepType ( d ) ? area . interpolate ( "step-after" ) : '' ;
isStepType ( d ) ? area . interpolate ( "step-after" ) : area . interpolate ( "linear" ) ;
return area ( data ) ;
return area ( data ) ;
} else {
} else {
x0 = x ( data [ 0 ] . x ) ;
x0 = x ( data [ 0 ] . x ) ;
@ -2427,7 +2482,34 @@
. y ( _ _axis _rotated ? subxx : function ( d ) { return getSubYScale ( d . id ) ( d . value ) ; } ) ;
. y ( _ _axis _rotated ? subxx : function ( d ) { return getSubYScale ( d . id ) ( d . value ) ; } ) ;
return function ( d ) {
return function ( d ) {
var data = filterRemoveNull ( d . values ) ;
var data = filterRemoveNull ( d . values ) ;
return isLineType ( d ) ? line ( data ) : "M " + subX ( data [ 0 ] . x ) + " " + getSubYScale ( d . id ) ( data [ 0 ] . value ) ;
if ( isLineType ( d ) ) {
return line ( data ) ;
} else if ( isStepType ( d ) ) {
line . interpolate ( "step-after" ) ;
return line ( data ) ;
} else {
return "M " + subX ( data [ 0 ] . x ) + " " + getSubYScale ( d . id ) ( data [ 0 ] . value ) ;
}
} ;
} ) ( ) ;
var areaOnSub = ( function ( ) {
var area = d3 . svg . area ( )
. x ( xx )
. y0 ( function ( d , i ) { return getSubYScale ( d . id ) ( 0 ) ; } )
. y1 ( function ( d , i ) { return getSubYScale ( d . id ) ( d . value ) ; } ) ;
return function ( d ) {
var data = filterRemoveNull ( d . values ) , x0 , y0 ;
if ( hasType ( [ d ] , 'area' ) || hasType ( [ d ] , 'area-spline' ) ) {
isSplineType ( d ) ? area . interpolate ( "cardinal" ) : area . interpolate ( "linear" ) ;
return area ( data ) ;
} else if ( hasType ( [ d ] , 'area-step' ) ) {
isStepType ( d ) ? area . interpolate ( "step-after" ) : area . interpolate ( "linear" ) ;
return area ( data ) ;
} else {
x0 = subX ( data [ 0 ] . x ) ;
y0 = getSubYScale ( d . id ) ( data [ 0 ] . value ) ;
return _ _axis _rotated ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0 ;
}
} ;
} ;
} ) ( ) ;
} ) ( ) ;
@ -2737,30 +2819,6 @@
. style ( "text-anchor" , "middle" )
. style ( "text-anchor" , "middle" )
. text ( getArcTitle ( ) ) ;
. text ( getArcTitle ( ) ) ;
// Define g for gauge chart area
// main.select('.' + CLASS.chart).append("g")
// .attr('class', CLASS.gauge)
// .attr("width", height)
// .attr("height", height);
// main.select('.' + CLASS.gauge).append('circle')
// .attr("cx", height / 2)
// .attr("cy", height / 2)
// .attr("r", height * 0.97 / 2)
// .style("fill", "#ccc")
// .style("stroke", "#000")
// .style("stroke-width", "0.5px");
// main.select('.' + CLASS.gauge).append("circle")
// .attr("cx", (height / 2))
// .attr("cy", (height / 2))
// .attr("r", 0.9 * (height * 0.97 / 2) )
// .style("fill", "#fff")
// .style("stroke", "#e0e0e0")
// .style("stroke-width", "2px");
// main.select('.' + CLASS.gauge).append('text')
// .attr('class', CLASS.gaugeTitle)
// .style("text-anchor", "middle")
// .text(getGaugeTitle());
main . select ( '.' + CLASS . chart ) . append ( "g" )
main . select ( '.' + CLASS . chart ) . append ( "g" )
. attr ( "class" , CLASS . chartTexts ) ;
. attr ( "class" , CLASS . chartTexts ) ;
@ -3379,12 +3437,14 @@
// .attr("d", lineOnMain)
// .attr("d", lineOnMain)
. attr ( "d" , drawLine )
. attr ( "d" , drawLine )
. style ( "opacity" , 1 ) ;
. style ( "opacity" , 1 ) ;
// steps
main . selectAll ( '.' + CLASS . step )
main . selectAll ( '.' + CLASS . step )
. style ( "opacity" , initialOpacity )
. style ( "opacity" , initialOpacity )
. transition ( ) . duration ( duration )
. transition ( ) . duration ( duration )
// .attr("d", lineOnMain)
// .attr("d", lineOnMain)
. attr ( "d" , drawLine )
. attr ( "d" , drawLine )
. style ( "opacity" , 1 ) ;
. style ( "opacity" , 1 ) ;
// area
main . selectAll ( '.' + CLASS . area )
main . selectAll ( '.' + CLASS . area )
. style ( "opacity" , 0 )
. style ( "opacity" , 0 )
. transition ( ) . duration ( duration )
. transition ( ) . duration ( duration )
@ -3423,6 +3483,7 @@
} ;
} ;
}
}
* /
* /
if ( isNaN ( this . _current . endAngle ) ) this . _current . endAngle = this . _current . startAngle ;
interpolate = d3 . interpolate ( this . _current , updated ) ;
interpolate = d3 . interpolate ( this . _current , updated ) ;
this . _current = interpolate ( 0 ) ;
this . _current = interpolate ( 0 ) ;
return function ( t ) { return getArc ( interpolate ( t ) , true ) ; } ;
return function ( t ) { return getArc ( interpolate ( t ) , true ) ; } ;
@ -3435,11 +3496,28 @@
. transition ( ) . duration ( duration )
. transition ( ) . duration ( duration )
. text ( textForArcLabel )
. text ( textForArcLabel )
. style ( "opacity" , function ( d ) { return isTargetToShow ( d . data . id ) && isArcType ( d . data ) ? 1 : 0 ; } ) ;
. style ( "opacity" , function ( d ) { return isTargetToShow ( d . data . id ) && isArcType ( d . data ) ? 1 : 0 ; } ) ;
if ( _ _gauge _style === "arc" ) {
main . selectAll ( '.' + CLASS . chartArc ) . select ( 'text.units' )
. attr ( "transform" , transformForArcLabel )
. style ( "opacity" , 0 )
. transition ( ) . duration ( duration )
. text ( ( _ _gauge _label _show ) ? _ _gauge _units : '' )
. style ( "opacity" , function ( d ) { return isTargetToShow ( d . data . id ) && isArcType ( d . data ) ? 1 : 0 ; } ) ;
main . selectAll ( '.' + CLASS . chartArc ) . select ( 'text.min' )
. attr ( "transform" , transformForArcLabel )
. style ( "opacity" , 0 )
. transition ( ) . duration ( duration )
. text ( ( _ _gauge _label _show ) ? _ _gauge _min : '' )
. style ( "opacity" , function ( d ) { return isTargetToShow ( d . data . id ) && isArcType ( d . data ) ? 1 : 0 ; } ) ;
main . selectAll ( '.' + CLASS . chartArc ) . select ( 'text.max' )
. attr ( "transform" , transformForArcLabel )
. style ( "opacity" , 0 )
. transition ( ) . duration ( duration )
. text ( ( _ _gauge _label _show ) ? _ _gauge _max : '' )
. style ( "opacity" , function ( d ) { return isTargetToShow ( d . data . id ) && isArcType ( d . data ) ? 1 : 0 ; } ) ;
}
main . select ( '.' + CLASS . chartArcsTitle )
main . select ( '.' + CLASS . chartArcsTitle )
. style ( "opacity" , hasDonutType ( c3 . data . targets ) ? 1 : 0 ) ;
. style ( "opacity" , hasDonutType ( c3 . data . targets ) || hasGaugeType ( c3 . data . targets ) ? 1 : 0 ) ;
// gauge
// main.selectAll('.' + CLASS.gauge).select('.' + CLASS.arc);
// subchart
// subchart
if ( _ _subchart _show ) {
if ( _ _subchart _show ) {
@ -3479,11 +3557,18 @@
. transition ( ) . duration ( duration )
. transition ( ) . duration ( duration )
. attr ( "d" , lineOnSub )
. attr ( "d" , lineOnSub )
. style ( 'opacity' , 1 ) ;
. style ( 'opacity' , 1 ) ;
// steps
context . selectAll ( '.' + CLASS . step )
context . selectAll ( '.' + CLASS . step )
. style ( "opacity" , initialOpacity )
. style ( "opacity" , initialOpacity )
. transition ( ) . duration ( duration )
. transition ( ) . duration ( duration )
. attr ( "d" , lineOnSub )
. attr ( "d" , lineOnSub )
. style ( 'opacity' , 1 ) ;
. style ( 'opacity' , 1 ) ;
// area
context . selectAll ( '.' + CLASS . area )
. style ( "opacity" , initialOpacity )
. transition ( ) . duration ( duration )
. attr ( "d" , areaOnSub )
. style ( 'opacity' , orgAreaOpacity ) ;
}
}
}
}
@ -3677,6 +3762,7 @@
. attr ( "class" , classLine )
. attr ( "class" , classLine )
. style ( "opacity" , 0 )
. style ( "opacity" , 0 )
. style ( "stroke" , function ( d ) { return color ( d . id ) ; } ) ;
. style ( "stroke" , function ( d ) { return color ( d . id ) ; } ) ;
// Steps
mainLineEnter . append ( "path" )
mainLineEnter . append ( "path" )
. attr ( 'class' , classStep )
. attr ( 'class' , classStep )
. style ( "opacity" , 0 )
. style ( "opacity" , 0 )
@ -3684,7 +3770,7 @@
// Areas
// Areas
mainLineEnter . append ( "path" )
mainLineEnter . append ( "path" )
. attr ( "class" , classArea )
. attr ( "class" , classArea )
. style ( "opacity" , function ( ) { orgAreaOpacity = ( _ _color _opacity ) ? _ _color _opacity : 1 ; return 0 ; } ) //+d3.select(this).style('opacity'); return 0; })
. style ( "opacity" , function ( ) { orgAreaOpacity = ( _ _color _opacity ) ? _ _color _opacity : 1 ; return orgAreaOpacity ; } ) //+d3.select(this).style('opacity'); return 0; })
. style ( "fill" , function ( d ) { return color ( d . id ) ; } ) ;
. style ( "fill" , function ( d ) { return color ( d . id ) ; } ) ;
// Circles for each data point on lines
// Circles for each data point on lines
mainLineEnter . append ( 'g' )
mainLineEnter . append ( 'g' )
@ -3708,10 +3794,24 @@
. data ( pie ( targets ) ) ;
. data ( pie ( targets ) ) ;
mainPieEnter = mainPieUpdate . enter ( ) . append ( "g" )
mainPieEnter = mainPieUpdate . enter ( ) . append ( "g" )
. attr ( "class" , function ( d ) { return CLASS . chartArc + generateClass ( CLASS . target , d . data . id ) ; } ) ;
. attr ( "class" , function ( d ) { return CLASS . chartArc + generateClass ( CLASS . target , d . data . id ) ; } ) ;
if ( _ _gauge _style === "arc" ) {
mainPieEnter . append ( "path" )
. attr ( "class" , "" )
. style ( "opacity" , 1 )
. style ( "fill" , _ _gauge _color ) // Where background color would receive customization.
. style ( "cursor" , "pointer" )
. attr ( "transform" , "scale(1,1)" )
. attr ( "d" , function ( d ) {
d . value = _ _gauge _max ;
d . startAngle = - 1 * ( Math . PI / 2 ) ;
d . endAngle = Math . PI / 2 ;
return getArc ( d , true ) ;
} ) ;
}
mainPieEnter . append ( "path" )
mainPieEnter . append ( "path" )
. attr ( "class" , classArc )
. attr ( "class" , classArc )
. style ( "opacity" , 0 )
. style ( "opacity" , 0 )
. style ( "fill" , function ( d ) { return color ( d . data . id ) ; } )
. style ( "fill" , function ( d ) { return ( _ _color _values ) ? levelColor ( d . data . values [ 0 ] . value ) : color ( d . data . id ) ; } ) // Where gauge reading color would receive customization.
. style ( "cursor" , function ( d ) { return _ _data _selection _isselectable ( d ) ? "pointer" : null ; } )
. style ( "cursor" , function ( d ) { return _ _data _selection _isselectable ( d ) ? "pointer" : null ; } )
. each ( function ( d ) { this . _current = d ; } )
. each ( function ( d ) { this . _current = d ; } )
. on ( 'mouseover' , function ( d , i ) {
. on ( 'mouseover' , function ( d , i ) {
@ -3736,10 +3836,40 @@
callback ( arcData , i ) ;
callback ( arcData , i ) ;
} ) ;
} ) ;
mainPieEnter . append ( "text" )
mainPieEnter . append ( "text" )
. attr ( "dy" , ".35em")
. attr ( "dy" , _ _gauge _style === "arc" ? "-0.35em" : ".35em")
. style ( "opacity" , 0 )
. style ( "opacity" , 0 )
. style ( "text-anchor" , "middle" )
. style ( "text-anchor" , "middle" )
. style ( "pointer-events" , "none" ) ;
. style ( "pointer-events" , "none" )
. style ( "font-size" , width / 10 + "px" ) ;
if ( _ _gauge _style === "arc" ) {
mainPieEnter . select ( 'text' ) . style ( 'fill' , '#000' ) ;
mainPieEnter . append ( "text" )
. attr ( "dy" , ".75em" )
. attr ( "class" , "units" )
. style ( "opacity" , 0 )
. style ( "text-anchor" , "middle" )
. style ( "pointer-events" , "none" )
. style ( 'fill' , '#000' )
. style ( "font-size" , width / 15 + "px" ) ;
mainPieEnter . append ( "text" )
. attr ( "dx" , - 1 * ( innerRadius + ( ( radius - innerRadius ) / 2 ) ) + "px" )
. attr ( "dy" , "1em" )
. attr ( "class" , "min" )
. style ( "opacity" , 0 )
. style ( "text-anchor" , "middle" )
. style ( "pointer-events" , "none" )
. style ( 'fill' , '#777' )
. style ( "font-size" , width / 20 + "px" ) ;
mainPieEnter . append ( "text" )
. attr ( "dx" , innerRadius + ( ( radius - innerRadius ) / 2 ) + "px" )
. attr ( "dy" , "1em" )
. attr ( "class" , "max" )
. style ( "opacity" , 0 )
. style ( "text-anchor" , "middle" )
. style ( "pointer-events" , "none" )
. style ( 'fill' , '#777' )
. style ( "font-size" , width / 20 + "px" ) ;
}
// MEMO: can not keep same color..., but not bad to update color in redraw
// MEMO: can not keep same color..., but not bad to update color in redraw
//mainPieUpdate.exit().remove();
//mainPieUpdate.exit().remove();
@ -3767,7 +3897,17 @@
contextLineEnter . append ( "path" )
contextLineEnter . append ( "path" )
. attr ( "class" , classLine )
. attr ( "class" , classLine )
. style ( "opacity" , 0 )
. style ( "opacity" , 0 )
. style ( "stroke" , function ( d ) { return color ( d . id ) ; } )
// Steps
contextLineEnter . append ( "path" )
. attr ( "class" , classStep )
. style ( "opacity" , 0 )
. style ( "stroke" , function ( d ) { return color ( d . id ) ; } ) ;
. style ( "stroke" , function ( d ) { return color ( d . id ) ; } ) ;
// Area
contextLineEnter . append ( "path" )
. attr ( "class" , classArea )
. style ( "opacity" , orgAreaOpacity )
. style ( "fill" , function ( d ) { return color ( d . id ) ; } ) ;
}
}
/*-- Show --*/
/*-- Show --*/