|
|
@ -107,7 +107,7 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { |
|
|
|
var l, totalLength = 0, offsets = {}, widths = {}, heights = {}, margins = [0], steps = {}, step = 0; |
|
|
|
var l, totalLength = 0, offsets = {}, widths = {}, heights = {}, margins = [0], steps = {}, step = 0; |
|
|
|
var withTransition, withTransitionForTransform; |
|
|
|
var withTransition, withTransitionForTransform; |
|
|
|
var hasFocused = $$.legend.selectAll('.' + CLASS.legendItemFocused).size(); |
|
|
|
var hasFocused = $$.legend.selectAll('.' + CLASS.legendItemFocused).size(); |
|
|
|
var texts, rects, tiles; |
|
|
|
var texts, rects, tiles, background; |
|
|
|
|
|
|
|
|
|
|
|
options = options || {}; |
|
|
|
options = options || {}; |
|
|
|
withTransition = getOption(options, "withTransition", true); |
|
|
|
withTransition = getOption(options, "withTransition", true); |
|
|
@ -249,13 +249,13 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { |
|
|
|
.attr('y', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegend) |
|
|
|
.attr('y', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegend) |
|
|
|
.attr('width', 10) |
|
|
|
.attr('width', 10) |
|
|
|
.attr('height', 10); |
|
|
|
.attr('height', 10); |
|
|
|
|
|
|
|
|
|
|
|
// Set background for inset legend
|
|
|
|
// Set background for inset legend
|
|
|
|
if ($$.isLegendInset && maxWidth !== 0) { |
|
|
|
background = $$.legend.select('.' + CLASS.legendBackground + ' rect'); |
|
|
|
$$.legend.insert('g', '.' + CLASS.legendItem) |
|
|
|
if ($$.isLegendInset && maxWidth > 0 && background.size() === 0) { |
|
|
|
|
|
|
|
background = $$.legend.insert('g', '.' + CLASS.legendItem) |
|
|
|
.attr("class", CLASS.legendBackground) |
|
|
|
.attr("class", CLASS.legendBackground) |
|
|
|
.append('rect') |
|
|
|
.append('rect'); |
|
|
|
.attr('height', $$.getLegendHeight() - 12) |
|
|
|
|
|
|
|
.attr('width', maxWidth * (step + 1) + 10); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
texts = $$.legend.selectAll('text') |
|
|
|
texts = $$.legend.selectAll('text') |
|
|
@ -281,6 +281,12 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { |
|
|
|
.attr('x', xForLegend) |
|
|
|
.attr('x', xForLegend) |
|
|
|
.attr('y', yForLegend); |
|
|
|
.attr('y', yForLegend); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (background) { |
|
|
|
|
|
|
|
(withTransition ? background.transition() : background) |
|
|
|
|
|
|
|
.attr('height', $$.getLegendHeight() - 12) |
|
|
|
|
|
|
|
.attr('width', maxWidth * (step + 1) + 10); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// toggle legend state
|
|
|
|
// toggle legend state
|
|
|
|
$$.legend.selectAll('.' + CLASS.legendItem) |
|
|
|
$$.legend.selectAll('.' + CLASS.legendItem) |
|
|
|
.classed(CLASS.legendItemHidden, function (id) { return !$$.isTargetToShow(id); }) |
|
|
|
.classed(CLASS.legendItemHidden, function (id) { return !$$.isTargetToShow(id); }) |
|
|
|