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
bbd203c0
Commit
bbd203c0
authored
Mar 04, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tooltip.format option - #49
parent
e5710a7e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
c3.js
c3.js
+8
-5
No files found.
c3.js
View file @
bbd203c0
...
@@ -137,19 +137,22 @@
...
@@ -137,19 +137,22 @@
// tooltip - show when mouseover on each data
// tooltip - show when mouseover on each data
var
__tooltip_enabled
=
getConfig
([
'tooltip'
,
'enabled'
],
true
),
var
__tooltip_enabled
=
getConfig
([
'tooltip'
,
'enabled'
],
true
),
__tooltip_format_title
=
getConfig
([
'tooltip'
,
'format'
,
'title'
],
null
),
__tooltip_format_value
=
getConfig
([
'tooltip'
,
'format'
,
'value'
],
null
),
__tooltip_contents
=
getConfig
([
'tooltip'
,
'contents'
],
function
(
d
)
{
__tooltip_contents
=
getConfig
([
'tooltip'
,
'contents'
],
function
(
d
)
{
var
xFormat
=
getXAxisTickFormat
(),
var
titleFormat
=
__tooltip_format_title
?
__tooltip_format_title
:
getXAxisTickFormat
(),
valueFormat
=
__tooltip_format_value
?
__tooltip_format_value
:
defaultValueFormat
,
text
,
i
,
title
,
value
,
name
;
text
,
i
,
title
,
value
,
name
;
for
(
i
=
0
;
i
<
d
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
d
.
length
;
i
++
)
{
if
(
!
d
[
i
]
||
!
isValue
(
d
[
i
].
value
))
{
continue
;
}
if
(
!
d
[
i
]
||
!
isValue
(
d
[
i
].
value
))
{
continue
;
}
if
(
!
text
)
{
if
(
!
text
)
{
title
=
xFormat
?
x
Format
(
d
[
i
].
x
)
:
d
[
i
].
x
;
title
=
titleFormat
?
title
Format
(
d
[
i
].
x
)
:
d
[
i
].
x
;
text
=
"<table class='-tooltip'><tr><th colspan='2'>"
+
title
+
"</th></tr>"
;
text
=
"<table class='-tooltip'><tr><th colspan='2'>"
+
title
+
"</th></tr>"
;
}
}
name
=
d
[
i
].
name
;
name
=
d
[
i
].
name
;
value
=
formattedValue
(
d
[
i
].
value
);
value
=
valueFormat
(
d
[
i
].
value
);
text
+=
"<tr class='-tooltip-name-"
+
d
[
i
].
id
+
"'><td class='name'><span style='background-color:"
+
color
(
d
[
i
].
id
)
+
"'></span>"
+
name
+
"</td><td class='value'>"
+
value
+
"</td></tr>"
;
text
+=
"<tr class='-tooltip-name-"
+
d
[
i
].
id
+
"'><td class='name'><span style='background-color:"
+
color
(
d
[
i
].
id
)
+
"'></span>"
+
name
+
"</td><td class='value'>"
+
value
+
"</td></tr>"
;
}
}
...
@@ -910,7 +913,7 @@
...
@@ -910,7 +913,7 @@
function
subxx
(
d
)
{
function
subxx
(
d
)
{
return
subX
(
d
.
x
);
return
subX
(
d
.
x
);
}
}
function
formattedValue
(
v
)
{
function
defaultValueFormat
(
v
)
{
var
yFormat
=
__axis_y_tick_format
?
__axis_y_tick_format
:
function
(
v
)
{
return
+
v
;
};
var
yFormat
=
__axis_y_tick_format
?
__axis_y_tick_format
:
function
(
v
)
{
return
+
v
;
};
return
yFormat
(
v
);
return
yFormat
(
v
);
}
}
...
@@ -2255,7 +2258,7 @@
...
@@ -2255,7 +2258,7 @@
.
attr
(
'text-anchor'
,
function
(
d
)
{
return
__axis_rotated
?
(
d
.
value
<
0
?
'end'
:
'start'
)
:
'middle'
;
})
.
attr
(
'text-anchor'
,
function
(
d
)
{
return
__axis_rotated
?
(
d
.
value
<
0
?
'end'
:
'start'
)
:
'middle'
;
})
.
style
(
"stroke"
,
'none'
)
.
style
(
"stroke"
,
'none'
)
.
style
(
"fill-opacity"
,
0
)
.
style
(
"fill-opacity"
,
0
)
.
text
(
function
(
d
)
{
return
formattedValue
(
d
.
value
);
});
.
text
(
function
(
d
)
{
return
defaultValueFormat
(
d
.
value
);
});
mainText
mainText
.
style
(
"fill-opacity"
,
initialOpacityForText
)
.
style
(
"fill-opacity"
,
initialOpacityForText
)
.
transition
().
duration
(
duration
)
.
transition
().
duration
(
duration
)
...
...
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