Commit c6d017dc authored by Bob Renwick's avatar Bob Renwick

only updateLegend when we actually want to show the legend for the first time

parent bfffa3c4
......@@ -3662,13 +3662,19 @@
c3_chart_internal_fn.initLegend = function () {
var $$ = this;
$$.legendHasRendered = false;
$$.legend = $$.svg.append("g").attr("transform", $$.getTranslate('legend'));
if (!$$.config.legend_show) {
$$.legend.style('visibility', 'hidden');
$$.hiddenLegendIds = $$.mapToIds($$.data.targets);
return;
}
// MEMO: call here to update legend box and tranlate for all
// MEMO: translate will be upated by this, so transform not needed in updateLegend()
$$.updateLegendWithDefaults();
};
c3_chart_internal_fn.updateLegendWithDefaults = function () {
var $$ = this;
$$.updateLegend($$.mapToIds($$.data.targets), {withTransform: false, withTransitionForTransform: false, withTransition: false});
};
c3_chart_internal_fn.updateSizeForLegend = function (legendHeight, legendWidth) {
......@@ -3745,6 +3751,9 @@
if (!config.legend_show) {
config.legend_show = true;
$$.legend.style('visibility', 'visible');
if (!$$.legendHasRendered) {
$$.updateLegendWithDefaults();
}
}
$$.removeHiddenLegendIds(targetIds);
$$.legend.selectAll($$.selectorLegends(targetIds))
......@@ -3981,6 +3990,7 @@
$$.updateSvgSize();
// Update g positions
$$.transformAll(withTransitionForTransform, transitions);
$$.legendHasRendered = true;
};
c3_chart_internal_fn.initAxis = function () {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
c3_chart_internal_fn.initLegend = function () {
var $$ = this;
$$.legendHasRendered = false;
$$.legend = $$.svg.append("g").attr("transform", $$.getTranslate('legend'));
if (!$$.config.legend_show) {
$$.legend.style('visibility', 'hidden');
$$.hiddenLegendIds = $$.mapToIds($$.data.targets);
return;
}
// MEMO: call here to update legend box and tranlate for all
// MEMO: translate will be upated by this, so transform not needed in updateLegend()
$$.updateLegendWithDefaults();
};
c3_chart_internal_fn.updateLegendWithDefaults = function () {
var $$ = this;
$$.updateLegend($$.mapToIds($$.data.targets), {withTransform: false, withTransitionForTransform: false, withTransition: false});
};
c3_chart_internal_fn.updateSizeForLegend = function (legendHeight, legendWidth) {
......@@ -83,6 +89,9 @@ c3_chart_internal_fn.showLegend = function (targetIds) {
if (!config.legend_show) {
config.legend_show = true;
$$.legend.style('visibility', 'visible');
if (!$$.legendHasRendered) {
$$.updateLegendWithDefaults();
}
}
$$.removeHiddenLegendIds(targetIds);
$$.legend.selectAll($$.selectorLegends(targetIds))
......@@ -319,4 +328,5 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) {
$$.updateSvgSize();
// Update g positions
$$.transformAll(withTransitionForTransform, transitions);
$$.legendHasRendered = true;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment