Commit built files

parent abbeb175
...@@ -8452,6 +8452,38 @@ ...@@ -8452,6 +8452,38 @@
tickTextCharSize = size; tickTextCharSize = size;
return size; return size;
} }
function hasIntersection (rect1, rect2) {
var r1x2 = rect1.x + rect1.width;
var r2x2 = rect2.x + rect2.width;
var r1y2 = rect1.y + rect1.height;
var r2y2 = rect2.y + rect2.height;
return (rect1.x < r2x2 && r1x2 > rect2.x &&
rect1.y < r2y2 && r1y2 > rect2.y);
}
function cullRects(rects){
if(rects.length < 2) return;
var cullGap = 0;
var i, j, l = rects.length;
for(i = 1, j = 0 ; i < l; i++){
if(hasIntersection(rects[i], rects[j])){
cullGap = Math.max(cullGap, i-j);
} else {
j = i;
}
}
if(!cullGap) return;
var cullStep = cullGap+1;
for(i = 0; i < l; i++){
if(i % cullStep){
rects[i] = null;
}
}
}
function axis(g) { function axis(g) {
g.each(function () { g.each(function () {
var g = d3.select(this); var g = d3.select(this);
...@@ -8539,16 +8571,6 @@ ...@@ -8539,16 +8571,6 @@
return dy; return dy;
} }
function hasIntersection (rect1, rect2) {
var r1x2 = rect1.x + rect1.width;
var r2x2 = rect2.x + rect2.width;
var r1y2 = rect1.y + rect1.height;
var r2y2 = rect2.y + rect2.height;
return (rect1.x < r2x2 && r1x2 > rect2.x &&
rect1.y < r2y2 && r1y2 > rect2.y);
}
function tickSize(d) { function tickSize(d) {
return innerTickSize; return innerTickSize;
} }
...@@ -8570,13 +8592,6 @@ ...@@ -8570,13 +8592,6 @@
tspan.exit().remove(); tspan.exit().remove();
var axisId = $$.isXAxis(orient) ? 'x' : 'y'; var axisId = $$.isXAxis(orient) ? 'x' : 'y';
var textClass = '.c3-axis-' + axisId + ' .tick'
var textRects = text.data().map(function(data) {
var rect = $$.getTextRect(textFormatted(data), textClass);
// Smaal additional padding between texts
rect.width += 10;
return rect;
});
var fontSize = parseFloat(getStyleValue($$, '.c3-axis-y .tick', 'font-size')); var fontSize = parseFloat(getStyleValue($$, '.c3-axis-y .tick', 'font-size'));
...@@ -8709,26 +8724,22 @@ ...@@ -8709,26 +8724,22 @@
break; break;
} }
var last = textRects.length - 1; var textClass = '.c3-axis-' + axisId + ' .tick';
var textRects = text.data().map(function(data) {
rectPositionFn(textRects[0], text.data()[0]); var rect = $$.getTextRect(textFormatted(data), textClass);
rectPositionFn(textRects[last], text.data().pop()); // Smaal additional padding between texts
rect.width += 10;
var addedTextRects = [textRects[0], textRects[last]]; return rect;
text.style('display', function(d, i){ });
if(i === 0 || i === last) return 'block';
var rect = textRects[i]; text.each(function(d, i){
rectPositionFn(rect, d); rectPositionFn(textRects[i], d);
var visible = !addedTextRects.some(function(added){
return hasIntersection(rect, added);
}); });
if(visible){ cullRects(textRects);
addedTextRects.push(rect);
}
return visible ? 'block' : 'none'; text.style('display', function(d, i){
return textRects[i] === null ? 'none' : 'block';
}); });
}); });
} }
......
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