Browse Source

Refactor tick char size calculation - #730

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

4
c3.js

@ -6525,7 +6525,7 @@
tickOffset = tickX = 0;
}
var text, tspan, sizeFor1Char = getSizeFor1Char(tick), counts = [];
var text, tspan, sizeFor1Char = getSizeFor1Char(g.select('.tick')), counts = [];
var tickLength = Math.max(innerTickSize, 0) + tickPadding,
isVertical = orient === 'left' || orient === 'right';
@ -6539,7 +6539,7 @@
}
if (!maxWidth || maxWidth <= 0) {
maxWidth = isVertical ? 95 : params.isCategory ? (Math.ceil(scale1(ticks[1]) - scale1(ticks[0])) - 10) : 110;
maxWidth = isVertical ? 95 : params.isCategory ? (Math.ceil(scale1(ticks[1]) - scale1(ticks[0])) - 12) : 110;
}
function split(splitted, text) {

2
c3.min.js vendored

File diff suppressed because one or more lines are too long

12
spec/axis-spec.js

@ -378,8 +378,8 @@ describe('c3 chart axis', function () {
var tick = chart.internal.main.select('.c3-axis-x').select('g.tick'),
tspans = tick.selectAll('tspan'),
expectedTickTexts = [
'this is a very',
'long tick text on',
'this is a very long',
'tick text on',
'category axis'
],
expectedX = '0';
@ -427,8 +427,8 @@ describe('c3 chart axis', function () {
tspans = tick.selectAll('tspan'),
expectedTickTexts = [
'this is a very long',
'tick text on',
'category axis'
'tick text on category',
'axis'
],
expectedX = '-9';
expect(tspans.size()).toBe(3);
@ -479,8 +479,8 @@ describe('c3 chart axis', function () {
var tick = chart.internal.main.select('.c3-axis-x').select('g.tick'),
tspans = tick.selectAll('tspan'),
expectedTickTexts = [
'this is a very long tick text',
'on category axis'
'this is a very long tick text on',
'category axis'
],
expectedX = '-9';
expect(tspans.size()).toBe(2);

4
src/c3.axis.js

@ -97,7 +97,7 @@ function c3_axis(d3, params) {
tickOffset = tickX = 0;
}
var text, tspan, sizeFor1Char = getSizeFor1Char(tick), counts = [];
var text, tspan, sizeFor1Char = getSizeFor1Char(g.select('.tick')), counts = [];
var tickLength = Math.max(innerTickSize, 0) + tickPadding,
isVertical = orient === 'left' || orient === 'right';
@ -111,7 +111,7 @@ function c3_axis(d3, params) {
}
if (!maxWidth || maxWidth <= 0) {
maxWidth = isVertical ? 95 : params.isCategory ? (Math.ceil(scale1(ticks[1]) - scale1(ticks[0])) - 10) : 110;
maxWidth = isVertical ? 95 : params.isCategory ? (Math.ceil(scale1(ticks[1]) - scale1(ticks[0])) - 12) : 110;
}
function split(splitted, text) {

Loading…
Cancel
Save