Tinderbox Forum

Counting and displaying occurrences of an item in a set

Hey there, I’m REALLY trying to become more self-reliant, but I can’t figure this one out.

I’ve created an agent to collect the notes I want.

Now I want to plot a pie chart based on the items in a string, $Status, within these notes. Specifically, I want the pie chart to show the number of items that are “Active”, “Inactive,” “Abandoned,” etc. (i.e. the various possibilities in the string). I can’t seem to figure out how to generate the count. Thanks.

OK, so you want to use a pie() chart. It plots the numerical percentage of a numerical value for an attribute.

However, I think you want to do something slightly different. You want a pie chart of a figure that doesn’t (yet) exist, i.e. the count of each discrete value for the items matching the agent. Is this correct?

If so you’ll need to abstract that data to a new container, each of whose children is one of those values. for each ‘value’ note, e.g. “Active”. You then store the count (which you’ll calculate via action code) of the occurrence of that value in a Number-type attribute which you use as the pie plots data source.

Note, the label on the pie chart’s legend is always $Name and you can’t change that, i.e. you can’t show the count value in the label.

So, I thin it is do-able, albeit with some assembly. If you want that new functionality ‘baked in’ to the app you could always make a feature request. If it seems odd this additional feature doesn’t already exist, I don’t recall this need ever being asked about before; either people haven’t needed it, or they tried and failed but never discussed the fact.

Discussion of this elsewhere reminds me that you can see these counts in attribute browser view as you can see per-category counts. It’s not an answer to the context of your request but you can at least get at the counts. See here and here for more on AB view.