here is my problem:
i am using a python flask server that fetches json data from mongo db, and in there i specify what fields to import.This data is in json format and is fetched like that only. Is it possible to do transformations to these fields once passed through crossfilter in graphs.js? e.g. i have a status attribute which can take values "Pass","In Progress","on Hold" or "Fail". I basically want to do a metric which tells me percent failure. So ideally i have to do some calculations on the data. Please advise on this.
Sample data (in tabular form for clarity) looks like:
TrialLocation | Subject Status
Site A | In progress
Site A | Pass
Site B | In progress
Site A | In progress
Site B | On Hold
Site A | Screen Failure
In this case i should get a bar chart with site name on x axis and on the y axis, i should get the metric calculating the failure percentage. which in this case would be 25% for Site A and 0% for Site B.
So i created chart in the first place which gave me the count of subjects per site.
var siteName = ndx.dimension(function(d) { return d["TrialLocation"];});
var numSubjectsBySite = siteName.group();
var siteLevelChart = dc.barChart("#site-level-count", "subjectView");
and finally the chart:
siteLevelChart
.width(2000)
.height(200)
.transitionDuration(1000)
.dimension(siteName)
.group(numSubjectsBySite)
.ordering(function(d){return d.value;})
So i thought, i would calculate the count of rows with SubjectStatus = "Screen Failure" and divide that by the total number of rows which in this case would be "numSubjectsBySite" variable Then when i introduced this code:
var countScreenFailures = ndx.dimension(function(d){ return d["SubjectStatus"];});
countScreenFailures.filter("Off Study");
My bar chart only shows the rows where Subject Status ="ScreenFailure".
How can i calculate the screen failure rate and then use it ? Please help me out?
thank you so much. Anmol