Add Y axis culling for non-rotated charts

parent e0f74dbf
...@@ -27,7 +27,14 @@ function c3_axis(d3, params, $$) { ...@@ -27,7 +27,14 @@ function c3_axis(d3, params, $$) {
return start < stop ? [ start, stop ] : [ stop, start ]; return start < stop ? [ start, stop ] : [ stop, start ];
} }
function shouldDrawTickText(id){ function shouldDrawTickText(id){
if(!$$.config.axis_rotated) return true; var heightLimits = [
// Left is width, right is number of tick labels to be removed
[-Infinity],
[150, 10],
[200, 5],
[270, 2],
[Infinity, 1]
];
var widthLimits = [ var widthLimits = [
// Left is width, right is number of tick labels to be removed // Left is width, right is number of tick labels to be removed
[-Infinity], [-Infinity],
...@@ -37,9 +44,11 @@ function c3_axis(d3, params, $$) { ...@@ -37,9 +44,11 @@ function c3_axis(d3, params, $$) {
[Infinity, 1] [Infinity, 1]
]; ];
var divisor; var divisor;
for(var i = widthLimits.length-1; i--; ){ var size = $$.config.axis_rotated ? $$.currentWidth : $$.currentHeight;
if($$.currentWidth > widthLimits[i][0]) { var sizeLimits = $$.config.axis_rotated ? widthLimits : heightLimits;
divisor = widthLimits[i+1][1]; for(var i = sizeLimits.length-1; i--; ){
if(size > sizeLimits[i][0]) {
divisor = sizeLimits[i+1][1];
break; break;
} }
} }
...@@ -181,11 +190,10 @@ function c3_axis(d3, params, $$) { ...@@ -181,11 +190,10 @@ function c3_axis(d3, params, $$) {
text = tick.select("text"); text = tick.select("text");
if($$.config.axis_rotated && orient === 'bottom') {
text.style('display', function(d, i){ text.style('display', function(d, i){
return shouldDrawTickText(i) ? 'block' : 'none'; return shouldDrawTickText(i) ? 'block' : 'none';
}); });
}
tspan = text.selectAll('tspan') tspan = text.selectAll('tspan')
.data(function (d, i) { .data(function (d, i) {
......
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