public void start(Stage stage) throws ParseException { stage.setTitle("Line Chart Sample"); final DateAxis xAxis = new DateAxis(); final NumberAxis yAxis = new NumberAxis(); xAxis.setLabel("Date");
DateAxis y = new DateAxis("Y") { @Override protected Date previousStandardDate(Date date, DateTickUnit unit) { Date prevDate = super.previousStandardDate(date, unit); Calendar calendar = Calendar.getInstance(TimeZone.getDefault()); calendar.setTime(prevDate); int firstDayOfWeek = calendar.getFirstDayOfWeek(); if (firstDayOfWeek != calendar.get(Calendar.DAY_OF_WEEK)) { calendar.set(Calendar.DAY_OF_WEEK, firstDayOfWeek); } return calendar.getTime(); } };
DateAxis axis = new DateAxis("Hour"); SimpleDateFormat format = new SimpleDateFormat("H"); format.setTimeZone(TimeZone.getTimeZone("GMT")); axis.setDateFormatOverride(format);
DateAxis y = new DateAxis("Y") { @Override protected Date previousStandardDate(Date date, DateTickUnit unit) { Date prevDate = super.previousStandardDate(date, unit); Calendar calendar = Calendar.getInstance(); calendar.setTime(prevDate); int showDayOfWeek = Calendar.TUESDAY; calendar.setFirstDayOfWeek(showDayOfWeek); if (showDayOfWeek != calendar.get(Calendar.DAY_OF_WEEK)) { calendar.set(Calendar.DAY_OF_WEEK, showDayOfWeek); } return calendar.getTime(); } };
DateAxis dateAxis = new DateAxis("Time"); dateAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm")); categoryplot.setRangeAxis(dateAxis);
XYPlot plot = chart.getXYPlot(); DateAxis axis = new DateAxis(); plot.setDomainAxis(axis); axis.setDateFormatOverride(new SimpleDateFormat("yyyy"));
XYPlot plot = (XYPlot) chart.getPlot(); DateAxis dateAxis = new DateAxis(); dateAxis.setDateFormatOverride(new SimpleDateFormat("dd-MM-yyyy")); plot.setDomainAxis(dateAxis);
XYPlot plot = chart.getXYPlot(); DateAxis axis = new DateAxis(); plot.setDomainAxis(axis); axis.setDateFormatOverride(new SimpleDateFormat("mm:ss.S"));
NumberAxis domain = new NumberAxis("X"); DateAxis range = new DateAxis("Y"); domain.setAutoRangeIncludesZero(false); XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false); XYPlot plot = new XYPlot(dataset, domain, range, renderer); JFreeChart chart = new JFreeChart( "Title", JFreeChart.DEFAULT_TITLE_FONT, plot, false);
SegmentedTimeline timeline = new SegmentedTimeline( 86400000l, // segment size = one day in ms (24*3600*1000) 5, // include 5 segments (days) 2); // exclude 2 segments (days) DateAxis axis = new DateAxis(); axis.setTimeline(timeline);
private ValueAxis createAxis(int dataType) { ValueAxis axis; if (ProductData.TYPE_UTC == dataType) { axis = new DateAxis("Date", TimeZone.getTimeZone("UTC"), Locale.ENGLISH); ((DateAxis) axis).setDateFormatOverride(SIMPLE_DATE_FORMAT); } else { axis = new NumberAxis(); ((NumberAxis) axis).setAutoRangeIncludesZero(false); } return axis; }
static DateAxis createTimeAxis( String label, SimpleDateFormat dateFormat ) { DateAxis timeAxis = new DateAxis( label ); timeAxis.setDateFormatOverride( dateFormat ); timeAxis.setLowerMargin( MARGIN ); timeAxis.setUpperMargin( MARGIN ); return timeAxis; }
private static ValueAxis createDateAxis() { DateAxis timeAxis = new DateAxis("Timestamp (" + DATE_FORMAT + ")"); SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); timeAxis.setDateFormatOverride(sdf); timeAxis.setLowerMargin(0D); timeAxis.setUpperMargin(0D); timeAxis.setAutoRange(true); timeAxis.setStandardTickUnits(DateAxis.createStandardDateTickUnits()); return defaultAxis(timeAxis); }
private static JFreeChart createChart() { CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis("Date/Time")); plot.setDomainPannable(true); plot.add(createSubplot1(createDataset1())); plot.add(createSubplot2(createDataset2())); // Get the horizontal Axis for the plot DateAxis axis = (DateAxis) plot.getDomainAxis(); // Change the unit tick to 5 hours axis.setTickUnit(new DateTickUnit(DateTickUnitType.HOUR, 5)); // Change the date format used to display tick values axis.setDateFormatOverride(new SimpleDateFormat("hh:mm")); JFreeChart chart = new JFreeChart("XYTaskDatasetDemo2", plot); chart.setBackgroundPaint(Color.white); ChartUtilities.applyCurrentTheme(chart); return chart; }
private JFreeChart createChart(TimeTableXYDataset chartData) { JFreeChart chart = ChartFactory.createStackedXYAreaChart( "Dogs and Cats", "Time", "Count", chartData, PlotOrientation.VERTICAL, false, true, false); DateAxis dateAxis = new DateAxis(); dateAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm")); dateAxis.setTickLabelFont(dateAxis.getTickLabelFont().deriveFont(20f)); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainAxis(dateAxis); return chart; }
public XYChartBuilder setDateXAxis(final boolean showAxisValues) { xAxis = new DateAxis(); ((DateAxis) xAxis).setTickMarkPosition(DateTickMarkPosition.MIDDLE); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); xAxis.setVisible(showAxisValues); plot.setDomainAxis(xAxis); return this; }
public static JFreeChart createTimeSeriesChart( XYDataset dataset, String title, String timeAxisLabel, String valueAxisLabel ) { ValueAxis timeAxis = new DateAxis( timeAxisLabel, TimeZone.getTimeZone( "GMT" ), Locale.getDefault() ); timeAxis.setLowerMargin( 0.02d ); timeAxis.setUpperMargin( 0.02d ); NumberAxis valueAxis = new NumberAxis( valueAxisLabel ); valueAxis.setAutoRangeIncludesZero( false ); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer( true, false ); XYToolTipGenerator toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance(); renderer.setBaseToolTipGenerator( toolTipGenerator ); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); plot.setRenderer( renderer ); boolean addLegend = true; return new JFreeChart( title, JFreeChart.DEFAULT_TITLE_FONT, plot, addLegend ); }
private JFreeChart createXYLineChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, boolean legend, boolean includeZero) { DateAxis xAxis = new DateAxis(xAxisLabel); xAxis.setDateFormatOverride(AXIS_DATE_FORMAT); NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setAutoRangeIncludesZero(includeZero); XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); }
private JFreeChart createBarChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, boolean legend) { DateAxis xAxis = new DateAxis(xAxisLabel); xAxis.setDateFormatOverride(AXIS_DATE_FORMAT); NumberAxis yAxis = new NumberAxis(yAxisLabel); XYBarRenderer renderer = new XYBarRenderer(); renderer.setShadowVisible(false); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); } }