diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/pie/PieChart02.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/pie/PieChart02.java
index b1f141f32..c742b77bc 100644
--- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/pie/PieChart02.java
+++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/pie/PieChart02.java
@@ -1,14 +1,10 @@
package org.knowm.xchart.demo.charts.pie;
import java.awt.Color;
-import java.util.Collection;
-
import org.knowm.xchart.PieChart;
import org.knowm.xchart.PieChartBuilder;
-import org.knowm.xchart.PieSeries;
import org.knowm.xchart.SwingWrapper;
import org.knowm.xchart.demo.charts.ExampleChart;
-import org.knowm.xchart.style.LabelGenerator;
import org.knowm.xchart.style.PieStyler.LabelType;
/**
@@ -20,7 +16,6 @@
*
Pie Chart
* PieChartBuilder
* Custom series palette
- * Custom label type
* Value Annotations
* Tooltips
*/
@@ -40,13 +35,6 @@ public PieChart getChart() {
PieChart chart =
new PieChartBuilder().width(800).height(600).title(getClass().getSimpleName()).build();
- // Series
- chart.addSeries("Gold", 24);
- chart.addSeries("Silver", 21);
- chart.addSeries("Platinum", 39);
- chart.addSeries("Copper", 17);
- chart.addSeries("Zinc", 40);
-
// Customize Chart
Color[] sliceColors =
new Color[] {
@@ -57,12 +45,18 @@ public PieChart getChart() {
new Color(246, 199, 182)
};
chart.getStyler().setSeriesColors(sliceColors);
- chart.getStyler().setLabelType(LabelType.Custom);
- chart.getStyler().setLabelGenerator(new CustomLabelGenerator(chart.getSeriesMap().values()));
+ chart.getStyler().setLabelType(LabelType.Value);
// chart.getStyler().setDecimalPattern("#0.000");
chart.getStyler().setToolTipsEnabled(true);
// chart.getStyler().setToolTipsAlwaysVisible(true);
+ // Series
+ chart.addSeries("Gold", 24);
+ chart.addSeries("Silver", 21);
+ chart.addSeries("Platinum", 39);
+ chart.addSeries("Copper", 17);
+ chart.addSeries("Zinc", 40);
+
return chart;
}
@@ -71,21 +65,4 @@ public String getExampleChartName() {
return getClass().getSimpleName() + " - Pie Chart Custom Color Palette";
}
-
- private static class CustomLabelGenerator implements LabelGenerator {
-
- private final double total;
-
- public CustomLabelGenerator(Collection values) {
-
- this.total = values.stream().map(PieSeries::getValue).mapToDouble(Number::doubleValue).sum();
- }
-
- @Override
- public String generateSeriesLabel(PieSeries series) {
-
- double percent = (series.getValue().doubleValue() / total) * 100;
- return String.format("%s (%.2f%%)", series.getValue(), percent);
- }
- }
}
diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_Pie.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_Pie.java
index f87f11a6f..94d6f52dd 100644
--- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_Pie.java
+++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_Pie.java
@@ -290,8 +290,6 @@ private void paintLabels(Graphics2D g, Rectangle2D pieBounds, double total, doub
} else {
label = series.getName() + " (" + y.toString() + ")";
}
- } else if (pieStyler.getLabelType() == LabelType.Custom) {
- label = pieStyler.getLabelGenerator().generateSeriesLabel(series);
}
TextLayout textLayout =
diff --git a/xchart/src/main/java/org/knowm/xchart/style/LabelGenerator.java b/xchart/src/main/java/org/knowm/xchart/style/LabelGenerator.java
deleted file mode 100644
index 31969dedd..000000000
--- a/xchart/src/main/java/org/knowm/xchart/style/LabelGenerator.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.knowm.xchart.style;
-
-import org.knowm.xchart.PieSeries;
-
-public interface LabelGenerator {
- String generateSeriesLabel(PieSeries series);
-}
diff --git a/xchart/src/main/java/org/knowm/xchart/style/PieStyler.java b/xchart/src/main/java/org/knowm/xchart/style/PieStyler.java
index 0c7fcefd4..6df15afa6 100644
--- a/xchart/src/main/java/org/knowm/xchart/style/PieStyler.java
+++ b/xchart/src/main/java/org/knowm/xchart/style/PieStyler.java
@@ -25,7 +25,6 @@ public class PieStyler extends Styler {
private Color labelsFontColor;
private double labelsDistance;
private LabelType labelType;
- private LabelGenerator labelGenerator;
private boolean isForceAllLabelsVisible;
private boolean isLabelsFontColorAutomaticEnabled;
private Color labelsFontColorAutomaticLight;
@@ -143,23 +142,6 @@ public PieStyler setLabelType(LabelType labelType) {
return this;
}
- public LabelGenerator getLabelGenerator() {
-
- return labelGenerator;
- }
-
- /**
- * Sets the Pie custom label generator
- *
- * @param labelGenerator
- */
- public PieStyler setLabelGenerator(LabelGenerator labelGenerator) {
-
- this.labelType = LabelType.Custom;
- this.labelGenerator = labelGenerator;
- return this;
- }
-
public boolean isForceAllLabelsVisible() {
return isForceAllLabelsVisible;
@@ -380,8 +362,7 @@ public enum LabelType {
Percentage,
Name,
NameAndPercentage,
- NameAndValue,
- Custom
+ NameAndValue
}
public enum ClockwiseDirectionType {