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
727ae80f
Commit
727ae80f
authored
Mar 30, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix show/hide API to update y domain - #70
parent
2e77578b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
13 deletions
+32
-13
c3.js
c3.js
+32
-13
c3.min.js
c3.min.js
+0
-0
No files found.
c3.js
View file @
727ae80f
...
@@ -284,6 +284,8 @@
...
@@ -284,6 +284,8 @@
};
};
})();
})();
var
hiddenTargetIds
=
[];
/*-- Set Chart Params --*/
/*-- Set Chart Params --*/
var
margin
,
margin2
,
margin3
,
width
,
width2
,
height
,
height2
,
currentWidth
,
currentHeight
,
legendHeight
,
legendWidth
;
var
margin
,
margin2
,
margin3
,
width
,
width2
,
height
,
height2
,
currentWidth
,
currentHeight
,
legendHeight
,
legendWidth
;
...
@@ -1081,8 +1083,8 @@
...
@@ -1081,8 +1083,8 @@
}
}
return
d3
.
max
(
Object
.
keys
(
ys
).
map
(
function
(
key
)
{
return
d3
.
max
(
ys
[
key
]);
}));
return
d3
.
max
(
Object
.
keys
(
ys
).
map
(
function
(
key
)
{
return
d3
.
max
(
ys
[
key
]);
}));
}
}
function
getYDomain
(
axisId
)
{
function
getYDomain
(
targets
,
axisId
)
{
var
yTargets
=
getTargets
(
function
(
d
)
{
return
getAxisId
(
d
.
id
)
===
axisId
;
}),
var
yTargets
=
targets
.
filter
(
function
(
d
)
{
return
getAxisId
(
d
.
id
)
===
axisId
;
}),
yMin
=
axisId
===
'y2'
?
__axis_y2_min
:
__axis_y_min
,
yMin
=
axisId
===
'y2'
?
__axis_y2_min
:
__axis_y_min
,
yMax
=
axisId
===
'y2'
?
__axis_y2_max
:
__axis_y_max
,
yMax
=
axisId
===
'y2'
?
__axis_y2_max
:
__axis_y_max
,
yDomainMin
=
isValue
(
yMin
)
?
yMin
:
getYDomainMin
(
yTargets
),
yDomainMin
=
isValue
(
yMin
)
?
yMin
:
getYDomainMin
(
yTargets
),
...
@@ -1370,6 +1372,18 @@
...
@@ -1370,6 +1372,18 @@
function
getTargets
(
filter
)
{
function
getTargets
(
filter
)
{
return
isDefined
(
filter
)
?
c3
.
data
.
targets
.
filter
(
filter
)
:
c3
.
data
.
targets
;
return
isDefined
(
filter
)
?
c3
.
data
.
targets
.
filter
(
filter
)
:
c3
.
data
.
targets
;
}
}
function
isTargetToShow
(
targetId
)
{
return
hiddenTargetIds
.
indexOf
(
targetId
)
<
0
;
}
function
filterTargetsToShow
(
targets
)
{
return
targets
.
filter
(
function
(
t
)
{
return
isTargetToShow
(
t
.
id
);
});
}
function
addHiddenTargetIds
(
targetIds
)
{
hiddenTargetIds
=
hiddenTargetIds
.
concat
(
targetIds
);
}
function
removeHiddenTargetIds
(
targetIds
)
{
hiddenTargetIds
=
hiddenTargetIds
.
filter
(
function
(
id
)
{
return
targetIds
.
indexOf
(
id
)
<
0
;
});
}
function
getValuesAsIdKeyed
(
targets
)
{
function
getValuesAsIdKeyed
(
targets
)
{
var
ys
=
{};
var
ys
=
{};
targets
.
forEach
(
function
(
t
)
{
targets
.
forEach
(
function
(
t
)
{
...
@@ -2179,8 +2193,8 @@
...
@@ -2179,8 +2193,8 @@
// Set domains for each scale
// Set domains for each scale
x
.
domain
(
d3
.
extent
(
getXDomain
(
c3
.
data
.
targets
)));
x
.
domain
(
d3
.
extent
(
getXDomain
(
c3
.
data
.
targets
)));
y
.
domain
(
getYDomain
(
'y'
));
y
.
domain
(
getYDomain
(
c3
.
data
.
targets
,
'y'
));
y2
.
domain
(
getYDomain
(
'y2'
));
y2
.
domain
(
getYDomain
(
c3
.
data
.
targets
,
'y2'
));
subX
.
domain
(
x
.
domain
());
subX
.
domain
(
x
.
domain
());
subY
.
domain
(
y
.
domain
());
subY
.
domain
(
y
.
domain
());
subY2
.
domain
(
y2
.
domain
());
subY2
.
domain
(
y2
.
domain
());
...
@@ -2727,6 +2741,7 @@
...
@@ -2727,6 +2741,7 @@
var
hideAxis
=
hasArcType
(
c3
.
data
.
targets
);
var
hideAxis
=
hasArcType
(
c3
.
data
.
targets
);
var
drawBar
,
drawBarOnSub
,
xForText
,
yForText
;
var
drawBar
,
drawBarOnSub
,
xForText
,
yForText
;
var
duration
,
durationForExit
,
durationForAxis
;
var
duration
,
durationForExit
,
durationForAxis
;
var
targetsToShow
=
filterTargetsToShow
(
c3
.
data
.
targets
);
options
=
isDefined
(
options
)
?
options
:
{};
options
=
isDefined
(
options
)
?
options
:
{};
withY
=
isDefined
(
options
.
withY
)
?
options
.
withY
:
true
;
withY
=
isDefined
(
options
.
withY
)
?
options
.
withY
:
true
;
...
@@ -2747,7 +2762,7 @@
...
@@ -2747,7 +2762,7 @@
}
}
if
(
withUpdateOrgXDomain
)
{
if
(
withUpdateOrgXDomain
)
{
x
.
domain
(
d3
.
extent
(
getXDomain
(
c3
.
data
.
targets
)));
x
.
domain
(
d3
.
extent
(
getXDomain
(
targetsToShow
)));
orgXDomain
=
x
.
domain
();
orgXDomain
=
x
.
domain
();
if
(
__zoom_enabled
)
{
zoom
.
scale
(
x
).
updateScaleExtent
();
}
if
(
__zoom_enabled
)
{
zoom
.
scale
(
x
).
updateScaleExtent
();
}
subX
.
domain
(
x
.
domain
());
subX
.
domain
(
x
.
domain
());
...
@@ -2759,8 +2774,8 @@
...
@@ -2759,8 +2774,8 @@
x
.
domain
(
brush
.
empty
()
?
orgXDomain
:
brush
.
extent
());
x
.
domain
(
brush
.
empty
()
?
orgXDomain
:
brush
.
extent
());
if
(
__zoom_enabled
)
{
zoom
.
scale
(
x
).
updateScaleExtent
();
}
if
(
__zoom_enabled
)
{
zoom
.
scale
(
x
).
updateScaleExtent
();
}
}
}
y
.
domain
(
getYDomain
(
'y'
));
y
.
domain
(
getYDomain
(
targetsToShow
,
'y'
));
y2
.
domain
(
getYDomain
(
'y2'
));
y2
.
domain
(
getYDomain
(
targetsToShow
,
'y2'
));
// axis
// axis
main
.
select
(
'.'
+
CLASS
.
axisX
).
style
(
"opacity"
,
hideAxis
?
0
:
1
).
transition
().
duration
(
durationForAxis
).
call
(
xAxis
);
main
.
select
(
'.'
+
CLASS
.
axisX
).
style
(
"opacity"
,
hideAxis
?
0
:
1
).
transition
().
duration
(
durationForAxis
).
call
(
xAxis
);
...
@@ -3304,7 +3319,7 @@
...
@@ -3304,7 +3319,7 @@
/*-- Show --*/
/*-- Show --*/
// Fade-in each chart
// Fade-in each chart
svg
.
selectAll
(
'.'
+
CLASS
.
target
)
svg
.
selectAll
(
'.'
+
CLASS
.
target
)
.
filter
(
function
(
d
)
{
return
isTargetToShow
(
d
.
id
);
})
.
transition
()
.
transition
()
.
style
(
"opacity"
,
1
);
.
style
(
"opacity"
,
1
);
}
}
...
@@ -3519,7 +3534,7 @@
...
@@ -3519,7 +3534,7 @@
candidatesForNoneArc
=
candidates
.
filter
(
isNoneArc
),
candidatesForNoneArc
=
candidates
.
filter
(
isNoneArc
),
candidatesForArc
=
candidates
.
filter
(
isArc
);
candidatesForArc
=
candidates
.
filter
(
isArc
);
function
focus
(
targets
)
{
function
focus
(
targets
)
{
targets
.
transition
().
duration
(
100
).
style
(
'opacity'
,
1
);
filterTargetsToShow
(
targets
)
.
transition
().
duration
(
100
).
style
(
'opacity'
,
1
);
}
}
c3
.
revert
();
c3
.
revert
();
c3
.
defocus
();
c3
.
defocus
();
...
@@ -3536,7 +3551,7 @@
...
@@ -3536,7 +3551,7 @@
candidatesForNoneArc
=
candidates
.
filter
(
isNoneArc
),
candidatesForNoneArc
=
candidates
.
filter
(
isNoneArc
),
candidatesForArc
=
candidates
.
filter
(
isArc
);
candidatesForArc
=
candidates
.
filter
(
isArc
);
function
defocus
(
targets
)
{
function
defocus
(
targets
)
{
targets
.
transition
().
duration
(
100
).
style
(
'opacity'
,
0.3
);
filterTargetsToShow
(
targets
)
.
transition
().
duration
(
100
).
style
(
'opacity'
,
0.3
);
}
}
c3
.
revert
();
c3
.
revert
();
defocus
(
candidatesForNoneArc
.
classed
(
CLASS
.
focused
,
false
));
defocus
(
candidatesForNoneArc
.
classed
(
CLASS
.
focused
,
false
));
...
@@ -3552,7 +3567,7 @@
...
@@ -3552,7 +3567,7 @@
candidatesForNoneArc
=
candidates
.
filter
(
isNoneArc
),
candidatesForNoneArc
=
candidates
.
filter
(
isNoneArc
),
candidatesForArc
=
candidates
.
filter
(
isArc
);
candidatesForArc
=
candidates
.
filter
(
isArc
);
function
revert
(
targets
)
{
function
revert
(
targets
)
{
targets
.
transition
().
duration
(
100
).
style
(
'opacity'
,
1
);
filterTargetsToShow
(
targets
)
.
transition
().
duration
(
100
).
style
(
'opacity'
,
1
);
}
}
revert
(
candidatesForNoneArc
.
classed
(
CLASS
.
focused
,
false
));
revert
(
candidatesForNoneArc
.
classed
(
CLASS
.
focused
,
false
));
revert
(
candidatesForArc
);
revert
(
candidatesForArc
);
...
@@ -3563,15 +3578,19 @@
...
@@ -3563,15 +3578,19 @@
};
};
c3
.
show
=
function
(
targetId
)
{
c3
.
show
=
function
(
targetId
)
{
removeHiddenTargetIds
(
targetId
);
svg
.
selectAll
(
selectorTarget
(
targetId
))
svg
.
selectAll
(
selectorTarget
(
targetId
))
.
transition
()
.
transition
()
.
style
(
'opacity'
,
1
);
.
style
(
'opacity'
,
1
);
redraw
({
withUpdateOrgXDomain
:
true
,
withUpdateXDomain
:
true
,
withLegend
:
false
});
};
};
c3
.
hide
=
function
(
targetId
)
{
c3
.
hide
=
function
(
targetId
)
{
addHiddenTargetIds
(
targetId
);
svg
.
selectAll
(
selectorTarget
(
targetId
))
svg
.
selectAll
(
selectorTarget
(
targetId
))
.
transition
()
.
transition
()
.
style
(
'opacity'
,
0
);
.
style
(
'opacity'
,
0
);
redraw
({
withUpdateOrgXDomain
:
true
,
withUpdateXDomain
:
true
,
withLegend
:
false
});
};
};
c3
.
unzoom
=
function
()
{
c3
.
unzoom
=
function
()
{
...
...
c3.min.js
View file @
727ae80f
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