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
0a3333bd
Commit
0a3333bd
authored
Apr 06, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix show/hide API and refactor target ids
parent
8fd122c4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
25 deletions
+29
-25
c3.js
c3.js
+29
-25
c3.min.js
c3.min.js
+0
-0
No files found.
c3.js
View file @
0a3333bd
...
@@ -1085,7 +1085,7 @@
...
@@ -1085,7 +1085,7 @@
//-- Domain --//
//-- Domain --//
function
getYDomainMin
(
targets
)
{
function
getYDomainMin
(
targets
)
{
var
ids
=
getTarget
Ids
(
targets
),
ys
=
getValuesAsIdKeyed
(
targets
),
j
,
k
,
baseId
,
idsInGroup
,
id
,
hasNegativeValue
;
var
ids
=
mapTo
Ids
(
targets
),
ys
=
getValuesAsIdKeyed
(
targets
),
j
,
k
,
baseId
,
idsInGroup
,
id
,
hasNegativeValue
;
if
(
__data_groups
.
length
>
0
)
{
if
(
__data_groups
.
length
>
0
)
{
hasNegativeValue
=
hasNegativeValueInTargets
(
targets
);
hasNegativeValue
=
hasNegativeValueInTargets
(
targets
);
for
(
j
=
0
;
j
<
__data_groups
.
length
;
j
++
)
{
for
(
j
=
0
;
j
<
__data_groups
.
length
;
j
++
)
{
...
@@ -1114,7 +1114,7 @@
...
@@ -1114,7 +1114,7 @@
return
d3
.
min
(
Object
.
keys
(
ys
).
map
(
function
(
key
)
{
return
d3
.
min
(
ys
[
key
]);
}));
return
d3
.
min
(
Object
.
keys
(
ys
).
map
(
function
(
key
)
{
return
d3
.
min
(
ys
[
key
]);
}));
}
}
function
getYDomainMax
(
targets
)
{
function
getYDomainMax
(
targets
)
{
var
ids
=
getTarget
Ids
(
targets
),
ys
=
getValuesAsIdKeyed
(
targets
),
j
,
k
,
baseId
,
idsInGroup
,
id
,
hasPositiveValue
;
var
ids
=
mapTo
Ids
(
targets
),
ys
=
getValuesAsIdKeyed
(
targets
),
j
,
k
,
baseId
,
idsInGroup
,
id
,
hasPositiveValue
;
if
(
__data_groups
.
length
>
0
)
{
if
(
__data_groups
.
length
>
0
)
{
hasPositiveValue
=
hasPositiveValueInTargets
(
targets
);
hasPositiveValue
=
hasPositiveValueInTargets
(
targets
);
for
(
j
=
0
;
j
<
__data_groups
.
length
;
j
++
)
{
for
(
j
=
0
;
j
<
__data_groups
.
length
;
j
++
)
{
...
@@ -1397,7 +1397,7 @@
...
@@ -1397,7 +1397,7 @@
// set target types
// set target types
if
(
__data_type
)
{
if
(
__data_type
)
{
setTargetType
(
getTarget
Ids
(
targets
).
filter
(
function
(
id
)
{
return
!
(
id
in
__data_types
);
}),
__data_type
);
setTargetType
(
mapTo
Ids
(
targets
).
filter
(
function
(
id
)
{
return
!
(
id
in
__data_types
);
}),
__data_type
);
}
}
// cache as original id keyed
// cache as original id keyed
...
@@ -1439,12 +1439,14 @@
...
@@ -1439,12 +1439,14 @@
}
}
return
maxTarget
;
return
maxTarget
;
}
}
function
getTargetIds
(
targets
)
{
function
mapToIds
(
targets
)
{
targets
=
isUndefined
(
targets
)
?
c3
.
data
.
targets
:
targets
;
return
targets
.
map
(
function
(
d
)
{
return
d
.
id
;
});
return
targets
.
map
(
function
(
d
)
{
return
d
.
id
;
});
}
}
function
hasTarget
(
id
)
{
function
mapToTargetIds
(
ids
)
{
var
ids
=
getTargetIds
(),
i
;
return
ids
?
(
typeof
ids
===
'string'
?
[
ids
]
:
ids
)
:
mapToIds
(
c3
.
data
.
targets
);
}
function
hasTarget
(
targets
,
id
)
{
var
ids
=
mapToIds
(
targets
),
i
;
for
(
i
=
0
;
i
<
ids
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
ids
.
length
;
i
++
)
{
if
(
ids
[
i
]
===
id
)
{
if
(
ids
[
i
]
===
id
)
{
return
true
;
return
true
;
...
@@ -1549,6 +1551,7 @@
...
@@ -1549,6 +1551,7 @@
return
targetId
||
targetId
===
0
?
'-'
+
(
targetId
.
replace
?
targetId
.
replace
(
/
([^
a-zA-Z0-9-_
])
/g
,
'-'
)
:
targetId
)
:
''
;
return
targetId
||
targetId
===
0
?
'-'
+
(
targetId
.
replace
?
targetId
.
replace
(
/
([^
a-zA-Z0-9-_
])
/g
,
'-'
)
:
targetId
)
:
''
;
}
}
function
selectorTarget
(
id
)
{
return
'.'
+
CLASS
.
target
+
getTargetSelectorSuffix
(
id
);
}
function
selectorTarget
(
id
)
{
return
'.'
+
CLASS
.
target
+
getTargetSelectorSuffix
(
id
);
}
function
selectorTargets
(
ids
)
{
return
ids
.
map
(
function
(
id
)
{
return
selectorTarget
(
id
);
});
}
function
initialOpacity
(
d
)
{
function
initialOpacity
(
d
)
{
return
d
.
value
!==
null
&&
withoutFadeIn
[
d
.
id
]
?
1
:
0
;
return
d
.
value
!==
null
&&
withoutFadeIn
[
d
.
id
]
?
1
:
0
;
...
@@ -1840,11 +1843,10 @@
...
@@ -1840,11 +1843,10 @@
//-- Type --//
//-- Type --//
function
setTargetType
(
targetIds
,
type
)
{
function
setTargetType
(
targetIds
,
type
)
{
var
i
,
ids
=
targetIds
?
(
typeof
targetIds
===
'string'
?
[
targetIds
]
:
targetIds
)
:
getTargetIds
();
mapToTargetIds
(
targetIds
).
forEach
(
function
(
id
)
{
for
(
i
=
0
;
i
<
ids
.
length
;
i
++
)
{
withoutFadeIn
[
id
]
=
(
type
===
__data_types
[
id
]);
withoutFadeIn
[
ids
[
i
]]
=
(
type
===
__data_types
[
ids
[
i
]]);
__data_types
[
id
]
=
type
;
__data_types
[
ids
[
i
]]
=
type
;
});
}
}
}
function
hasType
(
targets
,
type
)
{
function
hasType
(
targets
,
type
)
{
var
has
=
false
;
var
has
=
false
;
...
@@ -3288,7 +3290,7 @@
...
@@ -3288,7 +3290,7 @@
.
remove
();
.
remove
();
// update fadein condition
// update fadein condition
getTargetIds
(
).
forEach
(
function
(
id
)
{
mapToIds
(
c3
.
data
.
targets
).
forEach
(
function
(
id
)
{
withoutFadeIn
[
id
]
=
true
;
withoutFadeIn
[
id
]
=
true
;
});
});
}
}
...
@@ -3545,7 +3547,7 @@
...
@@ -3545,7 +3547,7 @@
done
=
function
()
{};
done
=
function
()
{};
}
}
// filter existing target
// filter existing target
targetIds
=
targetIds
.
filter
(
function
(
id
)
{
return
hasTarget
(
id
);
});
targetIds
=
targetIds
.
filter
(
function
(
id
)
{
return
hasTarget
(
c3
.
data
.
targets
,
id
);
});
// If no target, call done and return
// If no target, call done and return
if
(
!
targetIds
||
targetIds
.
length
===
0
)
{
if
(
!
targetIds
||
targetIds
.
length
===
0
)
{
done
();
done
();
...
@@ -3595,7 +3597,7 @@
...
@@ -3595,7 +3597,7 @@
}
}
function
updateLegend
(
targets
,
options
)
{
function
updateLegend
(
targets
,
options
)
{
var
ids
=
getTarget
Ids
(
targets
),
l
;
var
ids
=
mapTo
Ids
(
targets
),
l
;
var
xForLegend
,
xForLegendText
,
xForLegendRect
,
yForLegend
,
yForLegendText
,
yForLegendRect
;
var
xForLegend
,
xForLegendText
,
xForLegendRect
,
yForLegend
,
yForLegendText
,
yForLegendRect
;
var
paddingTop
=
4
,
paddingRight
=
26
,
maxWidth
=
0
,
maxHeight
=
0
,
posMin
=
10
;
var
paddingTop
=
4
,
paddingRight
=
26
,
maxWidth
=
0
,
maxHeight
=
0
,
posMin
=
10
;
var
totalLength
=
0
,
offsets
=
{},
widths
=
{},
heights
=
{},
margins
=
{},
steps
=
{},
step
=
0
;
var
totalLength
=
0
,
offsets
=
{},
widths
=
{},
heights
=
{},
margins
=
{},
steps
=
{},
step
=
0
;
...
@@ -3743,10 +3745,10 @@
...
@@ -3743,10 +3745,10 @@
/*-- Event Handling --*/
/*-- Event Handling --*/
function
isNoneArc
(
d
)
{
function
isNoneArc
(
d
)
{
return
hasTarget
(
d
.
id
);
return
hasTarget
(
c3
.
data
.
targets
,
d
.
id
);
}
}
function
isArc
(
d
)
{
function
isArc
(
d
)
{
return
'data'
in
d
&&
hasTarget
(
d
.
data
.
id
);
return
'data'
in
d
&&
hasTarget
(
c3
.
data
.
targets
,
d
.
data
.
id
);
}
}
function
getGridFilter
(
params
)
{
function
getGridFilter
(
params
)
{
var
value
=
params
&&
params
.
value
?
params
.
value
:
null
,
var
value
=
params
&&
params
.
value
?
params
.
value
:
null
,
...
@@ -3807,17 +3809,19 @@
...
@@ -3807,17 +3809,19 @@
revertLegend
();
revertLegend
();
};
};
c3
.
show
=
function
(
targetId
)
{
c3
.
show
=
function
(
targetIds
)
{
removeHiddenTargetIds
(
targetId
);
targetIds
=
mapToTargetIds
(
targetIds
);
svg
.
selectAll
(
selectorTarget
(
targetId
))
removeHiddenTargetIds
(
targetIds
);
svg
.
selectAll
(
selectorTargets
(
targetIds
))
.
transition
()
.
transition
()
.
style
(
'opacity'
,
1
);
.
style
(
'opacity'
,
1
);
redraw
({
withUpdateOrgXDomain
:
true
,
withUpdateXDomain
:
true
,
withLegend
:
false
});
redraw
({
withUpdateOrgXDomain
:
true
,
withUpdateXDomain
:
true
,
withLegend
:
false
});
};
};
c3
.
hide
=
function
(
targetId
)
{
c3
.
hide
=
function
(
targetIds
)
{
addHiddenTargetIds
(
targetId
);
targetIds
=
mapToTargetIds
(
targetIds
);
svg
.
selectAll
(
selectorTarget
(
targetId
))
addHiddenTargetIds
(
targetIds
);
svg
.
selectAll
(
selectorTargets
(
targetIds
))
.
transition
()
.
transition
()
.
style
(
'opacity'
,
0
);
.
style
(
'opacity'
,
0
);
redraw
({
withUpdateOrgXDomain
:
true
,
withUpdateXDomain
:
true
,
withLegend
:
false
});
redraw
({
withUpdateOrgXDomain
:
true
,
withUpdateXDomain
:
true
,
withLegend
:
false
});
...
@@ -3850,7 +3854,7 @@
...
@@ -3850,7 +3854,7 @@
// unload if needed
// unload if needed
if
(
'unload'
in
args
)
{
if
(
'unload'
in
args
)
{
// TODO: do not unload if target will load (included in url/rows/columns)
// TODO: do not unload if target will load (included in url/rows/columns)
unload
(
typeof
args
.
unload
===
'string'
?
[
args
.
unload
]
:
typeof
args
.
unload
===
'boolean'
&&
args
.
unload
?
getTargetIds
()
:
args
.
unload
,
function
()
{
unload
(
mapToTargetIds
((
typeof
args
.
unload
===
'boolean'
&&
args
.
unload
)
?
null
:
args
.
unload
)
,
function
()
{
loadFromArgs
(
args
);
loadFromArgs
(
args
);
});
});
}
else
{
}
else
{
...
@@ -3859,7 +3863,7 @@
...
@@ -3859,7 +3863,7 @@
};
};
c3
.
unload
=
function
(
targetIds
)
{
c3
.
unload
=
function
(
targetIds
)
{
unload
(
targetIds
?
typeof
targetIds
===
'string'
?
[
targetIds
]
:
targetIds
:
getTargetIds
(
),
function
()
{
unload
(
mapToTargetIds
(
targetIds
),
function
()
{
redraw
({
withUpdateOrgXDomain
:
true
,
withUpdateXDomain
:
true
,
withLegend
:
true
});
redraw
({
withUpdateOrgXDomain
:
true
,
withUpdateXDomain
:
true
,
withLegend
:
true
});
});
});
};
};
...
...
c3.min.js
View file @
0a3333bd
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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