private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart( "Bar Chart Demo 1", "Category", "Value", categorydataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setDomainGridlinesVisible(true); categoryplot.setRangeCrosshairVisible(true); categoryplot.setRangeCrosshairPaint(Color.blue); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setDrawBarOutline(false); GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64)); GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0)); GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0)); barrenderer.setSeriesPaint(0, gradientpaint); barrenderer.setSeriesPaint(1, gradientpaint1); barrenderer.setSeriesPaint(2, gradientpaint2); barrenderer.setLegendItemToolTipGenerator( new StandardCategorySeriesLabelGenerator("Tooltip: {0}")); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(0.52359877559829882D)); return jfreechart; }
private JFreeChart buildDifferenceChart(TimeSeriesCollection dataset, String title) { // Creat the chart JFreeChart chart = ChartFactory.createTimeSeriesChart( title, "Date", "Price", dataset, true, // legend true, // tool tips false // URLs ); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setRenderer( new XYDifferenceRenderer(new Color(112, 128, 222), new Color(112, 128, 222), false)); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(UnitType.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); ValueAxis domainAxis = new DateAxis("Date"); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); plot.setDomainAxis(domainAxis); plot.setForegroundAlpha(0.5f); return chart; }
private JFreeChart buildChart(TimeSeriesCollection dataset, String title, boolean endPoints) { // Create the chart JFreeChart chart = ChartFactory.createTimeSeriesChart(title, "Date", "Price", dataset, true, true, false); // Display each series in the chart with its point shape in the legend LegendTitle sl = chart.getLegend(); // sl.setDisplaySeriesShapes(true); // Setup the appearance of the chart chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(UnitType.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); // Display data points or just the lines? if (endPoints) { XYItemRenderer renderer = plot.getRenderer(); if (renderer instanceof StandardXYItemRenderer) { StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer; // rr.setPlotShapes(true); rr.setShapesFilled(true); rr.setItemLabelsVisible(true); } } // Tell the chart how we would like dates to read DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; }
public Chart(String title, String timeAxis, String valueAxis, TimeSeries data) { try { // Build the datasets dataset.addSeries(data); // Create the chart JFreeChart chart = ChartFactory.createTimeSeriesChart( title, timeAxis, valueAxis, dataset, true, true, false); // Setup the appearance of the chart chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(UnitType.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); // Tell the chart how we would like dates to read DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("EEE HH")); this.add(new ChartPanel(chart)); } catch (Exception e) { e.printStackTrace(); } }
private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYLineChart( "Ratings by Age", // Title "Age", // X label "Average Rating", // Y label dataset, // data PlotOrientation.VERTICAL, // Orientation false, // legend false, // tooltips false); // urls chart.setBorderPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createLineChart( "Statistical Line Chart Demo 1", "Type", "Value", categorydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setUpperMargin(0.0D); categoryaxis.setLowerMargin(0.0D); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setAutoRangeIncludesZero(true); StatisticalLineAndShapeRenderer statisticallineandshaperenderer = new StatisticalLineAndShapeRenderer(true, false); statisticallineandshaperenderer.setUseSeriesOffset(true); categoryplot.setRenderer(statisticallineandshaperenderer); return jfreechart; }
private static JFreeChart createChart() { XYDataset xydataset = createDirectionDataset(600); JFreeChart jfreechart = ChartFactory.createTimeSeriesChart( "Time", "Date", "Direction", xydataset, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.getDomainAxis().setLowerMargin(0.0D); xyplot.getDomainAxis().setUpperMargin(0.0D); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); TickUnits tickunits = new TickUnits(); tickunits.add(new NumberTickUnit(180D, new CompassFormat())); tickunits.add(new NumberTickUnit(90D, new CompassFormat())); tickunits.add(new NumberTickUnit(45D, new CompassFormat())); tickunits.add(new NumberTickUnit(22.5D, new CompassFormat())); numberaxis.setStandardTickUnits(tickunits); xyplot.setRangeAxis(numberaxis); XYAreaRenderer xyarearenderer = new XYAreaRenderer(); NumberAxis numberaxis1 = new NumberAxis("Force"); numberaxis1.setRange(0.0D, 12D); xyarearenderer.setSeriesPaint(0, new Color(0, 0, 255, 128)); xyplot.setDataset(1, createForceDataset(600)); xyplot.setRenderer(1, xyarearenderer); xyplot.setRangeAxis(1, numberaxis1); xyplot.mapDatasetToRangeAxis(1, 1); return jfreechart; }
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createStackedBarChart3D( "Stacked Bar Chart 3D Demo 2", "Category", "Value", categorydataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setNumberFormatOverride(new DecimalFormat("0.0%")); StackedBarRenderer3D stackedbarrenderer3d = (StackedBarRenderer3D) categoryplot.getRenderer(); stackedbarrenderer3d.setRenderAsPercentages(true); stackedbarrenderer3d.setDrawBarOutline(false); stackedbarrenderer3d.setBaseItemLabelGenerator( new StandardCategoryItemLabelGenerator( "{3}", NumberFormat.getIntegerInstance(), new DecimalFormat("0.0%"))); stackedbarrenderer3d.setBaseItemLabelsVisible(true); stackedbarrenderer3d.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); stackedbarrenderer3d.setBaseNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); return jfreechart; }
public String generatePieChart( String hitOrdNum, HttpSession session, PrintWriter pw, String courseId, int studentId) { /* int groupId=0; if (groupName.equals("All")){ groupId=0; }else{ groupId = studStatisticBean.getGroupIdByName(groupName); }*/ String filename = null; try { // Retrieve list of WebHits StudentsConceptChartDataSet whDataSet = new StudentsConceptChartDataSet(studStatisticBean, courseId, studentId); ArrayList list = whDataSet.getDataBySection(hitOrdNum); // Throw a custom NoDataException if there is no data if (list.size() == 0) { System.out.println("No data has been found"); throw new NoDataException(); } // Create and populate a PieDataSet DefaultPieDataset data = new DefaultPieDataset(); Iterator iter = list.listIterator(); while (iter.hasNext()) { StudentsConceptHit wh = (StudentsConceptHit) iter.next(); data.setValue(wh.getSection(), wh.getHitDegree()); } // Create the chart object PiePlot plot = new PiePlot(data); plot.setInsets(new Insets(0, 5, 5, 5)); plot.setURLGenerator(new StandardPieURLGenerator("xy_chart.jsp", "section")); plot.setToolTipGenerator(new StandardPieItemLabelGenerator()); JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(java.awt.Color.white); // Write the chart image to the temporary directory ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); filename = ServletUtilities.saveChartAsPNG(chart, 600, 400, info, session); // Write the image map to the PrintWriter ChartUtilities.writeImageMap(pw, filename, info); pw.flush(); } catch (NoDataException e) { System.out.println(e.toString()); filename = "public_nodata_500x300.png"; } catch (Exception e) { System.out.println("Exception - " + e.toString()); e.printStackTrace(System.out); filename = "public_error_500x300.png"; } return filename; }
private JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart( "Serialization Test 1", "Time", "Value", xydataset, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); ValueAxis valueaxis = xyplot.getDomainAxis(); valueaxis.setAutoRange(true); valueaxis.setFixedAutoRange(60000D); return jfreechart; }
/** * temporal helper function * * @param dataset * @return */ private JFreeChart createChart(TimeSeriesCollection dataset) { NumberAxis axis = new NumberAxis(null); axis.setAutoRangeIncludesZero(false); // parent=new CombinedRangeXYPlot(axis); // chart = null; // XYPlot plot2=new XYPlot(dataset2, new DateAxis(null), null, new StandardXYItemRenderer()); // XYPlot subplot2=new XYPldt(dataset2, new DateAxis("Date 2"), null, ) // parent.add(subplot1); // parent.add(subplot2); // chart=new JFreeChart(null, null, parent, false); chart = ChartFactory.createTimeSeriesChart(null, "", "", dataset, false, false, false); XYPlot plot1 = chart.getXYPlot(); plot1.setDataset(dataset); plot1.setRenderer(new StandardXYItemRenderer()); plot1.setSecondaryDataset(0, hld); CandlestickRenderer c1 = new CandlestickRenderer(); // c1.setAutoWidthFactor(1.0); // c1.setAutoWidthGap(0.1); c1.setBasePaint(new Color(255, 255, 255)); c1.setBaseOutlinePaint(new Color(255, 255, 255)); c1.setPaint(new Color(255, 255, 255)); c1.setUpPaint(new Color(255, 0, 0, 80)); c1.setDownPaint(new Color(0, 255, 0, 80)); plot1.setSecondaryRenderer(0, c1); // plot1.setSecondaryDataset(0, dataset2); XYDotRenderer xd1 = new XYDotRenderer(); // plot1.setSecondaryRenderer(0, new AreaXYRenderer(AreaXYRenderer.AREA_AND_SHAPES)); // plot1.setSecondaryRenderer(0, xd1); // chart=new JFreeChart("", null, plot1, false); chart.setBackgroundPaint(new Color(0, 0, 0)); return chart; }
/** * Handles a mouse wheel event from the underlying chart panel. * * @param e the event. */ public void mouseWheelMoved(MouseWheelEvent e) { JFreeChart chart = this.chartPanel.getChart(); if (chart == null) { return; } Plot plot = chart.getPlot(); if (plot instanceof Zoomable) { Zoomable zoomable = (Zoomable) plot; handleZoomable(zoomable, e); } else if (plot instanceof PiePlot) { PiePlot pp = (PiePlot) plot; pp.handleMouseWheelRotation(e.getWheelRotation()); } }
public MyDemoPanel() { super(new BorderLayout()); lastValue = new double[3]; CombinedDomainXYPlot combineddomainxyplot = new CombinedDomainXYPlot(new DateAxis("Time")); datasets = new TimeSeriesCollection[3]; for (int i = 0; i < 3; i++) { lastValue[i] = 100D; TimeSeries timeseries = new TimeSeries("Random " + i); datasets[i] = new TimeSeriesCollection(timeseries); NumberAxis numberaxis = new NumberAxis("Y" + i); numberaxis.setAutoRangeIncludesZero(false); XYPlot xyplot = new XYPlot(datasets[i], null, numberaxis, new StandardXYItemRenderer()); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); combineddomainxyplot.add(xyplot); } JFreeChart jfreechart = new JFreeChart("Dynamic Data Demo 3", combineddomainxyplot); addChart(jfreechart); LegendTitle legendtitle = (LegendTitle) jfreechart.getSubtitle(0); legendtitle.setPosition(RectangleEdge.RIGHT); legendtitle.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0.0D, 4D, 0.0D, 4D)); jfreechart.setBorderPaint(Color.black); jfreechart.setBorderVisible(true); ValueAxis valueaxis = combineddomainxyplot.getDomainAxis(); valueaxis.setAutoRange(true); valueaxis.setFixedAutoRange(20000D); ChartUtilities.applyCurrentTheme(jfreechart); ChartPanel chartpanel = new ChartPanel(jfreechart); add(chartpanel); JPanel jpanel = new JPanel(new FlowLayout()); for (int j = 0; j < 3; j++) { JButton jbutton1 = new JButton("Series " + j); jbutton1.setActionCommand("ADD_DATA_" + j); jbutton1.addActionListener(this); jpanel.add(jbutton1); } JButton jbutton = new JButton("ALL"); jbutton.setActionCommand("ADD_ALL"); jbutton.addActionListener(this); jpanel.add(jbutton); add(jpanel, "South"); chartpanel.setPreferredSize(new Dimension(500, 470)); chartpanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); }
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYLineChart( "Line Chart Demo 2", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return jfreechart; }
/** * Create a GUI that shows a graph for the specified user's payoff history * * @param user The user to show the Payoff history for */ public GraphGUI(User user) { super( user.getUserName() + "'s Payoff History (Over " + user.getPayoffHistory().size() + " Steps)"); this.userInfo = user; this.pack(); // Set size this.setMinimumSize(new Dimension(500, 500)); // Center the graph this.setLocationRelativeTo(null); // Create a series collection xySeriesCollection = new XYSeriesCollection(); // Create (refresh) chart data refreshChartData(); // Create an XY Line Chart chart = ChartFactory.createXYLineChart( "User Payoff Over Time", "Steps (Simulation Iterations)", "User Payoff", xySeriesCollection); chart.getPlot().setBackgroundPaint(Color.WHITE); chart.getPlot().setOutlinePaint(Color.BLACK); // Draw the Initial Chart chart.draw( (Graphics2D) this.getGraphics(), (Rectangle2D) new Rectangle2D.Double(0, 0, this.getWidth(), this.getHeight())); // Set the content pane to a graphics panel for drawing the graph this.setContentPane(new GraphPanel(this)); // Show the frame this.setVisible(true); // Subscribe to the user's UserPayoff events user.addPayoffListener(this); }
/** * Create the scatter chart using the ChartFactory built into JFreeChart * * @return m_chart A chart of type JFreeChart */ @Override public JFreeChart createChart() { JFreeChart CHART = ChartFactory.createPolarChart( super.GetTitle(), // chart title convertDataSet(), // orientation false, // Legend // // include legend true, // tooltips? false // URLs? ); Plot p = CHART.getPlot(); org.jfree.chart.plot.PolarPlot pl = (org.jfree.chart.plot.PolarPlot) p; PolarItemRenderer renderer = new PolarPlot.CustomRenderer(); pl.setRenderer(renderer); return CHART; }
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart( "Legal & General Unit Trust Prices", "Date", "Price Per Unit", xydataset, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); xylineandshaperenderer.setBaseItemLabelsVisible(true); } PeriodAxis periodaxis = new PeriodAxis("Date"); periodaxis.setTimeZone(TimeZone.getTimeZone("Pacific/Auckland")); periodaxis.setAutoRangeTimePeriodClass(org.jfree.data.time.Day.class); PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[3]; aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class, new SimpleDateFormat("d")); aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo( org.jfree.data.time.Month.class, new SimpleDateFormat("MMM"), new RectangleInsets(2D, 2D, 2D, 2D), new Font("SansSerif", 1, 10), Color.blue, false, new BasicStroke(0.0F), Color.lightGray); aperiodaxislabelinfo[2] = new PeriodAxisLabelInfo(org.jfree.data.time.Year.class, new SimpleDateFormat("yyyy")); periodaxis.setLabelInfo(aperiodaxislabelinfo); xyplot.setDomainAxis(periodaxis); ChartUtilities.applyCurrentTheme(jfreechart); return jfreechart; }
/** * Draws the chart using graphics * * @param g Graphics to Draw to */ public void drawChart(Graphics g) { // Update all chart data refreshChartData(); // Paint the chart if (chart != null && g != null) chart.draw( (Graphics2D) g, (Rectangle2D) new Rectangle2D.Double( 0, 0, g.getClipBounds().getWidth(), g.getClipBounds().getHeight())); }
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYLineChart( "Mälu hõivamine", "mälublokid", null, xydataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); XYStepAreaRenderer xysteparearenderer = new XYStepAreaRenderer(2); xysteparearenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); xysteparearenderer.setDefaultEntityRadius(6); xyplot.setRenderer(xysteparearenderer); XYPlot plot = (XYPlot) jfreechart.getPlot(); ValueAxis range = plot.getRangeAxis(); range.setVisible(false); return jfreechart; }
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart( "Time Series Demo 7", "Date", "Value", xydataset, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); NumberAxis numberaxis = new NumberAxis(null); numberaxis.setAutoRangeIncludesZero(false); xyplot.setRangeAxis(1, numberaxis); java.util.List list = Arrays.asList(new Integer[] {new Integer(0), new Integer(1)}); xyplot.mapDatasetToRangeAxes(0, list); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setAutoPopulateSeriesStroke(false); xylineandshaperenderer.setBaseStroke(new BasicStroke(1.5F, 1, 1)); xylineandshaperenderer.setDrawSeriesLineAsPath(true); GeneralPath generalpath = new GeneralPath(); generalpath.moveTo(-6F, 0.0F); generalpath.lineTo(-3F, 6F); generalpath.lineTo(3F, -6F); generalpath.lineTo(6F, 0.0F); xylineandshaperenderer.setLegendLine(generalpath); ChartUtilities.applyCurrentTheme(jfreechart); return jfreechart; }
public SerializationTest1(String s) { super(s); lastValue = 100D; series = new TimeSeries("Random Data"); TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(series); JFreeChart jfreechart = createChart(timeseriescollection); JFreeChart jfreechart1 = null; try { ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(); ObjectOutputStream objectoutputstream = new ObjectOutputStream(bytearrayoutputstream); objectoutputstream.writeObject(jfreechart); objectoutputstream.close(); jfreechart = null; Object obj = null; series = null; System.gc(); ObjectInputStream objectinputstream = new ObjectInputStream(new ByteArrayInputStream(bytearrayoutputstream.toByteArray())); jfreechart1 = (JFreeChart) objectinputstream.readObject(); objectinputstream.close(); } catch (Exception exception) { exception.printStackTrace(); } XYPlot xyplot = (XYPlot) jfreechart1.getPlot(); TimeSeriesCollection timeseriescollection1 = (TimeSeriesCollection) xyplot.getDataset(); series = timeseriescollection1.getSeries(0); ChartPanel chartpanel = new ChartPanel(jfreechart1); JButton jbutton = new JButton("Add New Data Item"); jbutton.setActionCommand("ADD_DATA"); jbutton.addActionListener(this); JPanel jpanel = new JPanel(new BorderLayout()); jpanel.add(chartpanel); jpanel.add(jbutton, "South"); chartpanel.setPreferredSize(new Dimension(500, 270)); setContentPane(jpanel); }
/** Creates fundamental diagram chart. */ private JFreeChart makeFDChart() { updateFDSeries(); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(ffFD); dataset.addSeries(cFD); dataset.addSeries(cdFD); JFreeChart chart = ChartFactory.createXYLineChart( null, // chart title "Density (vpm)", // x axis label "Flow (vph)", // y axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend false, // tooltips false // urls ); XYPlot plot = (XYPlot) chart.getPlot(); plot.getRenderer().setSeriesPaint(0, Color.GREEN); plot.getRenderer().setSeriesPaint(1, Color.RED); plot.getRenderer().setSeriesPaint(2, Color.BLUE); plot.getRenderer().setStroke(new BasicStroke(2)); return chart; }
protected void buildChart() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); chart = ChartFactory.createMultiplePieChart( "Untitled Chart", dataset, org.jfree.util.TableOrder.BY_COLUMN, false, true, false); chart.setAntiAlias(true); // chartPanel = new ScrollableChartPanel(chart, true); chartPanel = buildChartPanel(chart); // chartHolder.getViewport().setView(chartPanel); setChartPanel(chartPanel); JFreeChart baseChart = (JFreeChart) ((MultiplePiePlot) (chart.getPlot())).getPieChart(); PiePlot base = (PiePlot) (baseChart.getPlot()); base.setIgnoreZeroValues(true); base.setLabelOutlinePaint(java.awt.Color.WHITE); base.setLabelShadowPaint(java.awt.Color.WHITE); base.setMaximumLabelWidth( 0.25); // allow bigger labels by a bit (this will make the chart smaller) base.setInteriorGap(0.000); // allow stretch to compensate for the bigger label width base.setLabelBackgroundPaint(java.awt.Color.WHITE); base.setOutlinePaint(null); base.setBackgroundPaint(null); base.setShadowPaint(null); base.setSimpleLabels(false); // I think they're false anyway // change the look of the series title to be smaller StandardChartTheme theme = new StandardChartTheme("Hi"); TextTitle title = new TextTitle("Whatever", theme.getLargeFont()); title.setPaint(theme.getAxisLabelPaint()); title.setPosition(RectangleEdge.BOTTOM); baseChart.setTitle(title); // this must come last because the chart must exist for us to set its dataset setSeriesDataset(dataset); }
public String generateXYAreaChart( HttpSession session, PrintWriter pw, String courseId, int studentId) { String filename = null; /* int groupId=0; if (groupName.equals("All")){ groupId=0; }else{ groupId = studStatisticBean.getGroupIdByName(groupName); }*/ try { // Retrieve list of WebHits for each section and populate a TableXYDataset StudentsConceptChartDataSet cDataSet = new StudentsConceptChartDataSet(studStatisticBean, courseId, studentId); // cDataSet.setStudentStatisticBeanIdRef(studStatisticBean); ArrayList sections = cDataSet.getSections(); Iterator sectionIter = sections.iterator(); DefaultTableXYDataset dataset = new DefaultTableXYDataset(); while (sectionIter.hasNext()) { String section = (String) sectionIter.next(); ArrayList list = cDataSet.getDataByHitConcept(section); XYSeries dataSeries = new XYSeries(section, true, false); Iterator webHitIter = list.iterator(); while (webHitIter.hasNext()) { StudentsConceptHit cHit = (StudentsConceptHit) webHitIter.next(); dataSeries.add(cHit.getOrdNumb(), cHit.getHitDegree()); } dataset.addSeries(dataSeries); } // Throw a custom NoDataException if there is no data if (dataset.getItemCount() == 0) { System.out.println("No data has been found"); throw new NoDataException(); } // Create tooltip and URL generators SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy", Locale.UK); StandardXYToolTipGenerator ttg = new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, sdf, NumberFormat.getInstance()); TimeSeriesURLGenerator urlg = new TimeSeriesURLGenerator(sdf, "bar_chart.jsp", "series", "hitDate"); // Create the X-Axis DateAxis xAxis = new DateAxis(null); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); // Create the X-Axis NumberAxis yAxis = new NumberAxis(null); yAxis.setAutoRangeIncludesZero(true); // Create the renderer StackedXYAreaRenderer renderer = new StackedXYAreaRenderer(XYAreaRenderer.AREA_AND_SHAPES, ttg, urlg); renderer.setSeriesPaint(0, new Color(255, 255, 180)); renderer.setSeriesPaint(1, new Color(206, 230, 255)); renderer.setSeriesPaint(2, new Color(255, 230, 230)); renderer.setSeriesPaint(3, new Color(206, 255, 206)); renderer.setShapePaint(Color.gray); renderer.setShapeStroke(new BasicStroke(0.5f)); renderer.setShape(new Ellipse2D.Double(-3, -3, 6, 6)); renderer.setOutline(true); // Create the plot XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setForegroundAlpha(0.65f); // Reconfigure Y-Axis so the auto-range knows that the data is stacked yAxis.configure(); // Create the chart JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(java.awt.Color.white); // Write the chart image to the temporary directory ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); filename = ServletUtilities.saveChartAsPNG(chart, 600, 400, info, session); // Write the image map to the PrintWriter ChartUtilities.writeImageMap(pw, filename, info); pw.flush(); } catch (NoDataException e) { System.out.println(e.toString()); filename = "public_nodata_500x300.png"; } catch (Exception e) { System.out.println("Exception - " + e.toString()); e.printStackTrace(System.out); filename = "public_error_500x300.png"; } return filename; }
public ChartWindow(String title) { this.symbol = title; thisp = this; // initialize the main layout setTitle(title); mainpanel = new JPanel(); GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); mainpanel.setLayout(gbl); // build a toolbar // add a plain status bar this.statusLine = new JLabel("Done"); this.getContentPane().add(statusLine, BorderLayout.SOUTH); statusLine.setBackground(new Color(0, 0, 0)); statusLine.setForeground(new Color(255, 255, 255)); statusLine.setOpaque(true); // x1 = new TimeSeries("symbol", FixedMillisecond.class); dataset1.addSeries(x1); System.out.println("Populated."); // chart = createChart(dataset1); System.out.println("constr."); // chart.getXYPlot().setOrientation(PlotOrientation.VERTICAL); chart.setAntiAlias(false); chartPanel = new ChartPanel(chart); // int i = 0; gbc.anchor = gbc.NORTHWEST; gbc.fill = gbc.BOTH; gbc.weightx = 1; gbc.gridx = 0; gbc.weighty = 1; gbc.gridy = i; gbl.setConstraints(chartPanel, gbc); mainpanel.add(chartPanel); // System.out.println("add"); setVisible(true); setSize(new Dimension(400, 300)); // chartPanel.setPopupMenu(buildPopupMenu()); chartPanel.setMouseZoomable(true); chartPanel.setHorizontalAxisTrace(true); chartPanel.setVerticalAxisTrace(true); chartPanel.setHorizontalZoom(true); chartPanel.setOpaque(true); chartPanel.setBackground(new Color(0, 0, 0)); this.getContentPane().add(mainpanel, BorderLayout.CENTER); this.setSize(600, 400); this.toFront(); this.show(); }
/** converts data into a candlestick chart */ public void convert() { chart.setAntiAlias(false); chartPanel.setChart(chart); }
public String generateXYChart( String section, HttpSession session, PrintWriter pw, String courseId, int studentId) { /*int groupId=0; if (groupName.equals("All")){ groupId=0; }else{ groupId = studStatisticBean.getGroupIdByName(groupName); }*/ String filename = null; try { // Retrieve list of WebHits StudentsConceptChartDataSet cDataSet = new StudentsConceptChartDataSet(studStatisticBean, courseId, studentId); ArrayList list = cDataSet.getDataByHitConcept(section); // Throw a custom NoDataException if there is no data if (list.size() == 0) { System.out.println("No data has been found"); throw new NoDataException(); } // Create and populate an XYSeries Collection XYSeries dataSeries = new XYSeries("Students progress line"); Iterator iter = list.listIterator(); while (iter.hasNext()) { StudentsConceptHit ch = (StudentsConceptHit) iter.next(); dataSeries.add(ch.getOrdNumb(), ch.getHitDegree()); } XYSeriesCollection xyDataset = new XYSeriesCollection(dataSeries); NumberFormat nf = NumberFormat.getIntegerInstance(); NumberFormat nf2 = NumberFormat.getInstance(); String cTitle = null; // StandardXYToolTipGenerator ttg = new // StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,nf,nf2); CustomXYToolTipGenerator ttg = new CustomXYToolTipGenerator(); ttg.addToolTipSeries(cDataSet.getConceptNames()); StandardXYURLGenerator sxyUrlGen = new StandardXYURLGenerator("#", xyDataset.getSeriesName(0), "PassedConceptOrdNum"); ValueAxis ordNumAxis = new NumberAxis("Concept ordinal number"); NumberAxis valueAxis = new NumberAxis("Current knowledge"); // valueAxis.setAutoRangeIncludesZero(true); valueAxis.setRange(0.0, 6.0); // override default ordNumAxis.setAutoRange(true); ordNumAxis.setLowerMargin(0.0); StandardXYItemRenderer renderer = new StandardXYItemRenderer( StandardXYItemRenderer.LINES + StandardXYItemRenderer.SHAPES, ttg, sxyUrlGen); Marker marker = new ValueMarker(1.50); // / Marker marker2 = new ValueMarker(2.50); Marker marker3 = new ValueMarker(3.50); Marker marker4 = new ValueMarker(4.50); Marker marker5 = new ValueMarker(5.00); renderer.setShapesFilled(true); XYPlot plot = new XYPlot(xyDataset, ordNumAxis, valueAxis, renderer); plot.addRangeMarker(marker); plot.addRangeMarker(marker2); plot.addRangeMarker(marker3); plot.addRangeMarker(marker4); plot.addRangeMarker(marker5); XYTextAnnotation xyBad = new XYTextAnnotation("Bad", 1, 1); xyBad.setX(0.2); xyBad.setY(0.75); XYTextAnnotation xyNotBad = new XYTextAnnotation("Not Bad", 1, 1); xyNotBad.setX(0.2); xyNotBad.setY(2); XYTextAnnotation xyGood = new XYTextAnnotation("Good", 1, 1); xyGood.setX(0.2); xyGood.setY(3); XYTextAnnotation xyVeryGood = new XYTextAnnotation("Very Good", 1, 1); xyVeryGood.setX(0.2); xyVeryGood.setY(4); XYTextAnnotation xyExcellent = new XYTextAnnotation("Excellent", 1, 1); xyExcellent.setX(0.2); xyExcellent.setY(4.75); XYTextAnnotation xyExpert = new XYTextAnnotation("Expert", 1, 1); xyExpert.setX(0.2); xyExpert.setY(5.25); plot.addAnnotation(xyBad); plot.addAnnotation(xyNotBad); plot.addAnnotation(xyGood); plot.addAnnotation(xyVeryGood); plot.addAnnotation(xyExcellent); plot.addAnnotation(xyExpert); JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(java.awt.Color.white); // Write the chart image to the temporary directory ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); filename = ServletUtilities.saveChartAsPNG(chart, 600, 400, info, session); // Write the image map to the PrintWriter ChartUtilities.writeImageMap(pw, filename, info); pw.flush(); } catch (NoDataException e) { System.out.println(e.toString()); filename = "public_nodata_500x300.png"; } catch (Exception e) { System.out.println("Exception - " + e.toString()); e.printStackTrace(System.out); filename = "public_error_500x300.png"; } return filename; }
/** * Returns a sequence plot as a ChartPanel. * * @param aProteinSequencePanelParent the protein sequence panel parent * @param sparklineDataset the dataset * @param proteinAnnotations the protein annotations * @param addReferenceLine if true, a reference line is added * @param allowZooming if true, the user can zoom in the created plot/chart * @return a sequence plot */ public ChartPanel getSequencePlot( ProteinSequencePanelParent aProteinSequencePanelParent, JSparklinesDataset sparklineDataset, HashMap<Integer, ArrayList<ResidueAnnotation>> proteinAnnotations, boolean addReferenceLine, boolean allowZooming) { this.proteinSequencePanelParent = aProteinSequencePanelParent; DefaultCategoryDataset barChartDataset = new DefaultCategoryDataset(); StackedBarRenderer renderer = new StackedBarRenderer(); renderer.setShadowVisible(false); CategoryToolTipGenerator myTooltips = new ProteinAnnotations(proteinAnnotations); // add the data for (int i = 0; i < sparklineDataset.getData().size(); i++) { JSparklinesDataSeries sparklineDataSeries = sparklineDataset.getData().get(i); for (int j = 0; j < sparklineDataSeries.getData().size(); j++) { barChartDataset.addValue(sparklineDataSeries.getData().get(j), "" + i, "" + j); renderer.setSeriesPaint(i, sparklineDataSeries.getSeriesColor()); renderer.setSeriesToolTipGenerator(i, myTooltips); } } // create the chart JFreeChart chart = ChartFactory.createStackedBarChart( null, null, null, barChartDataset, PlotOrientation.HORIZONTAL, false, false, false); // fine tune the chart properites CategoryPlot plot = chart.getCategoryPlot(); // remove space before/after the domain axis plot.getDomainAxis().setUpperMargin(0); plot.getDomainAxis().setLowerMargin(0); // remove space before/after the range axis plot.getRangeAxis().setUpperMargin(0); plot.getRangeAxis().setLowerMargin(0); renderer.setRenderAsPercentages(true); renderer.setBaseToolTipGenerator(new IntervalCategoryToolTipGenerator()); // add the dataset to the plot plot.setDataset(barChartDataset); // hide unwanted chart details plot.getRangeAxis().setVisible(false); plot.getDomainAxis().setVisible(false); plot.setRangeGridlinesVisible(false); plot.setDomainGridlinesVisible(false); // add a reference line in the middle of the dataset if (addReferenceLine) { DefaultCategoryDataset referenceLineDataset = new DefaultCategoryDataset(); referenceLineDataset.addValue(1.0, "A", "B"); plot.setDataset(1, referenceLineDataset); LayeredBarRenderer referenceLineRenderer = new LayeredBarRenderer(); referenceLineRenderer.setSeriesBarWidth(0, referenceLineWidth); referenceLineRenderer.setSeriesFillPaint(0, referenceLineColor); referenceLineRenderer.setSeriesPaint(0, referenceLineColor); plot.setRenderer(1, referenceLineRenderer); } // set up the chart renderer plot.setRenderer(0, renderer); // hide the outline chart.getPlot().setOutlineVisible(false); // make sure the background is the same as the panel chart.getPlot().setBackgroundPaint(backgroundColor); chart.setBackgroundPaint(backgroundColor); final HashMap<Integer, ArrayList<ResidueAnnotation>> blockTooltips = proteinAnnotations; // create the chart panel ChartPanel chartPanel = new ChartPanel(chart); chartPanel.addChartMouseListener( new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent cme) { if (cme.getEntity() != null && cme.getTrigger().getButton() == MouseEvent.BUTTON1) { ((CategoryItemEntity) cme.getEntity()).getDataset(); Integer blockNumber = new Integer((String) ((CategoryItemEntity) cme.getEntity()).getRowKey()); ArrayList<ResidueAnnotation> annotation = blockTooltips.get(blockNumber); if (annotation != null) { proteinSequencePanelParent.annotationClicked(annotation, cme); } } } @Override public void chartMouseMoved(ChartMouseEvent cme) { cme.getTrigger() .getComponent() .setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); if (cme.getEntity() != null && cme.getEntity() instanceof CategoryItemEntity) { ((CategoryItemEntity) cme.getEntity()).getDataset(); Integer blockNumber = new Integer((String) ((CategoryItemEntity) cme.getEntity()).getRowKey()); ArrayList<ResidueAnnotation> annotation = blockTooltips.get(blockNumber); if (annotation != null && !annotation.isEmpty()) { if (blockTooltips.get(blockNumber).get(0).isClickable()) { cme.getTrigger() .getComponent() .setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); } } } } }); if (!allowZooming) { chartPanel.setPopupMenu(null); chartPanel.setRangeZoomable(false); } chartPanel.setBackground(Color.WHITE); return chartPanel; }
public String generateBarChart( String hitSection, HttpSession session, PrintWriter pw, String courseId, int studentId) { /* int groupId=0; if (groupName.equals("All")){ groupId=0; }else{ groupId = studStatisticBean.getGroupIdByName(groupName); }*/ String filename = null; try { // Retrieve list of WebHits StudentsConceptChartDataSet cDataSet = new StudentsConceptChartDataSet(studStatisticBean, courseId, studentId); ArrayList list = cDataSet.getDataBySection(hitSection); // Throw a custom NoDataException if there is no data if (list.size() == 0) { System.out.println("No data has been found"); throw new NoDataException(); } // Create and populate a CategoryDataset Iterator iter = list.listIterator(); DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); while (iter.hasNext()) { StudentsConceptHit wh = (StudentsConceptHit) iter.next(); // Comparable c1= Double.parseDouble(wh.getHitDegree()); dataSet.addValue( wh.getHitDegree(), "degree of mastery for concept ", String.valueOf(wh.getHitConcept())); } // Create the chart object CategoryAxis categoryAxis = new CategoryAxis("Concepts"); ValueAxis valueAxis = new NumberAxis("Degree of Mastery"); valueAxis.setRange(0.0, 6.0); categoryAxis.setCategoryLabelPositions( new CategoryLabelPositions().createUpRotationLabelPositions(45)); BarRenderer renderer = new BarRenderer(); renderer.setDrawBarOutline(true); renderer.setItemURLGenerator( new StandardCategoryURLGenerator("xy_chart.jsp", "series", "section")); StandardCategoryToolTipGenerator scttg = new StandardCategoryToolTipGenerator(); renderer.setToolTipGenerator(scttg); Plot plot = new CategoryPlot(dataSet, categoryAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(java.awt.Color.white); // Write the chart image to the temporary directory ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); filename = ServletUtilities.saveChartAsPNG(chart, 600, 400, info, session); // Write the image map to the PrintWriter ChartUtilities.writeImageMap(pw, filename, info); pw.flush(); } catch (NoDataException e) { System.out.println(e.toString()); filename = "public_nodata_500x300.png"; } catch (Exception e) { System.out.println("Exception - " + e.toString()); e.printStackTrace(System.out); filename = "public_error_500x300.png"; } return filename; }
private void addData( JFreeChart chart, DSLAMSource source, Timeinterval time, Serializable filter, Properties properties, Map<String, Object> colorScheme, Properties outputProperties) throws IOException { if (chart != null) { PerformanceCounterDataCollection cData = null; long dataSize = 0; try { cData = getPerformanceCounterDataCollection(source, time, filter, properties, outputProperties); Collection<PerformanceCounterData> data = null; Date d0 = null; // first timestamp for data Date d1 = null; // last timestamp for data RegularTimePeriod time0 = null; if (cData != null) { data = cData.getData(); { int l = data.size(); outputProperties.setProperty("data.count", Integer.toString(l)); } if (data != null && data.size() > 0) { dataSize = data.size(); // Set 'd0': { // TODO: Avoid assumption "data is sorted"! PerformanceCounterData e = data.iterator().next(); d0 = e.getTimestamp(); } // Set 'd1': { // TODO: Avoid assumption "data is sorted"! for (PerformanceCounterData e : data) { d1 = e.getTimestamp(); } } time0 = createRegularTimePeriod(d0); } } XYPlot plot = chart.getXYPlot(); // Set the first dataset: { TimeSeriesCollection dataset = new TimeSeriesCollection(); List<Paint> seriesPaint = new ArrayList<Paint>(); List<Stroke> seriesStroke = new ArrayList<Stroke>(); // Add series 'ES': { if (data != null && data.size() > 0) { TimeSeries series = new TimeSeries("ES", time0.getClass()); for (PerformanceCounterData e : data) { Date d = e.getTimestamp(); RegularTimePeriod timePeriod = createRegularTimePeriod(d); // Add point: { int value = getES(e); addOrUpdate(series, timePeriod, (double) value); } } seriesPaint.add((Paint) colorScheme.get("color.counter.es")); seriesStroke.add(STROKE_COUNTER_ES); dataset.addSeries(series); } } // Add series 'SES': { if (data != null && data.size() > 0) { TimeSeries series = new TimeSeries("SES", time0.getClass()); for (PerformanceCounterData e : data) { Date d = e.getTimestamp(); RegularTimePeriod timePeriod = createRegularTimePeriod(d); // Add point: { int value = getSES(e); addOrUpdate(series, timePeriod, (double) value); } } seriesPaint.add((Paint) colorScheme.get("color.counter.ses")); seriesStroke.add(STROKE_COUNTER_SES); dataset.addSeries(series); } } // Add series 'US': { if (data != null && data.size() > 0) { TimeSeries series = new TimeSeries("US", time0.getClass()); for (PerformanceCounterData e : data) { Date d = e.getTimestamp(); RegularTimePeriod timePeriod = createRegularTimePeriod(d); // Add point: { int value = getUS(e); addOrUpdate(series, timePeriod, (double) value); } } seriesPaint.add((Paint) colorScheme.get("color.counter.us")); seriesStroke.add(STROKE_COUNTER_US); dataset.addSeries(series); } } // superspeed { if (data != null && data.size() > 0) { TimeSeries series = new TimeSeries("LEFTRS", time0.getClass()); for (PerformanceCounterData e : data) { Date d = e.getTimestamp(); RegularTimePeriod timePeriod = createRegularTimePeriod(d); { int value = getPreviousLEFTRS(e); addOrUpdate(series, timePeriod, (double) value); } } seriesPaint.add((Paint) colorScheme.get("color.counter.previousleftrs")); seriesStroke.add(STROKE_COUNTER_US); dataset.addSeries(series); } } // ends { if (data != null && data.size() > 0) { boolean showLinearCurve = getShowLinearCurve(); if (showLinearCurve) { // Add series for a linear curve: { TimeSeries series = new TimeSeries("Linear", time0.getClass()); long t0 = d0.getTime(); long t1 = d1.getTime(); if (t0 < t1) { long timeX = 15 * 60 * 1000; // 15 minutes intervals // TODO: Read length of intervals from obtained data! double value0 = 0; double value1 = 900; // TODO: Read '900' from obtained data! long timeDelta = t1 - t0; double valueDelta = value1 - value0; long t = t0; int i = 0; while (t <= t1) { Date d = new Date(t); RegularTimePeriod timePeriod = createRegularTimePeriod(d); double value = value0 + ((t - t0) * valueDelta) / timeDelta; // Add point: { addOrUpdate(series, timePeriod, (double) value); } t += timeX; i += 1; } } seriesPaint.add(Color.red); seriesStroke.add(STROKE_COUNTER_DEFAULT); dataset.addSeries(series); } } } } setDefaultRenderer(chart, colorScheme, 0, seriesPaint, seriesStroke); plot.setDataset(0, dataset); plot.mapDatasetToRangeAxis(0, 0); } } finally { if (cData != null) { cData.dispose(); cData = null; } } if (outputProperties != null) { outputProperties.setProperty("data.count", Long.toString(dataSize)); } } }