views:

16

answers:

1

I'm trying to layout 2 linked charts, one above the other, similar to what you might see on the Google Finance page.

I can render both charts just fine, but getting the plotAreas to line up exactly is a bit of a mystery. The chart.plotArea.width of each chart seems to depend on the width of my Y axis labels. Thus the 2 charts are not the same width and have different values for chart.getCoord().l.

Right now, I'm using an offset which is manually calculated, but there must be a better way.

 this.chart.render();  // top chart, getCoords().w=800

 // manually set margins for lower chart to match
 this.chartVol.margins.l = this.chart.offsets.l - 59 + 10;  
 this.chartVol.margins.r = this.chart.offsets.r - 31 + 10;

 // render bottom chart
 this.chartVol.render();  // bottom chart same width, getCoords().w=800
A: 

There are two simple ways to do it:

  1. Use maxLabelSize and labelFunc. The former is the maximal label's size in pixels. The latter is a function, which takes a number, and returns a corresponding string label.
  2. Use labels, which is an array of {value, text} objects, and include one long dummy string of desired size at the end with some bogus value.

I don't recall how to do it without custom labels, so if you feel like it is really needed, please submit an enhancement ticket.

Eugene Lazutkin
I tried to use the identical dummy string for labels, but the plotAreas are still off by a few pixels.Q: where is the doc for maxLabelSize? what class does it belong to - I tried chart.addAxis('y',{maxLabelSize:5}) but it didn't seem to do anything.
michael
A: in the source code of dojox/charting/axis2d/Default.js at the moment. Regarding your unsuccessful attempt: {maxLabelSize: 5) is 5 pixels. I doubt that this was the idea. And you have to use it together with labelFunc. See the body of my answer above.
Eugene Lazutkin