Stats in chart and results

Hi all, Just want to say this is exactly what I have been looking for and it is fantastic for my needs, thank you Appgyver team!

I’m getting stuck on displaying results from data.

I have a chart (that is working as I’ve used static data) but I don’t know how to populate it with dynamic data. I have a log with before and after numbers (0-100) and would like to show both numbers over time. eg show both numbers as a data points (y axis) for each log point (time, x axis).

Also I was wondering if it’s somehow possible to take a list of text, group it and count the largest group? Or even better order them in size. Having trouble getting my head around turning a group of texts in to a list of numbers. MAP maybe?

Thanks again
Scott

So i’ve got this far but not sure if it’s possible to repeat somehow:

[[‘Counter’, ‘Before’, ‘After’], [PICK_ITEM(PLUCK(data.Logging1, “id”), COUNT(data.Logging1)), PICK_ITEM(PLUCK(data.Logging1, “Before”), COUNT(data.Logging1)), PICK_ITEM(PLUCK(data.Logging1, “After”), COUNT(data.Logging1))], [PICK_ITEM(PLUCK(data.Logging1, “id”), SUBTRACT(COUNT(data.Logging1), 1)), PICK_ITEM(PLUCK(data.Logging1, “Before”), SUBTRACT(COUNT(data.Logging1), 1)), PICK_ITEM(PLUCK(data.Logging1, “After”), SUBTRACT(COUNT(data.Logging1), 1))], [PICK_ITEM(PLUCK(data.Logging1, “id”), SUBTRACT(COUNT(data.Logging1), 2)), PICK_ITEM(PLUCK(data.Logging1, “Before”), SUBTRACT(COUNT(data.Logging1), 2)), PICK_ITEM(PLUCK(data.Logging1, “After”), SUBTRACT(COUNT(data.Logging1), 2))], [PICK_ITEM(PLUCK(data.Logging1, “id”), SUBTRACT(COUNT(data.Logging1), 3)), PICK_ITEM(PLUCK(data.Logging1, “Before”), SUBTRACT(COUNT(data.Logging1), 3)), PICK_ITEM(PLUCK(data.Logging1, “After”), SUBTRACT(COUNT(data.Logging1), 3))],[PICK_ITEM(PLUCK(data.Logging1, “id”), SUBTRACT(COUNT(data.Logging1), 4)), PICK_ITEM(PLUCK(data.Logging1, “Before”), SUBTRACT(COUNT(data.Logging1), 4)), PICK_ITEM(PLUCK(data.Logging1, “After”), SUBTRACT(COUNT(data.Logging1), 4))]]

I mean i could keep adding to the formula but im sure theres another way.

Here is what I get when there is more than 7 results anyway, don’t really know whats going on…

Any help would be greatly appreciated, :slight_smile:

Thanks

So heres a simplified version:

[[‘Counter’, ‘Before’, ‘After’], [PICK_ITEM(PLUCK(data.Logging1, “id”), 0), PICK_ITEM(PLUCK(data.Logging1, “Before”), 0), PICK_ITEM(PLUCK(data.Logging1, “After”), 0)], [PICK_ITEM(PLUCK(data.Logging1, “id”), 1), PICK_ITEM(PLUCK(data.Logging1, “Before”), 1), PICK_ITEM(PLUCK(data.Logging1, “After”), 1)],
[PICK_ITEM(PLUCK(data.Logging1, “id”), 2), PICK_ITEM(PLUCK(data.Logging1, “Before”), 2), PICK_ITEM(PLUCK(data.Logging1, “After”), 2)], [PICK_ITEM(PLUCK(data.Logging1, “id”), 3), PICK_ITEM(PLUCK(data.Logging1, “Before”), 3), PICK_ITEM(PLUCK(data.Logging1, “After”), 3)], etc.

I copied this into word and copy pasta it up to 99, then copied it into work flow. Still think theres probably a simple repeatable solution but I guess this works for now.

Please let me know if theres an easier way to sort ALL the data.

I sorted my data by key “id” (number counter) and it fixed up the graph too…

Hey @Scott_McPherson, what do you use to render the chart? D3.js or Google Charts?


I used the component example thats posted in these forums as a template. Used JS in data variables (page mounted) to set page variables that populated the graph (as in the example). Thats how I get the extra long workflow in the last page variable.

Im not even sure if its JS or google charts or both as it says both

Hi @Scott_McPherson, you can probably replace the long formula with a MAP (docs) That applies the same formula to each item in a list.

[[‘Counter’, ‘Before’, ‘After’], [MAP(data.graphX1, item.id), MAP(data.graphX1, item.Before), MAP(data.graphX1, item.After)]]

I tried this, it makes sense to me but doesn’t work.

I get this error:
List items are incompatible.

They are accessed from data variables accessing data with two numeric properties (and id).

Thanks for the help,

Each of the MAP functions produces a new list of its own so with that formula you’ll get:

[[‘Counter’, ‘Before’, ‘After’], [[id1, id2, id3], [before1, before2, before3], [after1, after2, after3]]]

You’ll need to have them in a single MAP:

MAP(data.graphX1, [item.id, item.Before, item.After])

and then add the first row to the list of lists with INSERT_ITEM_AT

Would that work?

INSERT_ITEM_AT(ORDER(MAP(data.graphX1, [item.id, item.Before, item.After]), item.id), 0, [‘Counter’, ‘Before’, ‘After’])

This works!! Had to order the data as well. Thank you so much!!!

I have also used a select function to give the last X results (as the chart gets crowded) with this defining the number of results the data variable uses in the chart. The page var graphix you can input a number in the ui (or is 0 on page load).

SELECT(SORT_BY_KEY(data.graphX1, “id”), pageVars.graphix <= (index))

This works ok but was wondering it its possible to select a range of results (rather than just the last x results)? I have tried the generate range but not sure how it fits.

Thanks again.

Hi, you can always add another condition to the SELECT formula to get a range, for example if you’d want 10 results at a time you could have a page variable start for the 1st item and then create another page variable offset with value 10 and write:

index >= pageVars.start && index < (pageVars.start + pageVars.offset)

SELECT(SORT_BY_KEY(data.graphX1, “id”), index >= pageVars.start && index < pageVars.end)

I used this to get the range.

Thanks again Ive got so much done today!!!
:slight_smile:

1 Like