You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The LayeredBarRenderer is assuming that the base for bars is at value 0.0, however this default can be overridden by calling the setBase() method that is inherited from the BarRenderer class. The rendering code, however, is ignoring this override.
Borrowing the demo code from #169 with a slight amendment - here the bar base is being set to 20.0 but this is ignored:
import java.awt.Dimension;
import java.awt.EventQueue;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.ChartUtils;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.LayeredBarRenderer;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.general.DatasetUtils;
import org.jfree.chart.ui.ApplicationFrame;
/** @see https://stackoverflow.com/a/63464855/230513 */
public final class LayeredBarChartDemo extends ApplicationFrame {
private static final String TITLE = "Layered Bar Chart Demo";
public LayeredBarChartDemo(final String title) {
super(title);
final double[][] data = new double[][]{{55, 60}, {25, 13}};
final CategoryDataset dataset = DatasetUtils.createCategoryDataset("Series ", "Factor ", data);
final CategoryAxis categoryAxis = new CategoryAxis("Category");
final ValueAxis valueAxis = new NumberAxis("Score (%)");
final LayeredBarRenderer renderer = new LayeredBarRenderer();
renderer.setDefaultToolTipGenerator(new StandardCategoryToolTipGenerator());
renderer.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator());
renderer.setDefaultItemLabelsVisible(true);
renderer.setBase(20.0);
final CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
plot.setOrientation(PlotOrientation.VERTICAL);
final JFreeChart chart = new JFreeChart(TITLE, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
ChartUtils.applyCurrentTheme(chart);
add(new ChartPanel(chart) {
@Override
public Dimension getPreferredSize() {
return new Dimension(640, 480);
}
});
}
public static void main(final String[] args) {
EventQueue.invokeLater(() -> {
final LayeredBarChartDemo demo = new LayeredBarChartDemo(TITLE);
demo.pack();
demo.setLocationRelativeTo(null);
demo.setVisible(true);
});
}
}
The text was updated successfully, but these errors were encountered:
The LayeredBarRenderer is assuming that the base for bars is at value 0.0, however this default can be overridden by calling the setBase() method that is inherited from the BarRenderer class. The rendering code, however, is ignoring this override.
Borrowing the demo code from #169 with a slight amendment - here the bar base is being set to 20.0 but this is ignored:
The text was updated successfully, but these errors were encountered: