Search code examples
simulationanylogic

How to count and illustrate agents based on specific parmeter values in bar charts?


My source is generating an agent called Sitz with several parameters which get their value out of a database. One of the parameters is product_type.

Now I would like to count and illustrate the number of Sitz for each product_type in bar chart. I am thinking of a bar chart which shows 2 bars, one with Sitz product_type = A400S and one with Sitz product_type = A660.

My idea is to write something like sink.count(agent.product_type = "A400S") as value in the bar charts data section, but this is not the right way. What would be the right code?


Solution

  • There are a ton of ways, here is one:

    First, create a variable countA440S. Then, in the sink, write

    if (agent.product_type.equals("A400S")) {
        countA440S++;
    }
    

    In your bar chart, link it to the variable as below: enter image description here

    PS: Best always check the example models first, many show how to apply these basic techniques