diff --git a/jOOQ/src/main/java/org/jooq/ChartFormat.java b/jOOQ/src/main/java/org/jooq/ChartFormat.java
index 9e7404b906..5ec4d09d78 100644
--- a/jOOQ/src/main/java/org/jooq/ChartFormat.java
+++ b/jOOQ/src/main/java/org/jooq/ChartFormat.java
@@ -66,6 +66,7 @@ public final class ChartFormat {
final boolean showVerticalLegend;
final String newline;
final DecimalFormat numericFormat;
+ final DecimalFormat percentFormat;
public ChartFormat() {
this(
@@ -81,7 +82,8 @@ public final class ChartFormat {
true,
true,
"\n",
- new DecimalFormat("###,###.00")
+ new DecimalFormat("###,###.00"),
+ new DecimalFormat("##0.00'%'")
);
}
@@ -98,7 +100,8 @@ public final class ChartFormat {
boolean showHorizontalLegend,
boolean showVerticalLegend,
String newline,
- DecimalFormat numericFormat
+ DecimalFormat numericFormat,
+ DecimalFormat percentFormat
) {
this.output = output;
this.type = type;
@@ -113,6 +116,7 @@ public final class ChartFormat {
this.showVerticalLegend = showVerticalLegend;
this.newline = newline;
this.numericFormat = numericFormat;
+ this.percentFormat = percentFormat;
}
/**
@@ -133,7 +137,8 @@ public final class ChartFormat {
showHorizontalLegend,
showVerticalLegend,
newline,
- numericFormat
+ numericFormat,
+ percentFormat
);
}
@@ -163,7 +168,8 @@ public final class ChartFormat {
showHorizontalLegend,
showVerticalLegend,
newline,
- numericFormat
+ numericFormat,
+ percentFormat
);
}
@@ -190,7 +196,8 @@ public final class ChartFormat {
showHorizontalLegend,
showVerticalLegend,
newline,
- numericFormat
+ numericFormat,
+ percentFormat
);
}
@@ -220,7 +227,8 @@ public final class ChartFormat {
showHorizontalLegend,
showVerticalLegend,
newline,
- numericFormat
+ numericFormat,
+ percentFormat
);
}
@@ -272,7 +280,8 @@ public final class ChartFormat {
showHorizontalLegend,
showVerticalLegend,
newline,
- numericFormat
+ numericFormat,
+ percentFormat
);
}
@@ -301,7 +310,8 @@ public final class ChartFormat {
showHorizontalLegend,
showVerticalLegend,
newline,
- numericFormat
+ numericFormat,
+ percentFormat
);
}
@@ -330,7 +340,8 @@ public final class ChartFormat {
showHorizontalLegend,
showVerticalLegend,
newline,
- numericFormat
+ numericFormat,
+ percentFormat
);
}
@@ -360,7 +371,8 @@ public final class ChartFormat {
showHorizontalLegend,
showVerticalLegend,
newline,
- numericFormat
+ numericFormat,
+ percentFormat
);
}
@@ -390,7 +402,8 @@ public final class ChartFormat {
newShowHorizontalLegend,
newShowVerticalLegend,
newline,
- numericFormat
+ numericFormat,
+ percentFormat
);
}
@@ -442,7 +455,8 @@ public final class ChartFormat {
showHorizontalLegend,
showVerticalLegend,
newNewline,
- numericFormat
+ numericFormat,
+ percentFormat
);
}
@@ -472,7 +486,8 @@ public final class ChartFormat {
showHorizontalLegend,
showVerticalLegend,
newline,
- newNumericFormat
+ newNumericFormat,
+ percentFormat
);
}
@@ -484,6 +499,37 @@ public final class ChartFormat {
return numericFormat;
}
+ /**
+ * The new numeric format for percentages, defaulting to ###.00'%'.
+ */
+ @NotNull
+ public ChartFormat percentFormat(DecimalFormat newPercentFormat) {
+ return new ChartFormat(
+ output,
+ type,
+ display,
+ width,
+ height,
+ category,
+ categoryAsText,
+ values,
+ shades,
+ showHorizontalLegend,
+ showVerticalLegend,
+ newline,
+ numericFormat,
+ newPercentFormat
+ );
+ }
+
+ /**
+ * The numeric format for percentages.
+ */
+ @NotNull
+ public DecimalFormat percentFormat() {
+ return percentFormat;
+ }
+
/**
* The chart output format.
*/
diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractResult.java b/jOOQ/src/main/java/org/jooq/impl/AbstractResult.java
index 4cf79d398b..e4c975a388 100644
--- a/jOOQ/src/main/java/org/jooq/impl/AbstractResult.java
+++ b/jOOQ/src/main/java/org/jooq/impl/AbstractResult.java
@@ -917,10 +917,12 @@ abstract class AbstractResult extends AbstractFormattable impl
}
int verticalLegendWidth = format.showVerticalLegend()
- ? Math.max(
- format.numericFormat().format(axisMin).length(),
- format.numericFormat().format(axisMax).length()
- )
+ ? (format.display() == Display.HUNDRED_PERCENT_STACKED)
+ ? fp.width(format.percentFormat().format(100.0))
+ : Math.max(
+ format.numericFormat().format(axisMin).length(),
+ format.numericFormat().format(axisMax).length()
+ )
: 0;
int horizontalLegendHeight = format.showHorizontalLegend() ? 1 : 0;
@@ -940,7 +942,7 @@ abstract class AbstractResult extends AbstractFormattable impl
if (format.showVerticalLegend()) {
String axisLegendString = (format.display() == Display.HUNDRED_PERCENT_STACKED)
- ? format.numericFormat().format(axisLegendPercent * 100.0) + "%"
+ ? format.percentFormat().format(axisLegendPercent * 100.0)
: format.numericFormat().format(axisLegend);
for (int x = fp.width(axisLegendString); x < verticalLegendWidth; x++)