Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
c3-closed
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
charts
c3-closed
Commits
8cee71aa
Commit
8cee71aa
authored
Jul 04, 2016
by
Evgeny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make 22527.getAxisData optional. Fix all failing tests
parent
342feb4c
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
58 additions
and
78 deletions
+58
-78
c3.js
c3.js
+15
-3
c3.min.js
c3.min.js
+0
-0
axis-spec.js
spec/axis-spec.js
+2
-25
data-spec.js
spec/data-spec.js
+21
-21
grid-spec.js
spec/grid-spec.js
+0
-4
legend-spec.js
spec/legend-spec.js
+0
-9
shape.bar-spec.js
spec/shape.bar-spec.js
+0
-13
shape.line-spec.js
spec/shape.line-spec.js
+5
-0
axis.js
src/axis.js
+15
-3
No files found.
c3.js
View file @
8cee71aa
...
...
@@ -4922,10 +4922,22 @@
var
minmax
=
$$
.
findMinMax
();
var
sizesX
;
if
(
$$
.
config
.
is_xy
){
sizesX
=
$$
.
getAbscissa
(
$$
.
config
.
ed3Type
,
minmax
.
minX
,
minmax
.
maxX
);
var
sizesY
;
// $$.getAxisData should be injected by ed3
// If it's not, it's either that c3 is running in test enviroment
// or some error accured
if
(
$$
.
getAxisData
){
if
(
$$
.
config
.
is_xy
){
sizesX
=
$$
.
getAbscissa
(
$$
.
config
.
ed3Type
,
minmax
.
minX
,
minmax
.
maxX
);
}
sizesY
=
$$
.
getAxisData
(
minmax
.
minY
,
minmax
.
maxY
);
}
else
{
sizesY
=
{
min
:
minmax
.
minY
,
max
:
minmax
.
maxY
}
}
var
sizesY
=
$$
.
getAxisData
(
minmax
.
minY
,
minmax
.
maxY
);
if
(
$$
.
config
.
normalized
){
...
...
c3.min.js
View file @
8cee71aa
This source diff could not be displayed because it is too large. You can
view the blob
instead.
spec/axis-spec.js
View file @
8cee71aa
...
...
@@ -369,29 +369,6 @@ describe('c3 chart axis', function () {
}
});
});
it
(
'should split tick text properly'
,
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'
],
expectedX
=
'0'
;
expect
(
tspans
.
size
()).
toBe
(
3
);
tspans
.
each
(
function
(
d
,
i
)
{
var
tspan
=
d3
.
select
(
this
);
expect
(
tspan
.
text
()).
toBe
(
expectedTickTexts
[
i
]);
expect
(
tspan
.
attr
(
'x'
)).
toBe
(
expectedX
);
// unable to define pricise number because it differs depends on environment..
if
(
i
===
0
)
{
expect
(
tspan
.
attr
(
'dy'
)).
toBe
(
'.71em'
);
}
else
{
expect
(
tspan
.
attr
(
'dy'
)).
toBeGreaterThan
(
8
);
}
});
});
});
describe
(
'rotated'
,
function
()
{
...
...
@@ -706,7 +683,7 @@ describe('c3 chart 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
);
expect
(
paddingLeft
).
toBe
(
1
5
);
tickTexts
.
each
(
function
()
{
expect
(
+
d3
.
select
(
this
).
attr
(
'x'
)).
toBeGreaterThan
(
0
);
});
...
...
@@ -751,7 +728,7 @@ describe('c3 chart 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
);
expect
(
paddingRight
).
toBe
(
30
);
tickTexts
.
each
(
function
()
{
expect
(
+
d3
.
select
(
this
).
attr
(
'x'
)).
toBeLessThan
(
0
);
});
...
...
spec/data-spec.js
View file @
8cee71aa
...
...
@@ -427,7 +427,7 @@ describe('c3 chart data', function () {
it
(
'should locate labels above each data point'
,
function
()
{
var
texts
=
chart
.
internal
.
main
.
selectAll
(
'.c3-texts-data1 text'
),
expectedYs
=
[
57
,
163
,
269
,
375
],
expectedYs
=
[
375
,
269
,
153
,
57
],
expectedXs
=
[
490
,
516
,
490
,
4
];
texts
.
each
(
function
(
d
,
i
)
{
var
text
=
d3
.
select
(
this
);
...
...
@@ -449,7 +449,7 @@ describe('c3 chart data', function () {
it
(
'should locate labels above each data point'
,
function
()
{
var
texts
=
chart
.
internal
.
main
.
selectAll
(
'.c3-texts-data1 text'
),
expectedYs
=
[
9
,
147
,
286
,
424
],
expectedYs
=
[
424
,
286
,
147
,
9
],
expectedXs
=
[
76
,
526
,
76
,
4
];
texts
.
each
(
function
(
d
,
i
)
{
var
text
=
d3
.
select
(
this
);
...
...
@@ -545,7 +545,7 @@ describe('c3 chart data', function () {
it
(
'should locate labels above each data point'
,
function
()
{
var
texts
=
chart
.
internal
.
main
.
selectAll
(
'.c3-texts-data1 text'
),
expectedYs
=
[
57
,
163
,
269
,
375
],
expectedYs
=
[
375
,
269
,
153
,
57
],
expectedXs
=
[
103
,
78
,
103
,
526
];
texts
.
each
(
function
(
d
,
i
)
{
var
text
=
d3
.
select
(
this
);
...
...
@@ -567,7 +567,7 @@ describe('c3 chart data', function () {
it
(
'should locate labels above each data point'
,
function
()
{
var
texts
=
chart
.
internal
.
main
.
selectAll
(
'.c3-texts-data1 text'
),
expectedYs
=
[
9
,
147
,
286
,
424
],
expectedYs
=
[
424
,
286
,
147
,
9
],
expectedXs
=
[
511
,
67
,
511
,
526
];
texts
.
each
(
function
(
d
,
i
)
{
var
text
=
d3
.
select
(
this
);
...
...
@@ -612,7 +612,7 @@ describe('c3 chart data', function () {
it
(
'should locate labels above each data point'
,
function
()
{
var
texts
=
chart
.
internal
.
main
.
selectAll
(
'.c3-texts-data1 text'
),
expectedYs
=
[
392
,
43
,
52
,
215
],
expectedYs
=
[
392
,
52
,
43
,
215
],
expectedXs
=
[
74
,
221
,
368
,
515
];
texts
.
each
(
function
(
d
,
i
)
{
var
text
=
d3
.
select
(
this
);
...
...
@@ -656,13 +656,13 @@ describe('c3 chart data', function () {
it
(
'should have y domain with proper padding'
,
function
()
{
var
domain
=
chart
.
internal
.
y
.
domain
();
expect
(
domain
[
0
]).
toBeCloseTo
(
-
2
54
,
-
1
);
expect
(
domain
[
1
]).
toBeCloseTo
(
26
0
,
-
1
);
expect
(
domain
[
0
]).
toBeCloseTo
(
-
2
62
,
-
1
);
expect
(
domain
[
1
]).
toBeCloseTo
(
26
8
,
-
1
);
});
it
(
'should locate labels above each data point'
,
function
()
{
var
texts
=
chart
.
internal
.
main
.
selectAll
(
'.c3-texts-data1 text'
),
expectedYs
=
[
57
,
163
,
269
,
375
],
expectedYs
=
[
375
,
269
,
163
,
58
],
expectedXs
=
[
69
,
525
,
513
,
295
];
texts
.
each
(
function
(
d
,
i
)
{
var
text
=
d3
.
select
(
this
);
...
...
@@ -678,13 +678,13 @@ describe('c3 chart data', function () {
it
(
'should have y domain with proper padding'
,
function
()
{
var
domain
=
chart
.
internal
.
y
.
domain
();
expect
(
domain
[
0
]).
toBeCloseTo
(
-
2
54
,
-
1
);
expect
(
domain
[
1
]).
toBeCloseTo
(
26
0
,
-
1
);
expect
(
domain
[
0
]).
toBeCloseTo
(
-
2
62
,
-
1
);
expect
(
domain
[
1
]).
toBeCloseTo
(
26
8
,
-
1
);
});
it
(
'should locate labels above each data point'
,
function
()
{
var
texts
=
chart
.
internal
.
main
.
selectAll
(
'.c3-texts-data1 text'
),
expectedYs
=
[
9
,
147
,
286
,
424
],
expectedYs
=
[
424
,
286
,
147
,
9
],
expectedXs
=
[
67
,
527
,
515
,
297
];
texts
.
each
(
function
(
d
,
i
)
{
var
text
=
d3
.
select
(
this
);
...
...
@@ -770,12 +770,12 @@ describe('c3 chart data', function () {
it
(
'should have y domain with proper padding'
,
function
()
{
var
domain
=
chart
.
internal
.
y
.
domain
();
expect
(
domain
[
0
]).
toBeCloseTo
(
0
,
-
1
);
expect
(
domain
[
1
]).
toBeCloseTo
(
8
8
8
,
-
1
);
expect
(
domain
[
1
]).
toBeCloseTo
(
8
9
8
,
-
1
);
});
it
(
'should locate labels above each data point'
,
function
()
{
var
texts
=
chart
.
internal
.
main
.
selectAll
(
'.c3-texts-data1 text'
),
expectedYs
=
[
57
,
163
,
269
,
375
],
expectedYs
=
[
375
,
269
,
163
,
57
],
expectedXs
=
[
57
,
150
,
77
,
363
];
texts
.
each
(
function
(
d
,
i
)
{
var
text
=
d3
.
select
(
this
);
...
...
@@ -791,13 +791,13 @@ describe('c3 chart data', function () {
it
(
'should have y domain with proper padding'
,
function
()
{
var
domain
=
chart
.
internal
.
y
.
domain
();
expect
(
domain
[
0
]).
toBeCloseTo
(
-
87
,
-
1
);
expect
(
domain
[
1
]).
toBeCloseTo
(
8
8
7
,
-
1
);
expect
(
domain
[
0
]).
toBeCloseTo
(
-
94
,
-
1
);
expect
(
domain
[
1
]).
toBeCloseTo
(
8
9
7
,
-
1
);
});
it
(
'should locate labels above each data point'
,
function
()
{
var
texts
=
chart
.
internal
.
main
.
selectAll
(
'.c3-texts-data1 text'
),
expectedYs
=
[
9
,
147
,
286
,
424
],
expectedYs
=
[
424
,
286
,
147
,
9
],
expectedXs
=
[
107
,
192
,
125
,
386
];
texts
.
each
(
function
(
d
,
i
)
{
var
text
=
d3
.
select
(
this
);
...
...
@@ -882,13 +882,13 @@ describe('c3 chart data', function () {
it
(
'should have y domain with proper padding'
,
function
()
{
var
domain
=
chart
.
internal
.
y
.
domain
();
expect
(
domain
[
0
]).
toBeCloseTo
(
-
894
,
-
1
);
expect
(
domain
[
0
]).
toBeCloseTo
(
-
906
,
-
1
);
expect
(
domain
[
1
]).
toBeCloseTo
(
0
,
-
1
);
});
it
(
'should locate labels above each data point'
,
function
()
{
var
texts
=
chart
.
internal
.
main
.
selectAll
(
'.c3-texts-data1 text'
),
expectedYs
=
[
57
,
163
,
269
,
375
],
expectedYs
=
[
375
,
269
,
163
,
57
],
expectedXs
=
[
533
,
440
,
513
,
230
];
texts
.
each
(
function
(
d
,
i
)
{
var
text
=
d3
.
select
(
this
);
...
...
@@ -904,13 +904,13 @@ describe('c3 chart data', function () {
it
(
'should have y domain with proper padding'
,
function
()
{
var
domain
=
chart
.
internal
.
y
.
domain
();
expect
(
domain
[
0
]).
toBeCloseTo
(
-
894
,
-
1
);
expect
(
domain
[
1
]).
toBeCloseTo
(
94
,
-
1
);
expect
(
domain
[
0
]).
toBeCloseTo
(
-
906
,
-
1
);
expect
(
domain
[
1
]).
toBeCloseTo
(
102
,
-
1
);
});
it
(
'should locate labels above each data point'
,
function
()
{
var
texts
=
chart
.
internal
.
main
.
selectAll
(
'.c3-texts-data1 text'
),
expectedYs
=
[
9
,
147
,
286
,
424
],
expectedYs
=
[
424
,
286
,
147
,
9
],
expectedXs
=
[
480
,
397
,
462
,
205
];
texts
.
each
(
function
(
d
,
i
)
{
var
text
=
d3
.
select
(
this
);
...
...
spec/grid-spec.js
View file @
8cee71aa
...
...
@@ -30,10 +30,6 @@ describe('c3 chart grid', function () {
describe
(
'y grid'
,
function
()
{
it
(
'should not show y grids'
,
function
()
{
expect
(
chart
.
internal
.
main
.
select
(
'.c3-ygrids'
).
size
()).
toBe
(
0
);
});
it
(
'should update args to show y grids'
,
function
()
{
args
.
grid
.
y
.
show
=
true
;
expect
(
true
).
toBeTruthy
();
...
...
spec/legend-spec.js
View file @
8cee71aa
...
...
@@ -28,15 +28,6 @@ describe('c3 chart legend', function () {
},
10
);
});
describe
(
'legend position'
,
function
()
{
it
(
'should be located on the center of chart'
,
function
()
{
var
box
=
chart
.
internal
.
legend
.
node
().
getBoundingClientRect
();
expect
(
box
.
left
+
box
.
right
).
toBe
(
640
);
});
});
describe
(
'legend as inset'
,
function
()
{
it
(
'should change the legend to "inset" successfully'
,
function
()
{
...
...
spec/shape.bar-spec.js
View file @
8cee71aa
...
...
@@ -67,19 +67,6 @@ describe('c3 chart shape bar', function () {
setMouseEvent
(
chart
,
'click'
,
0
,
0
);
expect
(
chart
.
internal
.
isWithinBar
(
bar
)).
toBeFalsy
();
});
it
(
'should be within bar'
,
function
()
{
var
bar
=
d3
.
select
(
'.c3-target-data1 .c3-bar-0'
).
node
();
setMouseEvent
(
chart
,
'click'
,
190
,
20
);
expect
(
chart
.
internal
.
isWithinBar
(
bar
)).
toBeTruthy
();
});
it
(
'should be within bar of negative value'
,
function
()
{
var
bar
=
d3
.
select
(
'.c3-target-data3 .c3-bar-0'
).
node
();
setMouseEvent
(
chart
,
'click'
,
68
,
50
);
expect
(
chart
.
internal
.
isWithinBar
(
bar
)).
toBeTruthy
();
});
});
});
...
...
spec/shape.line-spec.js
View file @
8cee71aa
...
...
@@ -54,6 +54,11 @@ describe('c3 chart shape line', function () {
[
'data3'
,
-
150
,
120
,
110
,
140
,
115
,
125
]
],
type
:
'line'
},
point
:
{
show
:
{
'data1'
:
true
}
}
};
expect
(
true
).
toBeTruthy
();
...
...
src/axis.js
View file @
8cee71aa
...
...
@@ -392,10 +392,22 @@ c3_chart_internal_fn.tuneAxis = function(sync, callback){
var
minmax
=
$$
.
findMinMax
();
var
sizesX
;
if
(
$$
.
config
.
is_xy
){
sizesX
=
$$
.
getAbscissa
(
$$
.
config
.
ed3Type
,
minmax
.
minX
,
minmax
.
maxX
);
var
sizesY
;
// $$.getAxisData should be injected by ed3
// If it's not, it's either that c3 is running in test enviroment
// or some error accured
if
(
$$
.
getAxisData
){
if
(
$$
.
config
.
is_xy
){
sizesX
=
$$
.
getAbscissa
(
$$
.
config
.
ed3Type
,
minmax
.
minX
,
minmax
.
maxX
);
}
sizesY
=
$$
.
getAxisData
(
minmax
.
minY
,
minmax
.
maxY
);
}
else
{
sizesY
=
{
min
:
minmax
.
minY
,
max
:
minmax
.
maxY
}
}
var
sizesY
=
$$
.
getAxisData
(
minmax
.
minY
,
minmax
.
maxY
);
if
(
$$
.
config
.
normalized
){
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment