Commit built code

parent f5f578b9
...@@ -1035,7 +1035,18 @@ ...@@ -1035,7 +1035,18 @@
xAxis.attr("transform", $$.getTranslate('x')); xAxis.attr("transform", $$.getTranslate('x'));
yAxis.attr("transform", $$.getTranslate('y')); yAxis.attr("transform", $$.getTranslate('y'));
y2Axis.attr("transform", $$.getTranslate('y2')); y2Axis.attr("transform", $$.getTranslate('y2'));
$$.main.select('.' + CLASS.chartArcs).attr("transform", $$.getTranslate('arc'));
var translation = $$.getTranslate('arc');
$$.main.select('.' + CLASS.chartArcs).attr("transform", translation);
// Save translation for future use in node.js
if(isNode()){
if($$.config.subType === "sub-pie"){
$$.config.sub_pie_position = translation.replace('translate(', '').replace(')', '').split(',').map(parseFloat);
} else if($$.config.subType === "sub-bar"){
$$.config.sub_bar_position = translation.replace('translate(', '').replace(')', '').split(',').map(parseFloat);
}
}
}; };
c3_chart_internal_fn.transformAll = function (withTransition, transitions) { c3_chart_internal_fn.transformAll = function (withTransition, transitions) {
var $$ = this; var $$ = this;
...@@ -3415,6 +3426,16 @@ ...@@ -3415,6 +3426,16 @@
// 4 points that make a bar // 4 points that make a bar
var points = getPoints(d, i); var points = getPoints(d, i);
// save computed values because node can't get size of DOM object
if(isNode()){
if(i === 0 && !$$.config.bar_coords) {
$$.config.bar_coords = {};
$$.config.bar_coords.bottom = points[0];
} else {
$$.config.bar_coords.top = points[1];
}
}
// switch points if axis is rotated, not applicable for sub chart // switch points if axis is rotated, not applicable for sub chart
var indexX = config.axis_rotated ? 1 : 0; var indexX = config.axis_rotated ? 1 : 0;
var indexY = config.axis_rotated ? 0 : 1; var indexY = config.axis_rotated ? 0 : 1;
...@@ -3558,6 +3579,14 @@ ...@@ -3558,6 +3579,14 @@
.each(function () { rect = this.getBoundingClientRect(); }); .each(function () { rect = this.getBoundingClientRect(); });
svg.remove(); svg.remove();
body.classed('c3', false); body.classed('c3', false);
// jsdom can't compute real size of text element
// getBoundingClientRect() returns zero-sized rect in jsdom
// This is a hack to estimate size depending on text length and average glyph size
if(isNode()){
// 4 is average glyph size. Warning! This may break on font change.
// 8 is size of square near the text.
rect.width = text.length * 4 - 8;
}
return rect; return rect;
}; };
c3_chart_internal_fn.generateXYForText = function (areaIndices, barIndices, lineIndices, forX) { c3_chart_internal_fn.generateXYForText = function (areaIndices, barIndices, lineIndices, forX) {
...@@ -5453,7 +5482,7 @@ ...@@ -5453,7 +5482,7 @@
main.select('.' + CLASS.chartArcsTitle) main.select('.' + CLASS.chartArcsTitle)
.style("opacity", $$.hasType('donut') || $$.hasType('gauge') ? 1 : 0); .style("opacity", $$.hasType('donut') || $$.hasType('gauge') ? 1 : 0);
if(!isNode() && ($$.config.hasSubs || $$.config.isSub)){ if(($$.config.hasSubs || $$.config.isSub)){
$$.buffer.onlastfinish("draw-lines"+$$.config.isSub, function(){ $$.buffer.onlastfinish("draw-lines"+$$.config.isSub, function(){
$$.buffer.onlastfinish("draw-lines"+$$.config.isSub, function(){ $$.buffer.onlastfinish("draw-lines"+$$.config.isSub, function(){
$$.ed3Internal.redrawLinesOnBoth(); $$.ed3Internal.redrawLinesOnBoth();
...@@ -6549,6 +6578,16 @@ ...@@ -6549,6 +6578,16 @@
$$.ed3Config.subBox = $$.getBox($$.main.selectAll(".sub-chart .c3-chart-bars")); $$.ed3Config.subBox = $$.getBox($$.main.selectAll(".sub-chart .c3-chart-bars"));
// Node can't compute bounding box and subBox will have all params set to 0
// Here we use previously saved coords in $$.config.bar_coords to fill subBox
if(isNode()){
if(!$$.config.bar_coords.bottom) return;
var position = $$.config.bar_coords.top;
$$.ed3Config.subBox.x = position[0];
$$.ed3Config.subBox.y = position[1];
$$.ed3Config.subBox.height = $$.config.bar_coords.bottom[1] - position[1];
}
if(isUndefined($$.ed3Config.coords[order])) return; if(isUndefined($$.ed3Config.coords[order])) return;
var coords = $$.ed3Config.coords[order]; var coords = $$.ed3Config.coords[order];
...@@ -6601,13 +6640,15 @@ ...@@ -6601,13 +6640,15 @@
} }
var sub = ($$.config.isSub ? $$ : $$.ed3Internal.subChart.internal).main;
var offset = parseFloat(sub.attr("transform").replace('translate(', '').replace(')').split(',')[0]);
return { return {
x1: x1, x1: x1 - ($$.config.isSub ? offset : 0),
x2: x2, x2: x2 + ($$.config.isSub ? 0 : offset),
y1: y1, y1: y1,
y2: y2 y2: y2
}; };
}; };
c3.chart.internal.fn.getLineCoordsForPie = function(center, order){ c3.chart.internal.fn.getLineCoordsForPie = function(center, order){
...@@ -6712,7 +6753,19 @@ ...@@ -6712,7 +6753,19 @@
line = main.selectAll(".lineForSubChart").filter(function(d, i){ return i === 0; }); line = main.selectAll(".lineForSubChart").filter(function(d, i){ return i === 0; });
} }
var center = $$.getCenter(main.selectAll('.c3-chart')); var center;
var pieSize = $$.radius;
var position = ($$.config.subType === 'sub-pie') ? $$.config.sub_pie_position : $$.config.sub_bar_position;
// Use previously saved coords in node instead of browser api for bounding box
if(isNode() && $$.config.subType.indexOf('sub') !== -1){
center = {
x: position[0],
y: position[1]
}
} else {
center = $$.getCenter(main.selectAll('.c3-chart'));
}
var coords; var coords;
...@@ -6733,7 +6786,15 @@ ...@@ -6733,7 +6786,15 @@
line = main.selectAll(".lineForSubChart").filter(function(d, i){ return i === 1; }); line = main.selectAll(".lineForSubChart").filter(function(d, i){ return i === 1; });
} }
// The same as 30 lines above
if(isNode() && $$.config.subType.indexOf('sub') !== -1){
center = {
x: position[0],
y: position[1]
}
} else {
center = $$.getCenter(main.selectAll('.c3-chart')); center = $$.getCenter(main.selectAll('.c3-chart'));
}
if($$.config.subType === "sub-pie"){ if($$.config.subType === "sub-pie"){
coords = $$.getLineCoordsForPie(center, 1); coords = $$.getLineCoordsForPie(center, 1);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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