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
80d76405
Commit
80d76405
authored
May 10, 2013
by
Masayuki Tanaka
Committed by
masayuki
May 10, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor for bar
parent
64cd68e8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
24 deletions
+28
-24
c3.js
c3.js
+28
-24
No files found.
c3.js
View file @
80d76405
...
...
@@ -984,7 +984,7 @@
}
function
draw
(
targets
)
{
var
barTargetsNum
=
getTargetsNum
(
isBarType
),
bar
Width
=
0
,
bar2Width
=
0
,
barIndices
,
barX
var
barTargetsNum
=
getTargetsNum
(
isBarType
),
bar
Indices
,
barX
,
barY
,
barW
,
barH
var
f
,
c
/*-- Main --*/
...
...
@@ -1021,9 +1021,11 @@
.
attr
(
"r"
,
__point_r
)
// Rects for each data
barWidth
=
(
xAxis
.
tickOffset
()
*
2
*
0.6
)
/
barTargetsNum
barIndices
=
getBarTargetIndices
()
barX
=
getBarX
(
barWidth
,
barTargetsNum
,
barIndices
)
barW
=
(
xAxis
.
tickOffset
()
*
2
*
0.6
)
/
barTargetsNum
barH
=
function
(
d
){
return
height
-
y
(
d
.
value
)
}
barX
=
getBarX
(
barW
,
barTargetsNum
,
barIndices
)
barY
=
function
(
d
){
return
y
(
d
.
value
)
}
f
.
append
(
'g'
)
.
attr
(
"class"
,
function
(
d
){
return
"target-bars target-bars-"
+
d
.
id
})
...
...
@@ -1036,9 +1038,9 @@
.
enter
().
append
(
"rect"
)
.
attr
(
"class"
,
function
(
d
,
i
){
return
"target-bar target-bar-"
+
i
})
.
attr
(
"x"
,
barX
)
.
attr
(
"y"
,
function
(
d
){
return
y
(
d
.
value
)
}
)
.
attr
(
"width"
,
barW
idth
)
.
attr
(
"height"
,
function
(
d
){
return
height
-
y
(
d
.
value
)
}
)
.
attr
(
"y"
,
barY
)
.
attr
(
"width"
,
barW
)
.
attr
(
"height"
,
barH
)
//-- Main Update Section --//
...
...
@@ -1052,21 +1054,21 @@
.
data
(
targets
)
.
filter
(
isLineType
)
.
selectAll
(
'circle'
)
.
data
(
function
(
d
)
{
return
d
.
values
})
.
data
(
function
(
d
){
return
d
.
values
})
.
transition
()
.
attr
(
"cx"
,
function
(
d
)
{
return
x
(
d
.
x
)
})
.
attr
(
"cy"
,
function
(
d
)
{
return
y
(
d
.
value
)
})
.
attr
(
"cx"
,
function
(
d
){
return
x
(
d
.
x
)
})
.
attr
(
"cy"
,
function
(
d
){
return
y
(
d
.
value
)
})
main
.
selectAll
(
".target-bars"
)
.
data
(
targets
)
.
filter
(
isBarType
)
.
selectAll
(
'rect'
)
.
data
(
function
(
d
)
{
return
d
.
values
})
.
data
(
function
(
d
){
return
d
.
values
})
.
transition
()
.
attr
(
"x"
,
barX
)
.
attr
(
"y"
,
function
(
d
){
return
y
(
d
.
value
)
}
)
.
attr
(
"width"
,
barW
idth
)
.
attr
(
"height"
,
function
(
d
){
return
height
-
y
(
d
.
value
)
}
)
.
attr
(
"y"
,
barY
)
.
attr
(
"width"
,
barW
)
.
attr
(
"height"
,
barH
)
/*-- Context --*/
...
...
@@ -1083,11 +1085,13 @@
.
attr
(
"class"
,
function
(
d
){
return
"target-line target-line-"
+
d
.
id
})
.
style
(
"stroke"
,
function
(
d
)
{
return
color
(
d
.
id
)
})
.
filter
(
isLineType
)
.
attr
(
"d"
,
function
(
d
)
{
return
line2
(
d
.
values
)
})
.
attr
(
"d"
,
function
(
d
)
{
return
line2
(
d
.
values
)
})
// Rects for each data
bar2Width
=
(
xAxis2
.
tickOffset
()
*
2
*
0.6
)
/
barTargetsNum
barX
=
getBarX
(
bar2Width
,
barTargetsNum
,
barIndices
)
barW
=
(
xAxis2
.
tickOffset
()
*
2
*
0.6
)
/
barTargetsNum
barH
=
function
(
d
){
return
height2
-
y2
(
d
.
value
)
}
barX
=
getBarX
(
barW
,
barTargetsNum
,
barIndices
)
barY
=
function
(
d
){
return
y2
(
d
.
value
)
}
c
.
append
(
'g'
)
.
attr
(
"class"
,
function
(
d
){
return
"target-bars target-bars-"
+
d
.
id
})
...
...
@@ -1098,9 +1102,9 @@
.
enter
().
append
(
"rect"
)
.
attr
(
"class"
,
function
(
d
,
i
){
return
"target-bar target-bar-"
+
i
})
.
attr
(
"x"
,
barX
)
.
attr
(
"y"
,
function
(
d
){
return
y2
(
d
.
value
)
}
)
.
attr
(
"width"
,
bar
2Width
)
.
attr
(
"height"
,
function
(
d
){
return
height2
-
y2
(
d
.
value
)
}
)
.
attr
(
"y"
,
barY
)
.
attr
(
"width"
,
bar
W
)
.
attr
(
"height"
,
barH
)
//-- Context Update Section --//
...
...
@@ -1108,18 +1112,18 @@
.
data
(
targets
)
.
filter
(
isLineType
)
.
transition
()
.
attr
(
"d"
,
function
(
d
)
{
return
line2
(
d
.
values
)
})
.
attr
(
"d"
,
function
(
d
)
{
return
line2
(
d
.
values
)
})
context
.
selectAll
(
".target-bars"
)
.
data
(
targets
)
.
filter
(
isBarType
)
.
selectAll
(
'rect'
)
.
data
(
function
(
d
)
{
return
d
.
values
})
.
data
(
function
(
d
){
return
d
.
values
})
.
transition
()
.
attr
(
"x"
,
barX
)
.
attr
(
"y"
,
function
(
d
){
return
y2
(
d
.
value
)
}
)
.
attr
(
"width"
,
bar
2Width
)
.
attr
(
"height"
,
function
(
d
){
return
height2
-
y2
(
d
.
value
)
}
)
.
attr
(
"y"
,
barY
)
.
attr
(
"width"
,
bar
W
)
.
attr
(
"height"
,
barH
)
}
/*-- Legend --*/
...
...
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