views:

71

answers:

1

I've been using the Dojo charting to create a Columns chart. I'm very impressed by it so far, but have decided I need a logarithmic y axis. Doesn't look like this is supported so far, though I've seen a blog entry implying it was planned at some point.

Does anyone know it it is possible at the moment? If not, then I'm happy to try writing the enhancement myself, so if anyone has some tips on where to start, they would be gratefully received. I suspect it's case of implementing a new Scale type, though I haven't spent much time digging through the source yet.

Thanks, Martin.

+1  A: 

dojox.gfx still doesn't have the logarithmic axis yet.

Update: One way to do it is to remap data along the logarithmic axis, and use the linear axis with custom labels. For example:

// we will transform our 'x' to a decadic logarithmic scale

var LOG10 = Math.log(10);

var data = [...]; // my data of {x, y}
var transformedData = dojo.map(data, function(value){
  return {
    x: Math.log(value.x) / LOG10,
    y: value.y // 'y' is unchanged
  };
});

// ...

// add the axis and the data
chart.addAxis("x", {
  natural: true,
  includeZero: true,
  // our logarithmic labels
  labels: [
    {value: 0, text: "1"},
    {value: 1, text: "10"},
    {value: 2, text: "100"},
    {value: 3, text: "1000"},
    {value: 4, text: "10^4"},
    {value: 5, text: "10^5"},
    {value: 6, text: "10^6"},
    {value: 7, text: "10^7"},
    {value: 8, text: "10^8"},
    {value: 9, text: "10^9"}
  ]
});
chart.addSeries("my data", transformedData);

// ...

Something like that will do the trick. The other option is to use labeling function to generate "logarithmic" labels automatically.

Eugene Lazutkin