- January 10, 2021 at 5:18 pm
I have multiple JSON files that I need to animate – each based on the same template.
The animation is a normal coordinate system and values for the x and y axis are nested in the JSON files. The graphic below shows the template and the layout for two different JSON files.
The problem is that the number of values for the x axis varies; meaning some JSON files only have 3 values, others 5, others 7, etc.
However, I want to have the x axis values in each animation evenly/symmetrically distributed on the x axis (the space in between the two red lines).
My first attempt was to count how many x values are in the JSON file and then distribute them along the x axis by dividing the pixel length of the axis by the number of values. But I failed to succeed here (How to count nest JSON values with expressions).
My other thought was to fix a first null and a last null and have all other values distributed in between them. No idea though how to do this with expressions.
Would anybody be able to help?
- January 12, 2021 at 8:11 am
Your graph is not here.
I also think it would help if you could post the content of a json file to see exactly how that data is.
- January 13, 2021 at 6:32 pm
this is the project file, a picture of the issue and the data file (you have to rename it to .json as json files cannot be uploaded here)
- January 14, 2021 at 9:02 am
The JSON wasn’t added unfortunately
- January 14, 2021 at 8:29 pm
i tried but json files are not possible to upload. so i renamed it to .txt file. but this wasnt uploaded either. can i contact you directly here?
- January 15, 2021 at 9:34 am
Can you share a cloud folder in which you got these 2 files?
- January 18, 2021 at 4:12 pm
There are both files in this dropbbox folder:
I am stuck with this:
The animation works for this JSON file. However, I have multiple other JSON files – and these vary with regards to the datapoints on the x axis.
Thus, I am looking for an expression that automatically checks, how many datapoints are in each JSON file when loaded and distributes them evenly/symmetrically along the x-axis.
Would any of you have an idea for that?
- January 23, 2021 at 9:45 pm
Hey Leonie, here are some thoughts based on your files:
1. If I understood correctly, your initial ideal will won’t work with dynamic number of data points, UNLESS you make sure there are that much layers created in the “Graph” comp. Meaning, if you do it now with more than 12 values – it won’t work (I guess you are aware of this, but just to highlight an issue of this approach)
2. In “Graph” comp, assuming your comp structure isn’t going to change, define seriesrating[X] as seriesrating[index+1] (as first layer in a list starts with index of 1, but arrays has indexing from 0). You won’t need to manually update it.
3. Now with above in mind, you should add a check which evaluates maximum seriesrating index in a .json, to not overcome maximum. This could be done in a control layer at the bottom of the comp, on in other place. Since you are approaching this Seasons-based, I would suggest collecting objects in array, which has matching “Season” index. Then – getting length of that objects array.
4. When number of season-items will be clear, you can interpolate X’s distances based on that number, and your comp/design width. However, 1st point must be taken into account for this.
5. I would suggest to not have contants attached to variables like “-600” and “900” – link them through Sliders, to have dynamically adjustable design.
Hope any of these helps to figure it out!
Log in to reply.