|
|
@ -33,64 +33,65 @@ describe('c3 chart axis', function () { |
|
|
|
|
|
|
|
|
|
|
|
describe('axis.y.tick.count', function () { |
|
|
|
describe('axis.y.tick.count', function () { |
|
|
|
|
|
|
|
|
|
|
|
it('should update args to have only 1 tick on y axis', function () { |
|
|
|
describe('with only 1 tick on y axis', function () { |
|
|
|
args.axis.y.tick.count = 1; |
|
|
|
beforeAll(function(){ |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
args.axis.y.tick.count = 1; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should have only 1 tick on y axis', function () { |
|
|
|
it('should have only 1 tick on y axis', function () { |
|
|
|
var ticksSize = d3.select('.c3-axis-y').selectAll('g.tick').size(); |
|
|
|
var ticksSize = d3.select('.c3-axis-y').selectAll('g.tick').size(); |
|
|
|
expect(ticksSize).toBe(1); |
|
|
|
expect(ticksSize).toBe(1); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should update args to have 2 ticks on y axis', function () { |
|
|
|
describe('with 2 ticks on y axis', function () { |
|
|
|
args.axis.y.tick.count = 2; |
|
|
|
beforeAll(function(){ |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
args.axis.y.tick.count = 2; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should have 2 ticks on y axis', function () { |
|
|
|
it('should have 2 ticks on y axis', function () { |
|
|
|
var ticksSize = d3.select('.c3-axis-y').selectAll('g.tick').size(); |
|
|
|
var ticksSize = d3.select('.c3-axis-y').selectAll('g.tick').size(); |
|
|
|
expect(ticksSize).toBe(2); |
|
|
|
expect(ticksSize).toBe(2); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should update args to have 3 ticks on y axis', function () { |
|
|
|
describe('with 3 ticks on y axis', function () { |
|
|
|
args.axis.y.tick.count = 3; |
|
|
|
beforeAll(function(){ |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
args.axis.y.tick.count = 3; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should have 3 ticks on y axis', function () { |
|
|
|
it('should have 3 ticks on y axis', function () { |
|
|
|
var ticksSize = d3.select('.c3-axis-y').selectAll('g.tick').size(); |
|
|
|
var ticksSize = d3.select('.c3-axis-y').selectAll('g.tick').size(); |
|
|
|
expect(ticksSize).toBe(3); |
|
|
|
expect(ticksSize).toBe(3); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('axis.y.tick.values', function () { |
|
|
|
describe('axis.y.tick.values', function () { |
|
|
|
|
|
|
|
|
|
|
|
var values = [100, 500]; |
|
|
|
var values = [100, 500]; |
|
|
|
|
|
|
|
|
|
|
|
it('should update args to have only 2 ticks on y axis', function () { |
|
|
|
describe('with only 2 ticks on y axis', function () { |
|
|
|
args.axis.y.tick.values = values; |
|
|
|
beforeAll(function(){ |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
args.axis.y.tick.values = values; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should have only 2 tick on y axis', function () { |
|
|
|
it('should have only 2 tick on y axis', function () { |
|
|
|
var ticksSize = d3.select('.c3-axis-y').selectAll('g.tick').size(); |
|
|
|
var ticksSize = d3.select('.c3-axis-y').selectAll('g.tick').size(); |
|
|
|
expect(ticksSize).toBe(2); |
|
|
|
expect(ticksSize).toBe(2); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should have specified tick texts', function () { |
|
|
|
it('should have specified tick texts', function () { |
|
|
|
d3.select('.c3-axis-y').selectAll('g.tick').each(function (d, i) { |
|
|
|
d3.select('.c3-axis-y').selectAll('g.tick').each(function (d, i) { |
|
|
|
var text = d3.select(this).select('text').text(); |
|
|
|
var text = d3.select(this).select('text').text(); |
|
|
|
expect(+text).toBe(values[i]); |
|
|
|
expect(+text).toBe(values[i]); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('axis y timeseries', function () { |
|
|
|
describe('axis y timeseries', function () { |
|
|
|
|
|
|
|
beforeAll(function () { |
|
|
|
it('should update args', function () { |
|
|
|
|
|
|
|
args = { |
|
|
|
args = { |
|
|
|
data: { |
|
|
|
data: { |
|
|
|
columns: [ |
|
|
|
columns: [ |
|
|
@ -107,7 +108,6 @@ describe('c3 chart axis', function () { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should have 7 ticks on y axis', function () { |
|
|
|
it('should have 7 ticks on y axis', function () { |
|
|
@ -126,27 +126,28 @@ describe('c3 chart axis', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should update args to set axis.y.time', function () { |
|
|
|
describe('with axis.y.time', function () { |
|
|
|
args.axis.y.tick.time = { |
|
|
|
beforeAll(function(){ |
|
|
|
value : 'seconds', |
|
|
|
args.axis.y.tick.time = { |
|
|
|
interval : 60 |
|
|
|
value : 'seconds', |
|
|
|
}; |
|
|
|
interval : 60 |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
}; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should have 4 ticks on y axis', function () { |
|
|
|
it('should have 4 ticks on y axis', function () { |
|
|
|
var ticksSize = d3.select('.c3-axis-y').selectAll('g.tick').size(); |
|
|
|
var ticksSize = d3.select('.c3-axis-y').selectAll('g.tick').size(); |
|
|
|
expect(ticksSize).toBe(4); // the count starts at initial value and increments by the set interval
|
|
|
|
expect(ticksSize).toBe(4); // the count starts at initial value and increments by the set interval
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should have specified 60 second intervals', function () { |
|
|
|
it('should have specified 60 second intervals', function () { |
|
|
|
var prevValue; |
|
|
|
var prevValue; |
|
|
|
d3.select('.c3-axis-y').selectAll('g.tick').each(function (d, i) { |
|
|
|
d3.select('.c3-axis-y').selectAll('g.tick').each(function (d, i) { |
|
|
|
if (i !== 0) { |
|
|
|
if (i !== 0) { |
|
|
|
var result = d - prevValue; |
|
|
|
var result = d - prevValue; |
|
|
|
expect(result).toEqual(60000); // expressed in milliseconds
|
|
|
|
expect(result).toEqual(60000); // expressed in milliseconds
|
|
|
|
} |
|
|
|
} |
|
|
|
prevValue = d; |
|
|
|
prevValue = d; |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -167,7 +168,7 @@ describe('c3 chart axis', function () { |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
chart = window.c3.generate(args); |
|
|
|
chart = window.c3.generate(args); |
|
|
|
window.generatedTicks = tickGenerator(); |
|
|
|
window.generatedTicks = tickGenerator(); // This should be removed from window
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should use function to generate ticks', function () { |
|
|
|
it('should use function to generate ticks', function () { |
|
|
@ -185,7 +186,7 @@ describe('c3 chart axis', function () { |
|
|
|
|
|
|
|
|
|
|
|
describe('not rotated', function () { |
|
|
|
describe('not rotated', function () { |
|
|
|
|
|
|
|
|
|
|
|
it('should update args successfully', function () { |
|
|
|
beforeAll(function () { |
|
|
|
args = { |
|
|
|
args = { |
|
|
|
data: { |
|
|
|
data: { |
|
|
|
columns: [ |
|
|
|
columns: [ |
|
|
@ -202,7 +203,6 @@ describe('c3 chart axis', function () { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should construct indexed x axis properly', function () { |
|
|
|
it('should construct indexed x axis properly', function () { |
|
|
@ -222,95 +222,95 @@ describe('c3 chart axis', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should set axis.x.tick.format', function () { |
|
|
|
describe('should set axis.x.tick.format', function () { |
|
|
|
args.axis.x = { |
|
|
|
beforeAll(function(){ |
|
|
|
tick: { |
|
|
|
args.axis.x = { |
|
|
|
format: function () { |
|
|
|
tick: { |
|
|
|
return 'very long tick text on x axis'; |
|
|
|
format: function () { |
|
|
|
|
|
|
|
return 'very long tick text on x axis'; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
}); |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('should split x axis tick text to multiple lines', function () { |
|
|
|
it('should split x axis tick text to multiple lines', function () { |
|
|
|
var ticks = chart.internal.main.select('.c3-axis-x').selectAll('g.tick'), |
|
|
|
var ticks = chart.internal.main.select('.c3-axis-x').selectAll('g.tick'), |
|
|
|
expectedTexts = ['very long tick text', 'on x axis'], |
|
|
|
expectedTexts = ['very long tick text', 'on x axis'], |
|
|
|
expectedX = '0'; |
|
|
|
expectedX = '0'; |
|
|
|
expect(ticks.size()).toBe(6); |
|
|
|
expect(ticks.size()).toBe(6); |
|
|
|
ticks.each(function () { |
|
|
|
ticks.each(function () { |
|
|
|
var tspans = d3.select(this).selectAll('tspan'); |
|
|
|
var tspans = d3.select(this).selectAll('tspan'); |
|
|
|
expect(tspans.size()).toBe(2); |
|
|
|
expect(tspans.size()).toBe(2); |
|
|
|
tspans.each(function (d, i) { |
|
|
|
tspans.each(function (d, i) { |
|
|
|
var tspan = d3.select(this); |
|
|
|
var tspan = d3.select(this); |
|
|
|
expect(tspan.text()).toBe(expectedTexts[i]); |
|
|
|
expect(tspan.text()).toBe(expectedTexts[i]); |
|
|
|
expect(tspan.attr('x')).toBe(expectedX); |
|
|
|
expect(tspan.attr('x')).toBe(expectedX); |
|
|
|
if (i === 0) { |
|
|
|
if (i === 0) { |
|
|
|
expect(tspan.attr('dy')).toBe('.71em'); |
|
|
|
expect(tspan.attr('dy')).toBe('.71em'); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
expect(tspan.attr('dy')).toBeGreaterThan(8); |
|
|
|
expect(tspan.attr('dy')).toBeGreaterThan(8); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('should construct y axis properly', function () { |
|
|
|
it('should construct y axis properly', function () { |
|
|
|
var ticks = chart.internal.main.select('.c3-axis-y').selectAll('g.tick'), |
|
|
|
var ticks = chart.internal.main.select('.c3-axis-y').selectAll('g.tick'), |
|
|
|
expectedX = '-9', |
|
|
|
expectedX = '-9', |
|
|
|
expectedDy = '3'; |
|
|
|
expectedDy = '3'; |
|
|
|
expect(ticks.size()).toBe(9); |
|
|
|
expect(ticks.size()).toBe(9); |
|
|
|
ticks.each(function (d) { |
|
|
|
ticks.each(function (d) { |
|
|
|
var tspans = d3.select(this).selectAll('tspan'); |
|
|
|
var tspans = d3.select(this).selectAll('tspan'); |
|
|
|
expect(tspans.size()).toBe(1); |
|
|
|
expect(tspans.size()).toBe(1); |
|
|
|
tspans.each(function () { |
|
|
|
tspans.each(function () { |
|
|
|
var tspan = d3.select(this); |
|
|
|
var tspan = d3.select(this); |
|
|
|
expect(tspan.text()).toBe(d + ''); |
|
|
|
expect(tspan.text()).toBe(d + ''); |
|
|
|
expect(tspan.attr('x')).toBe(expectedX); |
|
|
|
expect(tspan.attr('x')).toBe(expectedX); |
|
|
|
expect(tspan.attr('dy')).toBe(expectedDy); |
|
|
|
expect(tspan.attr('dy')).toBe(expectedDy); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('should construct y2 axis properly', function () { |
|
|
|
it('should construct y2 axis properly', function () { |
|
|
|
var ticks = chart.internal.main.select('.c3-axis-y2').selectAll('g.tick'), |
|
|
|
var ticks = chart.internal.main.select('.c3-axis-y2').selectAll('g.tick'), |
|
|
|
expectedX = '9', |
|
|
|
expectedX = '9', |
|
|
|
expectedDy = '3'; |
|
|
|
expectedDy = '3'; |
|
|
|
expect(ticks.size()).toBe(9); |
|
|
|
expect(ticks.size()).toBe(9); |
|
|
|
ticks.each(function (d) { |
|
|
|
ticks.each(function (d) { |
|
|
|
var tspans = d3.select(this).selectAll('tspan'); |
|
|
|
var tspans = d3.select(this).selectAll('tspan'); |
|
|
|
expect(tspans.size()).toBe(1); |
|
|
|
expect(tspans.size()).toBe(1); |
|
|
|
tspans.each(function () { |
|
|
|
tspans.each(function () { |
|
|
|
var tspan = d3.select(this); |
|
|
|
var tspan = d3.select(this); |
|
|
|
expect(tspan.text()).toBe(d + ''); |
|
|
|
expect(tspan.text()).toBe(d + ''); |
|
|
|
expect(tspan.attr('x')).toBe(expectedX); |
|
|
|
expect(tspan.attr('x')).toBe(expectedX); |
|
|
|
expect(tspan.attr('dy')).toBe(expectedDy); |
|
|
|
expect(tspan.attr('dy')).toBe(expectedDy); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should set big values in y', function () { |
|
|
|
describe('should set big values in y', function () { |
|
|
|
args.data.columns = [ |
|
|
|
beforeAll(function(){ |
|
|
|
['data1', 3000000000000000, 200, 100, 400, 150, 250], |
|
|
|
args.data.columns = [ |
|
|
|
['data2', 50, 20, 10, 40, 15, 25] |
|
|
|
['data1', 3000000000000000, 200, 100, 400, 150, 250], |
|
|
|
]; |
|
|
|
['data2', 50, 20, 10, 40, 15, 25] |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
]; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should not split y axis tick text to multiple lines', function () { |
|
|
|
it('should not split y axis tick text to multiple lines', function () { |
|
|
|
var ticks = chart.internal.main.select('.c3-axis-y2').selectAll('g.tick'); |
|
|
|
var ticks = chart.internal.main.select('.c3-axis-y2').selectAll('g.tick'); |
|
|
|
ticks.each(function () { |
|
|
|
ticks.each(function () { |
|
|
|
var tspans = d3.select(this).selectAll('tspan'); |
|
|
|
var tspans = d3.select(this).selectAll('tspan'); |
|
|
|
expect(tspans.size()).toBe(1); |
|
|
|
expect(tspans.size()).toBe(1); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('rotated', function () { |
|
|
|
describe('rotated', function () { |
|
|
|
|
|
|
|
|
|
|
|
it('should update args to rotate axis', function () { |
|
|
|
beforeAll(function () { |
|
|
|
args.axis.rotated = true; |
|
|
|
args.axis.rotated = true; |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should split x axis tick text to multiple lines', function () { |
|
|
|
it('should split x axis tick text to multiple lines', function () { |
|
|
@ -367,7 +367,7 @@ describe('c3 chart axis', function () { |
|
|
|
|
|
|
|
|
|
|
|
describe('not rotated', function () { |
|
|
|
describe('not rotated', function () { |
|
|
|
|
|
|
|
|
|
|
|
it('should update args successfully', function () { |
|
|
|
beforeAll(function () { |
|
|
|
args = { |
|
|
|
args = { |
|
|
|
data: { |
|
|
|
data: { |
|
|
|
x: 'x', |
|
|
|
x: 'x', |
|
|
@ -383,7 +383,6 @@ describe('c3 chart axis', function () { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should locate ticks properly', function () { |
|
|
|
it('should locate ticks properly', function () { |
|
|
@ -429,9 +428,8 @@ describe('c3 chart axis', function () { |
|
|
|
|
|
|
|
|
|
|
|
describe('rotated', function () { |
|
|
|
describe('rotated', function () { |
|
|
|
|
|
|
|
|
|
|
|
it('should update args to rotate axis', function () { |
|
|
|
beforeAll(function () { |
|
|
|
args.axis.rotated = true; |
|
|
|
args.axis.rotated = true; |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should locate ticks on rotated axis properly', function () { |
|
|
|
it('should locate ticks on rotated axis properly', function () { |
|
|
@ -480,11 +478,10 @@ describe('c3 chart axis', function () { |
|
|
|
|
|
|
|
|
|
|
|
describe('as null', function () { |
|
|
|
describe('as null', function () { |
|
|
|
|
|
|
|
|
|
|
|
it('should update args not to split ticks', function () { |
|
|
|
beforeAll(function () { //'without split ticks',
|
|
|
|
args.axis.x.tick = { |
|
|
|
args.axis.x.tick = { |
|
|
|
multiline: false |
|
|
|
multiline: false |
|
|
|
}; |
|
|
|
}; |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should split x tick', function () { |
|
|
|
it('should split x tick', function () { |
|
|
@ -497,11 +494,10 @@ describe('c3 chart axis', function () { |
|
|
|
|
|
|
|
|
|
|
|
describe('as value', function () { |
|
|
|
describe('as value', function () { |
|
|
|
|
|
|
|
|
|
|
|
it('should update args not to split ticks', function () { |
|
|
|
beforeAll(function () { // 'without split ticks',
|
|
|
|
args.axis.x.tick = { |
|
|
|
args.axis.x.tick = { |
|
|
|
width: 150 |
|
|
|
width: 150 |
|
|
|
}; |
|
|
|
}; |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should split x tick to 2 lines properly', function () { |
|
|
|
it('should split x tick to 2 lines properly', function () { |
|
|
@ -531,11 +527,10 @@ describe('c3 chart axis', function () { |
|
|
|
|
|
|
|
|
|
|
|
describe('with axis.x.tick.format', function () { |
|
|
|
describe('with axis.x.tick.format', function () { |
|
|
|
|
|
|
|
|
|
|
|
it('should update args to use axis.x.tick.format', function () { |
|
|
|
beforeAll(function () { // 'with axis.x.tick.format',
|
|
|
|
args.axis.x.tick.format = function () { |
|
|
|
args.axis.x.tick.format = function () { |
|
|
|
return ['this is a very long tick text', 'on category axis']; |
|
|
|
return ['this is a very long tick text', 'on category axis']; |
|
|
|
}; |
|
|
|
}; |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should have multiline tick text', function () { |
|
|
|
it('should have multiline tick text', function () { |
|
|
@ -556,7 +551,7 @@ describe('c3 chart axis', function () { |
|
|
|
|
|
|
|
|
|
|
|
describe('not rotated', function () { |
|
|
|
describe('not rotated', function () { |
|
|
|
|
|
|
|
|
|
|
|
it('should update args successfully', function () { |
|
|
|
beforeAll(function () { |
|
|
|
args = { |
|
|
|
args = { |
|
|
|
data: { |
|
|
|
data: { |
|
|
|
x: 'x', |
|
|
|
x: 'x', |
|
|
@ -575,7 +570,6 @@ describe('c3 chart axis', function () { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should rotate tick texts', function () { |
|
|
|
it('should rotate tick texts', function () { |
|
|
@ -603,7 +597,7 @@ describe('c3 chart axis', function () { |
|
|
|
|
|
|
|
|
|
|
|
describe('not rotated', function () { |
|
|
|
describe('not rotated', function () { |
|
|
|
|
|
|
|
|
|
|
|
it('should update args successfully', function () { |
|
|
|
beforeAll(function () { |
|
|
|
args = { |
|
|
|
args = { |
|
|
|
data: { |
|
|
|
data: { |
|
|
|
columns: [ |
|
|
|
columns: [ |
|
|
@ -620,7 +614,6 @@ describe('c3 chart axis', function () { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should rotate tick texts', function () { |
|
|
|
it('should rotate tick texts', function () { |
|
|
@ -646,7 +639,7 @@ describe('c3 chart axis', function () { |
|
|
|
|
|
|
|
|
|
|
|
describe('axis.x.tick.fit = true', function () { |
|
|
|
describe('axis.x.tick.fit = true', function () { |
|
|
|
|
|
|
|
|
|
|
|
it('should set args for indexed data', function () { |
|
|
|
beforeAll(function () { // 'should set args for indexed data',
|
|
|
|
args = { |
|
|
|
args = { |
|
|
|
data: { |
|
|
|
data: { |
|
|
|
columns: [ |
|
|
|
columns: [ |
|
|
@ -656,7 +649,6 @@ describe('c3 chart axis', function () { |
|
|
|
] |
|
|
|
] |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should show fitted ticks on indexed data', function () { |
|
|
|
it('should show fitted ticks on indexed data', function () { |
|
|
@ -664,93 +656,95 @@ describe('c3 chart axis', function () { |
|
|
|
expect(ticks.size()).toBe(6); |
|
|
|
expect(ticks.size()).toBe(6); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should set args for x-based data', function () { |
|
|
|
describe('should set args for x-based data', function () { |
|
|
|
args = { |
|
|
|
beforeAll(function(){ |
|
|
|
data: { |
|
|
|
args = { |
|
|
|
x: 'x', |
|
|
|
data: { |
|
|
|
columns: [ |
|
|
|
x: 'x', |
|
|
|
['x', 10, 20, 100, 110, 200, 1000], |
|
|
|
columns: [ |
|
|
|
['data1', 30, 200, 100, 400, 150, 250], |
|
|
|
['x', 10, 20, 100, 110, 200, 1000], |
|
|
|
['data2', 50, 20, 10, 40, 15, 25], |
|
|
|
['data1', 30, 200, 100, 400, 150, 250], |
|
|
|
['data3', 150, 120, 110, 140, 115, 125] |
|
|
|
['data2', 50, 20, 10, 40, 15, 25], |
|
|
|
] |
|
|
|
['data3', 150, 120, 110, 140, 115, 125] |
|
|
|
} |
|
|
|
] |
|
|
|
}; |
|
|
|
} |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
}; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should show fitted ticks on indexed data', function () { |
|
|
|
it('should show fitted ticks on indexed data', function () { |
|
|
|
var ticks = chart.internal.main.selectAll('.c3-axis-x g.tick'); |
|
|
|
var ticks = chart.internal.main.selectAll('.c3-axis-x g.tick'); |
|
|
|
expect(ticks.size()).toBe(6); |
|
|
|
expect(ticks.size()).toBe(6); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should show fitted ticks after hide and show', function () { |
|
|
|
it('should show fitted ticks after hide and show', function () { |
|
|
|
chart.hide(); |
|
|
|
chart.hide(); |
|
|
|
chart.show(); |
|
|
|
chart.show(); |
|
|
|
var ticks = chart.internal.main.selectAll('.c3-axis-x g.tick'); |
|
|
|
var ticks = chart.internal.main.selectAll('.c3-axis-x g.tick'); |
|
|
|
expect(ticks.size()).toBe(6); |
|
|
|
expect(ticks.size()).toBe(6); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('axis.x.tick.fit = false', function () { |
|
|
|
describe('axis.x.tick.fit = false', function () { |
|
|
|
|
|
|
|
|
|
|
|
it('should set args for indexed data', function () { |
|
|
|
describe('should set args for indexed data', function () { |
|
|
|
args = { |
|
|
|
beforeAll(function(){ |
|
|
|
data: { |
|
|
|
args = { |
|
|
|
columns: [ |
|
|
|
data: { |
|
|
|
['data1', 30, 200, 100, 400, 150, 250], |
|
|
|
columns: [ |
|
|
|
['data2', 50, 20, 10, 40, 15, 25], |
|
|
|
['data1', 30, 200, 100, 400, 150, 250], |
|
|
|
['data3', 150, 120, 110, 140, 115, 125] |
|
|
|
['data2', 50, 20, 10, 40, 15, 25], |
|
|
|
] |
|
|
|
['data3', 150, 120, 110, 140, 115, 125] |
|
|
|
}, |
|
|
|
] |
|
|
|
axis: { |
|
|
|
}, |
|
|
|
x: { |
|
|
|
axis: { |
|
|
|
tick: { |
|
|
|
x: { |
|
|
|
fit: false |
|
|
|
tick: { |
|
|
|
|
|
|
|
fit: false |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
}); |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('should show fitted ticks on indexed data', function () { |
|
|
|
it('should show fitted ticks on indexed data', function () { |
|
|
|
var ticks = chart.internal.main.selectAll('.c3-axis-x g.tick'); |
|
|
|
var ticks = chart.internal.main.selectAll('.c3-axis-x g.tick'); |
|
|
|
expect(ticks.size()).toBe(11); |
|
|
|
expect(ticks.size()).toBe(11); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should set args for x-based data', function () { |
|
|
|
|
|
|
|
args.data = { |
|
|
|
|
|
|
|
x: 'x', |
|
|
|
|
|
|
|
columns: [ |
|
|
|
|
|
|
|
['x', 10, 20, 100, 110, 200, 1000], |
|
|
|
|
|
|
|
['data1', 30, 200, 100, 400, 150, 250], |
|
|
|
|
|
|
|
['data2', 50, 20, 10, 40, 15, 25], |
|
|
|
|
|
|
|
['data3', 150, 120, 110, 140, 115, 125] |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
expect(true).toBeTruthy(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('should show fitted ticks on indexed data', function () { |
|
|
|
describe('should set args for x-based data', function () { |
|
|
|
var ticks = chart.internal.main.selectAll('.c3-axis-x g.tick'); |
|
|
|
beforeAll(function(){ |
|
|
|
expect(ticks.size()).toBe(10); |
|
|
|
args.data = { |
|
|
|
}); |
|
|
|
x: 'x', |
|
|
|
|
|
|
|
columns: [ |
|
|
|
|
|
|
|
['x', 10, 20, 100, 110, 200, 1000], |
|
|
|
|
|
|
|
['data1', 30, 200, 100, 400, 150, 250], |
|
|
|
|
|
|
|
['data2', 50, 20, 10, 40, 15, 25], |
|
|
|
|
|
|
|
['data3', 150, 120, 110, 140, 115, 125] |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should show fitted ticks after hide and show', function () { |
|
|
|
it('should show fitted ticks on indexed data', function () { |
|
|
|
chart.hide(); |
|
|
|
var ticks = chart.internal.main.selectAll('.c3-axis-x g.tick'); |
|
|
|
chart.show(); |
|
|
|
expect(ticks.size()).toBe(10); |
|
|
|
var ticks = chart.internal.main.selectAll('.c3-axis-x g.tick'); |
|
|
|
}); |
|
|
|
expect(ticks.size()).toBe(10); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('should show fitted ticks after hide and show', function () { |
|
|
|
|
|
|
|
chart.hide(); |
|
|
|
|
|
|
|
chart.show(); |
|
|
|
|
|
|
|
var ticks = chart.internal.main.selectAll('.c3-axis-x g.tick'); |
|
|
|
|
|
|
|
expect(ticks.size()).toBe(10); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('axis.y.inner', function () { |
|
|
|
describe('axis.y.inner', function () { |
|
|
|
|
|
|
|
|
|
|
|
it('should update args', function () { |
|
|
|
beforeAll(function () { |
|
|
|
args = { |
|
|
|
args = { |
|
|
|
data: { |
|
|
|
data: { |
|
|
|
columns: [ |
|
|
|
columns: [ |
|
|
@ -764,7 +758,6 @@ describe('c3 chart axis', function () { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should not have inner y axis', function () { |
|
|
|
it('should not have inner y axis', function () { |
|
|
@ -776,25 +769,25 @@ describe('c3 chart axis', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should update args to have inner y axis', function () { |
|
|
|
describe('with inner y axis', function () { |
|
|
|
args.axis.y.inner = true; |
|
|
|
beforeAll(function(){ |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
args.axis.y.inner = true; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should have inner y axis', function () { |
|
|
|
it('should have inner y axis', function () { |
|
|
|
var paddingLeft = chart.internal.getCurrentPaddingLeft(), |
|
|
|
var paddingLeft = chart.internal.getCurrentPaddingLeft(), |
|
|
|
tickTexts = chart.internal.main.selectAll('.c3-axis-y g.tick text'); |
|
|
|
tickTexts = chart.internal.main.selectAll('.c3-axis-y g.tick text'); |
|
|
|
expect(paddingLeft).toBe(1); |
|
|
|
expect(paddingLeft).toBe(1); |
|
|
|
tickTexts.each(function () { |
|
|
|
tickTexts.each(function () { |
|
|
|
expect(+d3.select(this).attr('x')).toBeGreaterThan(0); |
|
|
|
expect(+d3.select(this).attr('x')).toBeGreaterThan(0); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('axis.y2.inner', function () { |
|
|
|
describe('axis.y2.inner', function () { |
|
|
|
|
|
|
|
|
|
|
|
it('should update args', function () { |
|
|
|
beforeAll(function () { |
|
|
|
args = { |
|
|
|
args = { |
|
|
|
data: { |
|
|
|
data: { |
|
|
|
columns: [ |
|
|
|
columns: [ |
|
|
@ -809,7 +802,6 @@ describe('c3 chart axis', function () { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should not have inner y axis', function () { |
|
|
|
it('should not have inner y axis', function () { |
|
|
@ -821,20 +813,20 @@ describe('c3 chart axis', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should update args to have inner y axis', function () { |
|
|
|
describe('with inner y axis', function () { |
|
|
|
args.axis.y2.inner = true; |
|
|
|
beforeAll(function(){ |
|
|
|
expect(true).toBeTruthy(); |
|
|
|
args.axis.y2.inner = true; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should have inner y axis', function () { |
|
|
|
it('should have inner y axis', function () { |
|
|
|
var paddingRight = chart.internal.getCurrentPaddingRight(), |
|
|
|
var paddingRight = chart.internal.getCurrentPaddingRight(), |
|
|
|
tickTexts = chart.internal.main.selectAll('.c3-axis-2y g.tick text'); |
|
|
|
tickTexts = chart.internal.main.selectAll('.c3-axis-2y g.tick text'); |
|
|
|
expect(paddingRight).toBe(2); |
|
|
|
expect(paddingRight).toBe(2); |
|
|
|
tickTexts.each(function () { |
|
|
|
tickTexts.each(function () { |
|
|
|
expect(+d3.select(this).attr('x')).toBeLessThan(0); |
|
|
|
expect(+d3.select(this).attr('x')).toBeLessThan(0); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|