Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
vladminsky committed Jun 22, 2015
1 parent 59e5cdc commit 10fcca6
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 21 deletions.
41 changes: 30 additions & 11 deletions build/development/tauCharts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4524,6 +4524,7 @@ define('spec-transform-auto-layout',['exports', 'underscore', './utils/utils', '
unit.guide.x.cssClass += ' facet-axis';
unit.guide.x.avoidCollisions = true;
unit.guide.y.cssClass += ' facet-axis';
unit.guide.y.avoidCollisions = false;
}

var dimX = meta.dimension(unit.x);
Expand Down Expand Up @@ -4658,6 +4659,7 @@ define('spec-transform-auto-layout',['exports', 'underscore', './utils/utils', '
unit.guide.x.cssClass += ' facet-axis compact';
unit.guide.x.avoidCollisions = true;
unit.guide.y.cssClass += ' facet-axis compact';
unit.guide.y.avoidCollisions = true;

return calcUnitGuide(unit, meta, _2['default'].defaults({
xAxisPadding: 0,
Expand Down Expand Up @@ -5987,14 +5989,15 @@ define('utils/d3-decorators',['exports', '../utils/utils-draw', 'underscore', 'd
}
};

var d3_decorator_avoid_labels_collisions = function d3_decorator_avoid_labels_collisions(nodeScale) {
var d3_decorator_avoid_labels_collisions = function d3_decorator_avoid_labels_collisions(nodeScale, isHorizontal) {
var textOffsetStep = 11;
var refOffsetStart = -10;
var refOffsetStart = isHorizontal ? -10 : 20;
var translateParam = isHorizontal ? 0 : 1;
var layoutModel = [];
nodeScale.selectAll('.tick').each(function (a, i) {
var tick = _d32['default'].select(this);
var text = tick.text();
var translateX = parseFloat(tick.attr('transform').replace('translate(', '').split(',')[0]);
var translateX = parseFloat(tick.attr('transform').replace('translate(', '').split(',')[translateParam]);
var tText = tick.selectAll('text');
var tSpan = tText.selectAll('tspan');
var tNode = tSpan.empty() ? tText : tSpan;
Expand Down Expand Up @@ -6035,17 +6038,32 @@ define('utils/d3-decorators',['exports', '../utils/utils-draw', 'underscore', 'd
if (collideL || collideR) {
curr.l = resolveCollide(prev.l, collideL);

var oldY = parseFloat(curr.textRef.attr('y'));
var size = curr.textRef[0].length;
var text = curr.textRef.text();

if (size > 1) {
text = text.replace(/([\.]*$)/gi, '') + '...';
}

var oldY = parseFloat(curr.textRef.attr('y'));
var newY = oldY + curr.l * textOffsetStep; // -1 | 0 | +1

curr.textRef.attr('y', newY);
curr.tickRef.append('line').attr('class', 'label-ref').attr({
curr.textRef.text(function (d, i) {
return i === 0 ? text : '';
}).attr('y', newY);

var attrs = {
x1: 0,
x2: 0,
y1: newY - 1,
y1: newY + (isHorizontal ? -1 : 5),
y2: refOffsetStart
});
};

if (!isHorizontal) {
attrs.transform = 'rotate(-90)';
}

curr.tickRef.append('line').attr('class', 'label-ref').attr(attrs);
}

return curr;
Expand Down Expand Up @@ -6313,11 +6331,12 @@ define('elements/coords.cartesian',['exports', 'd3', 'underscore', '../utils/uti
(0, _utilsD3Decorators.d3_decorator_prettify_categorical_axis_ticks)(refAxisNode, scale, isHorizontal);
}

if (prettifyTick && isHorizontal && scale.guide.avoidCollisions) {
(0, _utilsD3Decorators.d3_decorator_avoid_labels_collisions)(refAxisNode);
(0, _utilsD3Decorators.d3_decorator_wrap_tick_label)(refAxisNode, scale.guide, isHorizontal);

if (prettifyTick && scale.guide.avoidCollisions) {
(0, _utilsD3Decorators.d3_decorator_avoid_labels_collisions)(refAxisNode, isHorizontal);
}

(0, _utilsD3Decorators.d3_decorator_wrap_tick_label)(refAxisNode, scale.guide, isHorizontal);
(0, _utilsD3Decorators.d3_decorator_prettify_axis_label)(refAxisNode, scale.guide.label, isHorizontal);

if (isHorizontal && scale.scaleType === 'time') {
Expand Down
Loading

0 comments on commit 10fcca6

Please sign in to comment.