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
3588b169
Commit
3588b169
authored
Feb 23, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sanitize '.' in target id for class selector - #37
parent
fe184c50
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
36 deletions
+44
-36
c3.js
c3.js
+44
-36
c3.min.js
c3.min.js
+0
-0
No files found.
c3.js
View file @
3588b169
...
@@ -464,9 +464,9 @@
...
@@ -464,9 +464,9 @@
function
textForArcLable
(
d
)
{
function
textForArcLable
(
d
)
{
return
__arc_label_fomat
(
d
,
getArcRatio
(
d
));
return
__arc_label_fomat
(
d
,
getArcRatio
(
d
));
}
}
function
expandArc
(
targetI
d
,
withoutFadeOut
)
{
function
expandArc
(
i
d
,
withoutFadeOut
)
{
var
target
=
svg
.
selectAll
(
'.chart-arc
.target'
+
(
targetId
?
'-'
+
targetId
:
''
)),
var
target
=
svg
.
selectAll
(
'.chart-arc
'
+
getTargetSelector
(
id
)),
noneTargets
=
svg
.
selectAll
(
'.-arc'
).
filter
(
function
(
data
)
{
return
data
.
data
.
id
!==
targetI
d
;
});
noneTargets
=
svg
.
selectAll
(
'.-arc'
).
filter
(
function
(
data
)
{
return
data
.
data
.
id
!==
i
d
;
});
target
.
selectAll
(
'path'
)
target
.
selectAll
(
'path'
)
.
transition
().
duration
(
50
)
.
transition
().
duration
(
50
)
.
attr
(
"d"
,
svgArcExpanded
)
.
attr
(
"d"
,
svgArcExpanded
)
...
@@ -481,8 +481,8 @@
...
@@ -481,8 +481,8 @@
noneTargets
.
style
(
"opacity"
,
0.3
);
noneTargets
.
style
(
"opacity"
,
0.3
);
}
}
}
}
function
unexpandArc
(
targetI
d
)
{
function
unexpandArc
(
i
d
)
{
var
target
=
svg
.
selectAll
(
'.chart-arc
.target'
+
(
targetId
?
'-'
+
targetId
:
''
));
var
target
=
svg
.
selectAll
(
'.chart-arc
'
+
getTargetSelector
(
id
));
target
.
selectAll
(
'path'
)
target
.
selectAll
(
'path'
)
.
transition
().
duration
(
50
)
.
transition
().
duration
(
50
)
.
attr
(
"d"
,
svgArc
);
.
attr
(
"d"
,
svgArc
);
...
@@ -1229,7 +1229,7 @@
...
@@ -1229,7 +1229,7 @@
//-- Shape --//
//-- Shape --//
function
getCircles
(
i
,
id
)
{
function
getCircles
(
i
,
id
)
{
return
(
id
?
main
.
selectAll
(
'.-circles-'
+
id
)
:
main
).
selectAll
(
'.-circle'
+
(
i
||
i
===
0
?
'-'
+
i
:
''
));
return
(
id
?
main
.
selectAll
(
'.-circles-'
+
id
)
:
main
).
selectAll
(
'.-circle'
+
(
i
sValue
(
i
)
?
'-'
+
i
:
''
));
}
}
function
expandCircles
(
i
,
id
)
{
function
expandCircles
(
i
,
id
)
{
getCircles
(
i
,
id
)
getCircles
(
i
,
id
)
...
@@ -1243,7 +1243,7 @@
...
@@ -1243,7 +1243,7 @@
.
attr
(
'r'
,
__point_r
);
.
attr
(
'r'
,
__point_r
);
}
}
function
getBars
(
i
)
{
function
getBars
(
i
)
{
return
main
.
selectAll
(
".-bar"
+
(
i
||
i
===
0
?
'-'
+
i
:
''
));
return
main
.
selectAll
(
".-bar"
+
(
i
sValue
(
i
)
?
'-'
+
i
:
''
));
}
}
function
expandBars
(
i
)
{
function
expandBars
(
i
)
{
getBars
(
i
).
classed
(
EXPANDED
,
false
);
getBars
(
i
).
classed
(
EXPANDED
,
false
);
...
@@ -2430,7 +2430,8 @@
...
@@ -2430,7 +2430,8 @@
.
style
(
"cursor"
,
function
(
d
)
{
return
__data_selection_isselectable
(
d
)
?
"pointer"
:
null
;
});
.
style
(
"cursor"
,
function
(
d
)
{
return
__data_selection_isselectable
(
d
)
?
"pointer"
:
null
;
});
// Update date for selected circles
// Update date for selected circles
targets
.
forEach
(
function
(
t
)
{
targets
.
forEach
(
function
(
t
)
{
main
.
selectAll
(
'.selected-circles-'
+
t
.
id
).
selectAll
(
'.selected-circle'
).
each
(
function
(
d
)
{
var
suffix
=
getTargetSelectorSuffix
(
t
.
id
);
main
.
selectAll
(
'.selected-circles'
+
suffix
).
selectAll
(
'.selected-circle'
).
each
(
function
(
d
)
{
d
.
value
=
t
.
values
[
d
.
x
].
value
;
d
.
value
=
t
.
values
[
d
.
x
].
value
;
});
});
});
});
...
@@ -2615,8 +2616,12 @@
...
@@ -2615,8 +2616,12 @@
/*-- Event Handling --*/
/*-- Event Handling --*/
function
getTargetSelector
(
target
)
{
function
getTargetSelectorSuffix
(
targetId
)
{
return
isDefined
(
target
)
?
'.target-'
+
target
:
'.target'
;
// TODO: sanitize target
return
targetId
?
'-'
+
targetId
.
replace
(
/
\.
/g
,
'
\\
.'
)
:
''
;
}
function
getTargetSelector
(
targetId
)
{
return
'.target'
+
getTargetSelectorSuffix
(
targetId
);
}
}
function
isNoneArc
(
d
)
{
function
isNoneArc
(
d
)
{
return
hasTarget
(
d
.
id
);
return
hasTarget
(
d
.
id
);
...
@@ -2625,8 +2630,8 @@
...
@@ -2625,8 +2630,8 @@
return
'data'
in
d
&&
hasTarget
(
d
.
data
.
id
);
return
'data'
in
d
&&
hasTarget
(
d
.
data
.
id
);
}
}
c3
.
focus
=
function
(
target
)
{
c3
.
focus
=
function
(
target
Id
)
{
var
candidates
=
svg
.
selectAll
(
getTargetSelector
(
target
)),
var
candidates
=
svg
.
selectAll
(
getTargetSelector
(
target
Id
)),
candidatesForNoneArc
=
candidates
.
filter
(
isNoneArc
),
candidatesForNoneArc
=
candidates
.
filter
(
isNoneArc
),
candidatesForArc
=
candidates
.
filter
(
isArc
);
candidatesForArc
=
candidates
.
filter
(
isArc
);
function
focus
(
targets
)
{
function
focus
(
targets
)
{
...
@@ -2637,13 +2642,13 @@
...
@@ -2637,13 +2642,13 @@
focus
(
candidatesForNoneArc
.
classed
(
'focused'
,
true
));
focus
(
candidatesForNoneArc
.
classed
(
'focused'
,
true
));
focus
(
candidatesForArc
);
focus
(
candidatesForArc
);
if
(
hasArcType
(
c3
.
data
.
targets
))
{
if
(
hasArcType
(
c3
.
data
.
targets
))
{
expandArc
(
target
,
true
);
expandArc
(
target
Id
,
true
);
}
}
focusLegend
(
target
);
focusLegend
(
target
Id
);
};
};
c3
.
defocus
=
function
(
target
)
{
c3
.
defocus
=
function
(
target
Id
)
{
var
candidates
=
svg
.
selectAll
(
getTargetSelector
(
target
)),
var
candidates
=
svg
.
selectAll
(
getTargetSelector
(
target
Id
)),
candidatesForNoneArc
=
candidates
.
filter
(
isNoneArc
),
candidatesForNoneArc
=
candidates
.
filter
(
isNoneArc
),
candidatesForArc
=
candidates
.
filter
(
isArc
);
candidatesForArc
=
candidates
.
filter
(
isArc
);
function
defocus
(
targets
)
{
function
defocus
(
targets
)
{
...
@@ -2653,13 +2658,13 @@
...
@@ -2653,13 +2658,13 @@
defocus
(
candidatesForNoneArc
.
classed
(
'focused'
,
false
));
defocus
(
candidatesForNoneArc
.
classed
(
'focused'
,
false
));
defocus
(
candidatesForArc
);
defocus
(
candidatesForArc
);
if
(
hasArcType
(
c3
.
data
.
targets
))
{
if
(
hasArcType
(
c3
.
data
.
targets
))
{
unexpandArc
(
target
);
unexpandArc
(
target
Id
);
}
}
defocusLegend
(
target
);
defocusLegend
(
target
Id
);
};
};
c3
.
revert
=
function
(
target
)
{
c3
.
revert
=
function
(
target
Id
)
{
var
candidates
=
svg
.
selectAll
(
getTargetSelector
(
target
)),
var
candidates
=
svg
.
selectAll
(
getTargetSelector
(
target
Id
)),
candidatesForNoneArc
=
candidates
.
filter
(
isNoneArc
),
candidatesForNoneArc
=
candidates
.
filter
(
isNoneArc
),
candidatesForArc
=
candidates
.
filter
(
isArc
);
candidatesForArc
=
candidates
.
filter
(
isArc
);
function
revert
(
targets
)
{
function
revert
(
targets
)
{
...
@@ -2668,19 +2673,19 @@
...
@@ -2668,19 +2673,19 @@
revert
(
candidatesForNoneArc
.
classed
(
'focused'
,
false
));
revert
(
candidatesForNoneArc
.
classed
(
'focused'
,
false
));
revert
(
candidatesForArc
);
revert
(
candidatesForArc
);
if
(
hasArcType
(
c3
.
data
.
targets
))
{
if
(
hasArcType
(
c3
.
data
.
targets
))
{
unexpandArc
(
target
);
unexpandArc
(
target
Id
);
}
}
revertLegend
();
revertLegend
();
};
};
c3
.
show
=
function
(
target
)
{
c3
.
show
=
function
(
target
Id
)
{
svg
.
selectAll
(
getTargetSelector
(
target
))
svg
.
selectAll
(
getTargetSelector
(
target
Id
))
.
transition
()
.
transition
()
.
style
(
'opacity'
,
1
);
.
style
(
'opacity'
,
1
);
};
};
c3
.
hide
=
function
(
target
)
{
c3
.
hide
=
function
(
target
Id
)
{
svg
.
selectAll
(
getTargetSelector
(
target
))
svg
.
selectAll
(
getTargetSelector
(
target
Id
))
.
transition
()
.
transition
()
.
style
(
'opacity'
,
0
);
.
style
(
'opacity'
,
0
);
};
};
...
@@ -2729,17 +2734,20 @@
...
@@ -2729,17 +2734,20 @@
}
}
};
};
c3
.
unload
=
function
(
target
)
{
c3
.
unload
=
function
(
target
Id
)
{
c3
.
data
.
targets
=
c3
.
data
.
targets
.
filter
(
function
(
d
)
{
c3
.
data
.
targets
=
c3
.
data
.
targets
.
filter
(
function
(
t
)
{
return
d
.
id
!==
target
;
return
t
.
id
!==
targetId
;
});
});
svg
.
selectAll
(
'.target-'
+
target
)
svg
.
selectAll
(
getTargetSelector
(
targetId
)
)
.
transition
()
.
transition
()
.
style
(
'opacity'
,
0
)
.
style
(
'opacity'
,
0
)
.
remove
();
.
remove
();
if
(
__legend_show
)
{
if
(
__legend_show
)
{
svg
.
selectAll
(
'.legend-item-'
+
target
).
remove
();
svg
.
selectAll
(
'.legend-item'
+
getTargetSelectorSuffix
(
targetId
))
.
transition
()
.
style
(
"opacity"
,
0
)
.
remove
();
updateLegend
(
c3
.
data
.
targets
);
updateLegend
(
c3
.
data
.
targets
);
}
}
...
@@ -2748,8 +2756,8 @@
...
@@ -2748,8 +2756,8 @@
}
}
};
};
c3
.
selected
=
function
(
target
)
{
c3
.
selected
=
function
(
target
Id
)
{
var
suffix
=
isDefined
(
target
)
?
'-'
+
target
:
''
;
var
suffix
=
getTargetSelectorSuffix
(
targetId
)
;
return
d3
.
merge
(
return
d3
.
merge
(
main
.
selectAll
(
'.-shapes'
+
suffix
).
selectAll
(
'.-shape'
)
main
.
selectAll
(
'.-shapes'
+
suffix
).
selectAll
(
'.-shape'
)
.
filter
(
function
()
{
return
d3
.
select
(
this
).
classed
(
SELECTED
);
})
.
filter
(
function
()
{
return
d3
.
select
(
this
).
classed
(
SELECTED
);
})
...
@@ -2863,12 +2871,12 @@
...
@@ -2863,12 +2871,12 @@
return
__regions
;
return
__regions
;
};
};
c3
.
data
.
get
=
function
(
i
d
)
{
c3
.
data
.
get
=
function
(
targetI
d
)
{
var
target
=
c3
.
data
.
getAsTarget
(
i
d
);
var
target
=
c3
.
data
.
getAsTarget
(
targetI
d
);
return
isDefined
(
target
)
?
target
.
values
.
map
(
function
(
d
)
{
return
d
.
value
;
})
:
undefined
;
return
isDefined
(
target
)
?
target
.
values
.
map
(
function
(
d
)
{
return
d
.
value
;
})
:
undefined
;
};
};
c3
.
data
.
getAsTarget
=
function
(
i
d
)
{
c3
.
data
.
getAsTarget
=
function
(
targetI
d
)
{
var
targets
=
getTargets
(
function
(
d
)
{
return
d
.
id
===
i
d
;
});
var
targets
=
getTargets
(
function
(
t
)
{
return
t
.
id
===
targetI
d
;
});
return
targets
.
length
>
0
?
targets
[
0
]
:
undefined
;
return
targets
.
length
>
0
?
targets
[
0
]
:
undefined
;
};
};
...
...
c3.min.js
View file @
3588b169
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