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
41741161
Commit
41741161
authored
Aug 21, 2015
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix stacking in timeseries data #1315 #1342 #1329
parent
d551192e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
2 deletions
+95
-2
c3.js
c3.js
+1
-1
c3.min.js
c3.min.js
+0
-0
shape.bar-spec.js
spec/shape.bar-spec.js
+93
-0
shape.js
src/shape.js
+1
-1
No files found.
c3.js
View file @
41741161
...
@@ -2797,7 +2797,7 @@
...
@@ -2797,7 +2797,7 @@
if
(
t
.
id
===
d
.
id
||
indices
[
t
.
id
]
!==
indices
[
d
.
id
])
{
return
;
}
if
(
t
.
id
===
d
.
id
||
indices
[
t
.
id
]
!==
indices
[
d
.
id
])
{
return
;
}
if
(
targetIds
.
indexOf
(
t
.
id
)
<
targetIds
.
indexOf
(
d
.
id
))
{
if
(
targetIds
.
indexOf
(
t
.
id
)
<
targetIds
.
indexOf
(
d
.
id
))
{
// check if the x values line up
// check if the x values line up
if
(
typeof
values
[
i
]
===
'undefined'
||
values
[
i
].
x
!==
d
.
x
)
{
if
(
typeof
values
[
i
]
===
'undefined'
||
+
values
[
i
].
x
!==
+
d
.
x
)
{
// "+" for timeseries
// if not, try to find the value that does line up
// if not, try to find the value that does line up
i
=
-
1
;
i
=
-
1
;
values
.
forEach
(
function
(
v
,
j
)
{
values
.
forEach
(
function
(
v
,
j
)
{
...
...
c3.min.js
View file @
41741161
This source diff could not be displayed because it is too large. You can
view the blob
instead.
spec/shape.bar-spec.js
View file @
41741161
...
@@ -9,6 +9,99 @@ describe('c3 chart shape bar', function () {
...
@@ -9,6 +9,99 @@ describe('c3 chart shape bar', function () {
chart
=
window
.
initChart
(
chart
,
args
,
done
);
chart
=
window
.
initChart
(
chart
,
args
,
done
);
});
});
describe
(
'with groups'
,
function
()
{
describe
(
'with indexed data'
,
function
()
{
it
(
'should update args'
,
function
()
{
args
=
{
data
:
{
columns
:
[
[
'data1'
,
30
,
200
,
-
100
,
400
,
-
150
,
250
],
[
'data2'
,
50
,
20
,
10
,
40
,
15
,
25
],
],
groups
:
[
[
'data1'
,
'data2'
],
],
type
:
'bar'
},
};
expect
(
true
).
toBeTruthy
();
});
it
(
'should be stacked'
,
function
()
{
var
expectedBottom
=
[
275
,
293
,
365
,
281
,
395
,
290
];
chart
.
internal
.
main
.
selectAll
(
'.c3-bars-data1 .c3-bar'
).
each
(
function
(
d
,
i
)
{
var
rect
=
d3
.
select
(
this
).
node
().
getBoundingClientRect
();
expect
(
rect
.
bottom
).
toBeCloseTo
(
expectedBottom
[
i
],
-
1
);
});
});
});
describe
(
'with timeseries data'
,
function
()
{
it
(
'should update args'
,
function
()
{
args
=
{
data
:
{
x
:
'date'
,
columns
:
[
[
'date'
,
'2012-12-24'
,
'2012-12-25'
,
'2012-12-26'
,
'2012-12-27'
,
'2012-12-28'
,
'2012-12-29'
],
[
'data1'
,
30
,
200
,
-
100
,
400
,
-
150
,
250
],
[
'data2'
,
50
,
20
,
10
,
40
,
15
,
25
],
],
groups
:
[
[
'data1'
,
'data2'
],
],
type
:
'bar'
},
axis
:
{
x
:
{
type
:
'timeseries'
,
}
}
};
expect
(
true
).
toBeTruthy
();
});
it
(
'should be stacked'
,
function
()
{
var
expectedBottom
=
[
275
,
293
,
365
,
281
,
395
,
290
];
chart
.
internal
.
main
.
selectAll
(
'.c3-bars-data1 .c3-bar'
).
each
(
function
(
d
,
i
)
{
var
rect
=
d3
.
select
(
this
).
node
().
getBoundingClientRect
();
expect
(
rect
.
bottom
).
toBeCloseTo
(
expectedBottom
[
i
],
-
1
);
});
});
});
describe
(
'with category data'
,
function
()
{
it
(
'should update args'
,
function
()
{
args
=
{
data
:
{
x
:
'date'
,
columns
:
[
[
'date'
,
'2012-12-24'
,
'2012-12-25'
,
'2012-12-26'
,
'2012-12-27'
,
'2012-12-28'
,
'2012-12-29'
],
[
'data1'
,
30
,
200
,
-
100
,
400
,
-
150
,
250
],
[
'data2'
,
50
,
20
,
10
,
40
,
15
,
25
],
],
groups
:
[
[
'data1'
,
'data2'
],
],
type
:
'bar'
},
axis
:
{
x
:
{
type
:
'category'
,
}
}
};
expect
(
true
).
toBeTruthy
();
});
it
(
'should be stacked'
,
function
()
{
var
expectedBottom
=
[
275
,
293
,
365
,
281
,
395
,
290
];
chart
.
internal
.
main
.
selectAll
(
'.c3-bars-data1 .c3-bar'
).
each
(
function
(
d
,
i
)
{
var
rect
=
d3
.
select
(
this
).
node
().
getBoundingClientRect
();
expect
(
rect
.
bottom
).
toBeCloseTo
(
expectedBottom
[
i
],
-
1
);
});
});
});
});
describe
(
'internal.isWithinBar'
,
function
()
{
describe
(
'internal.isWithinBar'
,
function
()
{
describe
(
'with normal axis'
,
function
()
{
describe
(
'with normal axis'
,
function
()
{
...
...
src/shape.js
View file @
41741161
...
@@ -42,7 +42,7 @@ c3_chart_internal_fn.getShapeOffset = function (typeFilter, indices, isSub) {
...
@@ -42,7 +42,7 @@ c3_chart_internal_fn.getShapeOffset = function (typeFilter, indices, isSub) {
if
(
t
.
id
===
d
.
id
||
indices
[
t
.
id
]
!==
indices
[
d
.
id
])
{
return
;
}
if
(
t
.
id
===
d
.
id
||
indices
[
t
.
id
]
!==
indices
[
d
.
id
])
{
return
;
}
if
(
targetIds
.
indexOf
(
t
.
id
)
<
targetIds
.
indexOf
(
d
.
id
))
{
if
(
targetIds
.
indexOf
(
t
.
id
)
<
targetIds
.
indexOf
(
d
.
id
))
{
// check if the x values line up
// check if the x values line up
if
(
typeof
values
[
i
]
===
'undefined'
||
values
[
i
].
x
!==
d
.
x
)
{
if
(
typeof
values
[
i
]
===
'undefined'
||
+
values
[
i
].
x
!==
+
d
.
x
)
{
// "+" for timeseries
// if not, try to find the value that does line up
// if not, try to find the value that does line up
i
=
-
1
;
i
=
-
1
;
values
.
forEach
(
function
(
v
,
j
)
{
values
.
forEach
(
function
(
v
,
j
)
{
...
...
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