Browse Source

Fix tick width for non-fit category axis - #726

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

4
c3.js

@ -6539,7 +6539,7 @@
}
if (!maxWidth || maxWidth <= 0) {
maxWidth = isVertical ? 95 : params.isCategory ? (tickOffset * 2 - 10) : 110;
maxWidth = isVertical ? 95 : params.isCategory ? (Math.ceil(scale1(ticks[1]) - scale1(ticks[0])) - 10) : 110;
}
function split(splitted, text) {
@ -6570,7 +6570,7 @@
if (orient === 'left' || orient === 'right') {
dy = -((counts[d.index] - 1) * (sizeFor1Char.h / 2) - (params.isCategory ? 2 : 3));
} else {
dy = params.isCategory ? ".40em" : ".71em";
dy = ".71em";
}
}
return dy;

2
c3.min.js vendored

File diff suppressed because one or more lines are too long

4
spec/axis-spec.js

@ -362,7 +362,7 @@ describe('c3 chart axis', function () {
ticks.each(function (d, i) {
var tspans = d3.select(this).selectAll('tspan'),
expectedX = '0',
expectedDy = '.40em';
expectedDy = '.71em';
if (i > 0) { // i === 0 should be checked in next test
expect(tspans.size()).toBe(1);
tspans.each(function () {
@ -390,7 +390,7 @@ describe('c3 chart axis', function () {
expect(tspan.attr('x')).toBe(expectedX);
// unable to define pricise number because it differs depends on environment..
if (i === 0) {
expect(tspan.attr('dy')).toBe('.40em');
expect(tspan.attr('dy')).toBe('.71em');
} else {
expect(tspan.attr('dy')).toBeGreaterThan(8);
}

4
src/c3.axis.js

@ -111,7 +111,7 @@ function c3_axis(d3, params) {
}
if (!maxWidth || maxWidth <= 0) {
maxWidth = isVertical ? 95 : params.isCategory ? (tickOffset * 2 - 10) : 110;
maxWidth = isVertical ? 95 : params.isCategory ? (Math.ceil(scale1(ticks[1]) - scale1(ticks[0])) - 10) : 110;
}
function split(splitted, text) {
@ -142,7 +142,7 @@ function c3_axis(d3, params) {
if (orient === 'left' || orient === 'right') {
dy = -((counts[d.index] - 1) * (sizeFor1Char.h / 2) - (params.isCategory ? 2 : 3));
} else {
dy = params.isCategory ? ".40em" : ".71em";
dy = ".71em";
}
}
return dy;

Loading…
Cancel
Save