knowm / XChart

XChart is a light-weight Java library for plotting data.
http://knowm.org/open-source/xchart
Apache License 2.0
1.48k stars 394 forks source link

XYSeries.getXYSeriesRenderStyle() is null even after variable Assignment #849

Open yanlzhl opened 2 months ago

yanlzhl commented 2 months ago
private void testRenderStyle(XYSeriesRenderStyle renderStyle) {
    // Create Chart
    XYChart chart = new XYChartBuilder().build();

    // Set default series render style
    chart.getStyler().setDefaultSeriesRenderStyle(renderStyle);

    // Add series
    XYSeries series = chart.addSeries("series1", new double[] {1, 2, 3}, new double[] {1, 2, 3});

    // Verify the series render style
    assertNotEquals(renderStyle, series.getXYSeriesRenderStyle());
  }

image

timmolter commented 1 month ago

please post a fully working isolated code example. You could use this as a start:

public class TestForIssue849 {

  public static void main(String[] args) throws ParseException {

    XYChart chart = getXYChart();
    new SwingWrapper(chart).displayChart();
  }

  public static XYChart getXYChart() {
    XYChart chart =
        new XYChartBuilder()
            .width(720)
            .height(480)
            .title("getXYSeriesRenderStyle Example")
            .xAxisTitle("Count")
            .yAxisTitle("Value")
            .build();

    double[] xValues = new double[] {1, 2, 3};
    double[] yValues = new double[] {1, 2, 3};
    chart.addSeries("main", xValues, yValues);

    return chart;
  }
}