Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Animating chart data from json – from 0 to json value

  • Animating chart data from json – from 0 to json value

    Posted by Otto Tasnadi on July 28, 2020 at 12:09 pm

    I have a chart that uses data from a json array.
    I have the next code on a position to calculate X position:

    var X = parseInt(thisComp.layer("X-1").text.sourceText);
    var X_max = parseInt(thisComp.layer("X_max_value_mo_1").text.sourceText);
    var X_min = parseInt(thisComp.layer("X_min_value_mo_1").text.sourceText);
    linear(X,X_min,X_max,thisComp.height-50,50);

    Any ideas on how to animate this on the timeline from 0 up to this number? I want to animate the chart to grow the values from X_min to X.
    I think I need to have two keyframes and to add some code for each one?
    Can anybody help me?

    Thanks!

    var X = parseInt(thisComp.layer("X-1").text.sourceText);
    var X_max = parseInt(thisComp.layer("X_max_value_mo_1").text.sourceText);
    var X_min = parseInt(thisComp.layer("X_min_value_mo_1").text.sourceText);
    linear(X,X_min,X_max,thisComp.height-50,50);

    Otto Tasnadi replied 5 years, 9 months ago 2 Members · 2 Replies
  • 2 Replies
  • Filip Vandueren

    July 28, 2020 at 1:06 pm

    I’m guessing you still need to do that first interpolation in your example ?

    You can always use an extra linear() controlled by a slider from 0-100.
    Like this:


    var X = parseInt(thisComp.layer("X-1").text.sourceText);
    var X_max = parseInt(thisComp.layer("X_max_value_mo_1").text.sourceText);
    var X_min = parseInt(thisComp.layer("X_min_value_mo_1").text.sourceText);

    var lin = linear(X,X_min,X_max,thisComp.height-50,50);

    sl = thisComp.layer("Null 1").effect("Slider Control")("Slider").value;

    linear(sl, 0, 100, X_min, lin);

  • Otto Tasnadi

    July 29, 2020 at 5:32 am

    Thanks a lot, It works like a charm (with small customization)!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy