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
319626fb
Commit
319626fb
authored
Oct 12, 2015
by
Evgeny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add width and height functions
parent
82ec630c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
0 deletions
+84
-0
api.chart-spec.js
spec/api.chart-spec.js
+60
-0
c3-helper.js
spec/c3-helper.js
+6
-0
api.chart.js
src/api.chart.js
+18
-0
No files found.
spec/api.chart-spec.js
0 → 100644
View file @
319626fb
describe
(
"c3 chart"
,
function
(){
'use strict'
;
var
chart
;
var
args
=
{
data
:
{
columns
:
[
[
'data1'
,
30
,
200
,
100
,
400
,
150
,
250
],
[
'data2'
,
5000
,
2000
,
1000
,
4000
,
1500
,
2500
]
]
}
};
beforeEach
(
function
(
done
)
{
chart
=
window
.
initChart
(
chart
,
args
,
done
);
});
describe
(
"width"
,
function
(){
it
(
"should get width when no arguments given"
,
function
(
done
){
// Just some unusual number
chart
.
resize
({
width
:
1087
,
height
:
1087
});
wait
(
function
(){
expect
(
chart
.
width
()).
toBe
(
1087
);
done
();
});
});
it
(
"should set width"
,
function
(
done
){
chart
.
width
(
1087
);
wait
(
function
(){
expect
(
chart
.
width
()).
toBe
(
1087
);
done
();
});
});
});
describe
(
"height"
,
function
(){
it
(
"should get height when no arguments given"
,
function
(
done
){
// Just some unusual number
chart
.
resize
({
width
:
1087
,
height
:
1087
});
wait
(
function
(){
expect
(
chart
.
height
()).
toBe
(
1087
);
done
();
});
});
it
(
"should set height"
,
function
(
done
){
chart
.
height
(
1087
);
wait
(
function
(){
expect
(
chart
.
height
()).
toBe
(
1087
);
done
();
});
});
});
});
spec/c3-helper.js
View file @
319626fb
...
...
@@ -45,3 +45,9 @@ function initChart(chart, args, done) {
return
chart
;
}
typeof
initChart
!==
'undefined'
;
function
wait
(
f
){
setTimeout
(
f
,
500
);
}
typeof
wait
!==
'undefined'
;
src/api.chart.js
View file @
319626fb
...
...
@@ -5,6 +5,24 @@ c3_chart_fn.resize = function (size) {
this
.
flush
();
};
c3_chart_fn
.
width
=
function
(
width
){
var
$$
=
this
.
internal
;
if
(
isUndefined
(
width
)){
return
$$
.
getCurrentWidth
();
}
$$
.
config
.
size_width
=
width
;
this
.
flush
();
};
c3_chart_fn
.
height
=
function
(
height
){
var
$$
=
this
.
internal
;
if
(
isUndefined
(
height
)){
return
$$
.
getCurrentHeight
();
}
$$
.
config
.
size_height
=
height
;
this
.
flush
();
};
c3_chart_fn
.
flush
=
function
()
{
var
$$
=
this
.
internal
;
$$
.
updateAndRedraw
({
withLegend
:
true
,
withTransition
:
false
,
withTransitionForTransform
:
false
});
...
...
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