List of usage examples for org.jfree.chart.axis NumberAxis setStandardTickUnits
public void setStandardTickUnits(TickUnitSource source)
From source file:com.google.jenkins.flakyTestHandler.plugin.TestFlakyStatsOverRevision.java
private JFreeChart createChart(CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createStackedAreaChart(null, // chart title null, // unused "count", // range axis label*/master dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false // urls );/*from www . j av a 2 s . c o m*/ chart.setBackgroundPaint(Color.white); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); CategoryAxis domainAxis = new ShiftedCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); StackedAreaRenderer ar = new StackedAreaRenderer2() { @Override public String generateToolTip(CategoryDataset dataset, int row, int column) { RevisionLabel label = (RevisionLabel) dataset.getColumnKey(column); Number value = dataset.getValue(row, column); switch (row) { case 0: return label.revision + ": " + value + " fails"; case 1: return label.revision + ": " + value + " passes"; default: return label.revision; } } }; plot.setRenderer(ar); ar.setSeriesPaint(0, ColorPalette.RED); // Fails. ar.setSeriesPaint(1, ColorPalette.BLUE); // Passes. // crop extra space around the graph plot.setInsets(new RectangleInsets(0, 0, 0, 5.0)); return chart; }
From source file:flexflux.analyses.result.ParetoAnalysisResult.java
public void plot() { XYSeriesCollection dataset = new XYSeriesCollection(); int i = 1;/*from ww w . j a v a 2 s.c om*/ for (Objective obj : oneDResults.keySet()) { XYSeries series = new XYSeries(obj.getName()); for (double val : oneDResults.get(obj)) { series.add(i, val); } dataset.addSeries(series); i++; } // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("", // chart title "Objectives", // x axis label "Values", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); ChartPanel chartPanel = new ChartPanel(chart); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setRangeGridlinePaint(Color.GRAY); plot.setDomainGridlinePaint(Color.GRAY); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setLinesVisible(false); renderer.setShapesVisible(true); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getDomainAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); JFrame frame = new JFrame("Pareto analysis one dimension results"); frame.add(chartPanel); frame.pack(); RefineryUtilities.centerFrameOnScreen(frame); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setVisible(true); for (PP2DResult r : twoDResults.keySet()) { r.plot(); } for (PP3DResult r : threeDResults.keySet()) { r.plot(); } }
From source file:org.ow2.clif.jenkins.chart.MovingStatChart.java
@Override protected JFreeChart createChart() { XYSeriesCollection coreDataset = new XYSeriesCollection(); coreDataset.addSeries(this.eventSerie); long periodMs = this.chartConfiguration.getStatisticalPeriod() * 1000L; XYSeriesCollection movingDataset = calculateMovingDataset(coreDataset, periodMs); XYSeriesCollection throughputDataset = calculateThroughputDataset(coreDataset, periodMs); JFreeChart chart;// w w w. j av a 2 s.c o m chart = ChartFactory .createXYLineChart( getBasicTitle() + " " + Messages.MovingChart_StatisticalPeriod( this.chartConfiguration.getStatisticalPeriod()), // chart title Messages.MovingChart_Time(), // x axis label Messages.MovingChart_ResponseTime(), // y axis label movingDataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); configureBasicPlotProperties(plot); // Force the 0 on vertical axis NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRangeIncludesZero(true); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // Force the 0 on horizontal axis NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(true); attachThroughputDatasetToDedicatedAxis(throughputDataset, plot); // Global renderer for moving stats plot.setRenderer(getGlobalRenderer()); // Dedicated Throughput renderer plot.setRenderer(1, getThroughputRenderer()); return chart; }
From source file:userInterface.CustomerWorkArea.CustomerWorkAreaJPanel.java
private void createChart() { DefaultCategoryDataset CarInspectionDataset = new DefaultCategoryDataset(); ArrayList<CarInspection> carInspectionList = userAccount.getPerson().getCarInspectionHistory() .getCarInspectionHistory();// w ww . j a va 2 s.co m /*At least 2 vital sign records needed to show chart */ if (carInspectionList.isEmpty() || carInspectionList.size() == 1) { JOptionPane.showMessageDialog(this, " At least 2 car Inspection records needed to show chart!", "Warning", JOptionPane.INFORMATION_MESSAGE); return; } for (CarInspection carList : carInspectionList) { CarInspectionDataset.addValue(carList.getAlignment(), "RR", carList.getTimestamp()); CarInspectionDataset.addValue(carList.getBattery(), "HR", carList.getTimestamp()); CarInspectionDataset.addValue(carList.getBrakingSys(), "BP", carList.getTimestamp()); CarInspectionDataset.addValue(carList.getOilCheck(), "WT", carList.getTimestamp()); } JFreeChart carInspectionChart = ChartFactory.createBarChart3D("Car Inspection Chart", "Time Stamp", "Values", CarInspectionDataset, PlotOrientation.VERTICAL, true, false, false); carInspectionChart.setBackgroundPaint(Color.white); CategoryPlot carChartPlot = carInspectionChart.getCategoryPlot(); carChartPlot.setBackgroundPaint(Color.lightGray); CategoryAxis vitalSignDomainAxis = carChartPlot.getDomainAxis(); vitalSignDomainAxis .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); NumberAxis vitalSignRangeAxis = (NumberAxis) carChartPlot.getRangeAxis(); vitalSignRangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartFrame chartFrame = new ChartFrame("Chart", carInspectionChart); chartFrame.setVisible(true); chartFrame.setSize(500, 500); }
From source file:edu.uara.wrappers.customcharts.CustomLineChart.java
/** * Set range axis to only display integer *///from www .j av a 2 s. co m @Override public void setTickIntegerUnit() { CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); }
From source file:org.mars_sim.msp.ui.swing.demo.BarChartDemo7.java
/** * Creates a sample chart.//from w ww. java 2 s. c o m * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo 7", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips? false // URLs? ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final IntervalMarker target = new IntervalMarker(4.5, 7.5); target.setLabel("Target Range"); target.setLabelFont(new Font("SansSerif", Font.ITALIC, 11)); target.setLabelAnchor(RectangleAnchor.LEFT); target.setLabelTextAnchor(TextAnchor.CENTER_LEFT); target.setPaint(new Color(222, 222, 255, 128)); plot.addRangeMarker(target, Layer.BACKGROUND); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); //renderer.setItemMargin(0.10); renderer.setMaximumBarWidth(.5); // set maximum width to 35% of chart // set up gradient paints for series... final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); // renderer.setLabelGenerator(new BarChartDemo7.LabelGenerator()); renderer.setDefaultItemLabelsVisible(true); final ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.INSIDE12, TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, -Math.PI / 2.0); renderer.setDefaultPositiveItemLabelPosition(p); final ItemLabelPosition p2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.CENTER_LEFT, TextAnchor.CENTER_LEFT, -Math.PI / 2.0); renderer.setPositiveItemLabelPositionFallback(p2); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:com.sonyericsson.jenkins.plugins.bfa.graphs.TimeSeriesChart.java
@Override protected JFreeChart createGraph() { TimeTableXYDataset dataset = createDataset(); ValueAxis xAxis = new DateAxis(); xAxis.setLowerMargin(0.0);/*from w w w . ja va 2s . co m*/ xAxis.setUpperMargin(0.0); Calendar lowerBound = getLowerGraphBound(); xAxis.setRange(lowerBound.getTimeInMillis(), Calendar.getInstance().getTimeInMillis()); NumberAxis yAxis = new NumberAxis(Y_AXIS_LABEL); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); StackedXYBarRenderer renderer = new StackedXYBarRenderer(); renderer.setBaseToolTipGenerator(new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int series, int item) { String seriesKey = dataset.getSeriesKey(series).toString(); StringBuilder sb = new StringBuilder(); if (seriesKey.equals(GRAPH_OTHERS)) { long timeInMillis = dataset.getX(series, item).longValue(); Date time = new Date(timeInMillis); TimePeriod period = null; if (intervalSize == Calendar.DATE) { period = new Day(time); } else if (intervalSize == Calendar.HOUR_OF_DAY) { period = new Hour(time); } else if (intervalSize == Calendar.MONTH) { period = new Month(time); } List<FailureCauseTimeInterval> excludedDataList = excludedDataForPeriod.get(period); if (excludedDataList != null) { Collections.sort(excludedDataList, new Comparator<FailureCauseTimeInterval>() { @Override public int compare(FailureCauseTimeInterval o1, FailureCauseTimeInterval o2) { return o2.getNumber() - o1.getNumber(); } }); for (FailureCauseTimeInterval excludedData : excludedDataList) { sb.append(excludedData).append(" \n"); } } } else { int number = dataset.getY(series, item).intValue(); sb.append(seriesKey).append(": ").append(number); } return sb.toString(); } }); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); plot.setRangeAxis(yAxis); JFreeChart chart = new JFreeChart(graphTitle, JFreeChart.DEFAULT_TITLE_FONT, plot, true); return chart; }
From source file:org.optaplanner.examples.cheaptime.swingui.CheapTimePanel.java
private XYPlot createTaskAssignmentPlot(TangoColorFactory tangoColorFactory, CheapTimeSolution solution) { OHLCSeriesCollection seriesCollection = new OHLCSeriesCollection(); Map<Machine, OHLCSeries> machineSeriesMap = new LinkedHashMap<Machine, OHLCSeries>( solution.getMachineList().size()); HighLowRenderer renderer = new HighLowRenderer(); renderer.setTickLength(0.0);//from www . j a va 2 s . co m int seriesIndex = 0; OHLCSeries unassignedProjectSeries = new OHLCSeries("Unassigned"); seriesCollection.addSeries(unassignedProjectSeries); machineSeriesMap.put(null, unassignedProjectSeries); renderer.setSeriesStroke(seriesIndex, new BasicStroke(3.0f)); renderer.setSeriesPaint(seriesIndex, TangoColorFactory.SCARLET_1); seriesIndex++; for (Machine machine : solution.getMachineList()) { OHLCSeries machineSeries = new OHLCSeries(machine.getLabel()); seriesCollection.addSeries(machineSeries); machineSeriesMap.put(machine, machineSeries); renderer.setSeriesStroke(seriesIndex, new BasicStroke(3.0f)); renderer.setSeriesPaint(seriesIndex, tangoColorFactory.pickColor(machine)); seriesIndex++; } List<TaskAssignment> taskAssignmentList = new ArrayList<TaskAssignment>(solution.getTaskAssignmentList()); Collections.sort(taskAssignmentList, groupByMachineCheckBox.isSelected() ? groupByMachineTaskAssignmentComparator : stableTaskAssignmentComparator); int pixelIndex = 0; for (TaskAssignment taskAssignment : taskAssignmentList) { Task task = taskAssignment.getTask(); Integer startPeriod = taskAssignment.getStartPeriod(); Integer endPeriod = taskAssignment.getEndPeriod(); if (startPeriod == null) { startPeriod = task.getStartPeriodRangeFrom(); endPeriod = startPeriod + task.getDuration(); } OHLCSeries machineSeries = machineSeriesMap.get(taskAssignment.getMachine()); machineSeries.add(new FixedMillisecond(pixelIndex), task.getStartPeriodRangeFrom(), startPeriod, endPeriod, task.getStartPeriodRangeTo() + task.getDuration()); pixelIndex++; } NumberAxis domainAxis = new NumberAxis("Task"); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setRange(-0.5, taskAssignmentList.size() - 0.5); domainAxis.setInverted(true); return new XYPlot(seriesCollection, domainAxis, null, renderer); }
From source file:regression.gui.RegressionChart.java
/** * Creates a chart.// www . ja v a 2 s. co m * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createScatterPlot("Wykres funkcji regresji", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesShape(0, ShapeUtilities.createRegularCross(3, 3)); renderer.setSeriesShape(2, ShapeUtilities.createRegularCross(3, 3)); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); renderer.setSeriesLinesVisible(2, false); plot.setRenderer(renderer); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:org.openmrs.module.laboratorymanagement.web.chart.EvolutionOfClientRegisteredPerDay.java
/** * @see org.openmrs.module.vcttrac.web.view.chart.AbstractChartView#createChart(java.util.Map, * javax.servlet.http.HttpServletRequest) */// w w w . j a v a 2 s . c om @Override protected JFreeChart createChart(Map<String, Object> model, HttpServletRequest request, String patientIdstr, String locationIdstr, int conceptId, Date startDate, Date endDate) { String categoryAxisLabel = " Year"; String valueAxisLabel = "Number of Lab tests"; String title = "EVolution of labotory test:" + Context.getConceptService().getConcept(conceptId).getDisplayString(); JFreeChart chart = ChartFactory.createLineChart(title, categoryAxisLabel, valueAxisLabel, createDataset(patientIdstr, locationIdstr, conceptId, startDate, endDate), // data PlotOrientation.VERTICAL, true, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setUpperMargin(0.15); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // customise the renderer... LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setItemLabelsVisible(true); return chart; }