how to establish relation between any two nodes of d3 tree layout - d3.js

I have a D3 tree layout.There will be relation between any two nodes,based on this relation i want to show some connection between 2 nodes.Till now i was using circles.on onmouse circles of the 2 nodes will be in some specified color.circles were not covering images exaclty.so i applied transform but it disturbing some other functionalities.
my sole purpose is to show some connection between any two nodes using circles or something else.i tried applying circles using CSS3 but it didnt work
is there any way to achieve my requirement

If I am understanding you, there are different ways to achieve this, and this is only one.
Consider this:
function highlight() {
var selectedClass = d3.select(this).attr("class");
d3.selectAll("circle")
.style("fill",function(d) {
if ( selectedClass == d3.select(this).attr("class"))
return "magenta";
});
}
Assuming you have established the relationship between any given number of nodes (two or more) by assigning them the same class (perhaps a big assumption), then code like the one above can display such relationship. If you click on one of the nodes (this function is called by the node .on("click"...), the others will also display the desired change, illustrated here by a change in color. Does this help?

Related

Selection script for maya

I'm noob in script but good in animation, I need some help to create a script selection.
I found an exemple :
import maya.cmds as cmds
# Get selected objects
curSel = maya.cmds.ls(sl=True)
# Or, you can also specify a type in the listRelatives command
nurbsNodes = maya.cmds.listRelatives(curSel, allDescendents=True, noIntermediate=True, fullPath=True, type="nurbsCurve", path=True)
cmds.select(nurbsNodes)
But It doesn't select all the character's controlers...
I would like If I select a character controler curve or locator and I run the script, the result is all controls who can be keyed should be selected. Without the referenced character name.
Thanks a lot for the one who can help
Currently the listRelatives command is being used to list all child nodes under the currently selected transforms, whose type is a NURBS Curve, e.g. type="nurbsCurve". Typically all nodes in Maya inherit from some other node type (It's worth checking the nodes in Maya help -> technical documents ->nodes). Luckily locator nodes and curves both inherit from 'geometryShape', so you should be able to replace "nurbsCurve" with "geometryShape", and that will probably get you most of the way there. You may need to ignore certain returned nodes though - i.e. polygonal meshes you are using for rendering.

rowscap and filter applied in wrong order in DC.JS rowChart

Still using DC.JS to get some analysis tools written for our tool performance. Thanks so much for having this library available.
I am trying to show which recipe setup times are the worst for a given set of data. Everything works great as long as you show the whole group. When you only display the specified topN using .rowscap on the rowChart the following happens:
The chart will show the right number of bars and they are even sorted properly but the chart has picked the topN unfiltered bars first and then ordered them. I want it to pick the topN from the ordered list, not the other way around. See jsfiddle for demo. (http://jsfiddle.net/za8ksj45/24/)
in the fiddle, the longest setup time belongs to recipeD.
But if you have more than two recipes selected before recipeD
it is dropped of the right (top2) chart.
line 099-110: reductio definition
line 120-140: removal of empty bins (works okay)
(This is very similar to a problem Gordon helped resolved earlier (dc.js rowChart topN without zeros) and I reused the code from that solution. Something went 'wrong' when I combined it with the reductio.js library.)
I think I am not returning the value portion of the reductio group somewhere but have been unable to figure it out. Any help would be appreciated.
The issue is that at the time you .slice(0,n) the group in your function to remove empty bins, the group is not ordered, so you effectively get a random 2 groups, not the top 2 groups. This is actually clear from the unfiltered view, as the "top2" view shows the 2nd and 3rd group from the "all" view, not the actual top 2 (at least for me).
The previous example worked because Crossfilter's standard groups are ordered by default, but in the case of a complex group like the one you are generating with Reductio, what should it order by? There's no way it can know, so Reductio doesn't mess with the ordering at all, which I suppose means it is ordering by the value property, which is an object.
You need to add one line to order your FactsByRecipe group by average and I think it should fix your problem:
FactsByRecipe.order(function(d) { return d.avg; });
Note that there can only be one ordering on a Crossfilter group, so if you want to show "top X" for more than one property of that group you'll need to create another wrapper (like the remove empty bins wrapper) but have the "top" function re-sort the group by the ordering you want.
Good luck!

Using dc.js without crossfilter

They have been various discussions on how to use dc.js simply as graph library (eg. to draw a piechart, a barchart...) without needing crossfilter, for instance if you simply want to draw a single pie when the data is already a (label, value).
I didn't find any example of how to do that. Is this possible on the 2.0 branch? Will it work for every chart?
So the "normal" way is to define data(), but as this function is already defined internally from some charts, it doesn't work that well:
in http://github.com/dc-js/dc.js/issues/584
Details: the following charts use .data() internally:
Stack Mixin (thus Line and Bar) - filters and then does stack d3.layout.stack on the data Cap Mixin (thus Pie and Row) - optionally limits the number of bins, sorts the groups using the ordering, and optionally creates the "others" bin
Number Chart - looks to see if the group has a value() function (e.g. it's a group-all). Otherwise, takes the top value. Runs the valueAccessor on the result (!!!)
Box Plot - adds a mapping function to the data. Filters out values (which are themselves arrays) that are of length 0.

Accessing data automatically assigned by force layout

I am creating a network of nodes and edges using force layout. My application has some dynamic nodes (which can be any number determined by backend code). I am allowing the force layout to assign the x and y for these dynamic nodes by itself which it does on calling force.start() function.
Now, there are a different set of nodes which are moving over the edges(eg. cars moving on roads) connecting the static and dynamic nodes. For this animation, I need to get the x and y values from the force.nodes() which it has assigned to the dynamic nodes. I tried the normal dot operator to get the values but it fails to return the actual value.
Below is one of the value of node
[09:13:07.505] ({name:"D_Exit_0", dynamic:true, act_cap:-1, danger:0, index:0, weight:1, x:3014.087389427884, y:513.2901517247882, px:3013.9965777253265, py:513.0782974731648})
The x and y values here are assigned by the force layout.
When I tried node.x, it is returning me a value I had accessed just before accessing this node. However, when I directly print the node using console.log(node) it gives the above output.
Kindly let me know how I can get the dynamic data assigned by the force layout itself i.e. value x: 3014.08.. in above case?
force.nodes() should return an array of all the nodes. To get the x value from one the first one, use force.nodes()[0].x (documentation).
To animate something along the connection between the nodes, you might better off working with force.links(), which returns all the links between nodes. If you're working off of one of the examples, there should be a line of code similar to var link = svg.selectAll(".link"); if there is you could, for example, slowly turn all the links green with:
> link.transition().duration(5000).style("stroke", "green")
If you have any more questions, post the code you have so far on jsfiddle or bl.ocks.org.

R: Which heatmap/image to get row-sorted plot without any dendrogram?

Which package is best for a heatmap/image with sorting on rows only, but don't show any dendrogram or other visual clutter (just a 2D colored grid with automatic named labels on both axes). I don't need fancy clustering beyond basic numeric sorting. The data is a 39x10 table of numerics in the range (0,0.21) which I want to visualize.
I searched SO (see this) and the R sites, and tried a few out. Check out R Graphical Manual to see an excellent searchable list of screenshots and corresponding packages.
The range of packages is confusing - which one is the preferred heatmap (like ggplot2 is for most other plotting)? Here is what I found out so far:
base::image - bad, no name labels on axes, no sorting/clustering
base::heatmap - options are far less intelligible than the following:
pheatmap::pheatmap - fantastic but can't seem to turn off the
dendrograms? (any hacks?)
ggplot2 people use geom_tile, as Andrie points out
gplots::heatmap.2 , ref - seems
to be favored by biotech people, but way overkill for my purposes. (no
relation to ggplot* or Prof Wickham)
plotrix::color2D.matplot also exists
base::heatmap is annoying, even with args heatmap(..., Colv=NA, keep.dendro=FALSE) it still plots the unwanted dendrogram on rows.
For now I'm going with pheatmap(..., cluster_cols=FALSE, cluster_rows=FALSE) and manually presorting my table, like this guy: Order of rows in heatmap?
Addendum: to display the value inside each cell, see: display a matrix, including the values, as a heatmap . I didn't need that but it's nice-to-have.
With pheatmap you can use options treeheight_row and treeheight_col and set these to 0.
just another option you have not mentioned...package bipartite as it is as simple as you say
library(bipartite)
mat<-matrix(c(1,2,3,1,2,3,1,2,3),byrow=TRUE,nrow=3)
rownames(mat)<-c("a","b","c")
colnames(mat)<-c("a","b","c")
visweb(mat,type="nested")

Resources