score:0

I think you can't set an ordinal domain for any line or scatter chart in nvd3. These lines are in the models.scatter definition:

  if ( isNaN(x.domain()[0])) {
      x.domain([-1,1]);
  }

  if ( isNaN(y.domain()[0])) {
      y.domain([-1,1]);
  }

Obviously this will disallow any ordinal scales for the x or y scales in this type of chart (which underlies the line chart and most of the other non-bar charts it seems).

score:2

Try setting rangeBounds([0, chartWidth]) for the scale. i.e

d3.scale.ordinal().domain(["1","5", "30", "600"]).rangeBounds([0, width]);

Correction : I thought your scales needed to be changed, but you actually want the line plotted to be have the values plotted equidistant. To do this you may want to modify the dataset you are sending to the lineGraph to something like.

var ds1 =  [ {
key: 'VAR-1',
color: '#FF7F0E',
values: [
{ "x" : "4", "y" : 0.07706} 
, { "x" : "3", "y" : 0.00553} 
, { "x" : "2", "y" : 0.00919} 
, { "x" : "1", "y" : 0.00969} 
]}
];

That way while the values shown in the x-axis will be ordinal (i.e 1, 5, 30, 600), the values plotted for the line will be on a linear scale.


Related Query

More Query from same tag