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
de322408
Commit
de322408
authored
May 28, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support json as input - #236
parent
4bfe25de
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
3 deletions
+35
-3
c3.js
c3.js
+13
-3
c3.min.js
c3.min.js
+0
-0
data_json.html
htdocs/samples/data_json.html
+22
-0
No files found.
c3.js
View file @
de322408
...
...
@@ -1453,6 +1453,13 @@
}
return
x
;
}
function
convertJsonToData
(
json
)
{
var
keys
=
Object
.
keys
(
json
),
new_rows
=
[];
keys
.
forEach
(
function
(
key
)
{
new_rows
.
push
([
key
].
concat
(
json
[
key
]));
});
return
convertColumnsToData
(
new_rows
);
}
function
convertRowsToData
(
rows
)
{
var
keys
=
rows
[
0
],
new_row
=
{},
new_rows
=
[],
i
,
j
;
for
(
i
=
1
;
i
<
rows
.
length
;
i
++
)
{
...
...
@@ -5054,7 +5061,7 @@
/*-- Load data and init chart with defined functions --*/
if
(
'url'
in
config
.
data
)
{
if
(
config
.
data
.
url
)
{
d3
.
xhr
(
config
.
data
.
url
,
function
(
error
,
data
)
{
// TODO: other mine/type
var
rows
=
d3
.
csv
.
parseRows
(
data
.
response
),
d
;
...
...
@@ -5069,10 +5076,13 @@
init
(
d
);
});
}
else
if
(
'rows'
in
config
.
data
)
{
else
if
(
config
.
data
.
json
)
{
init
(
convertJsonToData
(
config
.
data
.
json
));
}
else
if
(
config
.
data
.
rows
)
{
init
(
convertRowsToData
(
config
.
data
.
rows
));
}
else
if
(
'columns'
in
config
.
data
)
{
else
if
(
config
.
data
.
columns
)
{
init
(
convertColumnsToData
(
config
.
data
.
columns
));
}
else
{
...
...
c3.min.js
View file @
de322408
This source diff could not be displayed because it is too large. You can
view the blob
instead.
htdocs/samples/data_json.html
0 → 100644
View file @
de322408
<html>
<head>
<link
href=
"/css/c3.css"
rel=
"stylesheet"
type=
"text/css"
>
</head>
<body>
<div
id=
"chart"
></div>
<script
src=
"http://d3js.org/d3.v3.min.js"
charset=
"utf-8"
></script>
<script
src=
"/js/c3.js"
></script>
<script>
var
chart
=
c3
.
generate
({
data
:
{
json
:
{
data1
:
[
30
,
20
,
50
,
40
,
60
,
50
],
data2
:
[
200
,
130
,
90
,
240
,
130
,
220
],
data3
:
[
300
,
200
,
160
,
400
,
250
,
250
]
}
}
});
</script>
</body>
</html>
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