Java Code Examples for org.jfree.chart.plot.CategoryPlot#setDomainGridlinePosition()
The following examples show how to use
org.jfree.chart.plot.CategoryPlot#setDomainGridlinePosition() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RoboTaxiRequestHistoGramExport.java From amod with GNU General Public License v2.0 | 5 votes |
@Override public void summaryTarget(AnalysisSummary analysisSummary, File relativeDirectory, ColorDataIndexed colorScheme) { /** the data for the histogram is gathered from the RoboTaxiRequestRecorder, basic * information can also be retrieved from the analsysisSummary */ Tensor requestsPerRoboTaxi = roboTaxiRequestRecorder.getRequestsPerRoboTaxi(); Scalar numberOfRoboTaxis = RealScalar.of(requestsPerRoboTaxi.length()); Scalar totalRequestsServed = (Scalar) Total.of(requestsPerRoboTaxi); Scalar histoGrambinSize = Scalars.lessThan(RealScalar.ZERO, totalRequestsServed) ? // totalRequestsServed.divide(numberOfRoboTaxis.multiply(RealScalar.of(10))) : RealScalar.ONE; try { /** compute bins */ Scalar numValues = RationalScalar.of(requestsPerRoboTaxi.length(), 1); Tensor bins = BinCounts.of(requestsPerRoboTaxi, histoGrambinSize); bins = bins.divide(numValues).multiply(RealScalar.of(100)); // norm VisualSet visualSet = new VisualSet(colorScheme); visualSet.add(Range.of(0, bins.length()).multiply(histoGrambinSize), bins); // --- visualSet.setPlotLabel("Number of Requests Served per RoboTaxi"); visualSet.setAxesLabelY("% of RoboTaxis"); visualSet.setAxesLabelX("Requests"); JFreeChart jFreeChart = Histogram.of(visualSet, s -> "[" + s.number() + " , " + s.add(histoGrambinSize).number() + ")"); CategoryPlot categoryPlot = jFreeChart.getCategoryPlot(); categoryPlot.getDomainAxis().setLowerMargin(0.0); categoryPlot.getDomainAxis().setUpperMargin(0.0); categoryPlot.getDomainAxis().setCategoryMargin(0.0); categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_90); categoryPlot.setDomainGridlinePosition(CategoryAnchor.START); File file = new File(relativeDirectory, FILENAME); AmodeusChartUtils.saveAsPNG(jFreeChart, file.toString(), WIDTH, HEIGHT); GlobalAssert.that(file.isFile()); } catch (Exception exception) { System.err.println("Plot of the Number of Requests per RoboTaxi Failed"); exception.printStackTrace(); } }
Example 2
Source File: EyeCandySixtiesChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected JFreeChart createGanttChart() throws JRException { JFreeChart jfreeChart = super.createGanttChart(); CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot(); categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.STANDARD); categoryPlot.setDomainGridlinesVisible(true); categoryPlot.setDomainGridlinePosition(CategoryAnchor.END); categoryPlot.setDomainGridlineStroke(new BasicStroke( 0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] {1}, 0 ) ); categoryPlot.setDomainGridlinePaint(ChartThemesConstants.GRAY_PAINT_134); categoryPlot.setRangeGridlinesVisible(true); categoryPlot.setRangeGridlineStroke(new BasicStroke( 0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] {1}, 0 ) ); categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_134); categoryPlot.getDomainAxis().setTickLabelsVisible( //barPlot.isShowTickLabels() true ); CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer(); categoryRenderer.setBaseItemLabelsVisible(true); BarRenderer barRenderer = (BarRenderer)categoryRenderer; barRenderer.setSeriesPaint(0, ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(3)); barRenderer.setSeriesPaint(1, ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(0)); CategoryDataset categoryDataset = categoryPlot.getDataset(); if (categoryDataset != null) { for (int i = 0; i < categoryDataset.getRowCount(); i++) { barRenderer.setSeriesItemLabelFont(i, categoryPlot.getDomainAxis().getTickLabelFont()); barRenderer.setSeriesItemLabelsVisible(i, true); } } categoryPlot.setOutlinePaint(Color.DARK_GRAY); categoryPlot.setOutlineStroke(new BasicStroke(1.5f)); categoryPlot.setOutlineVisible(true); return jfreeChart; }
Example 3
Source File: AegeanChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected JFreeChart createGanttChart() throws JRException { JFreeChart jfreeChart = super.createGanttChart(); CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot(); categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.STANDARD); categoryPlot.setDomainGridlinesVisible(true); categoryPlot.setDomainGridlinePosition(CategoryAnchor.END); categoryPlot.setDomainGridlineStroke(new BasicStroke( 0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] {1}, 0 ) ); categoryPlot.setDomainGridlinePaint(ChartThemesConstants.GRAY_PAINT_217); categoryPlot.setRangeGridlinesVisible(true); categoryPlot.setRangeGridlineStroke(new BasicStroke( 0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] {1}, 0 ) ); categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217); // JRBarPlot barPlot = (BarPlot)categoryPlot; // categoryPlot.getDomainAxis().setTickLabelsVisible( // categoryPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels(). // true // ); CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer(); categoryRenderer.setBaseItemLabelsVisible(true); BarRenderer barRenderer = (BarRenderer)categoryRenderer; @SuppressWarnings("unchecked") List<Paint> seriesPaints = (List<Paint>)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SERIES_COLORS); barRenderer.setSeriesPaint(0, seriesPaints.get(3)); barRenderer.setSeriesPaint(1, seriesPaints.get(0)); CategoryDataset categoryDataset = categoryPlot.getDataset(); if(categoryDataset != null) { for(int i = 0; i < categoryDataset.getRowCount(); i++) { barRenderer.setSeriesItemLabelFont(i, categoryPlot.getDomainAxis().getTickLabelFont()); barRenderer.setSeriesItemLabelsVisible(i, true); // barRenderer.setSeriesPaint(i, GRADIENT_PAINTS[i]); // CategoryMarker categoryMarker = new CategoryMarker(categoryDataset.getColumnKey(i),MARKER_COLOR, new BasicStroke(1f)); // categoryMarker.setAlpha(0.5f); // categoryPlot.addDomainMarker(categoryMarker, Layer.BACKGROUND); } } categoryPlot.setOutlinePaint(Color.DARK_GRAY); categoryPlot.setOutlineStroke(new BasicStroke(1.5f)); categoryPlot.setOutlineVisible(true); return jfreeChart; }