private void plotSeperate(XYDataset dataset, String p) { NumberAxis rangeAxis1 = new NumberAxis(p); rangeAxis1.setAutoRangeIncludesZero(false); // override default rangeAxis1.setLowerMargin(0.40); // to leave room for volume bars DecimalFormat format = new DecimalFormat("0"); rangeAxis1.setNumberFormatOverride(format); final ValueAxis timeAxis = new DateAxis("Date"); timeAxis.setLowerMargin(0.02); // reduce the default margins timeAxis.setUpperMargin(0.02); XYPlot plot = new XYPlot(dataset, timeAxis, rangeAxis1, null); XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false); renderer1.setBaseToolTipGenerator( new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00#") ) ); plot.setRenderer(0, renderer1); final CombinedDomainXYPlot cplot1 = (CombinedDomainXYPlot)this.candlestickChart.getPlot(); if (plot != null) cplot1.add(plot, 1); // weight is 1. }
/** * Creates and returns a default instance of a candlesticks chart. * * @param title the chart title (<code>null</code> permitted). * @param timeAxisLabel a label for the time axis (<code>null</code> permitted). * @param valueAxisLabel a label for the value axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * * @return a candlestick chart. */ public static JFreeChart createCandlestickChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); plot.setRenderer(new CandlestickRenderer()); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
/** * Creates and returns a default instance of a high-low-open-close chart. * * @param title the chart title (<code>null</code> permitted). * @param timeAxisLabel a label for the time axis (<code>null</code> permitted). * @param valueAxisLabel a label for the value axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * * @return a high-low-open-close chart. */ public static JFreeChart createHighLowChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); HighLowRenderer renderer = new HighLowRenderer(); renderer.setToolTipGenerator(new HighLowItemLabelGenerator()); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
/** * Creates and returns a default instance of a high-low-open-close chart with * a special timeline. This timeline can be a {@link org.jfree.chart.axis.SegmentedTimeline} * such as the Monday trough Friday timeline that will remove Saturdays and Sundays from * the axis. * * @param title the chart title (<code>null</code> permitted). * @param timeAxisLabel a label for the time axis (<code>null</code> permitted). * @param valueAxisLabel a label for the value axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param timeline the timeline. * @param legend a flag specifying whether or not a legend is required. * * @return a high-low-open-close chart. */ public static JFreeChart createHighLowChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, Timeline timeline, boolean legend) { DateAxis timeAxis = new DateAxis(timeAxisLabel); timeAxis.setTimeline(timeline); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); HighLowRenderer renderer = new HighLowRenderer(); renderer.setToolTipGenerator(new HighLowItemLabelGenerator()); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
/** * Creates and returns a default instance of a signal chart. * * @param title the chart title (<code>null</code> permitted). * @param timeAxisLabel a label for the time axis (<code>null</code> permitted). * @param valueAxisLabel a label for the value axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * * @return a signal chart. */ public static JFreeChart createSignalChart(String title, String timeAxisLabel, String valueAxisLabel, SignalsDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); plot.setRenderer(new SignalRenderer()); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
/** * Creates and returns a default instance of a box and whisker chart. * * @param title the chart title (<code>null</code> permitted). * @param timeAxisLabel a label for the time axis (<code>null</code> permitted). * @param valueAxisLabel a label for the value axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * * @return a box and whisker chart. */ public static JFreeChart createBoxAndWhiskerChart(String title, String timeAxisLabel, String valueAxisLabel, BoxAndWhiskerXYDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); valueAxis.setAutoRangeIncludesZero(false); XYBoxAndWhiskerRenderer renderer = new XYBoxAndWhiskerRenderer(10.0); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
/** * Creates a wind plot with default settings. * * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel a label for the x-axis (<code>null</code> permitted). * @param yAxisLabel a label for the y-axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag that controls whether or not a legend is created. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A wind plot. * */ public static JFreeChart createWindPlot(String title, String xAxisLabel, String yAxisLabel, WindDataset dataset, boolean legend, boolean tooltips, boolean urls) { ValueAxis xAxis = new DateAxis(xAxisLabel); ValueAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setRange(-12.0, 12.0); WindItemRenderer renderer = new WindItemRenderer(); if (tooltips) { renderer.setToolTipGenerator(new StandardXYToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
/** * Test that the setRange() method works. */ public void testSetRange() { DateAxis axis = new DateAxis("Test Axis"); Calendar calendar = Calendar.getInstance(); calendar.set(1999, Calendar.JANUARY, 3); Date d1 = calendar.getTime(); calendar.set(1999, Calendar.JANUARY, 31); Date d2 = calendar.getTime(); axis.setRange(d1, d2); DateRange range = (DateRange) axis.getRange(); assertEquals(d1, range.getLowerDate()); assertEquals(d2, range.getUpperDate()); }
/** * Test the translation of Java2D values to data values. */ public void testJava2DToValue() { DateAxis axis = new DateAxis(); axis.setRange(50.0, 100.0); Rectangle2D dataArea = new Rectangle2D.Double(10.0, 50.0, 400.0, 300.0); double y1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT); assertTrue(same(y1, 95.8333333, 1.0)); double y2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT); assertTrue(same(y2, 95.8333333, 1.0)); double x1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP); assertTrue(same(x1, 58.125, 1.0)); double x2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM); assertTrue(same(x2, 58.125, 1.0)); axis.setInverted(true); double y3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT); assertTrue(same(y3, 54.1666667, 1.0)); double y4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT); assertTrue(same(y4, 54.1666667, 1.0)); double x3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP); assertTrue(same(x3, 91.875, 1.0)); double x4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM); assertTrue(same(x4, 91.875, 1.0)); }
/** * Creates and returns a default instance of a candlesticks chart. * * @param title the chart title (<code>null</code> permitted). * @param timeAxisLabel a label for the time axis (<code>null</code> * permitted). * @param valueAxisLabel a label for the value axis (<code>null</code> * permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A candlestick chart. */ public static JFreeChart createCandlestickChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); plot.setRenderer(new CandlestickRenderer()); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
/** * Creates and returns a default instance of a high-low-open-close chart. * * @param title the chart title (<code>null</code> permitted). * @param timeAxisLabel a label for the time axis (<code>null</code> * permitted). * @param valueAxisLabel a label for the value axis (<code>null</code> * permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A high-low-open-close chart. */ public static JFreeChart createHighLowChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); HighLowRenderer renderer = new HighLowRenderer(); renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator()); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
/** * Creates and returns a default instance of a high-low-open-close chart * with a special timeline. This timeline can be a * {@link org.jfree.chart.axis.SegmentedTimeline} such as the Monday * through Friday timeline that will remove Saturdays and Sundays from * the axis. * * @param title the chart title (<code>null</code> permitted). * @param timeAxisLabel a label for the time axis (<code>null</code> * permitted). * @param valueAxisLabel a label for the value axis (<code>null</code> * permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param timeline the timeline. * @param legend a flag specifying whether or not a legend is required. * * @return A high-low-open-close chart. */ public static JFreeChart createHighLowChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, Timeline timeline, boolean legend) { DateAxis timeAxis = new DateAxis(timeAxisLabel); timeAxis.setTimeline(timeline); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); HighLowRenderer renderer = new HighLowRenderer(); renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator()); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
/** * Creates and returns a default instance of a box and whisker chart. * * @param title the chart title (<code>null</code> permitted). * @param timeAxisLabel a label for the time axis (<code>null</code> * permitted). * @param valueAxisLabel a label for the value axis (<code>null</code> * permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A box and whisker chart. */ public static JFreeChart createBoxAndWhiskerChart(String title, String timeAxisLabel, String valueAxisLabel, BoxAndWhiskerXYDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); valueAxis.setAutoRangeIncludesZero(false); XYBoxAndWhiskerRenderer renderer = new XYBoxAndWhiskerRenderer(10.0); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); }
/** * Creates and returns a default instance of a high-low-open-close chart. * * @param title the chart title (<code>null</code> permitted). * @param timeAxisLabel a label for the time axis (<code>null</code> * permitted). * @param valueAxisLabel a label for the value axis (<code>null</code> * permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A high-low-open-close chart. */ public static JFreeChart createHighLowChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); HighLowRenderer renderer = new HighLowRenderer(); renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator()); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
/** * Creates and returns a default instance of a box and whisker chart. * * @param title the chart title (<code>null</code> permitted). * @param timeAxisLabel a label for the time axis (<code>null</code> * permitted). * @param valueAxisLabel a label for the value axis (<code>null</code> * permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A box and whisker chart. */ public static JFreeChart createBoxAndWhiskerChart(String title, String timeAxisLabel, String valueAxisLabel, BoxAndWhiskerXYDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); valueAxis.setAutoRangeIncludesZero(false); XYBoxAndWhiskerRenderer renderer = new XYBoxAndWhiskerRenderer(10.0); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
/** * Creates a wind plot with default settings. * * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel a label for the x-axis (<code>null</code> permitted). * @param yAxisLabel a label for the y-axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag that controls whether or not a legend is created. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A wind plot. * */ public static JFreeChart createWindPlot(String title, String xAxisLabel, String yAxisLabel, WindDataset dataset, boolean legend, boolean tooltips, boolean urls) { ValueAxis xAxis = new DateAxis(xAxisLabel); ValueAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setRange(-12.0, 12.0); WindItemRenderer renderer = new WindItemRenderer(); if (tooltips) { renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
/** * Creates and returns a default instance of a high-low-open-close chart. * * @param title the chart title ({@code null} permitted). * @param timeAxisLabel a label for the time axis ({@code null} * permitted). * @param valueAxisLabel a label for the value axis ({@code null} * permitted). * @param dataset the dataset for the chart ({@code null} permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A high-low-open-close chart. */ public static JFreeChart createHighLowChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); HighLowRenderer renderer = new HighLowRenderer(); renderer.setDefaultToolTipGenerator(new HighLowItemLabelGenerator()); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
/** * Creates and returns a default instance of a box and whisker chart. * * @param title the chart title ({@code null} permitted). * @param timeAxisLabel a label for the time axis ({@code null} * permitted). * @param valueAxisLabel a label for the value axis ({@code null} * permitted). * @param dataset the dataset for the chart ({@code null} permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A box and whisker chart. */ public static JFreeChart createBoxAndWhiskerChart(String title, String timeAxisLabel, String valueAxisLabel, BoxAndWhiskerXYDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); valueAxis.setAutoRangeIncludesZero(false); XYBoxAndWhiskerRenderer renderer = new XYBoxAndWhiskerRenderer(10.0); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
/** * Creates a wind plot with default settings. * * @param title the chart title ({@code null} permitted). * @param xAxisLabel a label for the x-axis ({@code null} permitted). * @param yAxisLabel a label for the y-axis ({@code null} permitted). * @param dataset the dataset for the chart ({@code null} permitted). * @param legend a flag that controls whether or not a legend is created. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A wind plot. * */ public static JFreeChart createWindPlot(String title, String xAxisLabel, String yAxisLabel, WindDataset dataset, boolean legend, boolean tooltips, boolean urls) { ValueAxis xAxis = new DateAxis(xAxisLabel); ValueAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setRange(-12.0, 12.0); WindItemRenderer renderer = new WindItemRenderer(); if (tooltips) { renderer.setDefaultToolTipGenerator(new StandardXYToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
public static JFreeChart createChart( XYDataset dataset ) { JFreeChart chart = ChartFactory.createTimeSeriesChart( "", // title QWIResources.getString( "x.axis" ), // x-axis label QWIResources.getString( "y.axis" ), // y-axis label dataset, // data false, // create legend? false, // generate tooltips? false // generate URLs? ); XYPlot plot = (XYPlot)chart.getPlot(); DateAxis axis = (DateAxis)plot.getDomainAxis(); axis.setDateFormatOverride( new SimpleDateFormat( "ssss" ) ); plot.getDomainAxis().setTickLabelsVisible( false ); plot.getDomainAxis().setAutoRange( true ); plot.getRangeAxis().setAutoRange( false ); plot.getRangeAxis().setRange( -0.2, 0.2 ); return chart; }
public static JFreeChart createChart( XYDataset dataset ) { JFreeChart chart = ChartFactory.createTimeSeriesChart( "", // title "x-axis", // x-axis label "y-axis", // y-axis label dataset, // data false, // create legend? false, // generate tooltips? false // generate URLs? ); XYPlot plot = (XYPlot)chart.getPlot(); DateAxis axis = (DateAxis)plot.getDomainAxis(); // axis.setDateFormatOverride( new SimpleDateFormat( "MMM-yyyy" ) ); axis.setDateFormatOverride( new SimpleDateFormat( "ssss" ) ); // plot.setRangeGridlinesVisible( false ); // plot.setDomainGridlinesVisible( false ); return chart; }
private void addChart() { JFreeChart chart = ChartFactory.createXYLineChart( "Balance Graph for " + this.address, "Time", "Total Krist", this.data, PlotOrientation.VERTICAL, false, true, false); XYPlot plot = chart.getXYPlot(); DateAxis domain = new DateAxis(); domain.setDateFormatOverride(new SimpleDateFormat("MMM dd, hh:mm a")); plot.setDomainAxis(domain); ChartPanel chartPanel = new ChartPanel(chart); setContentPane(chartPanel); revalidate(); repaint(); }
public void initCPUChart(){ cpuChart = ChartFactory.createTimeSeriesChart( CPU_USAGE, "S", CPU_USAGE, cpuSet, true, true, false); XYPlot localXYPlot = (XYPlot)cpuChart.getPlot(); localXYPlot.setDomainPannable(true); localXYPlot.setRangePannable(false); localXYPlot.setDomainCrosshairVisible(true); localXYPlot.setRangeCrosshairVisible(true); XYItemRenderer r = localXYPlot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } DateAxis axis = (DateAxis) localXYPlot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); }
public void initMemChart(){ memChart = ChartFactory.createTimeSeriesChart( MEM_USED, "Seconds", MEM_USED, memSet, true, true, false); XYPlot localXYPlot = (XYPlot)memChart.getPlot(); localXYPlot.setDomainPannable(true); localXYPlot.setRangePannable(false); localXYPlot.setDomainCrosshairVisible(true); localXYPlot.setRangeCrosshairVisible(true); XYItemRenderer r = localXYPlot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } DateAxis axis = (DateAxis) localXYPlot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); }
public void initNetChart(){ netChart = ChartFactory.createTimeSeriesChart( BW_USAGE, "Seconds", BW_USAGE, netSet, true, true, false); XYPlot localXYPlot = (XYPlot)netChart.getPlot(); localXYPlot.setDomainPannable(true); localXYPlot.setRangePannable(false); localXYPlot.setDomainCrosshairVisible(true); localXYPlot.setRangeCrosshairVisible(true); XYItemRenderer r = localXYPlot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } DateAxis axis = (DateAxis) localXYPlot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); }
public void initCPUChart(){ cpuChart = ChartFactory.createTimeSeriesChart( CPU_USAGE, "S", "percentage",//CPU_USAGE, cpuSet, true, true, false); XYPlot localXYPlot = (XYPlot)cpuChart.getPlot(); localXYPlot.setDomainPannable(true); localXYPlot.setRangePannable(false); localXYPlot.setDomainCrosshairVisible(true); localXYPlot.setRangeCrosshairVisible(true); XYItemRenderer r = localXYPlot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } DateAxis axis = (DateAxis) localXYPlot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); }
public void initMemChart(){ memChart = ChartFactory.createTimeSeriesChart( MEM_USED, "Seconds", "MB", //MEM_USED, memSet, true, true, false); XYPlot localXYPlot = (XYPlot)memChart.getPlot(); localXYPlot.setDomainPannable(true); localXYPlot.setRangePannable(false); localXYPlot.setDomainCrosshairVisible(true); localXYPlot.setRangeCrosshairVisible(true); XYItemRenderer r = localXYPlot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } DateAxis axis = (DateAxis) localXYPlot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); }
public void initNetChart(){ netChart = ChartFactory.createTimeSeriesChart( BW_USAGE, "Seconds", "percentage",//BW_USAGE, netSet, true, true, false); XYPlot localXYPlot = (XYPlot)netChart.getPlot(); localXYPlot.setDomainPannable(true); localXYPlot.setRangePannable(false); localXYPlot.setDomainCrosshairVisible(true); localXYPlot.setRangeCrosshairVisible(true); XYItemRenderer r = localXYPlot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } DateAxis axis = (DateAxis) localXYPlot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); }
private JFreeChart createChartObject(String title, TimeChartDefinition definition) { boolean legend = true; OHLCSeriesCollection ohlcSeriesCollection = new OHLCSeriesCollection(); TimeSeriesCollection timeSeriesCollection = new TimeSeriesCollection(); definition.ohlcSeries.forEach((seriesTitle, series) -> ohlcSeriesCollection.addSeries(series)); definition.timeSeries.forEach((seriesTitle, series) -> timeSeriesCollection.addSeries(series)); JFreeChart chartObject = ChartFactory.createCandlestickChart( title, "time", "price", ohlcSeriesCollection, legend); XYPlot xyPlot = chartObject.getXYPlot(); NumberAxis numberAxis = (NumberAxis)xyPlot.getRangeAxis(); DateAxis dateAxis = (DateAxis)xyPlot.getDomainAxis(); dateAxis.setDateFormatOverride(new SimpleDateFormat("dd-LLL-yy hh:mm", Locale.ENGLISH)); CandlestickRenderer renderer = (CandlestickRenderer)xyPlot.getRenderer(); renderer.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST); for (int i = 0, size = definition.ohlcSeries.size(); i < size; ++i) { renderer.setSeriesPaint(i, Color.decode("#222222")); } numberAxis.setAutoRangeIncludesZero(false); addDatasetToPlot(xyPlot, timeSeriesCollection); return chartObject; }
/** * Creates and returns a default instance of a candlesticks chart. * * @param title the chart title (<code>null</code> permitted). * @param timeAxisLabel a label for the time axis (<code>null</code> * permitted). * @param valueAxisLabel a label for the value axis (<code>null</code> * permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A candlestick chart. */ public static JFreeChart createCandlestickChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); plot.setRenderer(new CandlestickRenderer()); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
/** * Creates and returns a default instance of a high-low-open-close chart * with a special timeline. This timeline can be a * {@link org.jfree.chart.axis.SegmentedTimeline} such as the Monday * through Friday timeline that will remove Saturdays and Sundays from * the axis. * * @param title the chart title (<code>null</code> permitted). * @param timeAxisLabel a label for the time axis (<code>null</code> * permitted). * @param valueAxisLabel a label for the value axis (<code>null</code> * permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param timeline the timeline. * @param legend a flag specifying whether or not a legend is required. * * @return A high-low-open-close chart. */ public static JFreeChart createHighLowChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, Timeline timeline, boolean legend) { DateAxis timeAxis = new DateAxis(timeAxisLabel); timeAxis.setTimeline(timeline); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); HighLowRenderer renderer = new HighLowRenderer(); renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator()); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }