I am currently having troubles with displaying histograms and actually, I don't if what I try to is possible or not.
As shows the example code, I want to display histograms representing an information related to an agnt testA, stored in an agent testB. In the example code, the right information is displayed. However, it does not take into account the new agents testA created during the simulation.
Any advice is welcome.
Thank You
Mathieu
display "d"{
chart "information" type:series //histogram
// style:stack
{
datalist legend: testA accumulate each.name
value: testA accumulate 2;
}
}
--
You received this message because you are subscribed to the Google Groups "GAMA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gama-platfor...@googlegroups.com.
To post to this group, send email to gama-p...@googlegroups.com.
Visit this group at https://groups.google.com/group/gama-platform.
For more options, visit https://groups.google.com/d/optout.
model testDisplays
global{ list<string> lname;
list<int> lvalue;
list<rgb> lCol;
init{
create testA number:5;
create testB number:2;
}
reflex update {
loop tempA over:testA{
add tempA.name to: lname;
add sum(testB collect each.myA[tempA]) to: lvalue;
add tempA.color to: lCol;
// data tempA.name style: stack value:(testB collect each.myA[tempA]) color: tempA.color;
}
}
reflex creation{
create testA number:1;
}
}
species testA{
int a;
rgb color <- rgb(rnd(255),rnd(255),rnd(255));
init{
a <- rnd(10);
}
}
species testB{
map<testA,int> myA;
init{
loop temp over:testA{
add temp::temp.a to: myA;
}
}
reflex doSomething{
testA tempA <- one_of(testA);
put tempA.a at:tempA in: myA;
}
}
experiment testExpe type: gui {
output {
display "information"{
chart "information" type: histogram
style:stack
{
datalist lname value: lvalue color: lCol;
// datalist tempA collect(each.name) value: testA collect(each) color: tempA collect(each.color);
}
}
}
}
Your solution does not do quite what I what but it gave me ideas and I found the solution. I put the working code here so if anyone as the same problem, here my solution.
Thanks a lot
Mathieu