Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9068135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:07:08+00:00 2026-06-16T17:07:08+00:00

How can I format this sample data for a graph I am making in

  • 0

How can I format this sample data for a graph I am making in d3.js?

[
    [
        [
            "2",
            "2013-01-02 00:00:00+00"
        ],
        [
            "3",
            "2012-12-28 00:00:00+00"
        ],
        [
            "3",
            "2012-12-27 00:00:00+00"
        ],
        [
            "1",
            "2012-12-26 00:00:00+00"
        ],
        [
            "1",
            "2012-12-24 00:00:00+00"
        ],
        [
            "4",
            "2012-12-21 00:00:00+00"
        ],
        [
            "1",
            "2012-12-20 00:00:00+00"
        ]
    ],
    [
        [
            "1",
            "2012-12-27 00:00:00+00"
        ],
        [
            "2",
            "2012-12-21 00:00:00+00"
        ],
        [
            "2",
            "2012-12-18 00:00:00+00"
        ],
        [
            "1",
            "2012-12-17 00:00:00+00"
        ],
        [
            "1",
            "2012-11-27 00:00:00+00"
        ],
        [
            "1",
            "2012-11-03 00:00:00+00"
        ],
        [
            "1",
            "2012-10-27 00:00:00+00"
        ]
    ]
]

currently, my javascript console gives me Uncaught TypeError: Cannot use 'in' operator to search for '_dateElement' in NaN within d3.v3.js:1033 when d3 tries to parse this data

it seems that d3 doesn’t want to deal with numbers in quotation marks, without quotation marks makes invalid json, which my ajax call will not return, which means I won’t be able to parse the arrays in my d3 function.

I believe d3 can parse and format json but I am at an impasse. How do I format this data, the date objects will be my X axis in ascending order, and the Y axis will be a max of the integer values

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:07:10+00:00Added an answer on June 16, 2026 at 5:07 pm

    You will need to parse your input array into an output array with the data in the format you want. As C.Reed says in comments, use parseInt to convert string to number and use d3.time.format to convert string to date. https://github.com/mbostock/d3/wiki/Time-Formatting

    var date_in = "2013-01-02 00:00:00+00";
    var format = d3.time.format("%Y-%m-%d 00:00:00+00");
    var date_out = format.parse(date_in); 
    

    (assumes time is always 0)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how can i replace date/time in this format 'Fri Mar 23 15:21:08 2012' with
I can connect to server and get json data. it is in this format:
How can I format the following line to eliminate StyleCop warnings: this.BeginInvoke(this.updateHandler,new object[]{this.tmpbuf}); Now,
How can I build a query with this format with a sqlite3 database? CREATE
data1/data2/data3 How can I find and replace all cells with this format to only
Is there any tool that can parse/conver xml files to this format? I have
Can anybody help me get this date format like Fri, 01 Oct 22:26:23 +0200
In C# you can do this: foo = string.Format({0} {1} {2} {3} ..., aa,
How I can do something like this in C++: void my_print(format_string) { vector<string> data;
I have sample data in this form: { ID:2 Type:None Reference1:6369-545.1 Reference2:6369-545.2 Name:John Smith

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.