What format does C3/D3.js JSON data need to be in for bar charts?










0















Exploring and experimenting with C3/D3.



Goal: To have external data from .JSON file to render within the c3/d3js bar chart. How do I pull the x and y data and apply it to the axis?



Current: I currently have a string of JSON data simply like this a bunch of x and y values:
[

"x: 1540983600, y:16, x: 1541070000 y:25, x: 1541329200 y:20, x: 1541415600 y:21, x: 1541588400 y:10, x: 1541934000 y:15, x: 1542020400 y:9, x: 1541156400 y:4, x: 1541242800 y:7, x: 1541502000 y:6, x: 1541761200 y:1, x: 1541674800 y:6, x: 1541847600 y:1"
]



Current fetching data like this:



const Url='/linktoJSON/data.json';
$.ajax(
url: Url,
type: "GET",
success: function (result)
console.log(result)
,
error:function (error)
console.log('Error $error')

);



Graph render:



var chart = c3.generate({
bindto: '#chartBar',
data:
url: Url,
type: 'bar'
,
axis:
x:
type: 'category',
,
y:
label:
text: 'Count',
position: 'outer-middle'
,
max: 10,
min: 0,
padding:
top: 10,
bottom: 0


,










share|improve this question






















  • if that is your real json data and you expect it to render something useful you have a big problem. Look at the examples for D3 and use the same data format. Rewrite your BackEnd JSON provider code.

    – rioV8
    Nov 13 '18 at 10:10











  • Correct. This data is purely just test data that I've written. I've seen alot of JSON array formats used such as: var jsonCircles = [ "x_axis": 30, "y_axis": 30, "radius": 20, "color" : "green" , "x_axis": 70, "y_axis": 70, "radius": 20, "color" : "purple" , "x_axis": 110, "y_axis": 100, "radius": 20, "color" : "red" ]; Then pulling the data like this: jsonCircles[1].y_axis;

    – Kyle B
    Nov 13 '18 at 20:18
















0















Exploring and experimenting with C3/D3.



Goal: To have external data from .JSON file to render within the c3/d3js bar chart. How do I pull the x and y data and apply it to the axis?



Current: I currently have a string of JSON data simply like this a bunch of x and y values:
[

"x: 1540983600, y:16, x: 1541070000 y:25, x: 1541329200 y:20, x: 1541415600 y:21, x: 1541588400 y:10, x: 1541934000 y:15, x: 1542020400 y:9, x: 1541156400 y:4, x: 1541242800 y:7, x: 1541502000 y:6, x: 1541761200 y:1, x: 1541674800 y:6, x: 1541847600 y:1"
]



Current fetching data like this:



const Url='/linktoJSON/data.json';
$.ajax(
url: Url,
type: "GET",
success: function (result)
console.log(result)
,
error:function (error)
console.log('Error $error')

);



Graph render:



var chart = c3.generate({
bindto: '#chartBar',
data:
url: Url,
type: 'bar'
,
axis:
x:
type: 'category',
,
y:
label:
text: 'Count',
position: 'outer-middle'
,
max: 10,
min: 0,
padding:
top: 10,
bottom: 0


,










share|improve this question






















  • if that is your real json data and you expect it to render something useful you have a big problem. Look at the examples for D3 and use the same data format. Rewrite your BackEnd JSON provider code.

    – rioV8
    Nov 13 '18 at 10:10











  • Correct. This data is purely just test data that I've written. I've seen alot of JSON array formats used such as: var jsonCircles = [ "x_axis": 30, "y_axis": 30, "radius": 20, "color" : "green" , "x_axis": 70, "y_axis": 70, "radius": 20, "color" : "purple" , "x_axis": 110, "y_axis": 100, "radius": 20, "color" : "red" ]; Then pulling the data like this: jsonCircles[1].y_axis;

    – Kyle B
    Nov 13 '18 at 20:18














0












0








0








Exploring and experimenting with C3/D3.



Goal: To have external data from .JSON file to render within the c3/d3js bar chart. How do I pull the x and y data and apply it to the axis?



Current: I currently have a string of JSON data simply like this a bunch of x and y values:
[

"x: 1540983600, y:16, x: 1541070000 y:25, x: 1541329200 y:20, x: 1541415600 y:21, x: 1541588400 y:10, x: 1541934000 y:15, x: 1542020400 y:9, x: 1541156400 y:4, x: 1541242800 y:7, x: 1541502000 y:6, x: 1541761200 y:1, x: 1541674800 y:6, x: 1541847600 y:1"
]



Current fetching data like this:



const Url='/linktoJSON/data.json';
$.ajax(
url: Url,
type: "GET",
success: function (result)
console.log(result)
,
error:function (error)
console.log('Error $error')

);



Graph render:



var chart = c3.generate({
bindto: '#chartBar',
data:
url: Url,
type: 'bar'
,
axis:
x:
type: 'category',
,
y:
label:
text: 'Count',
position: 'outer-middle'
,
max: 10,
min: 0,
padding:
top: 10,
bottom: 0


,










share|improve this question














Exploring and experimenting with C3/D3.



Goal: To have external data from .JSON file to render within the c3/d3js bar chart. How do I pull the x and y data and apply it to the axis?



Current: I currently have a string of JSON data simply like this a bunch of x and y values:
[

"x: 1540983600, y:16, x: 1541070000 y:25, x: 1541329200 y:20, x: 1541415600 y:21, x: 1541588400 y:10, x: 1541934000 y:15, x: 1542020400 y:9, x: 1541156400 y:4, x: 1541242800 y:7, x: 1541502000 y:6, x: 1541761200 y:1, x: 1541674800 y:6, x: 1541847600 y:1"
]



Current fetching data like this:



const Url='/linktoJSON/data.json';
$.ajax(
url: Url,
type: "GET",
success: function (result)
console.log(result)
,
error:function (error)
console.log('Error $error')

);



Graph render:



var chart = c3.generate({
bindto: '#chartBar',
data:
url: Url,
type: 'bar'
,
axis:
x:
type: 'category',
,
y:
label:
text: 'Count',
position: 'outer-middle'
,
max: 10,
min: 0,
padding:
top: 10,
bottom: 0


,







javascript json d3.js c3.js






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 '18 at 3:45









Kyle BKyle B

11




11












  • if that is your real json data and you expect it to render something useful you have a big problem. Look at the examples for D3 and use the same data format. Rewrite your BackEnd JSON provider code.

    – rioV8
    Nov 13 '18 at 10:10











  • Correct. This data is purely just test data that I've written. I've seen alot of JSON array formats used such as: var jsonCircles = [ "x_axis": 30, "y_axis": 30, "radius": 20, "color" : "green" , "x_axis": 70, "y_axis": 70, "radius": 20, "color" : "purple" , "x_axis": 110, "y_axis": 100, "radius": 20, "color" : "red" ]; Then pulling the data like this: jsonCircles[1].y_axis;

    – Kyle B
    Nov 13 '18 at 20:18


















  • if that is your real json data and you expect it to render something useful you have a big problem. Look at the examples for D3 and use the same data format. Rewrite your BackEnd JSON provider code.

    – rioV8
    Nov 13 '18 at 10:10











  • Correct. This data is purely just test data that I've written. I've seen alot of JSON array formats used such as: var jsonCircles = [ "x_axis": 30, "y_axis": 30, "radius": 20, "color" : "green" , "x_axis": 70, "y_axis": 70, "radius": 20, "color" : "purple" , "x_axis": 110, "y_axis": 100, "radius": 20, "color" : "red" ]; Then pulling the data like this: jsonCircles[1].y_axis;

    – Kyle B
    Nov 13 '18 at 20:18

















if that is your real json data and you expect it to render something useful you have a big problem. Look at the examples for D3 and use the same data format. Rewrite your BackEnd JSON provider code.

– rioV8
Nov 13 '18 at 10:10





if that is your real json data and you expect it to render something useful you have a big problem. Look at the examples for D3 and use the same data format. Rewrite your BackEnd JSON provider code.

– rioV8
Nov 13 '18 at 10:10













Correct. This data is purely just test data that I've written. I've seen alot of JSON array formats used such as: var jsonCircles = [ "x_axis": 30, "y_axis": 30, "radius": 20, "color" : "green" , "x_axis": 70, "y_axis": 70, "radius": 20, "color" : "purple" , "x_axis": 110, "y_axis": 100, "radius": 20, "color" : "red" ]; Then pulling the data like this: jsonCircles[1].y_axis;

– Kyle B
Nov 13 '18 at 20:18






Correct. This data is purely just test data that I've written. I've seen alot of JSON array formats used such as: var jsonCircles = [ "x_axis": 30, "y_axis": 30, "radius": 20, "color" : "green" , "x_axis": 70, "y_axis": 70, "radius": 20, "color" : "purple" , "x_axis": 110, "y_axis": 100, "radius": 20, "color" : "red" ]; Then pulling the data like this: jsonCircles[1].y_axis;

– Kyle B
Nov 13 '18 at 20:18













0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53273480%2fwhat-format-does-c3-d3-js-json-data-need-to-be-in-for-bar-charts%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53273480%2fwhat-format-does-c3-d3-js-json-data-need-to-be-in-for-bar-charts%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo