Commit 3c5f1452 authored by Evgeny's avatar Evgeny

Fix ticks and grid filtering. Now filtering values from 0 to negative and from 0…

Fix ticks and grid filtering. Now filtering values from 0 to negative and from 0 to positive, rather than from negative to positive
parent caca8119
......@@ -3877,8 +3877,9 @@
var thinOutCoef = $$.getXThinOutCoef;
if(thinOutCoef > 1){
var indexOfZero = xgridData.indexOf(0);
xgridData = xgridData.filter(function(v, i){
return i % thinOutCoef == 0;
return (i - indexOfZero)%thinOutCoef == 0;
});
}
......@@ -3911,8 +3912,9 @@
var thinOutCoef = $$.getYThinOutCoef()
if(thinOutCoef > 1){
var indexOfZero = gridValues.indexOf(0);
gridValues = gridValues.filter(function(v, i){
return i%thinOutCoef == 0;
return (i - indexOfZero)%thinOutCoef == 0;
});
}
......@@ -6608,6 +6610,40 @@
value.value = Math.abs(value.value);
});
});
},
isXAxis = c3_chart_internal_fn.isXAxis = function(orient){
var $$ = this, config = $$.config;
if(config.axis_rotated){
if(orient === 'left' || orient === 'right'){
return true;
} else {
return false;
}
} else {
if(orient === 'top' || orient === 'bottom'){
return true;
} else {
return false;
}
}
},
isYAxis = c3_chart_internal_fn.isYAxis = function(orient){
var $$ = this, config = $$.config;
if(config.axis_rotated){
if(orient === 'top' || orient === 'bottom'){
return true;
} else {
return false;
}
} else {
if(orient === 'left' || orient === 'right'){
return true;
} else {
return false;
}
}
};
......@@ -8207,27 +8243,26 @@
var tickLength = Math.max(innerTickSize, 0) + tickPadding,
isVertical = orient === 'left' || orient === 'right';
var indexOfZero = ticks.indexOf(0);
// If we have 'broken' axis
if(indexOfZero === -1){
indexOfZero = 0;
}
// this should be called only when category axis
function splitTickText(d, maxWidth) {
var tickText = textFormatted(d),
subtext, spaceIndex, textWidth, thinOutCoef, splitted = [];
switch(orient){
case "top":
case "bottom":
{
thinOutCoef = $$.getXThinOutCoef();
break;
}
case "left":
case "right":
{
thinOutCoef = $$.getYThinOutCoef();
break;
}
if($$.isXAxis(orient)){
thinOutCoef = $$.getXThinOutCoef();
} else {
thinOutCoef = $$.getYThinOutCoef();
}
if(d % thinOutCoef !== 0){
if((d-indexOfZero) % thinOutCoef !== 0){
return [""];
}
......@@ -8281,7 +8316,7 @@
text = tick.select("text");
text.style('display', function(d, i){
return shouldDrawTickText(i) ? 'block' : 'none';
return shouldDrawTickText(i - indexOfZero) ? 'block' : 'none';
});
tspan = text.selectAll('tspan')
......@@ -8309,30 +8344,21 @@
var line = tick.select("line");
switch(orient){
case "bottom":
case "top":
{
if($$.config.grid_x_show){
var coef = $$.getXThinOutCoef();
if($$.isXAxis(orient)){
if($$.config.grid_x_show){
var coef = $$.getXThinOutCoef();
line.style('display', function(d, i){
return i%coef == 0 ? 'block' : 'none';
});
}
break;
line.style('display', function(d, i){
return (i-indexOfZero)%coef == 0 ? 'block' : 'none';
});
}
case "left":
case "right":
{
if($$.config.grid_y_show){
var coef = $$.getYThinOutCoef();
} else {
if($$.config.grid_y_show){
var coef = $$.getYThinOutCoef();
line.style('display', function(d, i){
return i%coef == 0 ? 'block' : 'none';
});
}
break;
line.style('display', function(d, i){
return (i-indexOfZero)%coef == 0 ? 'block' : 'none';
});
}
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -138,27 +138,26 @@ function c3_axis(d3, params, $$) {
var tickLength = Math.max(innerTickSize, 0) + tickPadding,
isVertical = orient === 'left' || orient === 'right';
var indexOfZero = ticks.indexOf(0);
// If we have 'broken' axis
if(indexOfZero === -1){
indexOfZero = 0;
}
// this should be called only when category axis
function splitTickText(d, maxWidth) {
var tickText = textFormatted(d),
subtext, spaceIndex, textWidth, thinOutCoef, splitted = [];
switch(orient){
case "top":
case "bottom":
{
thinOutCoef = $$.getXThinOutCoef();
break;
}
case "left":
case "right":
{
thinOutCoef = $$.getYThinOutCoef();
break;
}
if($$.isXAxis(orient)){
thinOutCoef = $$.getXThinOutCoef();
} else {
thinOutCoef = $$.getYThinOutCoef();
}
if(d % thinOutCoef !== 0){
if((d-indexOfZero) % thinOutCoef !== 0){
return [""];
}
......@@ -212,7 +211,7 @@ function c3_axis(d3, params, $$) {
text = tick.select("text");
text.style('display', function(d, i){
return shouldDrawTickText(i) ? 'block' : 'none';
return shouldDrawTickText(i - indexOfZero) ? 'block' : 'none';
});
tspan = text.selectAll('tspan')
......@@ -240,30 +239,21 @@ function c3_axis(d3, params, $$) {
var line = tick.select("line");
switch(orient){
case "bottom":
case "top":
{
if($$.config.grid_x_show){
var coef = $$.getXThinOutCoef();
if($$.isXAxis(orient)){
if($$.config.grid_x_show){
var coef = $$.getXThinOutCoef();
line.style('display', function(d, i){
return i%coef == 0 ? 'block' : 'none';
});
}
break;
line.style('display', function(d, i){
return (i-indexOfZero)%coef == 0 ? 'block' : 'none';
});
}
case "left":
case "right":
{
if($$.config.grid_y_show){
var coef = $$.getYThinOutCoef();
} else {
if($$.config.grid_y_show){
var coef = $$.getYThinOutCoef();
line.style('display', function(d, i){
return i%coef == 0 ? 'block' : 'none';
});
}
break;
line.style('display', function(d, i){
return (i-indexOfZero)%coef == 0 ? 'block' : 'none';
});
}
}
......
......@@ -35,8 +35,9 @@ c3_chart_internal_fn.updateXGrid = function (withoutUpdate) {
var thinOutCoef = $$.getXThinOutCoef;
if(thinOutCoef > 1){
var indexOfZero = xgridData.indexOf(0);
xgridData = xgridData.filter(function(v, i){
return i % thinOutCoef == 0;
return (i - indexOfZero)%thinOutCoef == 0;
});
}
......@@ -69,8 +70,9 @@ c3_chart_internal_fn.updateYGrid = function () {
var thinOutCoef = $$.getYThinOutCoef()
if(thinOutCoef > 1){
var indexOfZero = gridValues.indexOf(0);
gridValues = gridValues.filter(function(v, i){
return i%thinOutCoef == 0;
return (i - indexOfZero)%thinOutCoef == 0;
});
}
......
......@@ -120,5 +120,39 @@ var isValue = c3_chart_internal_fn.isValue = function (v) {
value.value = Math.abs(value.value);
});
});
},
isXAxis = c3_chart_internal_fn.isXAxis = function(orient){
var $$ = this, config = $$.config;
if(config.axis_rotated){
if(orient === 'left' || orient === 'right'){
return true;
} else {
return false;
}
} else {
if(orient === 'top' || orient === 'bottom'){
return true;
} else {
return false;
}
}
},
isYAxis = c3_chart_internal_fn.isYAxis = function(orient){
var $$ = this, config = $$.config;
if(config.axis_rotated){
if(orient === 'top' || orient === 'bottom'){
return true;
} else {
return false;
}
} else {
if(orient === 'left' || orient === 'right'){
return true;
} else {
return false;
}
}
};
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