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
a5461140
Commit
a5461140
authored
Nov 09, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid binding 3rd party property to c3 API - #647
parent
054f8517
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
27 deletions
+44
-27
c3.js
c3.js
+2
-2
c3.min.js
c3.min.js
+0
-0
core-spec.js
spec/core-spec.js
+40
-23
core.js
src/core.js
+2
-2
No files found.
c3.js
View file @
a5461140
...
...
@@ -14,12 +14,12 @@
// bind "this" to nested API
(
function
bindThis
(
fn
,
target
,
argThis
)
{
for
(
var
key
in
fn
)
{
Object
.
keys
(
fn
).
forEach
(
function
(
key
)
{
target
[
key
]
=
fn
[
key
].
bind
(
argThis
);
if
(
Object
.
keys
(
fn
[
key
]).
length
>
0
)
{
bindThis
(
fn
[
key
],
target
[
key
],
argThis
);
}
}
}
);
})(
c3_chart_fn
,
this
,
this
);
}
...
...
c3.min.js
View file @
a5461140
This source diff could not be displayed because it is too large. You can
view the blob
instead.
spec/core-spec.js
View file @
a5461140
...
...
@@ -8,35 +8,52 @@ describe('c3 chart', function () {
var
chart
,
d3
;
beforeEach
(
function
()
{
window
.
initDom
();
chart
=
window
.
c3
.
generate
({
data
:
{
columns
:
[
[
'data1'
,
30
,
200
,
100
,
400
,
150
,
250
],
[
'data2'
,
50
,
20
,
10
,
40
,
15
,
25
],
[
'data3'
,
150
,
120
,
110
,
140
,
115
,
125
]
]
}
});
var
args
=
{
data
:
{
columns
:
[
[
'data1'
,
30
,
200
,
100
,
400
,
150
,
250
],
[
'data2'
,
50
,
20
,
10
,
40
,
15
,
25
],
[
'data3'
,
150
,
120
,
110
,
140
,
115
,
125
]
]
}
};
beforeEach
(
function
(
done
)
{
chart
=
window
.
initChart
(
chart
,
args
,
done
);
d3
=
chart
.
internal
.
d3
;
});
it
(
'should be created'
,
function
()
{
var
svg
=
d3
.
select
(
'#chart svg'
);
expect
(
svg
).
not
.
toBeNull
();
});
describe
(
'init'
,
function
()
{
it
(
'should be created'
,
function
()
{
var
svg
=
d3
.
select
(
'#chart svg'
);
expect
(
svg
).
not
.
toBeNull
();
});
it
(
'should set 3rd party property to Function'
,
function
()
{
Function
.
prototype
.
$extIsFunction
=
true
;
expect
(
true
).
toBeTruthy
();
});
it
(
'should be created even if 3rd party property has been set'
,
function
()
{
var
svg
=
d3
.
select
(
'#chart svg'
);
expect
(
svg
).
not
.
toBeNull
();
});
it
(
'should have same width'
,
function
()
{
var
svg
=
d3
.
select
(
'#chart svg'
);
expect
(
+
svg
.
attr
(
'width'
)).
toBe
(
640
);
});
it
(
'should have same height'
,
function
()
{
var
svg
=
d3
.
select
(
'#chart svg'
);
expect
(
+
svg
.
attr
(
'height'
)).
toBe
(
480
);
describe
(
'size'
,
function
()
{
it
(
'should have same width'
,
function
()
{
var
svg
=
d3
.
select
(
'#chart svg'
);
expect
(
+
svg
.
attr
(
'width'
)).
toBe
(
640
);
});
it
(
'should have same height'
,
function
()
{
var
svg
=
d3
.
select
(
'#chart svg'
);
expect
(
+
svg
.
attr
(
'height'
)).
toBe
(
480
);
});
});
});
src/core.js
View file @
a5461140
...
...
@@ -9,12 +9,12 @@ function Chart(config) {
// bind "this" to nested API
(
function
bindThis
(
fn
,
target
,
argThis
)
{
for
(
var
key
in
fn
)
{
Object
.
keys
(
fn
).
forEach
(
function
(
key
)
{
target
[
key
]
=
fn
[
key
].
bind
(
argThis
);
if
(
Object
.
keys
(
fn
[
key
]).
length
>
0
)
{
bindThis
(
fn
[
key
],
target
[
key
],
argThis
);
}
}
}
);
})(
c3_chart_fn
,
this
,
this
);
}
...
...
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