score:1
Accepted answer
Transform your object to an array. First, get the keys and second, combine them with the value to an array. If it is still not in order, you can sort the array.
var data = Object.keys(data2).map(function (key) { return [key, data2[key]]; });
Demo:
var data2 = {'A': 2, 'B': 3, 'C': 4, 'D': 5};
var data = Object.keys(data2).map(function (key) { return [key, data2[key]]; });
console.log(data);
Source: stackoverflow.com
Related Query
- Unable to parse objects
- How to parse an array of objects using data method of d3js and display it in tool tip?
- d3js unable to parse json data
- Unable to parse date format in Javascript
- Hyperlinks in d3.js objects
- Unable to get node datum on mouseover in D3 v6
- IE10 d3.v3.js error: Unable to get property 'prototype' of undefined or null reference
- How to get maximum value from an array of objects to use in d3.scale.linear().domain()
- Sorting objects based on property value in D3
- nvd3.js : unable to bind onClick event with the data points in the svg
- Unable to get click event in D3 JavaScript library
- How do you access an array of Objects using D3?
- D3 time parse returns null
- d3: A sub array of objects
- D3.js Dynamic connector between objects
- Parse Uploaded CSV file using D3.js
- D3 function to parse the date not working
- Is it possible to set custom attributes of SVG objects as number and not as string?
- Unable to set max-width of SVG text
- Receive Uncaught SecurityError when accessing SVG objects from Javascript
- Import and parse SVG file in D3.js
- nvd3.js - unable to change color of line in line chart
- d3.csv unable to go up one directory
- d3.js create objects on top of each other
- How can I use D3.js to take an array of Javascript objects use them in a line graph?
- Traverse Array of objects to generate d3 Sankey Chart data
- d3 csv readin to objects in array
- Unable to render charts using Wicked PDF
- dc js - unable to redraw charts
- D3 - Unable to get data parameter on click event
More Query from same tag
- Icon not displaying correctly
- d3.js: Pass anonymous function as parameter to centering force?
- Why use a "listener rect" to set up zooming in d3?
- D3 map as black box
- Truncate text in d3
- Load Compressed csv data in d3 for page optimization
- c3 js pie chart from csv
- D3 Angular - line break in axis label
- Parse json in Tree map d3.js to get different colours
- How do your write a function that returns values from an array?
- D3js - How to integrate mini libraries like d3-scale in Angular CLI?
- d3 svg rect does not render in chrome
- Fill bar with gradient colors depending on the value
- nvd3 memory leak when creating a new chart
- d3.js is not able to load my json on chrome but firefox & IE is working fine
- How to get the total depth of an unknown JSON hierarchy?
- Displaying text over a node in a d3 force-layout graph
- D3 Bar Chart, bars not showing, axis on top
- nvd3 space between bars
- How to add an attribute to an existing svg:g tag on leaflet map
- Append text or circle in heatmap grid of d3js
- Add a scatterplot to this D3 line chart?
- Using dc.js on the clientside with crossfilter on the server
- creating a line chart using C3
- D3 chart is not clearing before redrawing
- D3 - Calling nested function invokes the parent function and result in repetition of charts
- Cannot select SVG foreignObject element in d3
- d3.js stacked bar graph values at end of each bar
- How to integrate a json data frame into an html file
- d3 append and enter issues