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
065df8be
Commit
065df8be
authored
Oct 25, 2015
by
Evgeny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add normalized functionality
parent
0884c496
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
13 deletions
+23
-13
core.js
src/core.js
+2
-3
stacked.js
src/stacked.js
+13
-10
util.js
src/util.js
+8
-0
No files found.
src/core.js
View file @
065df8be
...
...
@@ -394,9 +394,10 @@ c3_chart_internal_fn.updateSizes = function () {
}
};
c3_chart_internal_fn
.
updateTargets
=
function
(
t
argets
)
{
c3_chart_internal_fn
.
updateTargets
=
function
(
t
)
{
var
$$
=
this
;
var
targets
=
$$
.
normalize
(
t
);
/*-- Main --*/
//-- Text --//
...
...
@@ -496,8 +497,6 @@ c3_chart_internal_fn.redraw = function (options, transitions) {
$$
.
y2Axis
.
tickValues
(
$$
.
generateTickValues
(
$$
.
y2
.
domain
(),
config
.
axis_y2_tick_count
));
}
$$
.
normalize
();
// axes
$$
.
redrawAxis
(
transitions
,
hideAxis
);
...
...
src/stacked.js
View file @
065df8be
c3
.
chart
.
internal
.
fn
.
normalize
=
function
(){
var
$$
=
this
,
tr
=
[],
c
=
[],
data
=
$$
.
api
.
data
();
c3
.
chart
.
internal
.
fn
.
normalize
=
function
(
targets
){
var
$$
=
this
,
tr
=
[],
c
=
[];
if
(
!
$$
.
config
.
normalized
){
return
;
if
(
!
$$
.
config
.
normalized
||
isUndefined
(
targets
)
){
return
targets
;
}
for
(
var
k
=
0
;
k
<
data
[
0
].
values
.
length
;
k
++
)
{
var
data
=
copyArray
(
targets
);
for
(
var
k
=
0
;
k
<
targets
[
0
].
values
.
length
;
k
++
)
{
var
tt
=
0
;
for
(
c
in
data
)
{
tt
=
tt
+
data
[
c
].
values
[
k
].
value
;
for
(
c
in
targets
)
{
tt
=
tt
+
targets
[
c
].
values
[
k
].
value
;
}
tr
[
k
]
=
tt
;
}
for
(
c
in
data
)
{
for
(
c
in
targets
)
{
for
(
k
=
0
;
k
<
tr
.
length
;
k
++
)
{
data
[
c
].
values
[
k
].
value
=
data
[
c
].
values
[
k
].
value
/
tr
[
k
];
data
[
c
].
values
[
k
].
value
=
targets
[
c
].
values
[
k
].
value
/
tr
[
k
];
}
}
return
data
;
}
src/util.js
View file @
065df8be
...
...
@@ -63,9 +63,17 @@ var isValue = c3_chart_internal_fn.isValue = function (v) {
var
newObj
=
{};
for
(
var
key
in
oldObj
){
if
(
oldObj
.
hasOwnProperty
(
key
)){
if
(
typeof
oldObj
[
key
]
===
'object'
){
newObj
[
key
]
=
copyObject
(
oldObj
[
key
]);
}
else
if
(
Array
.
isArray
(
oldObj
[
key
])){
newObj
[
key
]
=
copyArray
(
oldObj
[
key
]);
}
else
if
(
typeof
oldObj
[
key
]
===
'function'
){
newObj
[
key
]
=
oldObj
[
key
].
bind
(
newObj
);
}
else
{
newObj
[
key
]
=
oldObj
[
key
];
}
}
}
return
newObj
;
},
copyArray
=
function
(
oldArray
){
...
...
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