1

trying to figure out dc.js scatter plot and getting hung up on structuring the inital data for it I think

var data = [
{ category: 'A', processVersion: 6},
{ category: 'A', processVersion: 6},
{ category: 'A', processVersion: 8},
{ category: 'A', processVersion: 7},
{ category: 'A', processVersion: 6},
{ category: 'A', processVersion: 7},
{ category: 'A', processVersion: 6},
{ category: 'A', processVersion: 7},
{ category: 'B', processVersion: 6},
{ category: 'B', processVersion: 8},
{ category: 'B', processVersion: 8},
{ category: 'B', processVersion: 7},
{ category: 'B', processVersion: 8}
];

var cf = crossfilter(data);

var dim = cf.dimension(function(d){ return [d.category, d.processVersion]; });
var grp = dim.group();
var scatterChart = dc.scatterPlot("#scatter-chart");

scatterChart
    .width(500)
  .height(300)
  .margins({
    top: 10,
    right: 20, 
    bottom: 30,
    left: 40
  })
  .dimension(dim)
  .group(grp)
  .x(d3.scale.linear().domain[0, 10]) // for each process version
  .y(d3.scale.linear().domain[0, 10]) // want count of records where categorys are like
  .renderHorizontalGridLines(true)
  .renderVerticalGridLines(true)
  .symbolSize(30)
  .highlightedSize(8)

  scatterchart.render();

What I want is to have the y as a count of each record that shares a given category per a given service version(x axis). So I have tried getting a count function into the initial dimesion array, or processing the data before hand which seems unnecessary because I am guessing there is a proper way to do that in crossfilter? the group result should have a key = [5, 3, "A"] I think where [0] is the processVersion, [1] is the count, etc.

Appreciate the assistance.

Gordon
  • 19,811
  • 4
  • 36
  • 74
Justin
  • 4,461
  • 22
  • 87
  • 152

0 Answers0