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

  • SEARCH
  • Home
  • 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 9234491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:48:09+00:00 2026-06-18T06:48:09+00:00

Please see this example: JsFiddle Question: I have the following JSON Array y= [

  • 0

Please see this example: JsFiddle

Question: I have the following JSON Array

y= [ {"LngTrend":15,"DblValue":10,"DtmStamp":1358226000000},     
{"LngTrend":16,"DblValue":92,"DtmStamp":1358226000000},    
{"LngTrend":17,"DblValue":45,"DtmStamp":1358226000000},
{"LngTrend":18,"DblValue":87,"DtmStamp":1358226000000},


{"LngTrend":15,"DblValue":10,"DtmStamp":1358226060000},
{"LngTrend":16,"DblValue":87,"DtmStamp":1358226060000},
{"LngTrend":17,"DblValue":45,"DtmStamp":1358226060000},
{"LngTrend":18,"DblValue":92,"DtmStamp":1358226060000} ]

I was trying to group these object by DtmStamp end up having something like this :

 x =  [[1358226000000,10,92,45,87],[1358226060000,10,87,45,92], .......]

In other words:

x[0][0] = y[0].DtmStamp ;
x[0][1] = y[0].LngTrend ;
x[0][2] = y[1].LngTrend ;
x[0][3] = y[2].LngTrend ; 
x[0][4] = y[3].LngTrend ;

Unfortunately, it ends with something I don’t want.

Here is what I have tried so far:

   var dataTrendArray = [];
           $.each(x, function (index, value) {
                var trendArray = [];
                if (index % 4 == 0) {
                    trendArray.push(x[index].DtmStamp);
                    for (var i = 0; i < 4; i++) {
                        index = eval(index + i);
                        trendArray.push(x[index].DblValue);
                    }
                }

               console.log(trendArray) ;
                dataTrendArray.push(trendArray);
            });

Can someone help me get on the right path?

  • 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-18T06:48:10+00:00Added an answer on June 18, 2026 at 6:48 am

    You can leverage JavaScript objects as a key/value data structure similar to a map. The property name will serve as the key, while the property value will serve as the value. This will allow you to group.

    var y = [
         {"LngTrend":15,"DblValue":10,"DtmStamp":1358226000000},     
         {"LngTrend":16,"DblValue":92,"DtmStamp":1358226000000},    
         {"LngTrend":17,"DblValue":45,"DtmStamp":1358226000000},
         {"LngTrend":18,"DblValue":87,"DtmStamp":1358226000000},
         {"LngTrend":15,"DblValue":10,"DtmStamp":1358226060000},
         {"LngTrend":16,"DblValue":87,"DtmStamp":1358226060000},
         {"LngTrend":17,"DblValue":45,"DtmStamp":1358226060000},
         {"LngTrend":18,"DblValue":92,"DtmStamp":1358226060000},
    ];
    
    var x = {};
    
    for (var i = 0; i < y.length; ++i) {
        var obj = y[i];
    
        //If a property for this DtmStamp does not exist yet, create
        if (x[obj.DtmStamp] === undefined)
            x[obj.DtmStamp] = [obj.DtmStamp]; //Assign a new array with the first element of DtmStamp.
    
        //x will always be the array corresponding to the current DtmStamp. Push a value the current value to it.
        x[obj.DtmStamp].push(obj.DblValue);
    }
    
    console.log(x); //x is now an object grouped by DtmStamp. You can easily turn it back into an array here.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

please see this example http://jsfiddle.net/7trcV/ what I'm trying to achieve is ability to put
please see this example: http://jsfiddle.net/qTjdX/ I want the red border-bottom to show as 1
Please see my following jsFiddle example where I am trying to push an Angular.js
Please see the solution to another question provided by ud3323: http://jsfiddle.net/ud3323/ykL69/ . This solution
Please see this example: if (strlen($_SESSION['userDetails']['THISNAME']) == 0) { $_SESSION['userDetails'][''.$THISNAME.'Error'] = autofocus; include $docRoot/html/forms/reg/user_info.html.php;
Please see this fiddle I want the scrolling div stop following when left div
Important : Please see this very much related question: Return multiple values in C++
I'm using the Google Maps API. Please see this JSON response . The HTML
Please see the back trace below, I don´t think I have seen this before
As you can see in this example http://jsfiddle.net/PCcj8/ I'd like to add some margin

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.