-
Notifications
You must be signed in to change notification settings - Fork 402
Open
Description
Describe the bug
When you have series using different render styles, like bar and line, the legend markers and text is displayed wonky.
To Reproduce
package com.ontailwind.main.reporting.loss.list;
import java.awt.*;
import java.util.Arrays;
import org.knowm.xchart.CategoryChartBuilder;
import org.knowm.xchart.CategorySeries;
import org.knowm.xchart.SwingWrapper;
import org.knowm.xchart.style.Styler;
import org.knowm.xchart.style.markers.SeriesMarkers;
public class MixedChartExample {
public static void main(String[] args) {
// Create chart
var chart =
new CategoryChartBuilder()
.width(800)
.height(600)
.title("Bar + Line Series Legend Marker Demo")
.xAxisTitle("Category")
.yAxisTitle("Value")
.build();
// General Styler settings
chart.getStyler().setLegendPosition(Styler.LegendPosition.OutsideS);
chart.getStyler().setLegendLayout(Styler.LegendLayout.Horizontal);
chart.getStyler().setLegendVisible(true);
// Bar Series
var barSeries =
chart.addSeries("Bar Series", Arrays.asList("A", "B", "C"), Arrays.asList(20, 40, 55));
barSeries.setChartCategorySeriesRenderStyle(CategorySeries.CategorySeriesRenderStyle.Bar);
barSeries.setFillColor(new Color(35, 127, 211));
// Line Series
var lineSeries =
chart.addSeries("Line Series", Arrays.asList("A", "B", "C"), Arrays.asList(15, 30, 45));
lineSeries.setChartCategorySeriesRenderStyle(CategorySeries.CategorySeriesRenderStyle.Line);
lineSeries.setLineColor(new Color(237, 133, 53));
lineSeries.setLineWidth(2.5f);
lineSeries.setMarker(SeriesMarkers.CIRCLE);
// Show chart
new SwingWrapper<>(chart).displayChart();
}
}
Screenshots
Expected behavior
The horizontal legend should display the legend markers and text uniformly.
Metadata
Metadata
Assignees
Labels
No labels