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
76cff822
Commit
76cff822
authored
May 29, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add 'length' and 'to' options to flow - #207
parent
759197fb
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
25 deletions
+50
-25
c3.js
c3.js
+37
-16
c3.min.js
c3.min.js
+0
-0
api_flow.html
htdocs/samples/api_flow.html
+5
-3
api_flow_timeseries.html
htdocs/samples/api_flow_timeseries.html
+8
-6
No files found.
c3.js
View file @
76cff822
...
@@ -2478,15 +2478,16 @@
...
@@ -2478,15 +2478,16 @@
area
=
__axis_rotated
?
area
.
x0
(
value0
).
x1
(
value1
).
y
(
xx
)
:
area
.
x
(
xx
).
y0
(
value0
).
y1
(
value1
);
area
=
__axis_rotated
?
area
.
x0
(
value0
).
x1
(
value1
).
y
(
xx
)
:
area
.
x
(
xx
).
y0
(
value0
).
y1
(
value1
);
return
function
(
d
)
{
return
function
(
d
)
{
var
data
=
filterRemoveNull
(
d
.
values
),
x0
,
y0
;
var
data
=
filterRemoveNull
(
d
.
values
),
x0
,
y0
,
path
;
if
(
isAreaType
(
d
))
{
if
(
isAreaType
(
d
))
{
return
area
.
interpolate
(
getInterpolate
(
d
))(
data
);
path
=
area
.
interpolate
(
getInterpolate
(
d
))(
data
);
}
else
{
}
else
{
x0
=
x
(
data
[
0
].
x
);
x0
=
x
(
data
[
0
].
x
);
y0
=
getYScale
(
d
.
id
)(
data
[
0
].
value
);
y0
=
getYScale
(
d
.
id
)(
data
[
0
].
value
);
return
__axis_rotated
?
"M "
+
y0
+
" "
+
x0
:
"M "
+
x0
+
" "
+
y0
;
path
=
__axis_rotated
?
"M "
+
y0
+
" "
+
x0
:
"M "
+
x0
+
" "
+
y0
;
}
}
return
path
?
path
:
"M 0 0"
;
};
};
}
}
...
@@ -2503,20 +2504,21 @@
...
@@ -2503,20 +2504,21 @@
if
(
!
__line_connect_null
)
{
line
=
line
.
defined
(
function
(
d
)
{
return
d
.
value
!=
null
;
});
}
if
(
!
__line_connect_null
)
{
line
=
line
.
defined
(
function
(
d
)
{
return
d
.
value
!=
null
;
});
}
return
function
(
d
)
{
return
function
(
d
)
{
var
data
=
__line_connect_null
?
filterRemoveNull
(
d
.
values
)
:
d
.
values
,
var
data
=
__line_connect_null
?
filterRemoveNull
(
d
.
values
)
:
d
.
values
,
x
=
isSub
?
x
:
subX
,
y
=
yScaleGetter
(
d
.
id
),
x0
=
0
,
y0
=
0
;
x
=
isSub
?
x
:
subX
,
y
=
yScaleGetter
(
d
.
id
),
x0
=
0
,
y0
=
0
,
path
;
if
(
isLineType
(
d
))
{
if
(
isLineType
(
d
))
{
if
(
__data_regions
[
d
.
id
])
{
if
(
__data_regions
[
d
.
id
])
{
return
lineWithRegions
(
data
,
x
,
y
,
__data_regions
[
d
.
id
]);
path
=
lineWithRegions
(
data
,
x
,
y
,
__data_regions
[
d
.
id
]);
}
else
{
}
else
{
return
line
.
interpolate
(
getInterpolate
(
d
))(
data
);
path
=
line
.
interpolate
(
getInterpolate
(
d
))(
data
);
}
}
}
else
{
}
else
{
if
(
data
[
0
])
{
if
(
data
[
0
])
{
x0
=
x
(
data
[
0
].
x
);
x0
=
x
(
data
[
0
].
x
);
y0
=
y
(
data
[
0
].
value
);
y0
=
y
(
data
[
0
].
value
);
}
}
return
__axis_rotated
?
"M "
+
y0
+
" "
+
x0
:
"M "
+
x0
+
" "
+
y0
;
path
=
__axis_rotated
?
"M "
+
y0
+
" "
+
x0
:
"M "
+
x0
+
" "
+
y0
;
}
}
return
path
?
path
:
"M 0 0"
;
};
};
}
}
...
@@ -3408,7 +3410,7 @@
...
@@ -3408,7 +3410,7 @@
}
}
function
redraw
(
options
,
transitions
)
{
function
redraw
(
options
,
transitions
)
{
var
xgrid
,
xgridAttr
,
xgridData
,
xgridLines
,
xgridLine
,
ygrid
,
ygridLines
,
ygridLine
;
var
xgrid
,
xgridAttr
,
xgridData
,
xgridLines
,
xgridLine
,
ygrid
,
ygridLines
,
ygridLine
,
flushXGrid
;
var
mainLine
,
mainArea
,
mainCircle
,
mainBar
,
mainArc
,
mainRegion
,
mainText
,
contextLine
,
contextArea
,
contextBar
,
eventRect
,
eventRectUpdate
;
var
mainLine
,
mainArea
,
mainCircle
,
mainBar
,
mainArc
,
mainRegion
,
mainText
,
contextLine
,
contextArea
,
contextBar
,
eventRect
,
eventRectUpdate
;
var
areaIndices
=
getShapeIndices
(
isAreaType
),
barIndices
=
getShapeIndices
(
isBarType
),
lineIndices
=
getShapeIndices
(
isLineType
),
maxDataCountTarget
,
tickOffset
;
var
areaIndices
=
getShapeIndices
(
isAreaType
),
barIndices
=
getShapeIndices
(
isBarType
),
lineIndices
=
getShapeIndices
(
isLineType
),
maxDataCountTarget
,
tickOffset
;
var
rectX
,
rectW
;
var
rectX
,
rectW
;
...
@@ -3542,8 +3544,6 @@
...
@@ -3542,8 +3544,6 @@
// grid
// grid
main
.
select
(
'line.'
+
CLASS
.
xgridFocus
).
style
(
"visibility"
,
"hidden"
);
main
.
select
(
'line.'
+
CLASS
.
xgridFocus
).
style
(
"visibility"
,
"hidden"
);
if
(
__grid_x_show
)
{
if
(
__grid_x_show
)
{
xgridData
=
generateGridData
(
__grid_x_type
,
x
);
tickOffset
=
isCategorized
?
xAxis
.
tickOffset
()
:
0
;
xgridAttr
=
__axis_rotated
?
{
xgridAttr
=
__axis_rotated
?
{
'x1'
:
0
,
'x1'
:
0
,
'x2'
:
width
,
'x2'
:
width
,
...
@@ -3555,12 +3555,20 @@
...
@@ -3555,12 +3555,20 @@
'y1'
:
margin
.
top
,
'y1'
:
margin
.
top
,
'y2'
:
height
'y2'
:
height
};
};
// this is used to flow
flushXGrid
=
function
(
withoutUpdate
)
{
xgridData
=
generateGridData
(
__grid_x_type
,
x
);
tickOffset
=
isCategorized
?
xAxis
.
tickOffset
()
:
0
;
xgrid
=
main
.
select
(
'.'
+
CLASS
.
xgrids
).
selectAll
(
'.'
+
CLASS
.
xgrid
)
xgrid
=
main
.
select
(
'.'
+
CLASS
.
xgrids
).
selectAll
(
'.'
+
CLASS
.
xgrid
)
.
data
(
xgridData
);
.
data
(
xgridData
);
xgrid
.
enter
().
append
(
'line'
).
attr
(
"class"
,
CLASS
.
xgrid
);
xgrid
.
enter
().
append
(
'line'
).
attr
(
"class"
,
CLASS
.
xgrid
);
if
(
!
withoutUpdate
)
{
xgrid
.
attr
(
xgridAttr
)
xgrid
.
attr
(
xgridAttr
)
.
style
(
"opacity"
,
function
()
{
return
+
d3
.
select
(
this
).
attr
(
__axis_rotated
?
'y1'
:
'x1'
)
===
(
__axis_rotated
?
height
:
0
)
?
0
:
1
;
});
.
style
(
"opacity"
,
function
()
{
return
+
d3
.
select
(
this
).
attr
(
__axis_rotated
?
'y1'
:
'x1'
)
===
(
__axis_rotated
?
height
:
0
)
?
0
:
1
;
});
}
xgrid
.
exit
().
remove
();
xgrid
.
exit
().
remove
();
};
flushXGrid
();
}
}
if
(
notEmpty
(
__grid_x_lines
))
{
if
(
notEmpty
(
__grid_x_lines
))
{
xgridLines
=
main
.
select
(
'.'
+
CLASS
.
xgridLines
).
selectAll
(
'.'
+
CLASS
.
xgridLine
)
xgridLines
=
main
.
select
(
'.'
+
CLASS
.
xgridLines
).
selectAll
(
'.'
+
CLASS
.
xgridLine
)
...
@@ -4009,13 +4017,12 @@
...
@@ -4009,13 +4017,12 @@
// update x domain to generate axis elements for flow
// update x domain to generate axis elements for flow
updateXDomain
(
targetsToShow
,
true
,
true
);
updateXDomain
(
targetsToShow
,
true
,
true
);
// update elements related to x scale
flushXGrid
(
true
);
// generate transform to flow
// generate transform to flow
translateX
=
x
(
flowStart
.
x
)
-
x
(
flowEnd
.
x
);
translateX
=
(
x
(
flowStart
.
x
)
-
x
(
flowEnd
.
x
))
*
(
isTimeSeries
?
0.9
:
1
);
// TODO: fix 0.9, I don't know why 0.9..
if
(
isTimeSeries
)
{
translateX
=
translateX
*
0.9
;
// TODO: fix 0.9, I don't know why 0.9..
scaleX
=
(
diffDomain
(
orgDomain
)
/
diffDomain
(
x
.
domain
()));
scaleX
=
(
diffDomain
(
orgDomain
)
/
diffDomain
(
x
.
domain
()));
}
transform
=
'translate('
+
translateX
+
',0) scale('
+
scaleX
+
',1)'
;
transform
=
'translate('
+
translateX
+
',0) scale('
+
scaleX
+
',1)'
;
d3
.
transition
().
ease
(
'linear'
).
duration
(
durationForFlow
).
each
(
function
()
{
d3
.
transition
().
ease
(
'linear'
).
duration
(
durationForFlow
).
each
(
function
()
{
...
@@ -4033,6 +4040,7 @@
...
@@ -4033,6 +4040,7 @@
var
i
,
shapes
=
[],
texts
=
[],
eventRects
=
[];
var
i
,
shapes
=
[],
texts
=
[],
eventRects
=
[];
// remove flowed elements
// remove flowed elements
if
(
flowLength
)
{
for
(
i
=
0
;
i
<
flowLength
;
i
++
)
{
for
(
i
=
0
;
i
<
flowLength
;
i
++
)
{
shapes
.
push
(
'.'
+
CLASS
.
shape
+
'-'
+
(
flowIndex
+
i
));
shapes
.
push
(
'.'
+
CLASS
.
shape
+
'-'
+
(
flowIndex
+
i
));
texts
.
push
(
'.'
+
CLASS
.
text
+
'-'
+
(
flowIndex
+
i
));
texts
.
push
(
'.'
+
CLASS
.
text
+
'-'
+
(
flowIndex
+
i
));
...
@@ -4042,10 +4050,12 @@
...
@@ -4042,10 +4050,12 @@
svg
.
selectAll
(
'.'
+
CLASS
.
texts
).
selectAll
(
texts
).
remove
();
svg
.
selectAll
(
'.'
+
CLASS
.
texts
).
selectAll
(
texts
).
remove
();
svg
.
selectAll
(
'.'
+
CLASS
.
eventRects
).
selectAll
(
eventRects
).
remove
();
svg
.
selectAll
(
'.'
+
CLASS
.
eventRects
).
selectAll
(
eventRects
).
remove
();
svg
.
select
(
'.'
+
CLASS
.
xgrid
).
remove
();
svg
.
select
(
'.'
+
CLASS
.
xgrid
).
remove
();
}
// draw again for removing flowed elements and reverting attr
// draw again for removing flowed elements and reverting attr
xgrid
xgrid
.
attr
(
'transform'
,
null
);
.
attr
(
'transform'
,
null
)
.
attr
(
xgridAttr
);
xgridLines
xgridLines
.
attr
(
'transform'
,
null
);
.
attr
(
'transform'
,
null
);
xgridLines
.
select
(
'line'
)
xgridLines
.
select
(
'line'
)
...
@@ -4074,7 +4084,8 @@
...
@@ -4074,7 +4084,8 @@
mainRegion
mainRegion
.
attr
(
'transform'
,
null
);
.
attr
(
'transform'
,
null
);
mainRegion
.
select
(
'rect'
).
filter
(
isRegionOnX
)
mainRegion
.
select
(
'rect'
).
filter
(
isRegionOnX
)
.
attr
(
"x"
,
regionX
);
.
attr
(
"x"
,
regionX
)
.
attr
(
"width"
,
regionWidth
);
eventRectUpdate
eventRectUpdate
.
attr
(
"x"
,
__axis_rotated
?
0
:
rectX
)
.
attr
(
"x"
,
__axis_rotated
?
0
:
rectX
)
.
attr
(
"y"
,
__axis_rotated
?
rectX
:
0
)
.
attr
(
"y"
,
__axis_rotated
?
rectX
:
0
)
...
@@ -4827,6 +4838,16 @@
...
@@ -4827,6 +4838,16 @@
});
});
c3
.
data
.
targets
=
c3
.
data
.
targets
.
concat
(
targets
);
// add remained
c3
.
data
.
targets
=
c3
.
data
.
targets
.
concat
(
targets
);
// add remained
// Update length to flow if needed
if
(
isDefined
(
args
.
to
))
{
length
=
0
;
c3
.
data
.
targets
[
0
].
values
.
forEach
(
function
(
v
)
{
if
(
v
.
x
<=
args
.
to
)
{
length
++
;
}
});
}
else
if
(
isDefined
(
args
.
length
))
{
length
=
args
.
length
;
}
// Set targets
// Set targets
updateTargets
(
c3
.
data
.
targets
);
updateTargets
(
c3
.
data
.
targets
);
...
...
c3.min.js
View file @
76cff822
This source diff could not be displayed because it is too large. You can
view the blob
instead.
htdocs/samples/api_flow.html
View file @
76cff822
...
@@ -74,9 +74,11 @@
...
@@ -74,9 +74,11 @@
[
'data1'
,
200
],
[
'data1'
,
200
],
[
'data3'
,
100
]
[
'data3'
,
100
]
],
],
duration
:
150
duration
:
150
,
length
:
0
});
});
}
},
length
:
2
});
});
},
1000
);
},
1000
);
...
@@ -87,7 +89,7 @@
...
@@ -87,7 +89,7 @@
// ['data2', 100],
// ['data2', 100],
[
'data3'
,
100
]
[
'data3'
,
100
]
],
],
duration
:
150
to
:
5
,
});
});
},
3000
);
},
3000
);
...
...
htdocs/samples/api_flow_timeseries.html
View file @
76cff822
...
@@ -60,11 +60,12 @@
...
@@ -60,11 +60,12 @@
setTimeout
(
function
()
{
setTimeout
(
function
()
{
chart
.
flow
({
chart
.
flow
({
columns
:
[
columns
:
[
[
'x'
,
'2013-01-21'
],
[
'x'
,
'2013-01-21'
,
'2013-01-25'
],
[
'data1'
,
500
],
[
'data1'
,
500
,
300
],
// ['data2', 100],
// ['data2', 100, 100],
[
'data3'
,
200
],
[
'data3'
,
200
,
150
],
]
],
min
:
new
Date
(
'2013-01-20'
),
});
});
},
1000
);
},
1000
);
...
@@ -75,7 +76,8 @@
...
@@ -75,7 +76,8 @@
[
'data1'
,
200
],
[
'data1'
,
200
],
[
'data2'
,
100
],
[
'data2'
,
100
],
[
'data3'
,
100
]
[
'data3'
,
100
]
]
],
length
:
0
});
});
},
2000
);
},
2000
);
...
...
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