Tick culling: depend on tick width

parent 4caef74d
......@@ -8401,7 +8401,9 @@
var start = domain[0], stop = domain[domain.length - 1];
return start < stop ? [ start, stop ] : [ stop, start ];
}
function shouldDrawTickText(id){
function shouldDrawTickText(id, m){
// Multiplier to handle long tick texts
m = m || 1;
var heightLimits = [
// Left is width, right is n
// Every nth tick will be shown
......@@ -8415,8 +8417,8 @@
// Left is width, right is n
// Every nth tick will be show
[-Infinity],
[100, 6],
[200, 4],
[70, 6],
[140, 4],
[300, 2],
[Infinity, 1]
];
......@@ -8424,7 +8426,7 @@
var size = $$.config.axis_rotated ? $$.currentWidth : $$.currentHeight;
var sizeLimits = $$.config.axis_rotated ? widthLimits : heightLimits;
for(var i = sizeLimits.length-1; i--; ){
if(size > sizeLimits[i][0]) {
if(size > sizeLimits[i][0] * m) {
divisor = sizeLimits[i+1][1];
break;
}
......@@ -8575,21 +8577,24 @@
text = tick.select("text");
text.style('display', function(d, i){
return shouldDrawTickText(i - indexOfZero) ? 'block' : 'none';
});
var maxTickLength = 1;
tspan = text.selectAll('tspan')
.data(function (d, i) {
var splitted = params.tickMultiline ? splitTickText(d, params.tickWidth) : [].concat(textFormatted(d));
counts[i] = splitted.length;
return splitted.map(function (s) {
maxTickLength = Math.max(maxTickLength, s.length);
return { index: i, splitted: String(s) };
});
});
tspan.enter().append('tspan');
tspan.exit().remove();
text.style('display', function(d, i){
return shouldDrawTickText(i - indexOfZero, $$.config.axis_rotated ? maxTickLength : 1) ? 'block' : 'none';
});
var fontSize = parseFloat(getStyleValue($$, '.c3-axis-y .tick', 'font-size'));
var axisId = $$.isXAxis(orient) ? 'x' : 'y';
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -34,7 +34,9 @@ function c3_axis(d3, params, $$) {
var start = domain[0], stop = domain[domain.length - 1];
return start < stop ? [ start, stop ] : [ stop, start ];
}
function shouldDrawTickText(id){
function shouldDrawTickText(id, m){
// Multiplier to handle long tick texts
m = m || 1;
var heightLimits = [
// Left is width, right is n
// Every nth tick will be shown
......@@ -48,8 +50,8 @@ function c3_axis(d3, params, $$) {
// Left is width, right is n
// Every nth tick will be show
[-Infinity],
[100, 6],
[200, 4],
[70, 6],
[140, 4],
[300, 2],
[Infinity, 1]
];
......@@ -57,7 +59,7 @@ function c3_axis(d3, params, $$) {
var size = $$.config.axis_rotated ? $$.currentWidth : $$.currentHeight;
var sizeLimits = $$.config.axis_rotated ? widthLimits : heightLimits;
for(var i = sizeLimits.length-1; i--; ){
if(size > sizeLimits[i][0]) {
if(size > sizeLimits[i][0] * m) {
divisor = sizeLimits[i+1][1];
break;
}
......@@ -208,21 +210,24 @@ function c3_axis(d3, params, $$) {
text = tick.select("text");
text.style('display', function(d, i){
return shouldDrawTickText(i - indexOfZero) ? 'block' : 'none';
});
var maxTickLength = 1;
tspan = text.selectAll('tspan')
.data(function (d, i) {
var splitted = params.tickMultiline ? splitTickText(d, params.tickWidth) : [].concat(textFormatted(d));
counts[i] = splitted.length;
return splitted.map(function (s) {
maxTickLength = Math.max(maxTickLength, s.length);
return { index: i, splitted: String(s) };
});
});
tspan.enter().append('tspan');
tspan.exit().remove();
text.style('display', function(d, i){
return shouldDrawTickText(i - indexOfZero, $$.config.axis_rotated ? maxTickLength : 1) ? 'block' : 'none';
});
var fontSize = parseFloat(getStyleValue($$, '.c3-axis-y .tick', 'font-size'));
var axisId = $$.isXAxis(orient) ? 'x' : 'y';
......
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