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
0eea1afb
Commit
0eea1afb
authored
Mar 16, 2015
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix data label position based on user agent
parent
97cc3eb3
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
4 deletions
+42
-4
Gruntfile.coffee
Gruntfile.coffee
+1
-0
c3.js
c3.js
+21
-2
c3.min.js
c3.min.js
+0
-0
text.js
src/text.js
+12
-2
ua.js
src/ua.js
+8
-0
No files found.
Gruntfile.coffee
View file @
0eea1afb
...
...
@@ -72,6 +72,7 @@ module.exports = (grunt) ->
'src/api.chart.js'
,
'src/api.tooltip.js'
,
'src/c3.axis.js'
,
'src/ua.js'
,
'src/polyfill.js'
,
'src/tail.js'
]
...
...
c3.js
View file @
0eea1afb
...
...
@@ -3347,12 +3347,22 @@
c3_chart_internal_fn
.
getYForText
=
function
(
points
,
d
,
textElement
)
{
var
$$
=
this
,
box
=
textElement
.
getBoundingClientRect
(),
offset
=
$$
.
isBarType
(
d
)
?
0
:
3
,
yPos
;
if
(
$$
.
config
.
axis_rotated
)
{
yPos
=
(
points
[
0
][
0
]
+
points
[
2
][
0
]
+
box
.
height
*
0.6
)
/
2
;
}
else
{
yPos
=
points
[
2
][
1
]
+
(
d
.
value
<
0
?
box
.
height
+
offset
:
(
-
3
-
offset
));
yPos
=
points
[
2
][
1
];
if
(
d
.
value
<
0
)
{
yPos
+=
box
.
height
;
if
(
$$
.
isBarType
(
d
)
&&
$$
.
isSafari
())
{
yPos
-=
3
;
}
else
if
(
!
$$
.
isBarType
(
d
)
&&
$$
.
isChrome
())
{
yPos
+=
3
;
}
}
else
{
yPos
+=
$$
.
isBarType
(
d
)
?
-
3
:
-
6
;
}
}
// show labels regardless of the domain if value is null
if
(
d
.
value
===
null
&&
!
$$
.
config
.
axis_rotated
)
{
...
...
@@ -6993,6 +7003,15 @@
return
axis
;
}
c3_chart_internal_fn
.
isSafari
=
function
()
{
var
ua
=
window
.
navigator
.
userAgent
;
return
ua
.
indexOf
(
'Safari'
)
>=
0
&&
ua
.
indexOf
(
'Chrome'
)
<
0
;
};
c3_chart_internal_fn
.
isChrome
=
function
()
{
var
ua
=
window
.
navigator
.
userAgent
;
return
ua
.
indexOf
(
'Chrome'
)
>=
0
;
};
// PhantomJS doesn't have support for Function.prototype.bind, which has caused confusion. Use
// this polyfill to avoid the confusion.
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind#Polyfill
...
...
c3.min.js
View file @
0eea1afb
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/text.js
View file @
0eea1afb
...
...
@@ -93,12 +93,22 @@ c3_chart_internal_fn.getXForText = function (points, d, textElement) {
c3_chart_internal_fn
.
getYForText
=
function
(
points
,
d
,
textElement
)
{
var
$$
=
this
,
box
=
textElement
.
getBoundingClientRect
(),
offset
=
$$
.
isBarType
(
d
)
?
0
:
3
,
yPos
;
if
(
$$
.
config
.
axis_rotated
)
{
yPos
=
(
points
[
0
][
0
]
+
points
[
2
][
0
]
+
box
.
height
*
0.6
)
/
2
;
}
else
{
yPos
=
points
[
2
][
1
]
+
(
d
.
value
<
0
?
box
.
height
+
offset
:
(
-
3
-
offset
));
yPos
=
points
[
2
][
1
];
if
(
d
.
value
<
0
)
{
yPos
+=
box
.
height
;
if
(
$$
.
isBarType
(
d
)
&&
$$
.
isSafari
())
{
yPos
-=
3
;
}
else
if
(
!
$$
.
isBarType
(
d
)
&&
$$
.
isChrome
())
{
yPos
+=
3
;
}
}
else
{
yPos
+=
$$
.
isBarType
(
d
)
?
-
3
:
-
6
;
}
}
// show labels regardless of the domain if value is null
if
(
d
.
value
===
null
&&
!
$$
.
config
.
axis_rotated
)
{
...
...
src/ua.js
0 → 100644
View file @
0eea1afb
c3_chart_internal_fn
.
isSafari
=
function
()
{
var
ua
=
window
.
navigator
.
userAgent
;
return
ua
.
indexOf
(
'Safari'
)
>=
0
&&
ua
.
indexOf
(
'Chrome'
)
<
0
;
};
c3_chart_internal_fn
.
isChrome
=
function
()
{
var
ua
=
window
.
navigator
.
userAgent
;
return
ua
.
indexOf
(
'Chrome'
)
>=
0
;
};
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