mirror of https://github.com/masayuki0812/c3.git
michalkop93
10 years ago
32 changed files with 1002 additions and 135 deletions
@ -1 +1 @@
|
||||
.c3 svg{font:10px sans-serif}.c3 line,.c3 path{fill:none;stroke:#000}.c3 text{-webkit-user-select:none;-moz-user-select:none;user-select:none}.c3-bars path,.c3-event-rect,.c3-legend-item-tile,.c3-xgrid-focus,.c3-ygrid{shape-rendering:crispEdges}.c3-chart-arc path{stroke:#fff}.c3-chart-arc text{fill:#fff;font-size:13px}.c3-grid line{stroke:#aaa}.c3-grid text{fill:#aaa}.c3-xgrid,.c3-ygrid{stroke-dasharray:3 3}.c3-text.c3-empty{fill:gray;font-size:2em}.c3-line{stroke-width:1px}.c3-circle._expanded_{stroke-width:1px;stroke:#fff}.c3-selected-circle{fill:#fff;stroke-width:2px}.c3-bar{stroke-width:0}.c3-bar._expanded_{fill-opacity:.75}.c3-chart-arcs-title{font-size:1.3em}.c3-target.c3-focused{opacity:1}.c3-target.c3-focused path.c3-line,.c3-target.c3-focused path.c3-step{stroke-width:2px}.c3-target.c3-defocused{opacity:.3!important}.c3-region{fill:#4682b4;fill-opacity:.1}.c3-brush .extent{fill-opacity:.1}.c3-legend-item{font-size:12px}.c3-legend-background{opacity:.75;fill:#fff;stroke:#d3d3d3;stroke-width:1}.c3-tooltip{border-collapse:collapse;border-spacing:0;background-color:#fff;empty-cells:show;-webkit-box-shadow:7px 7px 12px -9px #777;-moz-box-shadow:7px 7px 12px -9px #777;box-shadow:7px 7px 12px -9px #777;opacity:.9}.c3-tooltip tr{border:1px solid #CCC}.c3-tooltip th{background-color:#aaa;font-size:14px;padding:2px 5px;text-align:left;color:#FFF}.c3-tooltip td{font-size:13px;padding:3px 6px;background-color:#fff;border-left:1px dotted #999}.c3-tooltip td>span{display:inline-block;width:10px;height:10px;margin-right:6px}.c3-tooltip td.value{text-align:right}.c3-area{stroke-width:0;opacity:.2}.c3-chart-arcs .c3-chart-arcs-background{fill:#e0e0e0;stroke:none}.c3-chart-arcs .c3-chart-arcs-gauge-unit{fill:#000;font-size:16px}.c3-chart-arcs .c3-chart-arcs-gauge-max,.c3-chart-arcs .c3-chart-arcs-gauge-min{fill:#777}.c3-chart-arc .c3-gauge-value{fill:#000;font-size:28px} |
||||
.c3 svg{font:10px sans-serif}.c3 line,.c3 path{fill:none;stroke:#000}.c3 text{-webkit-user-select:none;-moz-user-select:none;user-select:none}.c3-bars path,.c3-event-rect,.c3-legend-item-tile,.c3-xgrid-focus,.c3-ygrid{shape-rendering:crispEdges}.c3-chart-arc path{stroke:#fff}.c3-chart-arc text{fill:#fff;font-size:13px}.c3-grid line{stroke:#aaa}.c3-grid text{fill:#aaa}.c3-xgrid,.c3-ygrid{stroke-dasharray:3 3}.c3-text.c3-empty{fill:gray;font-size:2em}.c3-line{stroke-width:1px}.c3-circle._expanded_{stroke-width:1px;stroke:#fff}.c3-selected-circle{fill:#fff;stroke-width:2px}.c3-bar{stroke-width:0}.c3-bar._expanded_{fill-opacity:.75}.c3-chart-arcs-title{font-size:1.3em}.c3-target.c3-focused{opacity:1}.c3-target.c3-focused path.c3-line,.c3-target.c3-focused path.c3-step{stroke-width:2px}.c3-target.c3-defocused{opacity:.3!important}.c3-region{fill:#4682b4;fill-opacity:.1}.c3-brush .extent{fill-opacity:.1}.c3-legend-item{font-size:12px}.c3-legend-background{opacity:.75;fill:#fff;stroke:#d3d3d3;stroke-width:1}.c3-tooltip-container{z-index:10}.c3-tooltip{border-collapse:collapse;border-spacing:0;background-color:#fff;empty-cells:show;-webkit-box-shadow:7px 7px 12px -9px #777;-moz-box-shadow:7px 7px 12px -9px #777;box-shadow:7px 7px 12px -9px #777;opacity:.9}.c3-tooltip tr{border:1px solid #CCC}.c3-tooltip th{background-color:#aaa;font-size:14px;padding:2px 5px;text-align:left;color:#FFF}.c3-tooltip td{font-size:13px;padding:3px 6px;background-color:#fff;border-left:1px dotted #999}.c3-tooltip td>span{display:inline-block;width:10px;height:10px;margin-right:6px}.c3-tooltip td.value{text-align:right}.c3-area{stroke-width:0;opacity:.2}.c3-chart-arcs .c3-chart-arcs-background{fill:#e0e0e0;stroke:none}.c3-chart-arcs .c3-chart-arcs-gauge-unit{fill:#000;font-size:16px}.c3-chart-arcs .c3-chart-arcs-gauge-max,.c3-chart-arcs .c3-chart-arcs-gauge-min{fill:#777}.c3-chart-arc .c3-gauge-value{fill:#000;font-size:28px} |
File diff suppressed because one or more lines are too long
@ -0,0 +1,126 @@
|
||||
var describe = window.describe, |
||||
expect = window.expect, |
||||
it = window.it, |
||||
beforeEach = window.beforeEach; |
||||
|
||||
describe('c3 api zoom', function () { |
||||
'use strict'; |
||||
|
||||
var chart, d3; |
||||
|
||||
var args = { |
||||
data: { |
||||
columns: [ |
||||
['data1', 30, 200, 100, 400, 150, 250], |
||||
['data2', 50, 20, 10, 40, 15, 25], |
||||
['data3', 150, 120, 110, 140, 115, 125] |
||||
] |
||||
}, |
||||
zoom: { |
||||
enabled: true |
||||
} |
||||
}; |
||||
|
||||
beforeEach(function (done) { |
||||
if (typeof chart === 'undefined') { |
||||
window.initDom(); |
||||
} |
||||
chart = window.c3.generate(args); |
||||
d3 = chart.internal.d3; |
||||
// chart.internal.d3.select('.jasmine_html-reporter').style('display', 'none');
|
||||
|
||||
window.setTimeout(function () { |
||||
done(); |
||||
}, 10); |
||||
}); |
||||
|
||||
describe('zoom', function () { |
||||
|
||||
it('should be zoomed properly', function () { |
||||
var target = [3, 5], domain; |
||||
chart.zoom(target); |
||||
domain = chart.internal.x.domain(); |
||||
expect(domain[0]).toBe(target[0]); |
||||
expect(domain[1]).toBe(target[1]); |
||||
}); |
||||
|
||||
it('should be zoomed properly again', function () { |
||||
var target = [1, 4], domain; |
||||
chart.zoom(target); |
||||
domain = chart.internal.x.domain(); |
||||
expect(domain[0]).toBe(target[0]); |
||||
expect(domain[1]).toBe(target[1]); |
||||
}); |
||||
|
||||
it('should load timeseries data', function () { |
||||
args = { |
||||
data: { |
||||
x: 'date', |
||||
columns: [ |
||||
['date', '2014-01-01', '2014-01-02', '2014-08-01', '2014-10-19'], |
||||
['data1', 30, 200, 100, 400] |
||||
] |
||||
}, |
||||
axis: { |
||||
x: { |
||||
type: 'timeseries' |
||||
} |
||||
}, |
||||
zoom: { |
||||
enabled: true |
||||
} |
||||
}; |
||||
expect(true).toBeTruthy(); |
||||
}); |
||||
|
||||
it('should be zoomed properly', function () { |
||||
var target = [new Date(2014, 7, 1), new Date(2014, 8, 1)], domain; |
||||
chart.zoom(target); |
||||
domain = chart.internal.x.domain(); |
||||
expect(+domain[0]).toBe(+target[0]); |
||||
expect(+domain[1]).toBe(+target[1]); |
||||
}); |
||||
|
||||
it('should be zoomed properly', function () { |
||||
var target = ['2014-08-01', '2014-09-01'], domain; |
||||
chart.zoom(target); |
||||
domain = chart.internal.x.domain(); |
||||
expect(+domain[0]).toBe(+chart.internal.parseDate(target[0])); |
||||
expect(+domain[1]).toBe(+chart.internal.parseDate(target[1])); |
||||
}); |
||||
|
||||
}); |
||||
|
||||
describe('unzoom', function () { |
||||
|
||||
it('should load indexed data', function () { |
||||
args = { |
||||
data: { |
||||
columns: [ |
||||
['data1', 30, 200, 100, 400, 150, 250] |
||||
] |
||||
}, |
||||
zoom: { |
||||
enabled: true |
||||
} |
||||
}; |
||||
expect(true).toBeTruthy(); |
||||
}); |
||||
|
||||
it('should be unzoomed properly', function () { |
||||
var target = [1, 4], orginal = chart.internal.x.domain(), domain; |
||||
|
||||
chart.zoom(target); |
||||
domain = chart.internal.x.domain(); |
||||
expect(domain[0]).toBe(target[0]); |
||||
expect(domain[1]).toBe(target[1]); |
||||
|
||||
chart.unzoom(); |
||||
domain = chart.internal.x.domain(); |
||||
expect(domain[0]).toBe(orginal[0]); |
||||
expect(domain[1]).toBe(orginal[1]); |
||||
}); |
||||
|
||||
}); |
||||
|
||||
}); |
@ -0,0 +1,149 @@
|
||||
var describe = window.describe, |
||||
expect = window.expect, |
||||
it = window.it, |
||||
beforeEach = window.beforeEach; |
||||
|
||||
describe('c3 chart data', function () { |
||||
'use strict'; |
||||
|
||||
var chart, d3; |
||||
|
||||
var args = { |
||||
data: { |
||||
columns: [ |
||||
['data1', 30, 200, 100, 400, 150, 250], |
||||
['data2', 50, 20, 10, 40, 15, 25], |
||||
['data3', 150, 120, 110, 140, 115, 125] |
||||
], |
||||
order: function () { |
||||
return 0; |
||||
} |
||||
} |
||||
}; |
||||
|
||||
beforeEach(function (done) { |
||||
if (typeof chart === 'undefined') { |
||||
window.initDom(); |
||||
} |
||||
chart = window.c3.generate(args); |
||||
d3 = chart.internal.d3; |
||||
chart.internal.d3.select('.jasmine_html-reporter').style('display', 'none'); |
||||
|
||||
window.setTimeout(function () { |
||||
done(); |
||||
}, 10); |
||||
}); |
||||
|
||||
describe('function in data.order', function () { |
||||
it('should return false in isOrderAsc and isOrderDesc functions', function () { |
||||
expect(chart.internal.isOrderAsc() || chart.internal.isOrderDesc()).toBe(false); |
||||
}); |
||||
}); |
||||
|
||||
describe('data.xs', function () { |
||||
|
||||
describe('normal x', function () { |
||||
|
||||
it('should have correct number of xs for each', function () { |
||||
expect(Object.keys(chart.internal.data.xs).length).toBe(3); |
||||
expect(chart.internal.data.xs.data1.length).toBe(6); |
||||
expect(chart.internal.data.xs.data2.length).toBe(6); |
||||
expect(chart.internal.data.xs.data3.length).toBe(6); |
||||
}); |
||||
|
||||
it('should have integer index as x', function () { |
||||
for (var i = 0; i < chart.internal.data.xs.data3.length; i++) { |
||||
expect(chart.internal.data.xs.data1[i]).toBe(i); |
||||
expect(chart.internal.data.xs.data2[i]).toBe(i); |
||||
expect(chart.internal.data.xs.data3[i]).toBe(i); |
||||
} |
||||
}); |
||||
|
||||
}); |
||||
|
||||
describe('timeseries x', function () { |
||||
it('should load timeseries data successfully', function () { |
||||
args = { |
||||
data: { |
||||
x : 'date', |
||||
columns: [ |
||||
['date', '2013-01-01', '2013-01-02', '2013-01-03'], |
||||
['data1', 30, 200, 100], |
||||
['data2', 130, 300, 200] |
||||
] |
||||
}, |
||||
axis : { |
||||
x : { |
||||
type : 'timeseries' |
||||
} |
||||
} |
||||
}; |
||||
expect(true).toBeTruthy(); |
||||
}); |
||||
|
||||
it('should have correct number of xs', function () { |
||||
expect(Object.keys(chart.internal.data.xs).length).toBe(2); |
||||
expect(chart.internal.data.xs.data1.length).toBe(3); |
||||
expect(chart.internal.data.xs.data2.length).toBe(3); |
||||
}); |
||||
|
||||
it('should have Date object as x', function () { |
||||
var xs = chart.internal.data.xs; |
||||
expect(+xs.data1[0]).toBe(+new Date(2013, 0, 1, 0, 0, 0)); |
||||
expect(+xs.data1[1]).toBe(+new Date(2013, 0, 2, 0, 0, 0)); |
||||
expect(+xs.data1[2]).toBe(+new Date(2013, 0, 3, 0, 0, 0)); |
||||
expect(+xs.data2[0]).toBe(+new Date(2013, 0, 1, 0, 0, 0)); |
||||
expect(+xs.data2[1]).toBe(+new Date(2013, 0, 2, 0, 0, 0)); |
||||
expect(+xs.data2[2]).toBe(+new Date(2013, 0, 3, 0, 0, 0)); |
||||
}); |
||||
}); |
||||
|
||||
describe('milliseconds timeseries x', function () { |
||||
it('should load timeseries data successfully', function () { |
||||
args = { |
||||
data: { |
||||
x : 'date', |
||||
xFormat: '%Y-%m-%d %H:%M:%S.%L', |
||||
columns: [ |
||||
['date', "2014-05-20 17:25:00.123", "2014-05-20 17:30:00.345"], |
||||
['data1', 30, 200], |
||||
['data2', 130, 300] |
||||
] |
||||
}, |
||||
axis: { |
||||
x: { |
||||
type: 'timeseries', |
||||
tick: { |
||||
format: '%Y-%m-%d %H:%M:%S.%L' |
||||
} |
||||
} |
||||
} |
||||
}; |
||||
expect(true).toBeTruthy(); |
||||
}); |
||||
|
||||
it('should have correct number of xs', function () { |
||||
expect(Object.keys(chart.internal.data.xs).length).toBe(2); |
||||
expect(chart.internal.data.xs.data1.length).toBe(2); |
||||
expect(chart.internal.data.xs.data2.length).toBe(2); |
||||
}); |
||||
|
||||
it('should have Date object as x', function () { |
||||
var xs = chart.internal.data.xs; |
||||
expect(+xs.data1[0]).toBe(+new Date(2014, 4, 20, 17, 25, 0, 123)); |
||||
expect(+xs.data1[1]).toBe(+new Date(2014, 4, 20, 17, 30, 0, 345)); |
||||
expect(+xs.data2[0]).toBe(+new Date(2014, 4, 20, 17, 25, 0, 123)); |
||||
expect(+xs.data2[1]).toBe(+new Date(2014, 4, 20, 17, 30, 0, 345)); |
||||
}); |
||||
|
||||
it('should have milliseconds tick format', function () { |
||||
var expected = ["2014-05-20 17:25:00.123", "2014-05-20 17:30:00.345"]; |
||||
chart.internal.main.selectAll('.c3-axis-x g.tick text').each(function (d, i) { |
||||
expect(d3.select(this).text()).toBe(expected[i]); |
||||
}); |
||||
}); |
||||
|
||||
}); |
||||
|
||||
}); |
||||
}); |
@ -0,0 +1,96 @@
|
||||
var describe = window.describe, |
||||
expect = window.expect, |
||||
it = window.it, |
||||
beforeEach = window.beforeEach; |
||||
|
||||
var initDom = window.initDom; |
||||
|
||||
describe('c3 chart axis', function () { |
||||
'use strict'; |
||||
|
||||
var chart, d3; |
||||
|
||||
var args = { |
||||
data: { |
||||
columns: [ |
||||
['data1', 30, 200, 100, 400, 150, 250], |
||||
['data2', 50, 20, 10, 40, 15, 25] |
||||
] |
||||
}, |
||||
axis: { |
||||
y: {}, |
||||
y2: {} |
||||
} |
||||
}; |
||||
|
||||
beforeEach(function (done) { |
||||
if (typeof chart === 'undefined') { |
||||
initDom(); |
||||
} |
||||
chart = window.c3.generate(args); |
||||
d3 = chart.internal.d3; |
||||
chart.internal.d3.select('.jasmine_html-reporter').style('display', 'none'); |
||||
|
||||
window.setTimeout(function () { |
||||
done(); |
||||
}, 10); |
||||
}); |
||||
|
||||
describe('axis.y.min', function () { |
||||
|
||||
it('should change axis.y.min to -100', function () { |
||||
args.axis.y.min = -100; |
||||
expect(true).toBeTruthy(); |
||||
}); |
||||
|
||||
it('should be set properly when smaller than max of data', function () { |
||||
var domain = chart.internal.y.domain(); |
||||
expect(domain[0]).toBe(-150); |
||||
expect(domain[1]).toBe(450); |
||||
}); |
||||
|
||||
it('should change axis.y.min to 500', function () { |
||||
args.axis.y.min = 500; |
||||
expect(true).toBeTruthy(); |
||||
}); |
||||
|
||||
it('should be set properly when bigger than max of data', function () { |
||||
var domain = chart.internal.y.domain(); |
||||
expect(domain[0]).toBe(499); |
||||
expect(domain[1]).toBe(511); |
||||
}); |
||||
|
||||
it('should change axis.y.min to undefined', function () { |
||||
args.axis.y.min = undefined; |
||||
expect(true).toBeTruthy(); |
||||
}); |
||||
|
||||
}); |
||||
|
||||
describe('axis.y.max', function () { |
||||
|
||||
it('should change axis.y.max to 1000', function () { |
||||
args.axis.y.max = 1000; |
||||
expect(true).toBeTruthy(); |
||||
}); |
||||
|
||||
it('should be set properly when bigger than min of data', function () { |
||||
var domain = chart.internal.y.domain(); |
||||
expect(domain[0]).toBe(-89); |
||||
expect(domain[1]).toBe(1099); |
||||
}); |
||||
|
||||
it('should change axis.y.max to 0', function () { |
||||
args.axis.y.max = 0; |
||||
expect(true).toBeTruthy(); |
||||
}); |
||||
|
||||
it('should be set properly when smaller than min of data', function () { |
||||
var domain = chart.internal.y.domain(); |
||||
expect(domain[0]).toBe(-11); |
||||
expect(domain[1]).toBe(1); |
||||
}); |
||||
|
||||
}); |
||||
|
||||
}); |
@ -0,0 +1,140 @@
|
||||
var describe = window.describe, |
||||
expect = window.expect, |
||||
it = window.it, |
||||
beforeEach = window.beforeEach; |
||||
|
||||
describe('c3 chart interaction', function () { |
||||
'use strict'; |
||||
|
||||
var chart, d3; |
||||
|
||||
var args = { |
||||
data: { |
||||
columns: [ |
||||
['data1', 30, 200, 100, 400, 150, 250], |
||||
['data2', 50, 20, 10, 40, 15, 25], |
||||
['data3', 150, 120, 110, 140, 115, 125] |
||||
] |
||||
} |
||||
}; |
||||
|
||||
beforeEach(function (done) { |
||||
if (typeof chart === 'undefined') { |
||||
window.initDom(); |
||||
} |
||||
chart = window.c3.generate(args); |
||||
d3 = chart.internal.d3; |
||||
chart.internal.d3.select('.jasmine_html-reporter').style('display', 'none'); |
||||
|
||||
window.setTimeout(function () { |
||||
done(); |
||||
}, 10); |
||||
}); |
||||
|
||||
describe('generate event rects', function () { |
||||
|
||||
describe('custom x', function () { |
||||
|
||||
it('should generate bar chart', function () { |
||||
args = { |
||||
data: { |
||||
x: 'x', |
||||
columns: [ |
||||
['x', 0, 1000, 3000, 10000], |
||||
['data', 10, 10, 10, 10] |
||||
], |
||||
type: 'bar' |
||||
} |
||||
}; |
||||
expect(true).toBeTruthy(); |
||||
}); |
||||
|
||||
it('should have 4 event rects properly', function () { |
||||
var lefts = [77.5, 137, 203.5, 402.5], |
||||
widths = [59.5, 66.5, 199, 191.5]; |
||||
d3.selectAll('.c3-event-rect').each(function (d, i) { |
||||
var box = d3.select(this).node().getBoundingClientRect(); |
||||
expect(box.left).toBe(lefts[i]); |
||||
expect(box.width).toBe(widths[i]); |
||||
}); |
||||
}); |
||||
|
||||
it('should generate bar chart with only one data', function () { |
||||
args = { |
||||
data: { |
||||
x: 'x', |
||||
columns: [ |
||||
['x', 0], |
||||
['data', 10] |
||||
], |
||||
type: 'bar' |
||||
} |
||||
}; |
||||
expect(true).toBeTruthy(); |
||||
}); |
||||
|
||||
it('should have 1 event rects properly', function () { |
||||
var eventRects = d3.selectAll('.c3-event-rect'); |
||||
expect(eventRects.size()).toBe(1); |
||||
eventRects.each(function () { |
||||
var box = d3.select(this).node().getBoundingClientRect(); |
||||
expect(box.left).toBe(40.5); |
||||
expect(box.width).toBe(590); |
||||
}); |
||||
}); |
||||
}); |
||||
|
||||
describe('timeseries', function () { |
||||
|
||||
it('should generate line chart with timeseries', function () { |
||||
args = { |
||||
data: { |
||||
x: 'x', |
||||
columns: [ |
||||
['x', '20140101', '20140201', '20140210', '20140301'], |
||||
['data', 10, 10, 10, 10] |
||||
] |
||||
} |
||||
}; |
||||
expect(true).toBeTruthy(); |
||||
}); |
||||
|
||||
it('should have 4 event rects properly', function () { |
||||
var lefts = [43.5, 191, 349, 494], |
||||
widths = [147.5, 158, 145, 134]; |
||||
d3.selectAll('.c3-event-rect').each(function (d, i) { |
||||
var box = d3.select(this).node().getBoundingClientRect(); |
||||
expect(box.left).toBe(lefts[i]); |
||||
expect(box.width).toBe(widths[i]); |
||||
}); |
||||
|
||||
}); |
||||
|
||||
it('should generate line chart with only 1 data timeseries', function () { |
||||
args = { |
||||
data: { |
||||
x: 'x', |
||||
columns: [ |
||||
['x', '20140101'], |
||||
['data', 10] |
||||
] |
||||
} |
||||
}; |
||||
expect(true).toBeTruthy(); |
||||
}); |
||||
|
||||
it('should have 1 event rects properly', function () { |
||||
var eventRects = d3.selectAll('.c3-event-rect'); |
||||
expect(eventRects.size()).toBe(1); |
||||
eventRects.each(function () { |
||||
var box = d3.select(this).node().getBoundingClientRect(); |
||||
expect(box.left).toBe(40.5); |
||||
expect(box.width).toBe(590); |
||||
}); |
||||
}); |
||||
|
||||
}); |
||||
|
||||
}); |
||||
|
||||
}); |
@ -0,0 +1,60 @@
|
||||
var describe = window.describe, |
||||
expect = window.expect, |
||||
it = window.it, |
||||
beforeEach = window.beforeEach; |
||||
|
||||
var initDom = window.initDom; |
||||
|
||||
describe('c3 chart shape line', function () { |
||||
'use strict'; |
||||
|
||||
var chart, d3; |
||||
|
||||
var args = { |
||||
data: { |
||||
columns: [ |
||||
['data1', 30, 200, 100, 400, -150, 250], |
||||
['data2', 50, 20, 10, 40, 15, 25], |
||||
['data3', -150, 120, 110, 140, 115, 125] |
||||
], |
||||
type: 'line' |
||||
} |
||||
}; |
||||
|
||||
beforeEach(function (done) { |
||||
if (typeof chart === 'undefined') { |
||||
initDom(); |
||||
} |
||||
chart = window.c3.generate(args); |
||||
d3 = chart.internal.d3; |
||||
chart.internal.d3.select('.jasmine_html-reporter').style('display', 'none'); |
||||
|
||||
window.setTimeout(function () { |
||||
done(); |
||||
}, 10); |
||||
}); |
||||
|
||||
describe('shape-rendering for line chart', function () { |
||||
|
||||
it("should not have shape-rendering when it's line chart", function () { |
||||
d3.selectAll('.c3-line').each(function () { |
||||
var style = d3.select(this).style('shape-rendering'); |
||||
expect(style).toBe('auto'); |
||||
}); |
||||
}); |
||||
|
||||
it('should chnage to step chart', function () { |
||||
args.data.type = 'step'; |
||||
expect(true).toBeTruthy(); |
||||
}); |
||||
|
||||
it("should have shape-rendering = crispedges when it's step chart", function () { |
||||
d3.selectAll('.c3-line').each(function () { |
||||
var style = d3.select(this).style('shape-rendering'); |
||||
expect(style).toBe('crispedges'); |
||||
}); |
||||
}); |
||||
|
||||
}); |
||||
|
||||
}); |
@ -0,0 +1,108 @@
|
||||
var describe = window.describe, |
||||
expect = window.expect, |
||||
it = window.it, |
||||
beforeEach = window.beforeEach; |
||||
|
||||
describe('c3 chart types', function () { |
||||
'use strict'; |
||||
|
||||
var chart, d3; |
||||
|
||||
var args = { |
||||
data: { |
||||
columns: [ |
||||
['data1', 30, 200, 100, 400, 150, 250], |
||||
['data2', 50, 20, 10, 40, 15, 25], |
||||
['data3', 150, 120, 110, 140, 115, 125] |
||||
], |
||||
type: 'pie' |
||||
} |
||||
}; |
||||
|
||||
beforeEach(function (done) { |
||||
if (typeof chart === 'undefined') { |
||||
window.initDom(); |
||||
} |
||||
chart = window.c3.generate(args); |
||||
d3 = chart.internal.d3; |
||||
chart.internal.d3.select('.jasmine_html-reporter').style('display', 'none'); |
||||
|
||||
window.setTimeout(function () { |
||||
done(); |
||||
}, 10); |
||||
}); |
||||
|
||||
describe('internal.hasArcType', function () { |
||||
|
||||
it('should return true', function () { |
||||
expect(chart.internal.hasArcType()).toBeTruthy(); |
||||
}); |
||||
|
||||
it('should change chart type to "bar" successfully', function () { |
||||
args.data.type = 'bar'; |
||||
expect(true).toBeTruthy(); |
||||
}); |
||||
|
||||
it('should return false', function () { |
||||
expect(chart.internal.hasArcType()).toBeFalsy(); |
||||
}); |
||||
|
||||
}); |
||||
|
||||
describe('internal.hasType', function () { |
||||
|
||||
it('should change chart type to "pie" successfully', function () { |
||||
args.data.type = 'pie'; |
||||
expect(true).toBeTruthy(); |
||||
}); |
||||
|
||||
it('should return true for "pie" type', function () { |
||||
expect(chart.internal.hasType('pie')).toBeTruthy(); |
||||
}); |
||||
|
||||
it('should return false for "line" type', function () { |
||||
expect(chart.internal.hasType('line')).toBeFalsy(); |
||||
}); |
||||
|
||||
it('should return false for "bar" type', function () { |
||||
expect(chart.internal.hasType('bar')).toBeFalsy(); |
||||
}); |
||||
|
||||
it('should unload successfully', function () { |
||||
chart.unload([]); |
||||
expect(true).toBeTruthy(); |
||||
}); |
||||
|
||||
it('should return true for "pie" type even if no data', function () { |
||||
expect(chart.internal.hasType('pie')).toBeTruthy(); |
||||
}); |
||||
|
||||
it('should return false for "line" type even if no data', function () { |
||||
expect(chart.internal.hasType('line')).toBeFalsy(); |
||||
}); |
||||
|
||||
it('should return false for "bar" type even if no data', function () { |
||||
expect(chart.internal.hasType('bar')).toBeFalsy(); |
||||
}); |
||||
|
||||
it('should change chart type to "bar" successfully', function () { |
||||
args.data.type = 'bar'; |
||||
expect(true).toBeTruthy(); |
||||
}); |
||||
|
||||
it('should return false for "pie" type even if no data', function () { |
||||
expect(chart.internal.hasType('pie')).toBeFalsy(); |
||||
}); |
||||
|
||||
it('should return false for "line" type even if no data', function () { |
||||
expect(chart.internal.hasType('line')).toBeFalsy(); |
||||
}); |
||||
|
||||
it('should return true for "bar" type even if no data', function () { |
||||
expect(chart.internal.hasType('bar')).toBeTruthy(); |
||||
}); |
||||
|
||||
|
||||
}); |
||||
|
||||
}); |
Loading…
Reference in new issue