GraphStream Users

Archives de la liste Aide


Changing pie-chart values


Chronologique Discussions 
  • From: Gaëtan Lesauvage <gaetanlesauvage AT gmail.com>
  • To: graphstream-users AT litislab.fr
  • Subject: Changing pie-chart values
  • Date: Thu, 29 Sep 2011 17:43:20 +0200

Hi developers!

I have a problem when I use pie-charts in my program. I can create the sprites and set the ui.style attribute with the shape "pie-chart" and the corresponding colors... I can also give the values using the attribute "ui.pie-values". The viewer displays the graph and the sprites correctly. Then I change the values of each pie-chart (using changingAttribute("ui.pie-values", ...) ) but it has no effect on the view.

I tried to change the position of the pie-charts. They move on the view but the colors proportions still the same. I also checked the value of the attribute "ui.pie-values", the values are changed in the model, but not on the view.

Do I correctly use the pie-chart sprites?


Thanks.


Code use to initialize each pie-chart: 

Sprite pie = scheduler.getSpriteManager().addSprite(id);
pie.addAttribute("ui.pie-values", pieValues.values().toArray());
pie.addAttribute("ui.style", "shape: pie-chart; fill-color: "+colors+"; size: 20px, 20px;");
pie.attachToNode(id);
pie.setPosition(Units.PX, 20, 20, 0);

Code use to change the values at each step of my program:

System.out.println(sprite.getId()+" @ = "+sprite);
Object[] v = sprite.getAttribute("ui.pie-values");
Random r = new Random();
int i1= r.nextInt(v.length);
for(int i=0; i<v.length; i++){
if(i == i1) v[i1] = 1f;
else v[i] = 0f;
System.out.println("v["+i+"]="+v[i]);
}
sprite.setAttribute("ui.pie-values", v);
String style = sprite.getAttribute("ui.style");
System.err.println("Style : "+style);
sprite.removeAttribute("ui.style");
sprite.addAttribute("ui.style", style);
sprite.setPosition(Units.PX, -1*sprite.getX(), 20, 0);


You may also find in attached files two snapshots of my graph: one after the initialization and the other after the first step of my simulation. As you can see, only the location of each pie-chart changed in the view. The colors ratio still the same despite they changed in the model.



-- 
Gaëtan Lesauvage
Laboratoire d'Informatique et du Traitement de L'information et des Systèmes
Faculté des Sciences et Techniques - Université du Havre
Bureau G012
+332 32 74 45 43
+336 42 87 41 64

Attachment: afterInitialization.png
Description: PNG image

Attachment: afterOneStep.png
Description: PNG image



  • Changing pie-chart values, Gaëtan Lesauvage, 29/09/2011

Archives gérées par MHonArc 2.6.16.

Top of page