List of usage examples for org.jfree.chart.plot XYPlot setDataset
public void setDataset(int index, XYDataset dataset)
From source file:com.romraider.logger.ecu.ui.tab.dyno.DynoChartPanel.java
private void addSeries1(JFreeChart chart, int index, XYSeries series, Color color) { XYDataset dataset = new XYSeriesCollection(series); XYPlot plot = chart.getXYPlot(); plot.setDataset(index, dataset); plot.setRenderer(index, buildTrendLineRendererY1(color)); }
From source file:com.romraider.logger.ecu.ui.tab.dyno.DynoChartPanel.java
private void addSeries2(JFreeChart chart, int index, XYSeries series, Color color) { XYDataset dataset = new XYSeriesCollection(series); XYPlot plot = chart.getXYPlot(); plot.setDataset(index, dataset); plot.setRenderer(index, buildTrendLineRendererY2(color)); }
From source file:com.romraider.logger.ecu.ui.tab.dyno.DynoChartPanel.java
private void addRef(JFreeChart chart, int index, XYSeries series, Color color) { XYDataset dataset = new XYSeriesCollection(series); XYPlot plot = chart.getXYPlot(); plot.setDataset(index, dataset); plot.setRenderer(index, buildTrendLineRenderer(color)); }
From source file:playground.dgrether.analysis.charts.DgAvgDeltaUtilsModeGroupChart.java
@Override public JFreeChart createChart() { XYPlot plot = new XYPlot(); ValueAxis xAxis = this.axisBuilder.createValueAxis("Income [Chf / Year]"); ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]"); plot.setDomainAxis(xAxis);//from www . j av a 2 s. c o m plot.setRangeAxis(yAxis); DgColorScheme colorScheme = new DgColorScheme(); XYItemRenderer renderer2; renderer2 = new XYLineAndShapeRenderer(true, true); plot.setDataset(0, this.dataset); for (int i = 0; i <= 3; i++) { renderer2.setSeriesStroke(i, new BasicStroke(2.0f)); renderer2.setSeriesOutlineStroke(i, new BasicStroke(3.0f)); renderer2.setSeriesPaint(i, colorScheme.getColor(i + 1, "a")); } plot.setRenderer(0, renderer2); JFreeChart chart = new JFreeChart("", plot); chart.setBackgroundPaint(ChartColor.WHITE); chart.getLegend().setItemFont(this.axisBuilder.getAxisFont()); chart.setTextAntiAlias(true); return chart; }
From source file:com.haskins.cloudtrailviewer.feature.MetricsFeature.java
private void showChart(String service) { final TimeSeriesCollection chartData = generateTimeSeriesData(service); JFreeChart chart = ChartFactory.createTimeSeriesChart(service, "Time", "Calls", chartData, false, true, false);/*from w w w. j ava2 s. com*/ // draw outter line XYLineAndShapeRenderer lineAndShapeRenderer = new XYLineAndShapeRenderer(); lineAndShapeRenderer.setPaint(new Color(64, 168, 228, 75)); lineAndShapeRenderer.setSeriesShape(0, new Ellipse2D.Double(-3, -3, 6, 6)); lineAndShapeRenderer.setSeriesShapesFilled(0, true); lineAndShapeRenderer.setSeriesShapesVisible(0, true); lineAndShapeRenderer.setUseOutlinePaint(true); lineAndShapeRenderer.setUseFillPaint(true); // draw filled area XYAreaRenderer renderer = new XYAreaRenderer(); renderer.setPaint(new Color(64, 168, 228, 50)); // configure Plot final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlineVisible(false); plot.setDataset(0, chartData); plot.setDataset(1, chartData); plot.setRenderer(0, lineAndShapeRenderer); plot.setRenderer(1, renderer); plot.getDomainAxis().setLowerMargin(0); plot.getDomainAxis().setUpperMargin(0); // format chart title TextTitle t = chart.getTitle(); t.setFont(new Font("Arial", Font.BOLD, 14)); // Cross Hairs xCrosshair = new Crosshair(Double.NaN, Color.GRAY, new BasicStroke(0f)); xCrosshair.setLabelVisible(true); xCrosshair.setLabelGenerator(new DateTimeCrosshairLabelGenerator()); CrosshairOverlay crosshairOverlay = new CrosshairOverlay(); crosshairOverlay.addDomainCrosshair(xCrosshair); // Create the panel chartPanel = new ChartPanel(chart); chartPanel.setMinimumDrawWidth(0); chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); chartPanel.setMinimumDrawHeight(0); chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); chartPanel.setMouseZoomable(true, false); chartPanel.setDomainZoomable(true); chartPanel.setRangeZoomable(false); chartPanel.addChartMouseListener(this); chartPanel.addOverlay(crosshairOverlay); // update the display chartCards.removeAll(); chartCards.add(chartPanel, ""); chartCards.revalidate(); }
From source file:de.mpg.mpi_inf.bioinf.netanalyzer.dec.LeastSquaresPowerLawDecorator.java
@Override public void decorate(JDialog aOwner, JFreeChart aChart, ComplexParamVisualizer aVisualizer, boolean aVerbose) { clearDataset(aChart, seriesName);/*from w w w . j a v a 2 s . com*/ final Point2D.Double[] dataPoints = JFreeChartConn.extractData(aChart); final Point2D.Double[] posPoints = keepPositive(dataPoints); if (posPoints != dataPoints && aVerbose) { // Display a warning that not all points will be included in the fit if (aVerbose) { JOptionPane.showMessageDialog(aOwner, Messages.SM_FITNONPOSITIVE, Messages.DT_FIT, JOptionPane.WARNING_MESSAGE); } } if (posPoints.length < 2) { // Error - not enough data points if (aVerbose) { Utils.showErrorBox(aOwner, Messages.DT_FIT, Messages.SM_FITPLNODATA); } return; } coefs = Fitter.leastSquaresPowerLawFit(posPoints); if (coefs != null) { final XYSeries newData = createFittingData(posPoints, isLogLog(aVisualizer.getSettings())); final XYPlot plot = aChart.getXYPlot(); int i = getDatasetIndex(plot, seriesName); if (i == -1) { i = createDataset(plot); } plot.setDataset(i, new XYSeriesCollection(newData)); if (aVerbose) { // Compute correlation final int count = posPoints.length; final double[] s1 = new double[count]; final double[] s2 = new double[count]; for (int j = 0; j < count; ++j) { s1[j] = posPoints[j].y; s2[j] = valueAt(posPoints[j].x); } Double corr = null; Double rsquared = null; try { corr = new Double(Fitter.computeCorr(s1, s2)); } catch (ArithmeticException ex) { // Correlation could not be computed; ignore } try { ArrayUtils.log(s1, true); ArrayUtils.log(s2, true); rsquared = new Double(Fitter.computeRSquared(s1, s2)); } catch (ArithmeticException ex) { // R-Squared could not be computed; ignore } // Inform the user what the coefficients are showReport(aOwner, corr, rsquared); } } else { // Could not fit power law if (aVerbose) { Utils.showErrorBox(aOwner, Messages.DT_FIT, Messages.SM_FITPLERROR); } } }
From source file:de.mpg.mpi_inf.bioinf.netanalyzer.dec.LeastSquaresLineDecorator.java
@Override public void decorate(JDialog aOwner, JFreeChart aChart, ComplexParamVisualizer aVisualizer, boolean aVerbose) { clearDataset(aChart, LeastSquaresLineDecorator.seriesName); final Point2D.Double[] dataPoints = JFreeChartConn.extractData(aChart); if (dataPoints.length < 2) { // Error - not enough data points if (aVerbose) { Utils.showErrorBox(aOwner, Messages.DT_FIT, Messages.SM_FITLINENODATA); }//from w w w .j ava2s.com return; } coefs = Fitter.leastSquaresLineFit(dataPoints); if (coefs != null) { final XYSeries newData = createFittingData(dataPoints, isLinear(aVisualizer.getSettings())); final XYPlot plot = aChart.getXYPlot(); int i = getDatasetIndex(plot, LeastSquaresLineDecorator.seriesName); if (i == -1) { i = createDataset(plot); } plot.setDataset(i, new XYSeriesCollection(newData)); if (aVerbose) { // Compute correlation final int count = dataPoints.length; final double[] s1 = new double[count]; final double[] s2 = new double[count]; for (int j = 0; j < count; ++j) { s1[j] = dataPoints[j].y; s2[j] = valueAt(dataPoints[j].x); } Double corr = null; Double rsquared = null; try { corr = new Double(Fitter.computeCorr(s1, s2)); } catch (ArithmeticException ex) { // Correlation could not be computed; ignore } try { rsquared = new Double(Fitter.computeRSquared(s1, s2)); } catch (ArithmeticException ex) { // R-Squared could not be computed; ignore } // Inform the user what the coefficients are showReport(aOwner, corr, rsquared); } } else { // Could not fit a line if (aVerbose) { Utils.showErrorBox(aOwner, Messages.DT_FIT, Messages.SM_FITLINEERROR); } } }
From source file:ec.ui.view.StabilityView.java
private JFreeChart createChart() { XYPlot plot = new XYPlot(); plot.setDataset(SMOOTH_INDEX, Charts.emptyXYDataset()); plot.setRenderer(SMOOTH_INDEX, smoothRenderer); plot.mapDatasetToDomainAxis(SMOOTH_INDEX, 0); plot.mapDatasetToRangeAxis(SMOOTH_INDEX, 0); plot.setDataset(MEAN_INDEX, Charts.emptyXYDataset()); plot.setRenderer(MEAN_INDEX, meanRenderer); plot.mapDatasetToDomainAxis(MEAN_INDEX, 0); plot.mapDatasetToRangeAxis(MEAN_INDEX, 0); plot.setDataset(POINTS_INDEX, Charts.emptyXYDataset()); plot.setRenderer(POINTS_INDEX, pointsRenderer); plot.mapDatasetToDomainAxis(POINTS_INDEX, 0); plot.mapDatasetToRangeAxis(POINTS_INDEX, 0); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); JFreeChart result = new JFreeChart("", TsCharts.CHART_TITLE_FONT, plot, false); result.setPadding(TsCharts.CHART_PADDING); return result; }
From source file:org.activequant.util.charting.Chart.java
/** * method to add a dot chart.//from w ww .ja v a 2 s . co m * @param title * @param dateAndValues */ public void addDotSeriesChart(String title, List<Tuple<TimeStamp, Double>> dateAndValues) { if (chart != null) { // final TimeSeries ts = new TimeSeries(title, Millisecond.class); for (Tuple<TimeStamp, Double> tuple : dateAndValues) { // TimeSeriesDataItem item = new TimeSeriesDataItem(new Millisecond(tuple.getObject1().getDate()), tuple.getObject2()); ts.addOrUpdate(item.getPeriod(), item.getValue()); } datasets.add(ts); final TimeSeriesCollection dataset = new TimeSeriesCollection(ts); final XYPlot plot1 = chart.getXYPlot(); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setShapesVisible(true); renderer.setLinesVisible(false); plot1.setDataset(datasets.size(), dataset); plot1.setRenderer(datasets.size(), renderer); } }
From source file:RLCcircuit.RLCcircuitJFrame.java
public JFreeChart getResultChart() { XYSeries series1 = new XYSeries("Resistor"); XYSeries series2 = new XYSeries("Inductor"); XYSeries series3 = new XYSeries("Capacitor"); for (double i = 0 + time; i < 100 + time; i++) { ValueCaculate(i / 1000.);/*w w w . java 2 s .c o m*/ series1.add(i, Rvoltage); } for (double i = 0 + time; i < 100 + time; i++) { ValueCaculate(i / 1000.); series2.add(i, Lvoltage); } for (double i = 0 + time; i < 100 + time; i++) { ValueCaculate(-i / 1000.); series3.add(i, Cvoltage); } XYSeriesCollection data1 = new XYSeriesCollection(series1); XYSeriesCollection data2 = new XYSeriesCollection(series2); XYSeriesCollection data3 = new XYSeriesCollection(series3); final JFreeChart chart = ChartFactory.createXYLineChart("Time-Voltage Graph", "Time", "Voltage", data1, PlotOrientation.VERTICAL, true, false, false); chart.setBackgroundPaint(null); XYPlot plot = chart.getXYPlot(); plot.setDataset(1, data2); plot.setDataset(2, data3); XYLineAndShapeRenderer Renderer1 = new XYLineAndShapeRenderer(); XYLineAndShapeRenderer Renderer2 = new XYLineAndShapeRenderer(); XYLineAndShapeRenderer Renderer3 = new XYLineAndShapeRenderer(); plot.setRenderer(0, Renderer1); plot.setRenderer(1, Renderer2); plot.setRenderer(2, Renderer3); Renderer1.setSeriesShapesVisible(0, false); Renderer2.setSeriesShapesVisible(0, false); Renderer3.setSeriesShapesVisible(0, false); plot.setBackgroundPaint(Color.black); plot.getDomainAxis().setVisible(false); plot.getRangeAxis().setVisible(false); plot.getRangeAxis().setRange(-20, 20); //chart.plotChanged(new PlotChangeEvent(plot)); return chart; }