Commit 347352d0 authored by Evgeny's avatar Evgeny

Fix problem with legend in nodejs

parent d56a4039
...@@ -4161,6 +4161,8 @@ ...@@ -4161,6 +4161,8 @@
var hasFocused = $$.legend.selectAll('.' + CLASS.legendItemFocused).size(); var hasFocused = $$.legend.selectAll('.' + CLASS.legendItemFocused).size();
var texts, rects, tiles, background; var texts, rects, tiles, background;
var nodeOffset = typeof process === 'undefined' ? 1 : 3;
options = options || {}; options = options || {};
withTransition = getOption(options, "withTransition", true); withTransition = getOption(options, "withTransition", true);
withTransitionForTransform = getOption(options, "withTransitionForTransform", true); withTransitionForTransform = getOption(options, "withTransitionForTransform", true);
...@@ -4242,15 +4244,24 @@ ...@@ -4242,15 +4244,24 @@
$$.updateLegendStep(step); $$.updateLegendStep(step);
} }
function getMargin(i){
if(margins[i] !== 'undefined'){
return margins[i];
} else {
return margins[0];
}
}
if ($$.isLegendRight) { if ($$.isLegendRight) {
xForLegend = function (id) { return maxWidth * steps[id]; }; xForLegend = function (id) { return maxWidth * steps[id] - 2*nodeOffset; };
yForLegend = function (id) { return margins[steps[id]] + offsets[id]; }; yForLegend = function (id) { return getMargin(steps[id]) + offsets[id]*nodeOffset };
} else if ($$.isLegendInset) { } else if ($$.isLegendInset) {
xForLegend = function (id) { return maxWidth * steps[id] + 10; }; xForLegend = function (id) { return maxWidth * steps[id] + 10 - 2*nodeOffset; };
yForLegend = function (id) { return margins[steps[id]] + offsets[id]; }; yForLegend = function (id) { return getMargin(steps[id]) + offsets[id]*nodeOffset; };
} else { } else {
xForLegend = function (id) { return margins[steps[id]] + offsets[id]; }; xForLegend = function (id) { return getMargin(steps[id]) + offsets[id]*nodeOffset; };
yForLegend = function (id) { return maxHeight * steps[id]; }; yForLegend = function (id) { return maxHeight * steps[id] - 2*nodeOffset; };
} }
xForLegendText = function (id, i) { return xForLegend(id, i) + 14; }; xForLegendText = function (id, i) { return xForLegend(id, i) + 14; };
yForLegendText = function (id, i) { return yForLegend(id, i) + 9; }; yForLegendText = function (id, i) { return yForLegend(id, i) + 9; };
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -120,6 +120,8 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { ...@@ -120,6 +120,8 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) {
var hasFocused = $$.legend.selectAll('.' + CLASS.legendItemFocused).size(); var hasFocused = $$.legend.selectAll('.' + CLASS.legendItemFocused).size();
var texts, rects, tiles, background; var texts, rects, tiles, background;
var nodeOffset = typeof process === 'undefined' ? 1 : 3;
options = options || {}; options = options || {};
withTransition = getOption(options, "withTransition", true); withTransition = getOption(options, "withTransition", true);
withTransitionForTransform = getOption(options, "withTransitionForTransform", true); withTransitionForTransform = getOption(options, "withTransitionForTransform", true);
...@@ -201,15 +203,24 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { ...@@ -201,15 +203,24 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) {
$$.updateLegendStep(step); $$.updateLegendStep(step);
} }
function getMargin(i){
if(margins[i] !== 'undefined'){
return margins[i];
} else {
return margins[0];
}
}
if ($$.isLegendRight) { if ($$.isLegendRight) {
xForLegend = function (id) { return maxWidth * steps[id]; }; xForLegend = function (id) { return maxWidth * steps[id] - 2*nodeOffset; };
yForLegend = function (id) { return margins[steps[id]] + offsets[id]; }; yForLegend = function (id) { return getMargin(steps[id]) + offsets[id]*nodeOffset };
} else if ($$.isLegendInset) { } else if ($$.isLegendInset) {
xForLegend = function (id) { return maxWidth * steps[id] + 10; }; xForLegend = function (id) { return maxWidth * steps[id] + 10 - 2*nodeOffset; };
yForLegend = function (id) { return margins[steps[id]] + offsets[id]; }; yForLegend = function (id) { return getMargin(steps[id]) + offsets[id]*nodeOffset; };
} else { } else {
xForLegend = function (id) { return margins[steps[id]] + offsets[id]; }; xForLegend = function (id) { return getMargin(steps[id]) + offsets[id]*nodeOffset; };
yForLegend = function (id) { return maxHeight * steps[id]; }; yForLegend = function (id) { return maxHeight * steps[id] - 2*nodeOffset; };
} }
xForLegendText = function (id, i) { return xForLegend(id, i) + 14; }; xForLegendText = function (id, i) { return xForLegend(id, i) + 14; };
yForLegendText = function (id, i) { return yForLegend(id, i) + 9; }; yForLegendText = function (id, i) { return yForLegend(id, i) + 9; };
......
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