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.
Related
I'd like to visualize how one variable in my dataset correlates with 13 other variables. Seaborn's PairGrid allows me to do this fairly easily, but the resulting figure ends up being a single row of graphs with 13 columns. For FacetGrid, there is a wrap_cols parameter that can be passed to make this type of plot look more attractive. Any suggestions for how to implement this column wrap with PairGrid?
The code I'm currently using to generate the 1x13 plot:
g = sns.PairGrid(dataframe, hue=classes, y_vars=var_of_interest, x_vars = list_of_13_covariates)
g.map(plt.scatter)
The PairGrid object does not have a col_wrap parameter.
See the docs here:
http://seaborn.pydata.org/generated/seaborn.PairGrid.html#seaborn.PairGrid
i am new in d3.js and i am trying to make a pie chart but in the structure i got two append one is append(“svg : g”) and another one is append(“svg: svg”),i am bit confused.So what is the difference between in this two append method?
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!
I am still at the learning stage of crossfilter and D3.
I have two questions about the example provided on Crossfilter
For the example they provided
1 . line 285:
var list = d3.selectAll(".list").data([flightList]);
In D3 wiki, selection.data([values[, key]]) The specified values is an array of data values, such as an array of numbers or objects, or a function that returns an array of values.
But flightList does not returns an array of values, and the augment for flightList is div.
2 . line 499:
dimension.filterRange(extent);
Why is there no function called for updating bar graphs by barPath()? How could the bar graph updating itself with data changed? So if the data changed, the graph will be updated at the same time?
1.
'list' is a selection that has a one-element array as it's data, and the single element is the function flightList.
On line 301, we see 'list.each(render);', meaning that the render function is called for each element in the 'list' selection, passing in its datum (flightList) as the first argument to the render function.
Therefore line 295 in the 'render(method)' function, which is 'd3.select(this).call(method);' can be more or less rewritten in the context of the list as 'd3.select(".list").call(flightList);', which calls the flightList function passing in the '.list' div as the argument. The flightList function then proceeds to build up the list of flights on top of that div.
At least, that's my reading. IMO, that code is very elegant and general, but extremely hard to follow as an example.
2.
Line 281 sets up an event listener on all the charts that re-renders everything (the 'renderAll' function) whenever a brush moves or finishes moving.
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")