@@ -3486,7 +3486,12 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
34863486 area = config . axis_rotated ? area . x0 ( value0 ) . x1 ( value1 ) . y ( xValue ) : area . x ( xValue ) . y0 ( config . area_above ? 0 : value0 ) . y1 ( value1 ) ;
34873487 if ( ! config . line_connectNull ) {
34883488 area = area . defined ( function ( d ) {
3489- return d . ribbonYs !== null ; //FIXME: check difference value/ribbonYs
3489+ if ( $$ . isRibbonType ( d ) ) {
3490+ return d . ribbonYs !== null ;
3491+ }
3492+ else {
3493+ return d . value !== null ;
3494+ }
34903495 } ) ;
34913496 }
34923497
@@ -3506,18 +3511,19 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
35063511 // ===== START OPAL EXTENSION =====
35073512 // in case of the ribbon type, the null defined sequence in the beginning needs to be cut off
35083513 if ( $$ . isRibbonType ( d ) ) {
3509- var sliceStart = 0 , valuesLength = values . length ;
3514+ var sliceStart = 0 , valuesLength = values . length , sliceEnd = 0 ;
35103515 for ( var i = 0 ; i < valuesLength ; i ++ ) {
35113516 if ( values [ i ] . ribbonYs . low === null && values [ i ] . ribbonYs . high === null )
35123517 sliceStart ++ ;
35133518 else break ;
35143519 }
3515- // var sliceStart = values.reduce(function (currentSliceStart, val) {
3516- // return val.ribbonYs.low === null && val.ribbonYs.high === null && currentSliceStart === 0
3517- // ? currentSliceStart++
3518- // : currentSliceStart;
3519- // }, 0);
3520- values = values . slice ( sliceStart , ( values . length ) ) ;
3520+
3521+ for ( var i = valuesLength - 1 ; i > 0 ; i -- ) {
3522+ if ( values [ i ] . ribbonYs . low === null && values [ i ] . ribbonYs . high === null )
3523+ sliceEnd ++ ;
3524+ else break ;
3525+ }
3526+ values = values . slice ( sliceStart , ( values . length - sliceEnd ) ) ;
35213527 }
35223528 // ===== END OPAL EXTENSION =====
35233529
@@ -4150,7 +4156,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
41504156 var $$ = this ,
41514157 config = $$ . config ,
41524158 dataToShow = selectedData . filter ( function ( d ) {
4153- return d && isValue ( d . value ) ;
4159+ if ( d ) { var ribbonIsValue = ( d . ribbonYs == undefined ) ? null : ( isValue ( d . ribbonYs . high ) && isValue ( d . ribbonYs . low ) ) ; }
4160+ return d && ( isValue ( d . value ) || ribbonIsValue ) ;
41544161 } ) ,
41554162 focusEl = $$ . main . selectAll ( 'line.' + CLASS . xgridFocus ) ,
41564163 xx = $$ . xx . bind ( $$ ) ;
@@ -4251,34 +4258,62 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
42514258 }
42524259 } ;
42534260 c3_chart_internal_fn . getTooltipContent = function ( d , defaultTitleFormat , defaultValueFormat , color ) {
4254- var $$ = this ,
4255- config = $$ . config ,
4261+ var $$ = this , config = $$ . config ,
42564262 titleFormat = config . tooltip_format_title || defaultTitleFormat ,
4257- nameFormat = config . tooltip_format_name || function ( name ) {
4258- return name ;
4259- } ,
4263+ nameFormat = config . tooltip_format_name || function ( name ) { return name ; } ,
42604264 valueFormat = config . tooltip_format_value || defaultValueFormat ,
4261- text ,
4262- i ,
4263- title ,
4264- value ,
4265- name ,
4266- bgcolor ,
4265+ text , i , title , value , name , bgcolor ,
42674266 orderAsc = $$ . isOrderAsc ( ) ;
42684267
4268+ //create an array that contains any CI's high AND low values as seperate entries
4269+ var completeArray = [ ] ; //.concat(d);
4270+ var offset = 0 ;
4271+
4272+ for ( i = 0 ; i < d . length ; i ++ ) {
4273+ if ( ! ( d [ i ] ) ) {
4274+ offset ++ ;
4275+ continue ; }
4276+
4277+ //append the data for one graph
4278+ completeArray . push ( {
4279+ id : d [ i ] . id ,
4280+ value : d [ i ] . value ,
4281+ name : d [ i ] . name ,
4282+ index : d [ i ] . index ,
4283+ x : d [ i ] . x
4284+ } ) ;
4285+
4286+
4287+ //append high and low data for ribbon type
4288+ if ( $$ . isRibbonType ( d [ i ] ) ) {
4289+ var sName = d [ i ] . name ;
4290+ //create a new element and append it to the array for the low value
4291+ completeArray . push ( {
4292+ id : d [ i ] . id ,
4293+ value : d [ i ] . ribbonYs . low ,
4294+ name : sName . concat ( " low" ) ,
4295+ index : d [ i ] . index ,
4296+ ribbonYs : d [ i ] . ribbonYs ,
4297+ x : d [ i ] . x
4298+ } ) ;
4299+ //change original CI element to represent the high value
4300+ completeArray [ i - offset ] . value = d [ i ] . ribbonYs . high ;
4301+ completeArray [ i - offset ] . name = sName . concat ( " high" ) ;
4302+ }
4303+ }
4304+
4305+
42694306 if ( config . data_groups . length === 0 ) {
4270- d . sort ( function ( a , b ) {
4271- var v1 = a ? a . value : null ,
4272- v2 = b ? b . value : null ;
4307+ completeArray . sort ( function ( a , b ) {
4308+ var v1 = a ? a . value : null , v2 = b ? b . value : null ;
42734309 return orderAsc ? v1 - v2 : v2 - v1 ;
42744310 } ) ;
42754311 } else {
42764312 var ids = $$ . orderTargets ( $$ . data . targets ) . map ( function ( i ) {
42774313 return i . id ;
42784314 } ) ;
4279- d . sort ( function ( a , b ) {
4280- var v1 = a ? a . value : null ,
4281- v2 = b ? b . value : null ;
4315+ completeArray . sort ( function ( a , b ) {
4316+ var v1 = a ? a . value : null , v2 = b ? b . value : null ;
42824317 if ( v1 > 0 && v2 > 0 ) {
42834318 v1 = a ? ids . indexOf ( a . id ) : null ;
42844319 v2 = b ? ids . indexOf ( b . id ) : null ;
@@ -4287,26 +4322,22 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
42874322 } ) ;
42884323 }
42894324
4290- for ( i = 0 ; i < d . length ; i ++ ) {
4291- if ( ! ( d [ i ] && ( d [ i ] . value || d [ i ] . value === 0 ) ) ) {
4292- continue ;
4293- }
4325+ for ( i = 0 ; i < completeArray . length ; i ++ ) {
4326+ if ( ! ( completeArray [ i ] && ( completeArray [ i ] . value || completeArray [ i ] . value === 0 ) ) ) { continue ; }
42944327
4295- if ( ! text ) {
4296- title = sanitise ( titleFormat ? titleFormat ( d [ i ] . x ) : d [ i ] . x ) ;
4328+ if ( ! text ) {
4329+ title = sanitise ( titleFormat ? titleFormat ( completeArray [ i ] . x ) : completeArray [ i ] . x ) ;
42974330 text = "<table class='" + $$ . CLASS . tooltip + "'>" + ( title || title === 0 ? "<tr><th colspan='2'>" + title + "</th></tr>" : "" ) ;
42984331 }
42994332
4300- value = sanitise ( valueFormat ( d [ i ] . value , d [ i ] . ratio , d [ i ] . id , d [ i ] . index , d ) ) ;
4333+ value = sanitise ( valueFormat ( completeArray [ i ] . value , completeArray [ i ] . ratio , completeArray [ i ] . id , completeArray [ i ] . index , completeArray ) ) ;
43014334 if ( value !== undefined ) {
43024335 // Skip elements when their name is set to null
4303- if ( d [ i ] . name === null ) {
4304- continue ;
4305- }
4306- name = sanitise ( nameFormat ( d [ i ] . name , d [ i ] . ratio , d [ i ] . id , d [ i ] . index ) ) ;
4307- bgcolor = $$ . levelColor ? $$ . levelColor ( d [ i ] . value ) : color ( d [ i ] . id ) ;
4336+ if ( completeArray [ i ] . name === null ) { continue ; }
4337+ name = sanitise ( nameFormat ( completeArray [ i ] . name , completeArray [ i ] . ratio , completeArray [ i ] . id , completeArray [ i ] . index ) ) ;
4338+ bgcolor = $$ . levelColor ? $$ . levelColor ( completeArray [ i ] . value ) : color ( completeArray [ i ] . id ) ;
43084339
4309- text += "<tr class='" + $$ . CLASS . tooltipName + "-" + $$ . getTargetSelectorSuffix ( d [ i ] . id ) + "'>" ;
4340+ text += "<tr class='" + $$ . CLASS . tooltipName + "-" + $$ . getTargetSelectorSuffix ( completeArray [ i ] . id ) + "'>" ;
43104341 text += "<td class='name'><span style='background-color:" + bgcolor + "'></span>" + name + "</td>" ;
43114342 text += "<td class='value'>" + value + "</td>" ;
43124343 text += "</tr>" ;
@@ -4358,7 +4389,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
43584389 var tWidth , tHeight , position ;
43594390 var forArc = $$ . hasArcType ( ) ,
43604391 dataToShow = selectedData . filter ( function ( d ) {
4361- return d && isValue ( d . value ) ;
4392+ if ( d ) { var ribbonIsValue = ( d . ribbonYs == undefined ) ? null : ( isValue ( d . ribbonYs . high ) && isValue ( d . ribbonYs . low ) ) ; }
4393+ return d && ( isValue ( d . value ) || ribbonIsValue ) ;
43624394 } ) ,
43634395 positionFunction = config . tooltip_position || c3_chart_internal_fn . tooltipPosition ;
43644396 if ( dataToShow . length === 0 || ! config . tooltip_show ) {
0 commit comments