Commit 90387157 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Refactor tick char size calculation - #730

parent 2c7a5835
......@@ -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) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -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);
......
......@@ -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) {
......
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