here is a question i sent to Ely Greenfield (a master of charts) and his
answers (this is interesting stuff, worth the reading):

ME:
I have a column chart with 2 columnSeries.
It's vertical axis is LinearAxis.
My mission is to make the columns be 1/5 height of the overall chart
height (but columns will still need to have their original values)
My idea was to make the maximum value of the vertical axis to be times 5
of the highest value of the 2 series = find the highest value in series1
and series2, take the higher of them and multiply by 5.
The obvious was the LinearAxis labelFunction – inside it find the
max value multiply it by 5 and assign to the LinearAxis maximum.
But this isn't working because of timing of creation - my 1 cent: as
I understand it the axis must know the maximum value BEFORE going to the
labelFunction.
I wasn't able to do this with the parseFunction as well.
Any ideas?
Again: My mission is to make the columns be 1/5 height of the overall
chart height.

ELY:
When you don't specify an explicit min/max on an axis, the axis instead
asks the elements in the chart for the min/max of the data they
represent. The Axis takes all of these values, computes the total
min/max, and then does a few other things to make sure labels look nice,
etc. before it decides what its min/max is.
The important point is that the axis doesn't actually look at the data.
THe Axis doesn't know anything about the individual series/elements in
the chart, so it can't compute the min/max on its own. Instead, it asks
the element to do whatever computations it needs, and reports the
min/max values back.
So you have two ways of solving your problem:
1) when your data arrives (or is updated), iterate over it yourself, and
compute the min/max values of the data.  explicitly assign the maximum
of your vertical axis to be five times the max value you computed from
your data.
2) subclass ColumnSeries, and have it report back its maximum as 5 times
its actual maximum. The Series has a method called describeData().  This
method is the one the axis calls to ask the series to describe its
min/max values. You could write a subclass that calls the super()
version, then takes whatever maximum value it is reporting and
multiplies it.   Keep in mind that describeData can be called multiple
times, once for each axis in the chart. So  make sure its being called
for the verticalAxis before you go meddling with the values.

ME:
1) i have auto refresh every X seconds so that will cause the axis to
change its maximum and though changing the height of the columns on
screen - this can cause some user confusion about the values.

2) i will try this. by subclass you mean with an item renderer? and i do
have 2 vertical axes - how do i decide to which the axis the method
returns?

ELY:
No, I don't mean an itemRenderer, but actually sub-classing the series
type:

public class MyColumnSeries extends ColumnSeries {
   ...
   override public function updateDisplayList(....)....
}

The axes are paired with the appropriate series...so the primary
verticalAxis calls describeData on the normal series, while the
secondaryVerticalAxis calls describeData on the secondarySeries.

Reply via email to