diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickCalculator.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickCalculator.java
index 03ac423e30abee53fd5463cda05952acda8b01b5..2f7447739b636fa01d1ecf42f3286ee5aad12d5b 100644
--- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickCalculator.java
+++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickCalculator.java
@@ -102,7 +102,8 @@ public abstract class AxisTickCalculator {
 
     // System.out.println("******");
 
-    double firstPosition = minValue - (minValue % gridStep) - gridStep;
+    double absoluteMinValue = minValue <= maxValue ? minValue : maxValue; 
+    double firstPosition = absoluteMinValue - (absoluteMinValue % gridStep) - gridStep;
     return firstPosition;
   }
 
diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickNumericalCalculator.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickNumericalCalculator.java
index ba41617daf38fbe098051c0d9df3d89d4c617b62..8b451ef280322abb6336123cedf25957b73dc231 100644
--- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickNumericalCalculator.java
+++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickNumericalCalculator.java
@@ -72,7 +72,8 @@ public class AxisTickNumericalCalculator extends AxisTickCalculator {
     // System.out.println("cleanedFirstPosition: " + cleanedFirstPosition);
 
     // generate all tickLabels and tickLocations from the first to last position
-    for (BigDecimal value = cleanedFirstPosition; value.compareTo(BigDecimal.valueOf(maxValue + 2 * cleanedGridStep.doubleValue())) < 0; value = value.add(cleanedGridStep)) {
+    double absoluteMaxValue = minValue <= maxValue ? maxValue : minValue;
+    for (BigDecimal value = cleanedFirstPosition; value.compareTo(BigDecimal.valueOf(absoluteMaxValue + 2 * cleanedGridStep.doubleValue())) < 0; value = value.add(cleanedGridStep)) {
 
       // System.out.println(value);
       String tickLabel = numberFormatter.formatNumber(value, minValue, maxValue, axisDirection);