0

I am trying to iterate over an array and based of the value in y: I want to color a point in my chart.

this is what the code i want to use looks like, so index 0 would be {x:1,y:1} (which is why this isnt working now, im guessing). I want to isolate y:1 then color with value === 1

this is my array

$.each(coords, function( index,value ) {
  if(value === 1){
    myColors2[index]="#A39FBB";
  • `value.x` and `value.y`. Each value in the array is an object. – Taplar Sep 09 '20 at 14:42
  • 2
    Does this answer your question? [How can I access and process nested objects, arrays or JSON?](https://stackoverflow.com/questions/11922383/how-can-i-access-and-process-nested-objects-arrays-or-json) – Taplar Sep 09 '20 at 14:42
  • yeah, didnt realise this was a thing, sorted my issue :) – ConfusedSpark Sep 09 '20 at 15:21

1 Answers1

0
$.each(coords, function( index,value ) {
  if(value.y === 1){
    myColors2[index]="#A39FBB";

Sunil Choudhary
  • 329
  • 1
  • 6