1

I have array of 3 columns (array has 6000 evalues and so each colum of array have 6000 values) in json file and store in variable called data. Using java script i need to store only first two columns of an array in a variable called edata. That is edata should contain array of two column of 6000 values.

That is 2 colum contain 6000 values each. Third colum should not be present.

Kindly help me in finding solution to it. I tried slice function but it only give 2 values as output i need 2 entire colums. that is from [[a,b,c],[a,b,c],[a,b,c],[a,b,c],[a,b,c]]............ to [[a,b],[a,b],[a,b],[a,b]]...........

$.ajax({
    url: "xxxxxxxxxxxxxxxxxxx",
    type: 'GET',
    context: document.body,
    success: function(data){
          //console.log(data);
     // http call for end
          var edata = data.slice(1,2);
var series= [{
            name: 'Touches',
            color: 'rgba(223, 83, 83, .5)',



            data: edata
3
  • 3
    provide the structure of data and also what have you done so far. Commented Sep 15, 2016 at 10:25
  • provide your table structure and php script Commented Sep 15, 2016 at 10:26
  • stackoverflow.com/a/7848073/2119863 Commented Sep 15, 2016 at 10:26

1 Answer 1

1

You can use the map function for this.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map

var edata = data.map(function(obj) {
    return {field1: obj.field1, field2: obj.field2}
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.