Browse Source

Fix centered category axis - #804

pull/813/head
Masayuki Tanaka 10 years ago
parent
commit
f834ca6ada
  1. 4
      c3.js
  2. 2
      c3.min.js
  3. 2
      spec/axis-spec.js
  4. 4
      src/c3.axis.js

4
c3.js

@ -6650,7 +6650,7 @@
var dy = sizeFor1Char.h;
if (i === 0) {
if (orient === 'left' || orient === 'right') {
dy = -((counts[d.index] - 1) * (sizeFor1Char.h / 2) - (params.isCategory ? 2 : 3));
dy = -((counts[d.index] - 1) * (sizeFor1Char.h / 2) - 3);
} else {
dy = ".71em";
}
@ -6659,7 +6659,7 @@
}
function tickSize(d) {
var tickPosition = scale(d) + tickOffset;
var tickPosition = scale(d) + (tickCentered ? 0 : tickOffset);
return range[0] < tickPosition && tickPosition < range[1] ? innerTickSize : 0;
}

2
c3.min.js vendored

File diff suppressed because one or more lines are too long

2
spec/axis-spec.js

@ -411,7 +411,7 @@ describe('c3 chart axis', function () {
ticks.each(function (d, i) {
var tspans = d3.select(this).selectAll('tspan'),
expectedX = '-9',
expectedDy = '2';
expectedDy = '3';
if (i > 0) { // i === 0 should be checked in next test
expect(tspans.size()).toBe(1);
tspans.each(function () {

4
src/c3.axis.js

@ -146,7 +146,7 @@ function c3_axis(d3, params) {
var dy = sizeFor1Char.h;
if (i === 0) {
if (orient === 'left' || orient === 'right') {
dy = -((counts[d.index] - 1) * (sizeFor1Char.h / 2) - (params.isCategory ? 2 : 3));
dy = -((counts[d.index] - 1) * (sizeFor1Char.h / 2) - 3);
} else {
dy = ".71em";
}
@ -155,7 +155,7 @@ function c3_axis(d3, params) {
}
function tickSize(d) {
var tickPosition = scale(d) + tickOffset;
var tickPosition = scale(d) + (tickCentered ? 0 : tickOffset);
return range[0] < tickPosition && tickPosition < range[1] ? innerTickSize : 0;
}

Loading…
Cancel
Save