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
70e3464b
Commit
70e3464b
authored
Feb 28, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add data.order option - #44
parent
7fbb2a5d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
3 deletions
+27
-3
c3.js
c3.js
+27
-3
c3.min.js
c3.min.js
+0
-0
No files found.
c3.js
View file @
70e3464b
...
...
@@ -59,6 +59,7 @@
__data_axes
=
getConfig
([
'data'
,
'axes'
],
{}),
__data_type
=
getConfig
([
'data'
,
'type'
],
null
),
__data_types
=
getConfig
([
'data'
,
'types'
],
{}),
__data_order
=
getConfig
([
'data'
,
'order'
],
null
),
__data_regions
=
getConfig
([
'data'
,
'regions'
],
{}),
__data_colors
=
getConfig
([
'data'
,
'colors'
],
{}),
__data_selection_enabled
=
getConfig
([
'data'
,
'selection'
,
'enabled'
],
false
),
...
...
@@ -951,6 +952,26 @@
return
closest
;
}
function
isOrderDesc
()
{
return
__data_order
&&
__data_order
.
toLowerCase
()
===
'desc'
;
}
function
isOrderAsc
()
{
return
__data_order
&&
__data_order
.
toLowerCase
()
===
'asc'
;
}
function
orderTargets
(
targets
)
{
var
orderAsc
=
isOrderAsc
(),
orderDesc
=
isOrderDesc
();
if
(
orderAsc
||
orderDesc
)
{
targets
.
sort
(
function
(
t1
,
t2
)
{
var
reducer
=
function
(
p
,
c
)
{
return
p
+
Math
.
abs
(
c
.
value
);
};
var
t1Sum
=
t1
.
values
.
reduce
(
reducer
,
0
),
t2Sum
=
t2
.
values
.
reduce
(
reducer
,
0
);
return
orderAsc
?
t2Sum
-
t1Sum
:
t1Sum
-
t2Sum
;
});
}
else
if
(
typeof
__data_order
===
'function'
)
{
targets
.
sort
(
__data_order
);
}
// TODO: accept name array for order
return
targets
;
}
//-- Tooltip --//
...
...
@@ -1050,13 +1071,14 @@
};
}
function
getBarOffset
(
barIndices
,
isSub
)
{
var
indicesIds
=
Object
.
keys
(
barIndices
);
var
targets
=
orderTargets
(
getTargets
(
isBarType
)),
targetIds
=
targets
.
map
(
function
(
t
)
{
return
t
.
id
;
});
return
function
(
d
,
i
)
{
var
scale
=
isSub
?
getSubYScale
(
d
.
id
)
:
getYScale
(
d
.
id
),
y0
=
scale
(
0
),
offset
=
y0
;
getTargets
(
isBarType
)
.
forEach
(
function
(
t
)
{
targets
.
forEach
(
function
(
t
)
{
if
(
t
.
id
===
d
.
id
||
barIndices
[
t
.
id
]
!==
barIndices
[
d
.
id
])
{
return
;
}
if
(
indicesIds
.
indexOf
(
t
.
id
)
<
indices
Ids
.
indexOf
(
d
.
id
)
&&
t
.
values
[
i
].
value
*
d
.
value
>
0
)
{
if
(
targetIds
.
indexOf
(
t
.
id
)
<
target
Ids
.
indexOf
(
d
.
id
)
&&
t
.
values
[
i
].
value
*
d
.
value
>
0
)
{
offset
+=
scale
(
t
.
values
[
i
].
value
)
-
y0
;
}
});
...
...
@@ -2161,6 +2183,8 @@
.
style
(
"opacity"
,
initialOpacity
)
.
transition
().
duration
(
duration
)
.
attr
(
'd'
,
drawBar
(
barIndices
,
false
))
// .style("fill", function (d) { return color(d.id); })
// .attr("class", classBar)
.
style
(
"opacity"
,
1
);
mainBar
.
exit
().
transition
().
duration
(
duration
)
.
style
(
'opacity'
,
0
)
...
...
c3.min.js
View file @
70e3464b
This diff is collapsed.
Click to expand it.
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