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
a6721dd1
Commit
a6721dd1
authored
Sep 19, 2013
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add otpion to show tooltip on init
parent
63dca550
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
9 deletions
+29
-9
c3.js
c3.js
+29
-9
c3.min.js
c3.min.js
+0
-0
No files found.
c3.js
View file @
a6721dd1
...
...
@@ -116,7 +116,10 @@
text
+=
"<tr><td><span style='background-color:"
+
color
(
d
[
i
].
id
)
+
"'></span>"
+
name
+
"</td><td class='value'>"
+
value
+
"</td></tr>"
;
}
return
text
+
"</table>"
;
});
}),
__tooltip_init_show
=
getConfig
([
'tooltip'
,
'init'
,
'show'
],
false
),
__tooltip_init_x
=
getConfig
([
'tooltip'
,
'init'
,
'x'
],
0
),
__tooltip_init_position
=
getConfig
([
'tooltip'
,
'init'
,
'position'
],
{
top
:
'0px'
,
left
:
'50px'
});
/*-- Set Variables --*/
...
...
@@ -419,6 +422,11 @@
//-- Data --//
function
addName
(
data
)
{
var
name
=
__data_names
[
data
.
id
];
data
.
name
=
isDefined
(
name
)
?
name
:
data
.
id
;
return
data
;
}
function
convertRowsToData
(
rows
)
{
var
keys
=
rows
[
0
],
new_row
=
{},
new_rows
=
[],
i
,
j
;
for
(
i
=
1
;
i
<
rows
.
length
;
i
++
)
{
...
...
@@ -786,6 +794,7 @@
var
targets
=
c3
.
data
.
targets
=
convertDataToTargets
(
data
);
var
rectX
,
rectW
;
var
grid
,
xgridLine
;
var
i
;
// TODO: set names if names not specified
...
...
@@ -872,15 +881,9 @@
.
on
(
'mouseover'
,
function
(
d
,
i
)
{
if
(
dragging
)
return
;
// do nothing if dragging
var
selectedData
=
c3
.
data
.
targets
.
map
(
function
(
d
){
return
d
.
values
[
i
]
;
});
var
j
,
newData
,
name
;
var
selectedData
=
c3
.
data
.
targets
.
map
(
function
(
d
){
return
addName
(
d
.
values
[
i
])
;
});
var
j
,
newData
;
// Add id,name to selectedData
for
(
j
=
0
;
j
<
selectedData
.
length
;
j
++
)
{
if
(
isUndefined
(
selectedData
[
j
]))
continue
;
name
=
__data_names
[
selectedData
[
j
].
id
];
selectedData
[
j
].
name
=
isDefined
(
name
)
?
name
:
selectedData
[
j
].
id
;
}
// Sort selectedData as names order
if
(
Object
.
keys
(
__data_names
).
length
>
0
)
{
newData
=
[];
...
...
@@ -1129,6 +1132,23 @@
// Draw with targets
redraw
({
withTransition
:
false
});
// Show tooltip if needed
if
(
__tooltip_init_show
)
{
if
(
isTimeSeries
&&
typeof
__tooltip_init_x
==
'string'
)
{
__tooltip_init_x
=
parseDate
(
__tooltip_init_x
);
for
(
i
=
0
;
i
<
targets
[
0
].
values
.
length
;
i
++
)
{
if
((
targets
[
0
].
values
[
i
].
x
-
__tooltip_init_x
)
==
0
)
break
;
}
__tooltip_init_x
=
i
;
}
tooltip
.
html
(
__tooltip_contents
(
targets
.
map
(
function
(
d
){
return
addName
(
d
.
values
[
__tooltip_init_x
]);
})));
tooltip
.
style
(
"top"
,
__tooltip_init_position
.
top
)
.
style
(
"left"
,
__tooltip_init_position
.
left
)
.
style
(
"visibility"
,
"visible"
);
}
}
function
redraw
(
options
)
{
...
...
c3.min.js
View file @
a6721dd1
This diff is collapsed.
Click to expand it.
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