/** * Creates a Chart with default style * * @param chartTitle the Chart title * @param xTitle The X-Axis title * @param yTitle The Y-Axis title * @param seriesName The name of the series * @param xData An array containing the X-Axis data * @param yData An array containing Y-Axis data * @return a Chart Object */ public static XYChart getChart( String chartTitle, String xTitle, String yTitle, String seriesName, double[] xData, double[] yData) { double[][] yData2d = {yData}; if (seriesName == null) { return getChart(chartTitle, xTitle, yTitle, null, xData, yData2d); } else { return getChart(chartTitle, xTitle, yTitle, new String[] {seriesName}, xData, yData2d); } }
public static void main(String[] args) throws Exception { double[] xData = new double[] {0.0, 1.0, 2.0}; double[] yData = new double[] {2.0, 1.0, 0.0}; // Create Chart XYChart chart = QuickChart.getChart("Sample Chart", "X", "Y", "y(x)", xData, yData); // Show it new SwingWrapper(chart).displayChart(); } }
public static void main(String[] args) throws Exception { double[] xData = new double[] {1.0, 2.0}; double[] yData = new double[] {Double.NaN, 1.0}; // Create Chart XYChart chart = QuickChart.getChart("Sample Chart", "X", "Y", "1", xData, yData); chart.getSeriesMap().get("1").setMarker(new Circle()); // Show it new SwingWrapper(chart).displayChart(); } }
public static void main(String[] args) throws IOException { double[] xData = new double[] {0.0, 1.0, 2.0}; double[] yData = new double[] {2.0, 1.0, 0.0}; // Create Chart XYChart chart = QuickChart.getChart("Sample Chart", "X", "Y", "y(x)", xData, yData); // Show it new SwingWrapper<XYChart>(chart).displayChart(); // Save it BitmapEncoder.saveBitmap(chart, "./Sample_Chart", BitmapFormat.PNG); // or save it in high-res BitmapEncoder.saveBitmapWithDPI(chart, "./Sample_Chart_300_DPI", BitmapFormat.PNG, 300); } }
public static void main(String[] args) throws Exception { double phase = 0; double[][] initdata = getSineData(phase); // Create Chart final XYChart chart = QuickChart.getChart( "Simple XChart Real-time Demo", "Radians", "Sine", "sine", initdata[0], initdata[1]); // Show it final SwingWrapper<XYChart> sw = new SwingWrapper<XYChart>(chart); sw.displayChart(); while (true) { phase += 2 * Math.PI * 2 / 20.0; Thread.sleep(100); final double[][] data = getSineData(phase); chart.updateXYSeries("sine", data[0], data[1], null); sw.repaintChart(); } }
private void go() { // Create Chart chart = QuickChart.getChart( "SwingWorker XChart Real-time Demo", "Time", "Value", "randomWalk", new double[] {0}, new double[] {0}); chart.getStyler().setLegendVisible(false); chart.getStyler().setXAxisTicksVisible(false); // Show it sw = new SwingWrapper<XYChart>(chart); sw.displayChart(); mySwingWorker = new MySwingWorker(); mySwingWorker.execute(); }
/** * Creates a Chart with default style * * @param chartTitle the Chart title * @param xTitle The X-Axis title * @param yTitle The Y-Axis title * @param seriesName The name of the series * @param xData An array containing the X-Axis data * @param yData An array containing Y-Axis data * @return a Chart Object */ public static XYChart getChart( String chartTitle, String xTitle, String yTitle, String seriesName, double[] xData, double[] yData) { double[][] yData2d = {yData}; if (seriesName == null) { return getChart(chartTitle, xTitle, yTitle, null, xData, yData2d); } else { return getChart(chartTitle, xTitle, yTitle, new String[] {seriesName}, xData, yData2d); } }