From 9d84462d9663cd15148a661c44a8a16cb03141d3 Mon Sep 17 00:00:00 2001 From: Tim Molter Date: Thu, 25 Apr 2024 21:25:40 +0200 Subject: [PATCH] test chart for issue #707 --- .../standalone/issues/TestForIssue707.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 xchart-demo/src/main/java/org/knowm/xchart/standalone/issues/TestForIssue707.java diff --git a/xchart-demo/src/main/java/org/knowm/xchart/standalone/issues/TestForIssue707.java b/xchart-demo/src/main/java/org/knowm/xchart/standalone/issues/TestForIssue707.java new file mode 100644 index 00000000..5227162f --- /dev/null +++ b/xchart-demo/src/main/java/org/knowm/xchart/standalone/issues/TestForIssue707.java @@ -0,0 +1,38 @@ +package org.knowm.xchart.standalone.issues; + +import org.knowm.xchart.CategoryChart; +import org.knowm.xchart.CategoryChartBuilder; +import org.knowm.xchart.CategorySeries; +import org.knowm.xchart.SwingWrapper; +import org.knowm.xchart.style.Styler; + +import java.text.ParseException; + +public class TestForIssue707 { + + public static void main(String[] args) throws ParseException { + + CategoryChart chart = getCategoryChart(); + new SwingWrapper(chart).displayChart(); + } + + public static CategoryChart getCategoryChart() { + double[] xData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0 }; + double[] yData = new double[] { 2.0, 1.5, 4.0, 3.77, 2.5 }; + + // Create Chart + CategoryChartBuilder builder = new CategoryChartBuilder(); + builder.title("Sample Chart") + .xAxisTitle("X") + .yAxisTitle("Y") + .theme(Styler.ChartTheme.Matlab); + CategoryChart chart = builder.build(); + // chart.getStyler().setYAxisMin(1.0); + chart.getStyler().setLabelsVisible(true); + //.setDefaultSeriesRenderStyle(CategorySeries.CategorySeriesRenderStyle.Line). + + chart.addSeries("y(x)", xData, yData); + + return chart; + } +}