0
votes

I am using dc.js to make a simple dashboard. My data is composed of five columns, date, node,type, variable and value. It combines resource monitoring data and events. They are defined in the variable column, under categories cpu, hd, int, mem and event. The type column is NA for resources and a certain string detailing the type of event. And the value column corresponds to the number of that certain resource in a certain moment or 1 if that row corresponds to an event.

Having said that, I want to plot a scatter plot with the date on the x axis and the presence or not of an event in the y axis, but I've not yet managed to do it. And I fear it has to do with an incorrect understanding of crossfilter. I'm fairly confident on how to code dimension, I have this:

var eventDim = ndx2.dimension(function(d){
   if (d.variable=="event"){
   return [d.Date.getTime(),d.type];
   }
});

But I can't grasp on how to create the group to do what I want and what valueAccessor I have to pass as a parameter to the scatter plot to plot what I want.

Any help would be appreciated.

Thanks in advance.

1

1 Answers

0
votes

The function you specify for the dimension should return just the key you want to use in that dimension. Multi-keys / array keys don't tend to work very well, so it's probably better just to use the date rather than wrapping it in an array, unless you really need the type to be part of the key.

I also wouldn't try to filter the data there. In the cases where the row is not an event, you'll return undefined, which tends not to sort very well and doesn't skip the rows.

Instead, I suggest perhaps creating the group with reduceSum, passing a function that returns 0 for non-events and 1 for events. This way you'll get a count of the number of events for each date.

This is only a start. Hope it helps!