1

i have a data set being returned as a cubism's metric such that it has values

0 = very bad
1 = okay
2 = bad

i can write a d3.scale such that

var ord = d3.scale.ordinal( [ 0, 1, 2, null ] ).range( [ -2, 2, -1, null ] );
for( var i=0; i<=2; i++ ) {
  console.log( i + ': ' + ord(i) );
}
console.log(  'null: ' + ord(null) );

and the terminal returns

0: -2
1: 2
2: -1
null: null 

looks good... however, when i try applying this scale to the cubism horizon chart, the chart renders fine, except the data represented doesn't show bad values as negative and good as positive:

  d3.select("body").selectAll(".horizon")
    .data( metrics )
  .enter().insert("div", ".bottom")
    .attr("class", "horizon")
  .call(
    context.horizon()
      .scale( d3.scale.ordinal([ 0, 1, 2, null ]).range([ -2, 2, -1, null ]) )
  );

what am i doing wrong?

yee379
  • 6,498
  • 10
  • 56
  • 101
  • What do you mean by it doesn't seem to work? Does the graph render incorrectly or not at all? Or is something else the issue? –  Jun 10 '13 at 06:28
  • the graph renders fine, but the scaling function doesn't appear to be applied (ie 'bad' data isn't negative). – yee379 Jun 10 '13 at 10:13

1 Answers1

0

check horizon.extent([extent])

https://github.com/square/cubism/wiki/Horizon