10:36:46 UTC
I have started using flare to visualize a simple graphs with nodes and edges-similar to the demo (layouts/tree ).
This simple code displays the tree structure but with any labels. I want to use the node name from the graphml file as the node name
Can anyone help me
Thanks
MRC
Public Function tutorial ()
{
Loaddata ();
}
Private function loaddata (): void
{
VaR DS: datasource = new datasource ("http: // localhost/deps-gml.xml", "graphml ");
VaR Loader: urlloader = Ds. Load ();
Loader. addeventlistener (event. Complete, function (EVT: Event): void {
VaR DS: DataSet = loader. Data as dataset;
Visualize (data. fromdataset (DS ));
});
}
Private function visualize (data: data): void
{
VaR FMT: textformat = new textformat ();
FMT. font = "Arial ";
FMT. size = 19;
FMT. Bold = false;
Vis = new visualization (data );
VIS. bounds = new rectangle (0, 0, 600,500 );
VIS. x = 100;
VIS. Y = 50
Addchild (VIS );
VaR LAN: labeler = new labeler ("data. nodes. Name", Data. nodes, FMT );
VIS. Operators. Add (LAN );
VIS. Operators. Add (New nodelinktreelayout ("toptobottom", 5, 10 ));
VIS. Update ();
}
Goosebumps4all12:20:00 UTC
I guess
VaR LAN: labeler = new labeler ("data. nodes. Name", Data. nodes, FMT );
Shocould be
VaR LAN: labeler = new labeler ("data. Name", Data. nodes, FMT );
Hope that is it
Cheers
Martin
Cortinas12:39:21 UTC
Thanks. I added the following and now I have labels ....
VIS. Data. nodes. Visit (function (NS: nodesprite): void {
NS. Data. Label = NS. Data. ID;
});
VaR LAN: labeler = new labeler ("data. Label", Data. nodes, FMT );
VIS. Operators. Add (LAN );
Pall21313:58:14 UTC
Hello all, just another similar question.
What if I want to reach the value of the node? For example, there is a node like:
...
<Node id = "node1"> somevalue </node>
...
And I want to use that 'somevalue' as the label. How can I do that? And also how can I reach that value directly and assign it to a variable?
I know these are probably very basic things for you, sorry.
Storycreator114:32:35 UTC
In the graphml format you have to write the value in a new sub-Tag:
<Node id = "dm">
<Data key = "value"> 50.0 </data>
</Node>
And before the <graph> tag you need to define this key
<Key ID = "value" for = "Node" ATTR. Name = "yournamehere" ATTR. type = "double"/>
(Of course you can use other names for the ID than "value ".)
Now you can access the value in flare with "data. yournamehere ".
Pall21305:55:04 UTC
OK, thank you for the answer. So I can use that "data. yournamehere" as a parameter to labeler and it'll work.
But I still don't know how to assign that value to a variable, anyone can help? In other words,
VaR S: String = what to write here?
Goosebumps4all09:17:08 UTC
VaR S: String = anodesprite. Data. yournamehere;
Where anodesprite is the nodesprite instance holding that value;
Pall21309:45:08 UTC
Thank you very much, it works perfectly.
Pall21311:02:53 UTC
OK so, I can use the key "name" in the data as the label for the node:
VaR LAN: labeler = new labeler ("data. Name", Data. nodes, FMT );
But what if I have another key (say "type") that I also want to show it in the label with the "name "? (So the label will look like "examplename, exampletype") is there any way to do this with the labeler? Or shoshould I just add a textfield to each node and write whatever I want to them?
Goosebumps4all12:59:51 UTC
Http://flare.prefuse.org/api/flare/vis/operator/label/Labeler.html#Labeler ()
Pall21314:27:04 UTC
OK, thank you. So I can use a function to determine the label. Another question though, is it possible to use more than one labelers for a node? If so, how?
Goosebumps4all16:17:31 UTC
Well I wocould suggest adding two labelers to the operator list and lew.us know how it goes
Pall21306:43:36 UTC
Well I tried adding two labelers but it doesn't seem to be working. The second one is always ignored. I also tried changing yoffset and verticalanchor values. Any ideas?
Goosebumps4all08:00:48 UTC
Surprising, yet looking into the class revealed that it is due to fact how the labelers class stores the textfied, Which is per default in anodesprite. Props. Label
Luckily this default flied can be customized, so far your second labeler you might do something like
Labeler2.access = "props. label2 ";
And work with this field for the case you do extra customizations for the texfield
Hope that helps
Martin
Pall21312:26:17 UTC
Great. Thank you very much.
Amit476710:47:23 UTC
First of all I wowould like say thanks to all for helping me in giving label to node. Specially
Cortinas (Cortinas.
Can anybody please tell how can I give label to edge between two nodes.
Amit476710:54:31 UTC
VIS. Data. edges. Visit (function (NS: nodesprite): void {
If (NS. Data. Label = "3 "){
NS. Data. Label = "ASD ";
} Else {
NS. Data. Label = "Amit ";
}
});
VaR lan1: labeler = new labeler ("data. Label", Data. edges, FMT );
// Vis. Operators. Add (LAN );
VIS. Operators. Add (lan1 );
VIS. Operators. Add (OPT [idx]. OP );
VIS. setoperator ("nodes", new propertyencoder (OPT [idx]. nodes, "nodes "));
VIS. setoperator ("edges", new propertyencoder (OPT [idx]. edges, "edges "));
I have tried same like in node but it showing nothing in the output
Amit476712:26:12 UTC
Hehe thnks alot guy I got the answer
VaR mm: Int = 0;
VIS. Data. edges. Visit (function (ES: edgesprite): void {
Es. Data. Label = "edge" + mm ++;
});
VIS. Data. edges. Visit (function (ES: edgesprite): void {
Es. addeventlistener (event. Render, updateedgelabelposition );
});
VaR Lae: labeler = new labeler ("data. Label", Data. edges, FMT, edgesprite, labeler. Layer );
// Var lan1: labeler = new labeler ("data. Label", Data. edges, FMT );
VIS. Operators. Add (LAN );