Skip to content

Range or Domain lines and labels not showing up with inverted min/max boundaries with INCREMENT_BY_VAL #125

@draekko

Description

@draekko

I've been trying to use the library to display near realtime graph data in an app that takes in environmental sensor data and have it display it in various time increments with time zero being right most and the increments in the past to the left. Something like this

Image

For example when i set the min domain boundary to be bigger than the the max value. So for say 10 minutes in the past left most and 0 to the left i get nothing showing up. I set up as such for the above:

graphXyPlot.setDomainStep(StepMode.INCREMENT_BY_VAL, 1.0);
graphXyPlot.setDomainBoundaries(10, 0, BoundaryMode.FIXED);

Not sure if its a bug or something i've missed that was obvious but when i dug into the code in XYGraphWidgets when i test for inverted domains and switch the min and max value for the for loop in drawGrid everything shows up right for the inverted range as selected by the value increment.

`

    // Draw Domain Lines:

    float domainLeft = gridRect.left;
    float domainRight = gridRect.right;
    float domainFudge = FUDGE;
    if (plot.getDomainStepMode() == INCREMENT_BY_VAL &&
            plot.getBounds().getMinX().floatValue() > plot.getBounds().getMaxX().floatValue()) {
        domainLeft = gridRect.right;
        domainRight = gridRect.left;
        domainFudge = FUDGE * -1;
    }

    final double domainStepPix = domainStep.getStepPix();
    final double iMin = (domainLeft - domainOriginPix - domainFudge) / domainStepPix;
    final double iMax = (domainRight - domainOriginPix + domainFudge) / domainStepPix;

`

Same for the range code

`

    float rangeBottom = gridRect.bottom;
    float rangeTop = gridRect.top;
    float rangeFudge = FUDGE;
    if (plot.getRangeStepMode() == INCREMENT_BY_VAL &&
            plot.getBounds().getMinY().floatValue() > plot.getBounds().getMaxY().floatValue()) {
        rangeBottom = gridRect.top;
        rangeTop = gridRect.bottom;
        rangeFudge = FUDGE * -1;
    }

    final double rangeStepPix = rangeStep.getStepPix();
    final double kMin = (rangeTop - rangeOriginPix - rangeFudge) / rangeStepPix;
    final double kMax = (rangeBottom - rangeOriginPix + rangeFudge) / rangeStepPix;

`

Is there something obvious i'm missing to make that work out or does it need fixing in the lib?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions