Commit d049e52c authored by Evgeny's avatar Evgeny

Add category names turning in debug mode

parent 5365a741
......@@ -8269,13 +8269,13 @@
isVertical = orient === 'left' || orient === 'right';
var indexOfZero = ticks.indexOf(0);
var shouldSplitText = true;
// If we have 'broken' axis
if(indexOfZero === -1){
indexOfZero = 0;
}
// this should be called only when category axis
function splitTickText(d, maxWidth) {
var tickText,
......@@ -8288,6 +8288,10 @@
tickText = textFormatted(d);
}
if(!shouldSplitText){
return [tickText.substr(0, 10)];
}
if($$.isXAxis(orient)){
thinOutCoef = $$.getXThinOutCoef();
} else {
......@@ -8347,6 +8351,23 @@
text = tick.select("text");
if(typeof turn_axis_ticks !== 'undefined'){
if($$.isXAxis(orient)){
if($$.isCategorized()){
shouldSplitText = false;
text.attr('transform', function(d, i){
var tickText = splitTickText(d)[0];
var offset = 15;
var tickSize = getSizeFor1Char(tickText).w * tickText.length + offset;
return 'rotate(-45) translate(' + (-tickSize / 2) + ', ' + (-tickOffset / Math.sqrt(2) / 2) + ')';
});
}
}
}
text.style('display', function(d, i){
return shouldDrawTickText(i - indexOfZero) ? 'block' : 'none';
});
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -139,13 +139,13 @@ function c3_axis(d3, params, $$) {
isVertical = orient === 'left' || orient === 'right';
var indexOfZero = ticks.indexOf(0);
var shouldSplitText = true;
// If we have 'broken' axis
if(indexOfZero === -1){
indexOfZero = 0;
}
// this should be called only when category axis
function splitTickText(d, maxWidth) {
var tickText,
......@@ -158,6 +158,14 @@ function c3_axis(d3, params, $$) {
tickText = textFormatted(d);
}
if(!shouldSplitText){
var postfix = '';
if(tickText.length > 12){
postfix = '...';
}
return [tickText.substr(0, 10) + postfix];
}
if($$.isXAxis(orient)){
thinOutCoef = $$.getXThinOutCoef();
} else {
......@@ -217,6 +225,23 @@ function c3_axis(d3, params, $$) {
text = tick.select("text");
if(typeof turn_axis_ticks !== 'undefined'){
if($$.isXAxis(orient)){
if($$.isCategorized()){
shouldSplitText = false;
text.attr('transform', function(d, i){
var tickText = splitTickText(d)[0];
var offset = 15;
var tickSize = getSizeFor1Char(tickText).w * tickText.length + offset;
return 'rotate(-45) translate(' + (-tickSize / 2) + ', ' + (-tickOffset / Math.sqrt(2) / 2) + ')';
});
}
}
}
text.style('display', function(d, i){
return shouldDrawTickText(i - indexOfZero) ? 'block' : 'none';
});
......
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