Where to process the data?

Many JS chart libraries require the data to be processed and formatted in a certain way or in one of multiple ways.
For example, ApexCharts has multiple ways to format the data.

One I use a lot is two arrays: one array for the x-axis categories and one array for the y-values. Or, for the pie chart, we need two arrays: the series and the labels.

Typically this data is not formatted in that way in a FileMaker table. In the case above those would be individual records, where the label (“Apple”) is in one field and the series value (23) is in a field “Sales”.

So the question is, how and where do you format the data?

We have two options: FileMaker scripting and JavaScript functions. Both work well.

So questions:

  1. What are the advantages of either location?

  2. What are the disadvantages of either location?

  3. How are they similar?

  4. Which one are you inclined to use? Why?