Menu

#2 Zero value in auto-range

closed-fixed
General (896)
5
2002-02-25
2000-12-04
No

Keith Iosso posted the following report about the VerticalNumberAxis class:

"I am using the autoranging and it mostly seems to work pretty well. I don't care whether my graphs include 0 and choose the option accordingly. When the lowest value in the graph is 0, suddenly there is no space below the 0. Data on the 0 axis then disappears.
For my purposes it would be better if there was always space below the vertical axis, even if the lowest value=0. Looking at the code, I see a test for "!=0" on lines 194 and 195 that is causing the problem. I can understand that approach when the option AutoRangeIncludesZero is true, but not otherwise. Although it has a problem in that when data = 0, it doesn't show on the chart.

Is this really how you want the autoscaling to work? I can fix the code myself for my own purposes if you want it to continue that way, but won't if you agree that it would be better without and want to change it in the real releases. "

Discussion

  • David Gilbert

    David Gilbert - 2002-02-25

    Logged In: YES
    user_id=112975

    I'm going to handle this (in version 0.7.4) by adding a new
    flag autoRangeStickyZero, then calculating the auto-range as
    follows:

    if \(this.autoRangeIncludesZero\) \{
    

    if (this.autoRangeStickyZero) {
    if (upper<=0.0) {
    upper = Math.max(0.0, Math.min(0.0,
    upper+upperMargin*range));
    }
    else {
    upper = upper+upperMargin*range;
    }
    if (lower>=0.0) {
    lower = Math.min(0.0, Math.max(0.0,
    lower-lowerMargin*range));
    }
    else {
    lower = lower-lowerMargin*range;
    }
    }
    else {
    upper = Math.max(0.0, upper+upperMargin*range);
    lower = Math.min(0.0, lower-lowerMargin*range);
    }
    }

    else \{
    

    if (this.autoRangeStickyZero) {
    if (upper<=0.0) {
    upper = Math.min(0.0,
    upper+upperMargin*range);
    }
    else {
    upper = upper+upperMargin*range;
    }
    if (lower>=0.0) {
    lower = Math.max(0.0,
    lower-lowerMargin*range);
    }
    else {
    lower = lower-lowerMargin*range;
    }
    }
    else {
    upper = upper+upperMargin*range;
    lower = lower-lowerMargin*range;
    }
    }

     
  • David Gilbert

    David Gilbert - 2002-02-25
    • status: open --> open-fixed
     
  • David Gilbert

    David Gilbert - 2002-02-25
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB