jasondavies/d3-parsets

Error: Invalid value for <rect> attribute width="9.399999999999999e-132"

falconair opened this issue · 1 comments

As far as I can tell, I am building the chart correctly and the data is formatted correctly. However, when I try to render my chart, I get the error "Error: Invalid value for attribute width="9.399999999999999e-132" "

Could this be because the "frequency" values are too large?

My code is as follows:

  //parallel sets chart
  var parsetchart = d3.parsets()
    .dimensions(['price performance', 'order size', 'order type'])
    .tension(.5)
    .value(function(row){ return row.freq;});

  var parsetvis = d3.select("#vis").append("svg")
  .attr("width", parsetchart.width())
  .attr("height", parsetchart.height());

  var test2 = ... (see below for data)

  parsetvis.datum(test2).call(parsetchart);

//test data (this is a legitimate dataset, values are measured aggregates of stock shares traded by the whole exchange, so the values may be very large indeed...much larger than what I have here).

var test2 = [
{"order type":"market","order size":"100-499","price performance":"price improved","freq":"1869390"},
{"order type":"market","order size":"500-1,999","price performance":"price improved","freq":"3246105"},
{"order type":"market","order size":"2,000-4,999","price performance":"price improved","freq":"2175928"},
{"order type":"market","order size":"5,000 or more","price performance":"price improved","freq":"1364679"},
{"order type":"marketable limit","order size":"100-499","price performance":"price improved","freq":"740954"},
{"order type":"marketable limit","order size":"500-1,999","price performance":"price improved","freq":"1636350"},
{"order type":"marketable limit","order size":"2,000-4,999","price performance":"price improved","freq":"1039836"},
{"order type":"marketable limit","order size":"5,000 or more","price performance":"price improved","freq":"990820"},
{"order type":"inside-the-quote limit","order size":"100-499","price performance":"price improved","freq":"0"},
{"order type":"inside-the-quote limit","order size":"500-1,999","price performance":"price improved","freq":"0"},
{"order type":"inside-the-quote limit","order size":"2,000-4,999","price performance":"price improved","freq":"0"},
{"order type":"inside-the-quote limit","order size":"5,000 or more","price performance":"price improved","freq":"0"},
{"order type":"at-the-quote limit","order size":"100-499","price performance":"price improved","freq":"0"},
{"order type":"at-the-quote limit","order size":"500-1,999","price performance":"price improved","freq":"0"},
{"order type":"at-the-quote limit","order size":"2,000-4,999","price performance":"price improved","freq":"0"},
{"order type":"at-the-quote limit","order size":"5,000 or more","price performance":"price improved","freq":"0"},
{"order type":"near-the-quote limit","order size":"100-499","price performance":"price improved","freq":"0"},
{"order type":"near-the-quote limit","order size":"500-1,999","price performance":"price improved","freq":"0"},
{"order type":"near-the-quote limit","order size":"2,000-4,999","price performance":"price improved","freq":"0"},
{"order type":"near-the-quote limit","order size":"5,000 or more","price performance":"price improved","freq":"0"},
{"order type":"market","order size":"100-499","price performance":"at quote","freq":"178528"},
{"order type":"market","order size":"500-1,999","price performance":"at quote","freq":"222823"},
{"order type":"market","order size":"2,000-4,999","price performance":"at quote","freq":"175089"},
{"order type":"market","order size":"5,000 or more","price performance":"at quote","freq":"122417"},
{"order type":"marketable limit","order size":"100-499","price performance":"at quote","freq":"1521296"},
{"order type":"marketable limit","order size":"500-1,999","price performance":"at quote","freq":"2238074"},
{"order type":"marketable limit","order size":"2,000-4,999","price performance":"at quote","freq":"1328908"},
{"order type":"marketable limit","order size":"5,000 or more","price performance":"at quote","freq":"870033"},
{"order type":"inside-the-quote limit","order size":"100-499","price performance":"at quote","freq":"0"},
{"order type":"inside-the-quote limit","order size":"500-1,999","price performance":"at quote","freq":"0"},
{"order type":"inside-the-quote limit","order size":"2,000-4,999","price performance":"at quote","freq":"0"},
{"order type":"inside-the-quote limit","order size":"5,000 or more","price performance":"at quote","freq":"0"},
{"order type":"at-the-quote limit","order size":"100-499","price performance":"at quote","freq":"0"},
{"order type":"at-the-quote limit","order size":"500-1,999","price performance":"at quote","freq":"0"},
{"order type":"at-the-quote limit","order size":"2,000-4,999","price performance":"at quote","freq":"0"},
{"order type":"at-the-quote limit","order size":"5,000 or more","price performance":"at quote","freq":"0"},
{"order type":"near-the-quote limit","order size":"100-499","price performance":"at quote","freq":"0"},
{"order type":"near-the-quote limit","order size":"500-1,999","price performance":"at quote","freq":"0"},
{"order type":"near-the-quote limit","order size":"2,000-4,999","price performance":"at quote","freq":"0"},
{"order type":"near-the-quote limit","order size":"5,000 or more","price performance":"at quote","freq":"0"}
];

You were returning strings for values, which is what caused it to break. You could fix this by coercing values to numbers in the value accessor, e.g. function(d) { return +d.freq; }. However, this is no longer necessary as of version 1.2.4, which auto-coerces all values to numbers.