Closed fl-Ash closed 14 years ago
Which version of the JIT are you using? 1.1.3? Could you paste some code so I can see the issue in more detail please?
Thanks
yes 1.1.3
//example from the example itself var json = { id: "node02", name: "0.2", data: {}, children: [{ id: "node13", name: "1.3", data: {$color : '#aaa', $type : 'circle'}, children: [{ id: "node24", name: "2.4", data: {}, children: [{ id: "node35", name: "3.5", data: {}, children: [{ id: "node46", name: "4.6", data: {}, children: [] }] }, .........
the shape does change but not the color as specified in the data.
well, i forgot to mention, this not only applies to the spacetree but for hypertree as well...
That's not proper JSON. In JSON all keys must be strings. Try setting "$color", "$type", ... instead of $color, $type.
already tried that too before, just tried it again, same thing, no effect for the color, but for the rest it does work though, as a mentioned, for the circle shape it does turn into circle compared to the rest which havent been overridden. For the color it remains same as the default specified.
Do you have an onBeforePlotNode or something like that configured? If you don't, could you add an onBeforePlotNode controller and console.log(node.data) to see what's inside? That seems to be very weird if you know what I mean.... all examples use this kind of data.
i'm working directly on the example available for download 1.1.3, only added the color parameter to see, for the rest it is as default in your example scripts.
on what example?
well, i'm not too conversant with the script, simple things i can understand but not the ones you are asking to do, where should i add the console.log(node.data)?
example 1
Please could you post this as a question in the google group? That way you'll get a faster answer and you'll be able to paste the entire code (or append it). The Google Group's at http://groups.google.com/group/javascript-information-visualization-toolkit . Thanks and sorry for the inconvenience.
BTW the example1 in Spacetree adds an onBeforePlotNode handler that is triggered before plotting a node and the code from the example explicitly sets values to the $color property, overriding the ones you setted in the json data. Here:
//This method is called right before plotting
//a node. It's useful for changing an individual node
//style properties before plotting it.
//The data properties prefixed with a dollar
//sign will override the global node style properties.
onBeforePlotNode: function(node){
//add some color to the nodes in the path between the
//root node and the selected node.
if (node.selected) {
node.data.$color = "#ff7";
}
else {
delete node.data.$color;
var GUtil = Graph.Util;
//if the node belongs to the last plotted level
if(!GUtil.anySubnode(node, "exist")) {
//count children number
var count = 0;
GUtil.eachSubnode(node, function(n) { count++; });
//assign a node color based on
//how many children it has
node.data.$color = ['#aaa', '#baa', '#caa', '#daa', '#eaa', '#faa'][count];
}
}
},
yes exactly, but then how to make it go through? I this same example above by commenting the line 'delete node.data.$color;' the node accepts the overriden color, but then it doesnt return it back to how it was if the node is clicked... it takes the clicked color. I'll post that in the google group to see what happens.
The node color in spacetree does not change even when overiding data parameter with $color : '#FF0' for example. Node overridable has been set to true.
How can this be solved please?