/** * Creates a chart. * * @param dataset the dataset. * @return a chart. */ AFreeChart createChart(XYDataset dataset) { AFreeChart chart = ChartFactory.createTimeSeriesChart( "Heart Data Report", // title "heart data", // (red-systolic,blue-diastolic,green-heart-rate)", // x-axis // label "value", // y-axis label dataset, // data true, // create legend? true, false // generate URLs? ); chart.setBackgroundPaintType(new SolidColor(Color.GREEN)); // chart.setBackgroundPaintType( Color.GREEN); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaintType(new SolidColor(Color.LTGRAY)); plot.setDomainGridlinePaintType(new SolidColor(Color.WHITE)); plot.setRangeGridlinePaintType(new SolidColor(Color.WHITE)); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("yyyy/MM/dd/HH:mm:ss")); // MMM-yyyy")); //////////////////////////////// // plot.setLabelFont(new Font("SansSerif", Typeface.NORMAL, 12)); // plot.setNoDataMessage("No data available"); // plot.setCircular(false); // plot.setLabelGap(0.02); return chart; }