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
ac8b8725
You need to sign in or sign up before continuing.
Commit
ac8b8725
authored
Oct 13, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix data type when no data - #580
parent
b64efaf9
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
128 additions
and
4 deletions
+128
-4
c3.js
c3.js
+10
-2
c3.min.js
c3.min.js
+0
-0
type-spec.js
spec/type-spec.js
+108
-0
type.js
src/type.js
+10
-2
No files found.
c3.js
View file @
ac8b8725
...
@@ -3092,11 +3092,19 @@
...
@@ -3092,11 +3092,19 @@
};
};
c3_chart_internal_fn
.
hasType
=
function
(
type
,
targets
)
{
c3_chart_internal_fn
.
hasType
=
function
(
type
,
targets
)
{
var
$$
=
this
,
types
=
$$
.
config
.
data_types
,
has
=
false
;
var
$$
=
this
,
types
=
$$
.
config
.
data_types
,
has
=
false
;
(
targets
||
$$
.
data
.
targets
).
forEach
(
function
(
t
)
{
targets
=
targets
||
$$
.
data
.
targets
;
if
((
types
[
t
.
id
]
&&
types
[
t
.
id
].
indexOf
(
type
)
>=
0
)
||
(
!
(
t
.
id
in
types
)
&&
type
===
'line'
))
{
if
(
targets
.
length
)
{
targets
.
forEach
(
function
(
target
)
{
var
t
=
types
[
target
.
id
];
if
((
t
&&
t
.
indexOf
(
type
)
>=
0
)
||
(
!
t
&&
type
===
'line'
))
{
has
=
true
;
has
=
true
;
}
}
});
});
}
else
{
Object
.
keys
(
types
).
forEach
(
function
(
id
)
{
if
(
types
[
id
]
===
type
)
{
has
=
true
;
}
});
}
return
has
;
return
has
;
};
};
c3_chart_internal_fn
.
hasArcType
=
function
(
targets
)
{
c3_chart_internal_fn
.
hasArcType
=
function
(
targets
)
{
...
...
c3.min.js
View file @
ac8b8725
This source diff could not be displayed because it is too large. You can
view the blob
instead.
spec/type-spec.js
0 → 100644
View file @
ac8b8725
var
describe
=
window
.
describe
,
expect
=
window
.
expect
,
it
=
window
.
it
,
beforeEach
=
window
.
beforeEach
;
describe
(
'c3 chart types'
,
function
()
{
'use strict'
;
var
chart
,
d3
;
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
]
],
type
:
'pie'
}
};
beforeEach
(
function
(
done
)
{
if
(
typeof
chart
===
'undefined'
)
{
window
.
initDom
();
}
chart
=
window
.
c3
.
generate
(
args
);
d3
=
chart
.
internal
.
d3
;
chart
.
internal
.
d3
.
select
(
'.jasmine_html-reporter'
).
style
(
'display'
,
'none'
);
window
.
setTimeout
(
function
()
{
done
();
},
10
);
});
describe
(
'internal.hasArcType'
,
function
()
{
it
(
'should return true'
,
function
()
{
expect
(
chart
.
internal
.
hasArcType
()).
toBeTruthy
();
});
it
(
'should change chart type to "bar" successfully'
,
function
()
{
args
.
data
.
type
=
'bar'
;
expect
(
true
).
toBeTruthy
();
});
it
(
'should return false'
,
function
()
{
expect
(
chart
.
internal
.
hasArcType
()).
toBeFalsy
();
});
});
describe
(
'internal.hasType'
,
function
()
{
it
(
'should change chart type to "pie" successfully'
,
function
()
{
args
.
data
.
type
=
'pie'
;
expect
(
true
).
toBeTruthy
();
});
it
(
'should return true for "pie" type'
,
function
()
{
expect
(
chart
.
internal
.
hasType
(
'pie'
)).
toBeTruthy
();
});
it
(
'should return false for "line" type'
,
function
()
{
expect
(
chart
.
internal
.
hasType
(
'line'
)).
toBeFalsy
();
});
it
(
'should return false for "bar" type'
,
function
()
{
expect
(
chart
.
internal
.
hasType
(
'bar'
)).
toBeFalsy
();
});
it
(
'should unload successfully'
,
function
()
{
chart
.
unload
([]);
expect
(
true
).
toBeTruthy
();
});
it
(
'should return true for "pie" type even if no data'
,
function
()
{
expect
(
chart
.
internal
.
hasType
(
'pie'
)).
toBeTruthy
();
});
it
(
'should return false for "line" type even if no data'
,
function
()
{
expect
(
chart
.
internal
.
hasType
(
'line'
)).
toBeFalsy
();
});
it
(
'should return false for "bar" type even if no data'
,
function
()
{
expect
(
chart
.
internal
.
hasType
(
'bar'
)).
toBeFalsy
();
});
it
(
'should change chart type to "bar" successfully'
,
function
()
{
args
.
data
.
type
=
'bar'
;
expect
(
true
).
toBeTruthy
();
});
it
(
'should return false for "pie" type even if no data'
,
function
()
{
expect
(
chart
.
internal
.
hasType
(
'pie'
)).
toBeFalsy
();
});
it
(
'should return false for "line" type even if no data'
,
function
()
{
expect
(
chart
.
internal
.
hasType
(
'line'
)).
toBeFalsy
();
});
it
(
'should return true for "bar" type even if no data'
,
function
()
{
expect
(
chart
.
internal
.
hasType
(
'bar'
)).
toBeTruthy
();
});
});
});
src/type.js
View file @
ac8b8725
...
@@ -10,11 +10,19 @@ c3_chart_internal_fn.setTargetType = function (targetIds, type) {
...
@@ -10,11 +10,19 @@ c3_chart_internal_fn.setTargetType = function (targetIds, type) {
};
};
c3_chart_internal_fn
.
hasType
=
function
(
type
,
targets
)
{
c3_chart_internal_fn
.
hasType
=
function
(
type
,
targets
)
{
var
$$
=
this
,
types
=
$$
.
config
.
data_types
,
has
=
false
;
var
$$
=
this
,
types
=
$$
.
config
.
data_types
,
has
=
false
;
(
targets
||
$$
.
data
.
targets
).
forEach
(
function
(
t
)
{
targets
=
targets
||
$$
.
data
.
targets
;
if
((
types
[
t
.
id
]
&&
types
[
t
.
id
].
indexOf
(
type
)
>=
0
)
||
(
!
(
t
.
id
in
types
)
&&
type
===
'line'
))
{
if
(
targets
.
length
)
{
targets
.
forEach
(
function
(
target
)
{
var
t
=
types
[
target
.
id
];
if
((
t
&&
t
.
indexOf
(
type
)
>=
0
)
||
(
!
t
&&
type
===
'line'
))
{
has
=
true
;
has
=
true
;
}
}
});
});
}
else
{
Object
.
keys
(
types
).
forEach
(
function
(
id
)
{
if
(
types
[
id
]
===
type
)
{
has
=
true
;
}
});
}
return
has
;
return
has
;
};
};
c3_chart_internal_fn
.
hasArcType
=
function
(
targets
)
{
c3_chart_internal_fn
.
hasArcType
=
function
(
targets
)
{
...
...
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