Thursday 15 July 2010

dc.js - Crossfilter dimension and group to filter out data below certain threshold -


I have the following data, and I'm trying to plot the chart twice:

  • Any type of unit is less than one version of version 2.0

where both charts have the type of X-axis unit.

The problem is that the chart is correct:

When I select the bar on the second chart, then I expect to see the unit only with the versions; 2.0 in the data table and the first chart i.e. a record in this case. But what I find is all the units of that specific type (which I hope to click once in the first chart) i.e. 3 records

see

I think that With this problem, how do I group for the version chart:

  var versionGroup = type1Dim.group (). Vulnerable (DC) .pluck ('version_count'));  

Data:

  var data = [{"version": 1.0, "serial": '1A', "type": "a" } "Serial": "2A", "type": "A"}, {"version": 2.0, "serial": '2AA', "type": "a"}, {"version": 2.0 "Serial": '2b', 'type': "b"}, {"version": 2.5, "serial": '25b ',' type ': "b"}, {"version": 1.0 , "Serial": '1b', 'type': "b"}]; As mentioned in the above comments, we repeat it and give clarification about something.  

Things

You can use composite keys and then filter the group using the "fake group", as you did in your updated Basic so that this effect can be obtained .

The thing to understand about crossfilter keys is that it always continues to forcibly force them, and this is probably the most common and most stable way to do this. Values. So if you want a composite key, it's best to create it as a string just because if you pass it as an array, then the crossfilter will force it in the string and give you the , - that can be done to work, and I know that dc.js scatterplot does this, but I do not recommend it. It is less efficient than making the stars (because you do this instead of being in the crossfilter internally once), and because you have too much control.

There is a long discussion with Jason Davis here

Firstly the composite key:

  var type1Dim = ndx.  

Dimensions (function (d) {if (d.version> 2.0) returns '1.' + d.type; else return '2.' + d.type;});

(The most random separator will be '\ x0' but '.' works fine here.)

< P> Next, a plain key accelerator:

  .keyAccessor (function (d) {return d.key;})  

and we will give it to DC . JS also estimates the order scale domain:

  .x (d3.scale.ordinal ());  

And it works, but now the tick's ugly composite key is. To fix it:

  versionChart.xAxis () .tickformat (function (d) {return dslipat ('.') [1];}); My fork:  

Edit: I forgot to update the duplicate group generator, which does not matter here, but in general, this key should also be divided: Remove

  function Version2 (source_group) {return {all: function} {return source_group.all (). Filter (function (d) {return d.key.split ('.') [0]! = 2;}); }}; }  

No comments:

Post a Comment