Comparing version 0.6.2 to 0.6.3
@@ -5,3 +5,3 @@ { | ||
"description": "A D3-based reusable chart library", | ||
"version": "0.6.2", | ||
"version": "0.6.3", | ||
"keywords": [], | ||
@@ -8,0 +8,0 @@ "dependencies": { |
{ | ||
"name": "c3", | ||
"version": "0.6.2", | ||
"version": "0.6.3", | ||
"description": "D3-based reusable chart library", | ||
@@ -12,3 +12,3 @@ "main": "c3.js", | ||
"build:js": "npm run build:js:rollup && npm run build:js:uglify", | ||
"build:js:rollup": "rollup -c > c3.js", | ||
"build:js:rollup": "rollup -c", | ||
"build:js:uglify": "uglifyjs c3.js --compress --mangle --comments -o c3.min.js", | ||
@@ -72,3 +72,3 @@ "build:css": "npm run build:css:sass && npm run build:css:min", | ||
"nodemon": "^1.11.0", | ||
"rollup": "^0.60.0", | ||
"rollup": "^0.62.0", | ||
"rollup-plugin-babel": "^3.0.3", | ||
@@ -75,0 +75,0 @@ "uglify-js": "^3.3.17", |
@@ -7,5 +7,9 @@ import babel from 'rollup-plugin-babel'; | ||
output: { | ||
file: 'c3.js', | ||
name: 'c3', | ||
format: 'umd', | ||
banner: `/* @license C3.js v${pkg.version} | (c) C3 Team and other contributors | http://c3js.org/ */` | ||
banner: `/* @license C3.js v${pkg.version} | (c) C3 Team and other contributors | http://c3js.org/ */`, | ||
globals:{ | ||
d3:'d3' | ||
} | ||
}, | ||
@@ -19,3 +23,4 @@ plugins: [babel({ | ||
] | ||
})] | ||
})], | ||
external: ['d3'], | ||
}; |
@@ -52,3 +52,27 @@ describe('c3 api axis', function () { | ||
it('updates axis max values', function () { | ||
chart.axis.max({x: 100, y: 300, y2: 100}); | ||
var max_values = chart.axis.max(); | ||
expect(max_values.x).toBe(100); | ||
expect(max_values.y).toBe(300); | ||
expect(max_values.y2).toBe(100); | ||
}); | ||
it('updates axis min values', function () { | ||
chart.axis.min({x: 0, y: 20, y2: 50}); | ||
var min_values = chart.axis.min(); | ||
expect(min_values.x).toBe(0); | ||
expect(min_values.y).toBe(20); | ||
expect(min_values.y2).toBe(50); | ||
}); | ||
it('updates axis range', function () { | ||
chart.axis.range({min: 5, max: 250}); | ||
var range = chart.axis.range(); | ||
expect(range.max.y).toBe(250); | ||
expect(range.min.y).toBe(5); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -51,2 +51,13 @@ describe('c3 api zoom', function () { | ||
it('should set the max zoom properly', function () { | ||
chart.zoom.max(100); | ||
expect(chart.zoom.max()).toBe(100); | ||
}); | ||
it('should set the min zoom properly', function () { | ||
chart.zoom.min(-1); | ||
expect(chart.zoom.min()).toBe(-1); | ||
}); | ||
describe('with timeseries data', function () { | ||
@@ -53,0 +64,0 @@ beforeAll(function(){ |
@@ -1,2 +0,2 @@ | ||
describe('c3 chart axis', function () { | ||
describe('c3 chart axis', function() { | ||
'use strict'; | ||
@@ -30,14 +30,14 @@ | ||
beforeEach(function (done) { | ||
beforeEach(function(done) { | ||
chart = window.initChart(chart, args, done); | ||
}); | ||
describe('axis.y.tick.count', function () { | ||
describe('axis.y.tick.count', function() { | ||
describe('with only 1 tick on y axis', function () { | ||
beforeAll(function(){ | ||
describe('with only 1 tick on y axis', function() { | ||
beforeAll(function() { | ||
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(); | ||
@@ -48,8 +48,8 @@ expect(ticksSize).toBe(1); | ||
describe('with 2 ticks on y axis', function () { | ||
beforeAll(function(){ | ||
describe('with 2 ticks on y axis', function() { | ||
beforeAll(function() { | ||
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(); | ||
@@ -60,8 +60,8 @@ expect(ticksSize).toBe(2); | ||
describe('with 3 ticks on y axis', function () { | ||
beforeAll(function(){ | ||
describe('with 3 ticks on y axis', function() { | ||
beforeAll(function() { | ||
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(); | ||
@@ -73,12 +73,12 @@ expect(ticksSize).toBe(3); | ||
describe('axis.y.tick.values', function () { | ||
describe('axis.y.tick.values', function() { | ||
var values = [100, 500]; | ||
describe('with only 2 ticks on y axis', function () { | ||
beforeAll(function(){ | ||
describe('with only 2 ticks on y axis', function() { | ||
beforeAll(function() { | ||
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(); | ||
@@ -88,4 +88,4 @@ expect(ticksSize).toBe(2); | ||
it('should have specified tick texts', function () { | ||
d3.select('.c3-axis-y').selectAll('g.tick').each(function (d, i) { | ||
it('should have specified tick texts', function() { | ||
d3.select('.c3-axis-y').selectAll('g.tick').each(function(d, i) { | ||
var text = d3.select(this).select('text').text(); | ||
@@ -98,7 +98,146 @@ expect(+text).toBe(values[i]); | ||
describe('axis y timeseries', function () { | ||
beforeAll(function () { | ||
describe('axis x timeseries with seconds', function() { | ||
beforeAll(function() { | ||
args = { | ||
data: { | ||
type: 'line', | ||
columns: [ | ||
["epoch", 1401879600000, 1401883200000, 1401886800000], | ||
["y", 1955, 2419, 2262] | ||
], | ||
xs: { | ||
y: "epoch" | ||
} | ||
}, | ||
axis: { | ||
x: { | ||
type: "timeseries", | ||
min: new Date(1401879600000), | ||
max: new Date(1401969600000), | ||
localtime: false | ||
} | ||
} | ||
}; | ||
}); | ||
it('should have 3 ticks on x axis', function() { | ||
var ticksSize = d3.select('.c3-axis-x').selectAll('g.tick').size(); | ||
expect(ticksSize).toBe(3); | ||
}); | ||
it('should have specified 1 hour intervals', function() { | ||
var prevValue; | ||
d3.select('.c3-axis-x').selectAll('g.tick').each(function(d, i) { | ||
if (i !== 0) { | ||
var result = d - prevValue; | ||
expect(result).toEqual(3600000); // expressed in milliseconds | ||
} | ||
prevValue = d; | ||
}); | ||
}); | ||
describe('changing min x time and columns', function() { | ||
beforeAll(function() { | ||
args.axis.x.min = new Date(1401876000000); | ||
args.axis.x.max = new Date(1401876075000); | ||
args.data.columns = [ | ||
["epoch", 1401876000000, 1401876015000, 1401876030000, 1401876045000, 1401876060000, 1401876075000], | ||
["y", 1968, 1800, 1955, 2419, 2262, 1940] | ||
]; | ||
}); | ||
it('should have 6 ticks on x axis', function() { | ||
var ticksSize = d3.select('.c3-axis-x').selectAll('g.tick').size(); | ||
expect(ticksSize).toBe(6); // the count starts at initial value and increments by the set interval | ||
}); | ||
it('should have specified 15 seconds intervals', function() { | ||
var prevValue; | ||
d3.select('.c3-axis-x').selectAll('g.tick').each(function(d, i) { | ||
if (i !== 0) { | ||
var result = d - prevValue; | ||
expect(result).toEqual(15000); // expressed in milliseconds | ||
} | ||
prevValue = d; | ||
}); | ||
}); | ||
describe('with axis.x.time.format %Y-%m-%d %H:%M:%S', function() { | ||
beforeAll(function() { | ||
args.axis.x.tick = { | ||
format: "%M:%S" // https://github.com/mbostock/d3/wiki/Time-Formatting#wiki-format | ||
}; | ||
}); | ||
var textDates = [ | ||
'00:00', | ||
'00:15', | ||
'00:30', | ||
'00:45', | ||
'01:00', | ||
'01:15' | ||
]; | ||
it('should format x ticks as dates with time', function() { | ||
var ticks = d3.select('.c3-axis-x').selectAll('g.tick').selectAll('tspan').each(function(d) { | ||
expect(d.splitted).toEqual(textDates[d.index]); | ||
}); | ||
expect(ticks.size()).toBe(6); | ||
}); | ||
}); | ||
}); | ||
}); | ||
describe('axis x timeseries with iso dates', function() { | ||
beforeAll(function() { | ||
args = { | ||
data: { | ||
type: 'line', | ||
columns: [ | ||
["epoch", 1527811200000, 1527897600000, 1527984000000], | ||
["y", 1955, 2419, 2262] | ||
], | ||
xs: { | ||
y: "epoch" | ||
} | ||
}, | ||
axis: { | ||
x: { | ||
type: "timeseries", | ||
min: new Date('2018-06-01'), | ||
max: new Date('2018-06-03'), | ||
localtime: false, | ||
tick: { | ||
format: "%Y-%m-%dT%H:%M:%S" // https://github.com/mbostock/d3/wiki/Time-Formatting#wiki-format | ||
} | ||
} | ||
} | ||
}; | ||
}); | ||
var textDates = [ | ||
'2018-06-01T00:00:00', | ||
'2018-06-02T00:00:00', | ||
'2018-06-03T00:00:00' | ||
]; | ||
it('should format x ticks as dates', function() { | ||
var ticks = d3.select('.c3-axis-x').selectAll('g.tick').selectAll('tspan').each(function(d) { | ||
expect(d.splitted).toEqual(textDates[d.index]); | ||
}); | ||
expect(ticks.size()).toBe(3); | ||
}); | ||
}); | ||
describe('axis y timeseries', function() { | ||
beforeAll(function() { | ||
args = { | ||
data: { | ||
columns: [ | ||
["times", 60000, 120000, 180000, 240000] | ||
@@ -109,6 +248,5 @@ ] | ||
y: { | ||
type : 'timeseries', | ||
type: 'timeseries', | ||
tick: { | ||
time: { | ||
} | ||
time: {} | ||
} | ||
@@ -120,3 +258,3 @@ } | ||
it('should have 7 ticks on y axis', function () { | ||
it('should have 7 ticks on y axis', function() { | ||
var ticksSize = d3.select('.c3-axis-y').selectAll('g.tick').size(); | ||
@@ -126,5 +264,5 @@ expect(ticksSize).toBe(7); // the count starts at initial value and increments by the set interval | ||
it('should have specified 30 second intervals', function () { | ||
it('should have specified 30 second intervals', function() { | ||
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) { | ||
@@ -138,11 +276,11 @@ var result = d - prevValue; | ||
describe('with axis.y.time', function () { | ||
beforeAll(function(){ | ||
describe('with axis.y.time', function() { | ||
beforeAll(function() { | ||
args.axis.y.tick.time = { | ||
type : d3.timeSecond, | ||
interval : 60 | ||
type: d3.timeSecond, | ||
interval: 60 | ||
}; | ||
}); | ||
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(); | ||
@@ -152,5 +290,5 @@ 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; | ||
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) { | ||
@@ -166,3 +304,3 @@ var result = d - prevValue; | ||
describe('axis.x.tick.values', function () { | ||
describe('axis.x.tick.values', function() { | ||
describe('formatted correctly when negative', function() { | ||
@@ -174,4 +312,3 @@ var xValues = [-3.3, -2.2, -1.1, 1.1, 2.2, 3.3]; | ||
columns: [ | ||
['x'].concat(xValues), | ||
['data1', 30, 200, 100, 400, 150, 250], | ||
['x'].concat(xValues), ['data1', 30, 200, 100, 400, 150, 250], | ||
] | ||
@@ -181,3 +318,3 @@ }; | ||
it ('should not generate whole number for negative values', function() { | ||
it('should not generate whole number for negative values', function() { | ||
var tickValues = []; | ||
@@ -189,4 +326,4 @@ d3.select('.c3-axis-x').selectAll('g.tick').selectAll('tspan').each(function(d, i) { expect(tickValues.push(parseFloat(d.splitted)) === xValues[i]); }); | ||
describe('function is provided', function () { | ||
var tickGenerator = function () { | ||
describe('function is provided', function() { | ||
var tickGenerator = function() { | ||
var values = []; | ||
@@ -198,3 +335,3 @@ for (var i = 0; i <= 300; i += 50) { | ||
}; | ||
beforeEach(function () { | ||
beforeEach(function() { | ||
args.axis.x = { | ||
@@ -209,4 +346,4 @@ tick: { | ||
it('should use function to generate ticks', function () { | ||
d3.select('.c3-axis-x').selectAll('g.tick').each(function (d, i) { | ||
it('should use function to generate ticks', function() { | ||
d3.select('.c3-axis-x').selectAll('g.tick').each(function(d, i) { | ||
var tick = d3.select(this).select('text').text(); | ||
@@ -219,9 +356,9 @@ expect(+tick).toBe(window.generatedTicks[i]); | ||
describe('axis.x.tick.width', function () { | ||
describe('axis.x.tick.width', function() { | ||
describe('indexed x axis and y/y2 axis', function () { | ||
describe('indexed x axis and y/y2 axis', function() { | ||
describe('not rotated', function () { | ||
describe('not rotated', function() { | ||
beforeAll(function () { | ||
beforeAll(function() { | ||
args = { | ||
@@ -245,3 +382,3 @@ data: { | ||
it('should construct indexed x axis properly', function () { | ||
it('should construct indexed x axis properly', function() { | ||
var ticks = chart.internal.main.select('.c3-axis-x').selectAll('g.tick'), | ||
@@ -251,6 +388,6 @@ expectedX = '0', | ||
expect(ticks.size()).toBe(6); | ||
ticks.each(function (d, i) { | ||
ticks.each(function(d, i) { | ||
var tspans = d3.select(this).selectAll('tspan'); | ||
expect(tspans.size()).toBe(1); | ||
tspans.each(function () { | ||
tspans.each(function() { | ||
var tspan = d3.select(this); | ||
@@ -264,7 +401,7 @@ expect(tspan.text()).toBe(i + ''); | ||
describe('should set axis.x.tick.format', function () { | ||
beforeAll(function(){ | ||
describe('should set axis.x.tick.format', function() { | ||
beforeAll(function() { | ||
args.axis.x = { | ||
tick: { | ||
format: function () { | ||
format: function() { | ||
return 'very long tick text on x axis'; | ||
@@ -276,3 +413,3 @@ } | ||
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'), | ||
@@ -282,6 +419,6 @@ expectedTexts = ['very long tick text', 'on x axis'], | ||
expect(ticks.size()).toBe(6); | ||
ticks.each(function () { | ||
ticks.each(function() { | ||
var tspans = d3.select(this).selectAll('tspan'); | ||
expect(tspans.size()).toBe(2); | ||
tspans.each(function (d, i) { | ||
tspans.each(function(d, i) { | ||
var tspan = d3.select(this); | ||
@@ -299,3 +436,3 @@ expect(tspan.text()).toBe(expectedTexts[i]); | ||
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'), | ||
@@ -305,6 +442,6 @@ expectedX = '-9', | ||
expect(ticks.size()).toBe(9); | ||
ticks.each(function (d) { | ||
ticks.each(function(d) { | ||
var tspans = d3.select(this).selectAll('tspan'); | ||
expect(tspans.size()).toBe(1); | ||
tspans.each(function () { | ||
tspans.each(function() { | ||
var tspan = d3.select(this); | ||
@@ -318,3 +455,3 @@ expect(tspan.text()).toBe(d + ''); | ||
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'), | ||
@@ -324,6 +461,6 @@ expectedX = '9', | ||
expect(ticks.size()).toBe(9); | ||
ticks.each(function (d) { | ||
ticks.each(function(d) { | ||
var tspans = d3.select(this).selectAll('tspan'); | ||
expect(tspans.size()).toBe(1); | ||
tspans.each(function () { | ||
tspans.each(function() { | ||
var tspan = d3.select(this); | ||
@@ -338,4 +475,4 @@ expect(tspan.text()).toBe(d + ''); | ||
describe('should set big values in y', function () { | ||
beforeAll(function(){ | ||
describe('should set big values in y', function() { | ||
beforeAll(function() { | ||
args.data.columns = [ | ||
@@ -347,5 +484,5 @@ ['data1', 3000000000000000, 200, 100, 400, 150, 250], | ||
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'); | ||
ticks.each(function () { | ||
ticks.each(function() { | ||
var tspans = d3.select(this).selectAll('tspan'); | ||
@@ -358,9 +495,9 @@ expect(tspans.size()).toBe(1); | ||
describe('rotated', function () { | ||
describe('rotated', function() { | ||
beforeAll(function () { | ||
beforeAll(function() { | ||
args.axis.rotated = true; | ||
}); | ||
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'), | ||
@@ -370,6 +507,6 @@ expectedTexts = ['very long tick text on', 'x axis'], | ||
expect(ticks.size()).toBe(6); | ||
ticks.each(function () { | ||
ticks.each(function() { | ||
var tspans = d3.select(this).selectAll('tspan'); | ||
expect(tspans.size()).toBe(2); | ||
tspans.each(function (d, i) { | ||
tspans.each(function(d, i) { | ||
var tspan = d3.select(this); | ||
@@ -387,3 +524,3 @@ expect(tspan.text()).toBe(expectedTexts[i]); | ||
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-y').selectAll('g.tick'), | ||
@@ -402,6 +539,6 @@ expectedTexts = [ | ||
expect(ticks.size()).toBe(7); | ||
ticks.each(function (d, i) { | ||
ticks.each(function(d, i) { | ||
var tspans = d3.select(this).selectAll('tspan'); | ||
expect(tspans.size()).toBe(1); | ||
tspans.each(function () { | ||
tspans.each(function() { | ||
var tspan = d3.select(this); | ||
@@ -418,7 +555,7 @@ expect(tspan.text()).toBe(expectedTexts[i]); | ||
describe('category axis', function () { | ||
describe('category axis', function() { | ||
describe('not rotated', function () { | ||
describe('not rotated', function() { | ||
beforeAll(function () { | ||
beforeAll(function() { | ||
args = { | ||
@@ -441,5 +578,5 @@ data: { | ||
it('should locate ticks properly', function () { | ||
it('should locate ticks properly', function() { | ||
var ticks = chart.internal.main.select('.c3-axis-x').selectAll('g.tick'); | ||
ticks.each(function (d, i) { | ||
ticks.each(function(d, i) { | ||
var tspans = d3.select(this).selectAll('tspan'), | ||
@@ -450,3 +587,3 @@ expectedX = '0', | ||
expect(tspans.size()).toBe(1); | ||
tspans.each(function () { | ||
tspans.each(function() { | ||
var tspan = d3.select(this); | ||
@@ -460,3 +597,3 @@ expect(tspan.attr('x')).toBe(expectedX); | ||
xit('should split tick text properly', function () { | ||
xit('should split tick text properly', function() { | ||
var tick = chart.internal.main.select('.c3-axis-x').select('g.tick'), | ||
@@ -471,3 +608,3 @@ tspans = tick.selectAll('tspan'), | ||
expect(tspans.size()).toBe(3); | ||
tspans.each(function (d, i) { | ||
tspans.each(function(d, i) { | ||
var tspan = d3.select(this); | ||
@@ -486,11 +623,11 @@ expect(tspan.text()).toBe(expectedTickTexts[i]); | ||
describe('rotated', function () { | ||
describe('rotated', function() { | ||
beforeAll(function () { | ||
beforeAll(function() { | ||
args.axis.rotated = true; | ||
}); | ||
it('should locate ticks on rotated axis properly', function () { | ||
it('should locate ticks on rotated axis properly', function() { | ||
var ticks = chart.internal.main.select('.c3-axis-x').selectAll('g.tick'); | ||
ticks.each(function (d, i) { | ||
ticks.each(function(d, i) { | ||
var tspans = d3.select(this).selectAll('tspan'), | ||
@@ -501,3 +638,3 @@ expectedX = '-9', | ||
expect(tspans.size()).toBe(1); | ||
tspans.each(function () { | ||
tspans.each(function() { | ||
var tspan = d3.select(this); | ||
@@ -511,3 +648,3 @@ expect(tspan.attr('x')).toBe(expectedX); | ||
it('should split tick text on rotated axis properly', function () { | ||
it('should split tick text on rotated axis properly', function() { | ||
var tick = chart.internal.main.select('.c3-axis-x').select('g.tick'), | ||
@@ -522,3 +659,3 @@ tspans = tick.selectAll('tspan'), | ||
expect(tspans.size()).toBe(3); | ||
tspans.each(function (d, i) { | ||
tspans.each(function(d, i) { | ||
var tspan = d3.select(this); | ||
@@ -538,7 +675,7 @@ expect(tspan.text()).toBe(expectedTickTexts[i]); | ||
describe('option used', function () { | ||
describe('option used', function() { | ||
describe('as null', function () { | ||
describe('as null', function() { | ||
beforeAll(function () { //'without split ticks', | ||
beforeAll(function() { //'without split ticks', | ||
args.axis.x.tick = { | ||
@@ -549,3 +686,3 @@ multiline: false | ||
it('should split x tick', function () { | ||
it('should split x tick', function() { | ||
var tick = chart.internal.main.select('.c3-axis-x').select('g.tick'), | ||
@@ -558,5 +695,5 @@ tspans = tick.selectAll('tspan'); | ||
describe('as value', function () { | ||
describe('as value', function() { | ||
beforeAll(function () { // 'without split ticks', | ||
beforeAll(function() { // 'without split ticks', | ||
args.axis.x.tick = { | ||
@@ -567,3 +704,3 @@ width: 150 | ||
it('should split x tick to 2 lines properly', function () { | ||
it('should split x tick to 2 lines properly', function() { | ||
var tick = chart.internal.main.select('.c3-axis-x').select('g.tick'), | ||
@@ -577,3 +714,3 @@ tspans = tick.selectAll('tspan'), | ||
expect(tspans.size()).toBe(2); | ||
tspans.each(function (d, i) { | ||
tspans.each(function(d, i) { | ||
var tspan = d3.select(this); | ||
@@ -610,3 +747,3 @@ expect(tspan.text()).toBe(expectedTickTexts[i]); | ||
tspans.each(function (d, i) { | ||
tspans.each(function(d, i) { | ||
var tspan = d3.select(this); | ||
@@ -620,6 +757,6 @@ expect(tspan.text()).toBe(expectedTickText[i]); | ||
describe('with axis.x.tick.format', function () { | ||
describe('with axis.x.tick.format', function() { | ||
beforeAll(function () { // 'with axis.x.tick.format', | ||
args.axis.x.tick.format = function () { | ||
beforeAll(function() { // 'with axis.x.tick.format', | ||
args.axis.x.tick.format = function() { | ||
return ['this is a very long tick text', 'on category axis']; | ||
@@ -629,3 +766,3 @@ }; | ||
it('should have multiline tick text', function () { | ||
it('should have multiline tick text', function() { | ||
var tick = chart.internal.main.select('.c3-axis-x').select('g.tick'), | ||
@@ -635,3 +772,3 @@ tspans = tick.selectAll('tspan'), | ||
expect(tspans.size()).toBe(2); | ||
tspans.each(function (d, i) { | ||
tspans.each(function(d, i) { | ||
var tspan = d3.select(this); | ||
@@ -645,7 +782,7 @@ expect(tspan.text()).toBe(expectedTickTexts[i]); | ||
describe('axis.x.tick.rotate', function () { | ||
describe('axis.x.tick.rotate', function() { | ||
describe('not rotated', function () { | ||
describe('not rotated', function() { | ||
beforeAll(function () { | ||
beforeAll(function() { | ||
args = { | ||
@@ -671,4 +808,4 @@ data: { | ||
it('should rotate tick texts', function () { | ||
chart.internal.main.selectAll('.c3-axis-x g.tick').each(function () { | ||
it('should rotate tick texts', function() { | ||
chart.internal.main.selectAll('.c3-axis-x g.tick').each(function() { | ||
var tick = d3.select(this), | ||
@@ -683,3 +820,3 @@ text = tick.select('text'), | ||
it('should have automatically calculated x axis height', function () { | ||
it('should have automatically calculated x axis height', function() { | ||
var box = chart.internal.main.select('.c3-axis-x').node().getBoundingClientRect(), | ||
@@ -694,7 +831,7 @@ height = chart.internal.getHorizontalAxisHeight('x'); | ||
describe('axis.y.tick.rotate', function () { | ||
describe('axis.y.tick.rotate', function() { | ||
describe('not rotated', function () { | ||
describe('not rotated', function() { | ||
beforeAll(function () { | ||
beforeAll(function() { | ||
args = { | ||
@@ -718,4 +855,4 @@ data: { | ||
it('should rotate tick texts', function () { | ||
chart.internal.main.selectAll('.c3-axis-y g.tick').each(function () { | ||
it('should rotate tick texts', function() { | ||
chart.internal.main.selectAll('.c3-axis-y g.tick').each(function() { | ||
var tick = d3.select(this), | ||
@@ -730,3 +867,3 @@ text = tick.select('text'), | ||
it('should have automatically calculated y axis width', function () { | ||
it('should have automatically calculated y axis width', function() { | ||
var box = chart.internal.main.select('.c3-axis-y').node().getBoundingClientRect(); | ||
@@ -739,7 +876,7 @@ expect(box.width).toBeCloseTo(590, 1); | ||
describe('axis.x.tick.fit', function () { | ||
describe('axis.x.tick.fit', function() { | ||
describe('axis.x.tick.fit = true', function () { | ||
describe('axis.x.tick.fit = true', function() { | ||
beforeAll(function () { // 'should set args for indexed data', | ||
beforeAll(function() { // 'should set args for indexed data', | ||
args = { | ||
@@ -756,3 +893,3 @@ data: { | ||
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'); | ||
@@ -762,4 +899,4 @@ expect(ticks.size()).toBe(6); | ||
describe('should set args for x-based data', function () { | ||
beforeAll(function(){ | ||
describe('should set args for x-based data', function() { | ||
beforeAll(function() { | ||
args = { | ||
@@ -778,3 +915,3 @@ data: { | ||
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'); | ||
@@ -784,3 +921,3 @@ 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(); | ||
@@ -794,6 +931,6 @@ chart.show(); | ||
describe('axis.x.tick.fit = false', function () { | ||
describe('axis.x.tick.fit = false', function() { | ||
describe('should set args for indexed data', function () { | ||
beforeAll(function(){ | ||
describe('should set args for indexed data', function() { | ||
beforeAll(function() { | ||
args = { | ||
@@ -817,3 +954,3 @@ data: { | ||
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'); | ||
@@ -825,4 +962,4 @@ expect(ticks.size()).toBe(11); | ||
describe('should set args for x-based data', function () { | ||
beforeAll(function(){ | ||
describe('should set args for x-based data', function() { | ||
beforeAll(function() { | ||
args.data = { | ||
@@ -839,3 +976,3 @@ x: 'x', | ||
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'); | ||
@@ -845,3 +982,3 @@ expect(ticks.size()).toBe(10); | ||
it('should show fitted ticks after hide and show', function () { | ||
it('should show fitted ticks after hide and show', function() { | ||
chart.hide(); | ||
@@ -856,5 +993,5 @@ chart.show(); | ||
describe('axis.y.inner', function () { | ||
describe('axis.y.inner', function() { | ||
beforeAll(function () { | ||
beforeAll(function() { | ||
args = { | ||
@@ -875,7 +1012,7 @@ data: { | ||
it('should not have inner y axis', function () { | ||
it('should not have inner y axis', function() { | ||
var paddingLeft = chart.internal.getCurrentPaddingLeft(), | ||
tickTexts = chart.internal.main.selectAll('.c3-axis-y g.tick text'); | ||
expect(paddingLeft).toBeGreaterThan(19); | ||
tickTexts.each(function () { | ||
tickTexts.each(function() { | ||
expect(+d3.select(this).attr('x')).toBeLessThan(0); | ||
@@ -885,12 +1022,12 @@ }); | ||
describe('with inner y axis', function () { | ||
beforeAll(function(){ | ||
describe('with inner y axis', function() { | ||
beforeAll(function() { | ||
args.axis.y.inner = true; | ||
}); | ||
it('should have inner y axis', function () { | ||
it('should have inner y axis', function() { | ||
var paddingLeft = chart.internal.getCurrentPaddingLeft(), | ||
tickTexts = chart.internal.main.selectAll('.c3-axis-y g.tick text'); | ||
expect(paddingLeft).toBe(1); | ||
tickTexts.each(function () { | ||
tickTexts.each(function() { | ||
expect(+d3.select(this).attr('x')).toBeGreaterThan(0); | ||
@@ -902,5 +1039,5 @@ }); | ||
describe('axis.y2.inner', function () { | ||
describe('axis.y2.inner', function() { | ||
beforeAll(function () { | ||
beforeAll(function() { | ||
args = { | ||
@@ -922,7 +1059,7 @@ data: { | ||
it('should not have inner y axis', function () { | ||
it('should not have inner y axis', function() { | ||
var paddingRight = chart.internal.getCurrentPaddingRight(), | ||
tickTexts = chart.internal.main.selectAll('.c3-axis-2y g.tick text'); | ||
expect(paddingRight).toBeGreaterThan(19); | ||
tickTexts.each(function () { | ||
tickTexts.each(function() { | ||
expect(+d3.select(this).attr('x')).toBeGreaterThan(0); | ||
@@ -932,12 +1069,12 @@ }); | ||
describe('with inner y axis', function () { | ||
beforeAll(function(){ | ||
describe('with inner y axis', function() { | ||
beforeAll(function() { | ||
args.axis.y2.inner = true; | ||
}); | ||
it('should have inner y axis', function () { | ||
it('should have inner y axis', function() { | ||
var paddingRight = chart.internal.getCurrentPaddingRight(), | ||
tickTexts = chart.internal.main.selectAll('.c3-axis-2y g.tick text'); | ||
expect(paddingRight).toBe(2); | ||
tickTexts.each(function () { | ||
tickTexts.each(function() { | ||
expect(+d3.select(this).attr('x')).toBeLessThan(0); | ||
@@ -944,0 +1081,0 @@ }); |
@@ -474,4 +474,3 @@ import CLASS from './class'; | ||
backgroundArc = $$.arcs.select('g.' + CLASS.chartArcsBackground).selectAll('path.' + CLASS.chartArcsBackground).data($$.data.targets); | ||
backgroundArc.enter().append("path"); | ||
backgroundArc | ||
backgroundArc.enter().append("path") | ||
.attr("class", function (d, i) { return CLASS.chartArcsBackground + ' ' + CLASS.chartArcsBackground +'-'+ i; }) | ||
@@ -478,0 +477,0 @@ .attr("d", function (d1) { |
import CLASS from './class'; | ||
import { Component } from './core'; | ||
import { isValue, isFunction, isString, isEmpty } from './util'; | ||
import {isValue, isFunction, isString, isEmpty, Component } from './util'; | ||
@@ -5,0 +4,0 @@ export var c3_axis_fn; |
import Axis from './axis'; | ||
import CLASS from './class'; | ||
import { isValue, isFunction, isString, isUndefined, isDefined, ceil10, asHalfPixel, diffDomain, isEmpty, notEmpty, getOption, hasValue, sanitise, getPathBox } from './util'; | ||
import { | ||
c3, | ||
isEmpty, | ||
notEmpty, | ||
isValue, | ||
isFunction, | ||
isString, | ||
isUndefined, | ||
isDefined, | ||
ceil10, | ||
asHalfPixel, | ||
diffDomain, | ||
getOption, | ||
hasValue, | ||
sanitise, | ||
getPathBox | ||
} from './util'; | ||
export var c3 = { version: "0.6.2" }; | ||
export {c3}; | ||
@@ -10,46 +26,2 @@ export var c3_chart_fn; | ||
export function Component(owner, componentKey, fn) { | ||
this.owner = owner; | ||
c3.chart.internal[componentKey] = fn; | ||
} | ||
function Chart(config) { | ||
var $$ = this.internal = new ChartInternal(this); | ||
$$.loadConfig(config); | ||
$$.beforeInit(config); | ||
$$.init(); | ||
$$.afterInit(config); | ||
// bind "this" to nested API | ||
(function bindThis(fn, target, argThis) { | ||
Object.keys(fn).forEach(function (key) { | ||
target[key] = fn[key].bind(argThis); | ||
if (Object.keys(fn[key]).length > 0) { | ||
bindThis(fn[key], target[key], argThis); | ||
} | ||
}); | ||
})(c3_chart_fn, this, this); | ||
} | ||
function ChartInternal(api) { | ||
var $$ = this; | ||
$$.d3 = window.d3 ? window.d3 : typeof require !== 'undefined' ? require("d3") : undefined; | ||
$$.api = api; | ||
$$.config = $$.getDefaultConfig(); | ||
$$.data = {}; | ||
$$.cache = {}; | ||
$$.axes = {}; | ||
} | ||
c3.generate = function (config) { | ||
return new Chart(config); | ||
}; | ||
c3.chart = { | ||
fn: Chart.prototype, | ||
internal: { | ||
fn: ChartInternal.prototype, | ||
} | ||
}; | ||
c3_chart_fn = c3.chart.fn; | ||
@@ -56,0 +28,0 @@ c3_chart_internal_fn = c3.chart.internal.fn; |
@@ -1,3 +0,40 @@ | ||
import { c3_chart_internal_fn } from './core'; | ||
import {ChartInternal} from './chart-internal'; | ||
export var c3 = { version: "0.6.3" , | ||
chart: { | ||
fn: Chart.prototype, | ||
internal: { | ||
fn: ChartInternal.prototype, | ||
} | ||
} | ||
}; | ||
export function Chart(config) { | ||
var $$ = this.internal = new ChartInternal(this); | ||
$$.loadConfig(config); | ||
$$.beforeInit(config); | ||
$$.init(); | ||
$$.afterInit(config); | ||
// bind "this" to nested API | ||
(function bindThis(fn, target, argThis) { | ||
Object.keys(fn).forEach(function (key) { | ||
target[key] = fn[key].bind(argThis); | ||
if (Object.keys(fn[key]).length > 0) { | ||
bindThis(fn[key], target[key], argThis); | ||
} | ||
}); | ||
})(c3.chart.fn, this, this); | ||
} | ||
c3.generate = function (config) { | ||
return new Chart(config); | ||
}; | ||
export function Component(owner, componentKey, fn) { | ||
this.owner = owner; | ||
c3.chart.internal[componentKey] = fn; | ||
} | ||
export var isValue = function (v) { | ||
@@ -16,3 +53,3 @@ return v || v === 0; | ||
export var isUndefined = function (v) { | ||
return typeof v === 'undefined'; | ||
return typeof v === 'undefined'; | ||
}; | ||
@@ -35,3 +72,3 @@ export var isDefined = function (v) { | ||
export var notEmpty = function (o) { | ||
return !c3_chart_internal_fn.isEmpty(o); | ||
return !c3.chart.internal.fn.isEmpty(o); | ||
}; | ||
@@ -38,0 +75,0 @@ export var getOption = function (options, key, defaultValue) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3620059
537
35105