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
Evgeny
c3-closed
Commits
bfac88c2
Commit
bfac88c2
authored
Dec 06, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix axis.y2.inner - #742
parent
56d9d450
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
107 additions
and
23 deletions
+107
-23
c3.js
c3.js
+4
-3
c3.min.js
c3.min.js
+0
-0
axis-spec.js
spec/axis-spec.js
+90
-0
interaction-spec.js
spec/interaction-spec.js
+7
-15
tooltip-spec.js
spec/tooltip-spec.js
+2
-2
core.js
src/core.js
+1
-1
size.js
src/size.js
+3
-2
No files found.
c3.js
View file @
bfac88c2
...
...
@@ -114,7 +114,7 @@
$$
.
xOrient
=
config
.
axis_rotated
?
"left"
:
"bottom"
;
$$
.
yOrient
=
config
.
axis_rotated
?
(
config
.
axis_y_inner
?
"top"
:
"bottom"
)
:
(
config
.
axis_y_inner
?
"right"
:
"left"
);
$$
.
y2Orient
=
config
.
axis_rotated
?
(
config
.
axis_y
_inner
?
"bottom"
:
"top"
)
:
(
config
.
axis_y
_inner
?
"left"
:
"right"
);
$$
.
y2Orient
=
config
.
axis_rotated
?
(
config
.
axis_y
2_inner
?
"bottom"
:
"top"
)
:
(
config
.
axis_y2
_inner
?
"left"
:
"right"
);
$$
.
subXOrient
=
config
.
axis_rotated
?
"left"
:
"bottom"
;
$$
.
isLegendRight
=
config
.
legend_position
===
'right'
;
...
...
@@ -2519,7 +2519,7 @@
}
else
if
(
config
.
axis_rotated
)
{
return
defaultPadding
+
legendWidthOnRight
;
}
else
if
(
!
config
.
axis_y2_show
||
config
.
axis_y2_inner
)
{
// && !config.axis_rotated
return
defaultPadding
+
legendWidthOnRight
+
(
$$
.
getY2AxisLabelPosition
().
isOuter
?
20
:
0
);
return
2
+
legendWidthOnRight
+
(
$$
.
getY2AxisLabelPosition
().
isOuter
?
20
:
0
);
}
else
{
return
ceil10
(
$$
.
getAxisWidthByAxisId
(
'y2'
))
+
legendWidthOnRight
;
}
...
...
@@ -2547,9 +2547,10 @@
c3_chart_internal_fn
.
getSvgLeft
=
function
(
withoutRecompute
)
{
var
$$
=
this
,
config
=
$$
.
config
,
hasLeftAxisRect
=
config
.
axis_rotated
||
(
!
config
.
axis_rotated
&&
!
config
.
axis_y_inner
),
leftAxisClass
=
config
.
axis_rotated
?
CLASS
.
axisX
:
CLASS
.
axisY
,
leftAxis
=
$$
.
main
.
select
(
'.'
+
leftAxisClass
).
node
(),
svgRect
=
leftAxis
?
leftAxis
.
getBoundingClientRect
()
:
{
right
:
0
},
svgRect
=
leftAxis
&&
hasLeftAxisRect
?
leftAxis
.
getBoundingClientRect
()
:
{
right
:
0
},
chartRect
=
$$
.
selectChart
.
node
().
getBoundingClientRect
(),
hasArc
=
$$
.
hasArcType
(),
svgLeft
=
svgRect
.
right
-
chartRect
.
left
-
(
hasArc
?
0
:
$$
.
getCurrentPaddingLeft
(
withoutRecompute
));
...
...
c3.min.js
View file @
bfac88c2
This source diff could not be displayed because it is too large. You can
view the blob
instead.
spec/axis-spec.js
View file @
bfac88c2
...
...
@@ -674,4 +674,94 @@ describe('c3 chart axis', function () {
});
});
describe
(
'axis.y.inner'
,
function
()
{
it
(
'should update args'
,
function
()
{
args
=
{
data
:
{
columns
:
[
[
'data1'
,
30
,
200
,
100
,
400
,
150
,
250
],
[
'data2'
,
50
,
20
,
10
,
40
,
15
,
25
]
]
},
axis
:
{
y
:
{
inner
:
false
}
}
};
expect
(
true
).
toBeTruthy
();
});
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
).
toBe
(
50
);
tickTexts
.
each
(
function
()
{
expect
(
+
d3
.
select
(
this
).
attr
(
'x'
)).
toBeLessThan
(
0
);
});
});
it
(
'should update args to have inner y axis'
,
function
()
{
args
.
axis
.
y
.
inner
=
true
;
expect
(
true
).
toBeTruthy
();
});
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
()
{
expect
(
+
d3
.
select
(
this
).
attr
(
'x'
)).
toBeGreaterThan
(
0
);
});
});
});
describe
(
'axis.y2.inner'
,
function
()
{
it
(
'should update args'
,
function
()
{
args
=
{
data
:
{
columns
:
[
[
'data1'
,
30
,
200
,
100
,
400
,
150
,
250
],
[
'data2'
,
50
,
20
,
10
,
40
,
15
,
25
]
]
},
axis
:
{
y2
:
{
show
:
true
,
inner
:
false
}
}
};
expect
(
true
).
toBeTruthy
();
});
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
).
toBe
(
40
);
tickTexts
.
each
(
function
()
{
expect
(
+
d3
.
select
(
this
).
attr
(
'x'
)).
toBeGreaterThan
(
0
);
});
});
it
(
'should update args to have inner y axis'
,
function
()
{
args
.
axis
.
y2
.
inner
=
true
;
expect
(
true
).
toBeTruthy
();
});
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
()
{
expect
(
+
d3
.
select
(
this
).
attr
(
'x'
)).
toBeLessThan
(
0
);
});
});
});
});
spec/interaction-spec.js
View file @
bfac88c2
...
...
@@ -19,16 +19,8 @@ describe('c3 chart interaction', function () {
};
beforeEach
(
function
(
done
)
{
if
(
typeof
chart
===
'undefined'
)
{
window
.
initDom
();
}
chart
=
window
.
c3
.
generate
(
args
);
chart
=
window
.
initChart
(
chart
,
args
,
done
);
d3
=
chart
.
internal
.
d3
;
chart
.
internal
.
d3
.
select
(
'.jasmine_html-reporter'
).
style
(
'display'
,
'none'
);
window
.
setTimeout
(
function
()
{
done
();
},
10
);
});
describe
(
'generate event rects'
,
function
()
{
...
...
@@ -50,8 +42,8 @@ describe('c3 chart interaction', function () {
});
it
(
'should have 4 event rects properly'
,
function
()
{
var
lefts
=
[
7
7.5
,
137
,
203.5
,
402
.5
],
widths
=
[
59.5
,
66.5
,
199
,
191.5
];
var
lefts
=
[
7
8
,
138
,
205.5
,
407
.5
],
widths
=
[
60
,
67.5
,
202
,
194
];
d3
.
selectAll
(
'.c3-event-rect'
).
each
(
function
(
d
,
i
)
{
var
box
=
d3
.
select
(
this
).
node
().
getBoundingClientRect
();
expect
(
box
.
left
).
toBe
(
lefts
[
i
]);
...
...
@@ -79,7 +71,7 @@ describe('c3 chart interaction', function () {
eventRects
.
each
(
function
()
{
var
box
=
d3
.
select
(
this
).
node
().
getBoundingClientRect
();
expect
(
box
.
left
).
toBe
(
40.5
);
expect
(
box
.
width
).
toBe
(
59
0
);
expect
(
box
.
width
).
toBe
(
59
8
);
});
});
});
...
...
@@ -100,8 +92,8 @@ describe('c3 chart interaction', function () {
});
it
(
'should have 4 event rects properly'
,
function
()
{
var
lefts
=
[
43.5
,
19
1
,
349
,
494
],
widths
=
[
14
7.5
,
158
,
145
,
134
];
var
lefts
=
[
43.5
,
19
3
,
353
,
500
],
widths
=
[
14
9.5
,
160
,
147
,
136
];
d3
.
selectAll
(
'.c3-event-rect'
).
each
(
function
(
d
,
i
)
{
var
box
=
d3
.
select
(
this
).
node
().
getBoundingClientRect
();
expect
(
box
.
left
).
toBe
(
lefts
[
i
]);
...
...
@@ -129,7 +121,7 @@ describe('c3 chart interaction', function () {
eventRects
.
each
(
function
()
{
var
box
=
d3
.
select
(
this
).
node
().
getBoundingClientRect
();
expect
(
box
.
left
).
toBe
(
40.5
);
expect
(
box
.
width
).
toBe
(
59
0
);
expect
(
box
.
width
).
toBe
(
59
8
);
});
});
...
...
spec/tooltip-spec.js
View file @
bfac88c2
...
...
@@ -35,7 +35,7 @@ describe('c3 chart tooltip', function () {
top
=
Math
.
floor
(
+
tooltipContainer
.
style
(
'top'
).
replace
(
/px/
,
''
)),
left
=
Math
.
floor
(
+
tooltipContainer
.
style
(
'left'
).
replace
(
/px/
,
''
)),
topExpected
=
115
,
leftExpected
=
30
4
;
leftExpected
=
30
7
;
expect
(
top
).
toBe
(
topExpected
);
expect
(
left
).
toBe
(
leftExpected
);
});
...
...
@@ -57,7 +57,7 @@ describe('c3 chart tooltip', function () {
top
=
Math
.
floor
(
+
tooltipContainer
.
style
(
'top'
).
replace
(
/px/
,
''
)),
left
=
Math
.
floor
(
+
tooltipContainer
.
style
(
'left'
).
replace
(
/px/
,
''
)),
topExpected
=
115
,
leftExpected
=
30
4
;
leftExpected
=
30
7
;
expect
(
top
).
toBe
(
topExpected
);
expect
(
left
).
toBe
(
leftExpected
);
});
...
...
src/core.js
View file @
bfac88c2
...
...
@@ -109,7 +109,7 @@ c3_chart_internal_fn.initParams = function () {
$$
.
xOrient
=
config
.
axis_rotated
?
"left"
:
"bottom"
;
$$
.
yOrient
=
config
.
axis_rotated
?
(
config
.
axis_y_inner
?
"top"
:
"bottom"
)
:
(
config
.
axis_y_inner
?
"right"
:
"left"
);
$$
.
y2Orient
=
config
.
axis_rotated
?
(
config
.
axis_y
_inner
?
"bottom"
:
"top"
)
:
(
config
.
axis_y
_inner
?
"left"
:
"right"
);
$$
.
y2Orient
=
config
.
axis_rotated
?
(
config
.
axis_y
2_inner
?
"bottom"
:
"top"
)
:
(
config
.
axis_y2
_inner
?
"left"
:
"right"
);
$$
.
subXOrient
=
config
.
axis_rotated
?
"left"
:
"bottom"
;
$$
.
isLegendRight
=
config
.
legend_position
===
'right'
;
...
...
src/size.js
View file @
bfac88c2
...
...
@@ -35,7 +35,7 @@ c3_chart_internal_fn.getCurrentPaddingRight = function () {
}
else
if
(
config
.
axis_rotated
)
{
return
defaultPadding
+
legendWidthOnRight
;
}
else
if
(
!
config
.
axis_y2_show
||
config
.
axis_y2_inner
)
{
// && !config.axis_rotated
return
defaultPadding
+
legendWidthOnRight
+
(
$$
.
getY2AxisLabelPosition
().
isOuter
?
20
:
0
);
return
2
+
legendWidthOnRight
+
(
$$
.
getY2AxisLabelPosition
().
isOuter
?
20
:
0
);
}
else
{
return
ceil10
(
$$
.
getAxisWidthByAxisId
(
'y2'
))
+
legendWidthOnRight
;
}
...
...
@@ -63,9 +63,10 @@ c3_chart_internal_fn.getParentHeight = function () {
c3_chart_internal_fn
.
getSvgLeft
=
function
(
withoutRecompute
)
{
var
$$
=
this
,
config
=
$$
.
config
,
hasLeftAxisRect
=
config
.
axis_rotated
||
(
!
config
.
axis_rotated
&&
!
config
.
axis_y_inner
),
leftAxisClass
=
config
.
axis_rotated
?
CLASS
.
axisX
:
CLASS
.
axisY
,
leftAxis
=
$$
.
main
.
select
(
'.'
+
leftAxisClass
).
node
(),
svgRect
=
leftAxis
?
leftAxis
.
getBoundingClientRect
()
:
{
right
:
0
},
svgRect
=
leftAxis
&&
hasLeftAxisRect
?
leftAxis
.
getBoundingClientRect
()
:
{
right
:
0
},
chartRect
=
$$
.
selectChart
.
node
().
getBoundingClientRect
(),
hasArc
=
$$
.
hasArcType
(),
svgLeft
=
svgRect
.
right
-
chartRect
.
left
-
(
hasArc
?
0
:
$$
.
getCurrentPaddingLeft
(
withoutRecompute
));
...
...
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