Skip to main content
stephanied41225197
Participant
May 11, 2018
Question

JSON graph

  • May 11, 2018
  • 2 replies
  • 639 views

Hello, I am using data located in a JSON file to create a graph.

In the below example, I pull a temperature # for the month of "Jan".

I would like to replace "Jan" by the current layer's name or better, by the name of the layer right below, to which I would add +1.

I have tried thisComp.layer(index).name with no luck.

eval("var variable="+footage("exportedxls.json").sourceText);

hauteur = variable[0].Jan;

min = thisComp.layer("Slider Controls").effect("Min")("Slider");

max = thisComp.layer("Slider Controls").effect("Max")("Slider");

max_movement = -thisComp.layer("Slider Controls").effect("Max Movement")("Slider")

newBaseline = thisComp.layer("Slider Controls").effect("New Baseline")("Slider");

myYheight = ((hauteur - min) / max) * max_movement + newBaseline;

myXspace = thisComp.layer(index+1).transform.position[0]+thisComp.layer("Slider Controls").effect("Space btw points")("Slider");

[myXspace, myYheight]

Would anyone be able to help me out?

Thank you,

Alex

    This topic has been closed for replies.

    2 replies

    stephanied41225197
    Participant
    May 12, 2018

    This is my JSON file:

    [{"p1":"0.1"}]

    Works:The below code will return the value 0.1:

    eval("var variable="+footage("exportedxls.json").sourceText);

    hauteur = variable[0].p1;

    Does not work: The below code will not return any value:

    eval("var variable="+footage("exportedxls.json").sourceText);

    hauteur = variable[0].thisComp.layer(index).name;

    Note that the layer's name is p1.

    Mylenium
    Legend
    May 11, 2018

    And what the are the layers actually called? Where is the layer name in your code even used? What error do you get? I'm confused.

    Mylenium

    stephanied41225197
    Participant
    May 11, 2018

    I am very new art this and confused too...

    Let's focus on: "I would like to replace "Jan" by the current layer's name". (whatever the name of the layer would be)

    Would this be possible?

    Thanks for your help.

    Mylenium
    Legend
    May 11, 2018

    Sure, but your are still not really explaining what specifically the issue is. Your layer.name construct should work, so the real question becomes what error you are running into. String conversion issues? Don't know where to place the code? What else?

    Mylenium