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
81bec125
Commit
81bec125
authored
May 28, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add data.mineType option for JSON - #236
parent
de322408
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
14 deletions
+39
-14
c3.js
c3.js
+24
-11
c3.min.js
c3.min.js
+0
-0
data_url.html
htdocs/samples/data_url.html
+15
-3
No files found.
c3.js
View file @
81bec125
...
...
@@ -1453,6 +1453,18 @@
}
return
x
;
}
function
convertCsvToData
(
csv
)
{
var
rows
=
d3
.
csv
.
parseRows
(
csv
),
d
;
if
(
rows
.
length
===
1
)
{
d
=
[{}];
rows
[
0
].
forEach
(
function
(
id
)
{
d
[
0
][
id
]
=
null
;
});
}
else
{
d
=
d3
.
csv
.
parse
(
csv
);
}
return
d
;
}
function
convertJsonToData
(
json
)
{
var
keys
=
Object
.
keys
(
json
),
new_rows
=
[];
keys
.
forEach
(
function
(
key
)
{
...
...
@@ -2118,7 +2130,7 @@
}
function
isLineType
(
d
)
{
var
id
=
(
typeof
d
===
'string'
)
?
d
:
d
.
id
;
return
!
(
id
in
__data_types
)
||
[
'line'
,
'spline'
,
'area'
,
'area-spline'
,
'step'
,
'area-step'
].
indexOf
(
__data_types
[
id
])
>=
0
;
return
!
__data_types
[
id
]
||
[
'line'
,
'spline'
,
'area'
,
'area-spline'
,
'step'
,
'area-step'
].
indexOf
(
__data_types
[
id
])
>=
0
;
}
function
isStepType
(
d
)
{
var
id
=
(
typeof
d
===
'string'
)
?
d
:
d
.
id
;
...
...
@@ -5061,21 +5073,22 @@
/*-- Load data and init chart with defined functions --*/
if
(
config
.
data
.
url
)
{
function
initWithUrl
(
args
)
{
var
type
=
args
.
mineType
?
args
.
mineType
:
'csv'
;
d3
.
xhr
(
config
.
data
.
url
,
function
(
error
,
data
)
{
// TODO: other mine/type
var
rows
=
d3
.
csv
.
parseRows
(
data
.
response
),
d
;
if
(
rows
.
length
===
1
)
{
d
=
[{}];
rows
[
0
].
forEach
(
function
(
id
)
{
d
[
0
][
id
]
=
null
;
});
var
d
;
if
(
type
===
'json'
)
{
d
=
convertJsonToData
(
JSON
.
parse
(
data
.
response
));
}
else
{
d
=
d3
.
csv
.
parse
(
data
.
response
);
d
=
convertCsvToData
(
data
.
response
);
}
init
(
d
);
});
}
if
(
config
.
data
.
url
)
{
initWithUrl
(
config
.
data
);
}
else
if
(
config
.
data
.
json
)
{
init
(
convertJsonToData
(
config
.
data
.
json
));
}
...
...
@@ -5086,7 +5099,7 @@
init
(
convertColumnsToData
(
config
.
data
.
columns
));
}
else
{
throw
Error
(
'url or rows or columns is required.'
);
throw
Error
(
'url or
json or
rows or columns is required.'
);
}
return
c3
;
...
...
c3.min.js
View file @
81bec125
This source diff could not be displayed because it is too large. You can
view the blob
instead.
htdocs/samples/data_url.html
View file @
81bec125
...
...
@@ -3,16 +3,28 @@
<link
href=
"/css/c3.css"
rel=
"stylesheet"
type=
"text/css"
>
</head>
<body>
<div
id=
"chart"
></div>
<div
id=
"chart1"
></div>
<div
id=
"chart2"
></div>
<script
src=
"http://d3js.org/d3.v3.min.js"
charset=
"utf-8"
></script>
<script
src=
"/js/c3.
min.
js"
></script>
<script
src=
"/js/c3.js"
></script>
<script>
var
chart
=
c3
.
generate
({
var
chart1
=
c3
.
generate
({
bindto
:
'#chart1'
,
data
:
{
url
:
'/data/c3_test.csv'
}
});
var
chart2
=
c3
.
generate
({
bindto
:
'#chart2'
,
data
:
{
url
:
'/data/c3_test.json'
,
mineType
:
'json'
}
});
</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