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
6d1bacd9
Commit
6d1bacd9
authored
Feb 17, 2014
by
mikhail samoilov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Subchart bar refactoring, allow negative values
parent
0988b8de
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
34 deletions
+29
-34
.gitignore
.gitignore
+1
-0
c3.js
c3.js
+18
-24
chart_bar_stacked.html
htdocs/samples/chart_bar_stacked.html
+10
-10
No files found.
.gitignore
View file @
6d1bacd9
# npm modules
node_modules
bower_components
c3.js
View file @
6d1bacd9
...
...
@@ -1938,18 +1938,16 @@
// bars
var
barOnMain
=
function
(
isSub
)
{
var
drawBar
=
function
(
isSub
)
{
var
barW
=
getBarW
(
xAxis
,
barTargetsNum
,
!!
isSub
),
barX
=
getBarX
(
barW
,
barTargetsNum
,
barIndices
),
barY
=
getBarY
(
!!
isSub
),
barOffset
=
getBarOffset
(
barIndices
);
x
=
getBarX
(
barW
,
barTargetsNum
,
barIndices
,
!!
isSub
),
y
=
getBarY
(
!!
isSub
),
barOffset
=
getBarOffset
(
barIndices
,
!!
isSub
),
yScale
=
isSub
?
getSubYScale
:
getYScale
;
return
function
(
d
,
i
)
{
var
y
=
barY
;
var
x
=
barX
;
var
y0
=
getYScale
(
d
.
id
)(
0
),
offset
=
barOffset
(
d
,
i
)
||
y0
;
// offset is for stacked bar chart, by default
var
y0
=
yScale
(
d
.
id
)(
0
),
offset
=
barOffset
(
d
,
i
)
||
y0
;
// offset is for stacked bar chart
// 4 points that make a bar
var
points
=
[
...
...
@@ -1977,16 +1975,14 @@
.
data
(
barData
);
mainBar
.
enter
().
append
(
'path'
)
.
attr
(
'd'
,
barOnMain
(
false
))
.
attr
(
'd'
,
drawBar
(
false
))
.
style
(
"stroke"
,
'none'
)
.
style
(
"fill"
,
function
(
d
)
{
return
color
(
d
.
id
);
})
.
attr
(
"class"
,
classBar
);
mainBar
.
style
(
"opacity"
,
0
)
.
transition
().
duration
(
duration
)
.
attr
(
'd'
,
barOnMain
(
false
))
.
style
(
'opacity'
,
1
);
.
attr
(
'd'
,
drawBar
(
false
));
mainBar
.
exit
().
transition
().
duration
(
duration
)
.
style
(
'opacity'
,
0
)
...
...
@@ -2058,21 +2054,19 @@
brush
.
extent
(
x
.
orgDomain
()).
update
();
}
// bars
barW
=
getBarW
(
subXAxis
,
barTargetsNum
,
true
);
barH
=
getBarH
(
height2
,
true
);
barX
=
getBarX
(
barW
,
barTargetsNum
,
barIndices
,
true
);
barY
=
getBarY
(
barH
,
barIndices
,
false
,
true
);
contextBar
=
context
.
selectAll
(
'.-bars'
).
selectAll
(
'.-bar'
)
.
data
(
barData
);
contextBar
.
transition
().
duration
(
duration
)
.
attr
(
"x"
,
barX
).
attr
(
"y"
,
barY
).
attr
(
"width"
,
barW
).
attr
(
"height"
,
barH
);
contextBar
.
enter
().
append
(
'rect'
)
.
attr
(
"class"
,
classBar
)
.
attr
(
"x"
,
barX
).
attr
(
"y"
,
barY
).
attr
(
"width"
,
barW
).
attr
(
"height"
,
barH
)
contextBar
.
enter
().
append
(
'path'
)
.
attr
(
'd'
,
drawBar
(
true
))
.
style
(
"stroke"
,
'none'
)
.
style
(
"fill"
,
function
(
d
)
{
return
color
(
d
.
id
);
})
.
attr
(
"class"
,
classBar
);
contextBar
.
style
(
"opacity"
,
0
)
.
transition
()
.
transition
().
duration
(
duration
)
.
attr
(
'd'
,
drawBar
(
true
))
.
style
(
'opacity'
,
1
);
contextBar
.
exit
().
transition
()
contextBar
.
exit
().
transition
()
.
duration
(
duration
)
.
style
(
'opacity'
,
0
)
.
remove
();
// lines
...
...
htdocs/samples/chart_bar_stacked.html
View file @
6d1bacd9
<html>
<head>
<head>
<link
href=
"/css/c3.css"
rel=
"stylesheet"
type=
"text/css"
>
</head>
<body>
<div
id=
"chart"
></div>
</head>
<body>
<div
id=
"chart"
></div>
<script
src=
"http://d3js.org/d3.v3.min.js"
charset=
"utf-8"
></script>
<script
src=
"/js/c3.min
.js"
></script>
<script>
<script
src=
"/js/c3
.js"
></script>
<script>
var
chart
=
c3
.
generate
({
data
:
{
columns
:
[
[
'data1'
,
30
,
200
,
1
00
,
400
,
150
,
250
],
[
'data2'
,
130
,
100
,
14
0
,
200
,
150
,
50
]
[
'data1'
,
30
,
200
,
2
00
,
400
,
150
,
250
],
[
'data2'
,
130
,
-
100
,
10
0
,
200
,
150
,
50
]
],
types
:
{
data1
:
'bar'
,
...
...
@@ -28,6 +28,6 @@
}
}
});
</script>
</body>
</script>
</body>
</html>
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