Refine search
XYPlot plot = chart.getXYPlot(); DateAxis axis = new DateAxis(); plot.setDomainAxis(axis); axis.setDateFormatOverride(new SimpleDateFormat("yyyy"));
DateAxis dateAxis = new DateAxis(timeAxisTitle); DateTickUnit unit = null; unit = new DateTickUnit(DateTickUnit.MINUTE,15); DateFormat chartFormatter = new SimpleDateFormat("yyyy/MM/dd HH:mm"); dateAxis.setDateFormatOverride(chartFormatter); dateAxis.setTickUnit(unit); NumberAxis valueAxis = new NumberAxis(valueAxisTitle);
/** * Sets the axis range and sends an {@link AxisChangeEvent} to all * registered listeners. * * @param lower the lower bound for the axis. * @param upper the upper bound for the axis. */ public void setRange(Date lower, Date upper) { if (lower.getTime() >= upper.getTime()) { throw new IllegalArgumentException("Requires 'lower' < 'upper'."); } setRange(new DateRange(lower, upper)); }
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"); yAxis.setLabel("Events"); SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MMM/yyyy");
static DateAxis createTimeAxis( String label, SimpleDateFormat dateFormat ) { DateAxis timeAxis = new DateAxis( label ); timeAxis.setDateFormatOverride( dateFormat ); timeAxis.setLowerMargin( MARGIN ); timeAxis.setUpperMargin( MARGIN ); return timeAxis; }
/** * Sets the minimum date visible on the axis and sends an * {@link AxisChangeEvent} to all registered listeners. If * {@code date} is on or after the current maximum date for * the axis, the maximum date will be shifted to preserve the current * length of the axis. * * @param date the date ({@code null} not permitted). * * @see #getMinimumDate() * @see #setMaximumDate(Date) */ public void setMinimumDate(Date date) { Args.nullNotPermitted(date, "date"); // check the new minimum date relative to the current maximum date Date maxDate = getMaximumDate(); long maxMillis = maxDate.getTime(); long newMinMillis = date.getTime(); if (maxMillis <= newMinMillis) { Date oldMin = getMinimumDate(); long length = maxMillis - oldMin.getTime(); maxDate = new Date(newMinMillis + length); } setRange(new DateRange(date, maxDate), true, false); fireChangeEvent(); }
/** * Sets the minimum date visible on the axis and sends an * {@link AxisChangeEvent} to all registered listeners. If * <code>date</code> is on or after the current maximum date for * the axis, the maximum date will be shifted to preserve the current * length of the axis. * * @param date the date (<code>null</code> not permitted). * * @see #getMinimumDate() * @see #setMaximumDate(Date) */ public void setMinimumDate(Date date) { if (date == null) { throw new IllegalArgumentException("Null 'date' argument."); } // check the new minimum date relative to the current maximum date Date maxDate = getMaximumDate(); long maxMillis = maxDate.getTime(); long newMinMillis = date.getTime(); if (maxMillis <= newMinMillis) { Date oldMin = getMinimumDate(); long length = maxMillis - oldMin.getTime(); maxDate = new Date(newMinMillis + length); } setRange(new DateRange(date, maxDate), true, false); notifyListeners(new AxisChangeEvent(this)); }
private final long t = new Date().getTime(); "Test", "Day", "Value", dataset, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); DateAxis domain = (DateAxis) plot.getDomainAxis(); domain.setDateFormatOverride(DateFormat.getDateInstance()); return chart;
chartStartDate = new Date(1477461600000L); chartEndDate = new Date(1477497600000L); chart = createIntervalStackedChart(); ChartPanel chartPanel = new ChartPanel(chart); xyRend.setSeriesPaint(5, Color.GREEN); dateAxis = new DateAxis(); dateAxis.setVerticalTickLabels(true); dateAxis.setDateFormatOverride(new SimpleDateFormat("dd.MM.yy HH:mm")); XYPlot plot = new XYPlot(dataset, new SymbolAxis("", catArray), dateAxis, xyRend); plot.setOrientation(PlotOrientation.HORIZONTAL); plot.setBackgroundPaint(Color.LIGHT_GRAY); return new JFreeChart(plot);
private CombinedDomainXYPlot plot; private Timer timer; private Day now = new Day(new Date()); chart = new JFreeChart("Title", JFreeChart.DEFAULT_TITLE_FONT, plot, true); plot.setDomainAxis(new DateAxis("Domain")); subplotTop = new XYPlot(); subplotBottom = new XYPlot(); subplotTop.setDataset(emptyDataset("Set 1")); subplotTop.setRenderer(new XYLineAndShapeRenderer()); subplotTop.setRangeAxis(new NumberAxis("Range")); subplotBottom.setDataset(emptyDataset("Set 2")); subplotBottom.setRenderer(new XYLineAndShapeRenderer()); subplotBottom.setRangeAxis(new NumberAxis("Range"));
protected void autoAdjustRange() { Plot plot = getPlot(); (long) r.getUpperBound()); long lower; long fixedAutoRange = (long) getFixedAutoRange(); if (fixedAutoRange > 0.0) { lower = upper - fixedAutoRange; lower = this.timeline.toTimelineValue((long) r.getLowerBound()); double range = upper - lower; long minRange = (long) getAutoRangeMinimumSize(); if (range < minRange) { long expand = (long) (minRange - range) / 2; lower = lower - expand; upper = upper + (long) (range * getUpperMargin()); lower = lower - (long) (range * getLowerMargin()); DateRange dr = new DateRange(new Date(lower), new Date(upper)); setRange(dr, false, false);
private JFreeChart createAmountChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart( "", // title resourceMap.getString("graphDate.text"), // x-axis label resourceMap.getString("graphCBills.text"), // y-axis label dataset); chart.setBackgroundPaint(Color.WHITE); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(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.setDefaultShapesVisible(true); renderer.setDefaultShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); chart.removeLegend(); return chart; }
XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setDefaultShapesVisible(true); renderer.setDefaultShapesFilled(true); renderer.setDefaultToolTipGenerator(new StandardXYToolTipGenerator(toolTipFormat, new SimpleDateFormat( dateFormatTooltip), new DecimalFormat()) { @Override lGraphColors.add(ColorUtils.toAwtColor(sportType.getColor())); plot.setDataset(1, dataset); stackedRenderer.setSeriesPaint(i, tempColor); stackedRenderer.setDefaultToolTipGenerator(new StandardXYToolTipGenerator(toolTipFormat, new SimpleDateFormat( dateFormatTooltip), new DecimalFormat()) { @Override plot.setRenderer(1, stackedRenderer); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat(dateFormatAxis)); if (dateTickUnit != null) { axis.setTickUnit(dateTickUnit); chart.getLegend().setPosition(RectangleEdge.RIGHT);
jobInSchedule = true; XYPlot plot = (XYPlot) chart.getPlot(); DateAxis axis = (DateAxis) plot.getDomainAxis(); final Date minDate = axis.getMinimumDate(); final Date maxDate = autoUpdate ? new Date(System.currentTimeMillis()) : axis.getMaximumDate(); if (autoUpdate) { axis.setMaximumDate(maxDate);
JFreeChart chart = ChartFactory.createScatterPlot("Inventory", "Date", "Count", jds, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = chart.getXYPlot(); plot.setDomainAxis(new DateAxis("Date")); f.add(new ChartPanel(chart)); f.pack(); f.setVisible(true); for (int i = 0; i < jds.getItemCount(); i++) { System.out.println(new Date(jds.getX(0, i).longValue()));
timeSeriesCollection.addSeries(series ); this.domainAxis = new DateAxis("Time"); NumberAxis rangeAxis = new NumberAxis(""); XYBarRenderer renderer = new XYBarRenderer(); renderer.setShadowVisible(false); Day d = new Day(new Date()); RegularTimePeriod regularTimePeriod = d.next(); for (int index = 0; index < domainCount; index++) { public void stateChanged(ChangeEvent event) { int value = this.slider.getValue(); long minimum = domainAxis.getMinimumDate().getTime(); long maximum = domainAxis.getMaximumDate().getTime(); if (value<lastValue) { // left minimum = minimum - delta; domainAxis.setRange(range); lastValue = value;
renderer1.setSeriesPaint(0, Color.BLUE); DateAxis domainAxis = new DateAxis(""); domainAxis.setTickUnit (new DateTickUnit (DateTickUnit.DAY, 7, new SimpleDateFormat ("yyyy-MM-dd"))); domainAxis.setTickMarkPosition (DateTickMarkPosition.START); domainAxis.setVerticalTickLabels (true); domainAxis.setLowerMargin (0.01); domainAxis.setUpperMargin (0.01); NumberAxis rangeAxis = new NumberAxis("count"); rangeAxis.setStandardTickUnits (NumberAxis.createIntegerTickUnits ()); XYPlot plot1 = new XYPlot(dataset1, null, rangeAxis, renderer1); plot1.setBackgroundPaint(Color.lightGray); plot1.setDomainGridlinePaint(Color.white); plot1.setRangeGridlinePaint(Color.white); JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, cplot, false); LegendTitle legend = new LegendTitle(cplot); chart.addSubtitle(legend); chart.setBackgroundPaint (parseColor (statsManager.getChartBackgroundColor ()));
public JFreeChart createStackedBarChart(String title, XYDataset dataset) { DateAxis domainAxis = new DateAxis("Date"); domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); domainAxis.setLowerMargin(0.01); domainAxis.setUpperMargin(0.01); NumberAxis rangeAxis = new NumberAxis("Hours"); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperMargin(0.10); // leave some space for item labels StackedXYBarRenderer renderer = new StackedXYBarRenderer(0.15); // StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(); renderer.setDrawBarOutline(false); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER)); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0} : {1} = {2}", new SimpleDateFormat("yyyy"), new DecimalFormat("0"))); XYPlot plot = new XYPlot(dataset, domainAxis, rangeAxis, renderer); JFreeChart chart = new JFreeChart(title, plot); chart.removeLegend(); chart.setTextAntiAlias(RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT); LegendTitle legend = new LegendTitle(plot); legend.setBackgroundPaint(Color.white); legend.setFrame(new BlockBorder()); legend.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(legend); return chart; }
false // generate URLs? ); XYPlot plot = (XYPlot) chart.getPlot(); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MM-dd HH:mm"));
private void configureTimeAxis(XYPlot plot) { DateAxis timeAxis = (DateAxis) plot.getDomainAxis(); final Date start = getStartTime(getTimespan()); final Date end = getEndTime(getTimespan()); timeAxis.setRange(start, end); final Locale locale = i18n.getLocale(); IoParameters parameters = getParameters(); String timeformat = parameters.getTimeFormat(); DateFormat requestTimeFormat = new SimpleDateFormat(timeformat, locale); final DateTimeZone timezone = getTimezone(); requestTimeFormat.setTimeZone(timezone.toTimeZone()); timeAxis.setDateFormatOverride(requestTimeFormat); timeAxis.setTimeZone(timezone.toTimeZone()); }