Search in sources :

Example 6 with ValueMarker

use of org.jfree.chart.plot.ValueMarker in project java-examples by urvanov-ru.

the class MyTestCustomizer method customize.

public void customize(JFreeChart chart, JRChart jasperChart) {
    // Позиция, на которой
    ValueMarker marker = new ValueMarker(6);
    // рисуем линию
    marker.setPaint(Color.BLUE);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.addRangeMarker(marker);
}
Also used : ValueMarker(org.jfree.chart.plot.ValueMarker) CategoryPlot(org.jfree.chart.plot.CategoryPlot)

Example 7 with ValueMarker

use of org.jfree.chart.plot.ValueMarker in project memory-map-plugin by Praqma.

the class MemoryMapBuildAction method doDrawMemoryMapUsageGraph.

public void doDrawMemoryMapUsageGraph(StaplerRequest req, StaplerResponse rsp) throws IOException {
    DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> dataSet = new DataSetBuilder<>();
    String members = req.getParameter("categories");
    String graphTitle = req.getParameter("title");
    String uniqueDataSet = req.getParameter("dataset");
    int w = Integer.parseInt(req.getParameter("width"));
    int h = Integer.parseInt(req.getParameter("height"));
    List<String> memberList = Arrays.asList(members.split(","));
    HashMap<String, ValueMarker> markers = new HashMap<>();
    String scale = getRecorder().getScale();
    double max = buildDataSet(memberList, uniqueDataSet, dataSet, markers);
    filterMarkers(markers);
    String s = "";
    if (scale.equalsIgnoreCase("kilo")) {
        s = "k";
    } else if (scale.equalsIgnoreCase("mega")) {
        s = "M";
    } else if (scale.equalsIgnoreCase("giga")) {
        s = "G";
    }
    String byteLegend = s + "Bytes";
    String wordLegend = s + "Words";
    String legend = getRecorder().getShowBytesOnGraph() ? byteLegend : wordLegend;
    JFreeChart chart = createPairedBarCharts(graphTitle, legend, max * 1.1d, 0d, dataSet.build(), markers.values());
    chart.setBackgroundPaint(Color.WHITE);
    chart.getLegend().setPosition(RectangleEdge.BOTTOM);
    ChartUtil.generateGraph(req, rsp, chart, w, h);
}
Also used : DataSetBuilder(hudson.util.DataSetBuilder) ValueMarker(org.jfree.chart.plot.ValueMarker) JFreeChart(org.jfree.chart.JFreeChart)

Example 8 with ValueMarker

use of org.jfree.chart.plot.ValueMarker in project neo4j by neo4j.

the class CoverageChartWriter method createBarChart.

private JFreeChart createBarChart(Map<String, Integer> data) {
    if (cached != null) {
        return cached;
    }
    JFreeChart chart = ChartFactory.createBarChart("Spec suite tag distribution", "Tags", "Occurrences in queries", createCategoryDataset(data));
    // styling
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);
    plot.addRangeMarker(new ValueMarker(HORIZONTAL_LINE_VALUE, Color.BLACK, new BasicStroke(2)));
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setSeriesPaint(0, ChartColor.DARK_RED);
    renderer.setBarPainter(new StandardBarPainter());
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
    cached = chart;
    return chart;
}
Also used : CategoryAxis(org.jfree.chart.axis.CategoryAxis) StandardBarPainter(org.jfree.chart.renderer.category.StandardBarPainter) BarRenderer(org.jfree.chart.renderer.category.BarRenderer) ValueMarker(org.jfree.chart.plot.ValueMarker) JFreeChart(org.jfree.chart.JFreeChart) CategoryPlot(org.jfree.chart.plot.CategoryPlot)

Example 9 with ValueMarker

use of org.jfree.chart.plot.ValueMarker in project hmftools by hartwigmedical.

the class GradientBarCustomizer method addValueMarker.

private static void addValueMarker(@NotNull final CategoryPlot categoryPlot, final int position, @NotNull final String text) {
    final Marker marker = new ValueMarker(position);
    final float[] dash = { 3 };
    marker.setStroke(new BasicStroke(1.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10, dash, 0));
    marker.setPaint(new Color(49, 49, 49));
    marker.setLabel(text);
    marker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    marker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
    categoryPlot.addRangeMarker(marker);
}
Also used : BasicStroke(java.awt.BasicStroke) Color(java.awt.Color) ValueMarker(org.jfree.chart.plot.ValueMarker) Marker(org.jfree.chart.plot.Marker) ValueMarker(org.jfree.chart.plot.ValueMarker)

Example 10 with ValueMarker

use of org.jfree.chart.plot.ValueMarker in project Course_Generator by patrovite.

the class JPanelProfil method RefreshProfilChart.

/**
 * Update the profil chart
 */
public void RefreshProfilChart() {
    if (track == null)
        return;
    if (track.data.isEmpty())
        return;
    // -- Clear all series
    if (datasetProfil.getSeriesCount() > 0)
        datasetProfil.removeAllSeries();
    XYPlot plot = chartProfil.getXYPlot();
    plot.clearDomainMarkers();
    // -- Populate the serie
    XYSeries serie1 = new XYSeries("Elevation/Distance");
    int cmpt = 1;
    for (CgData r : track.data) {
        double x = r.getTotal(settings.Unit) / 1000;
        double y = r.getElevation(settings.Unit);
        serie1.add(x, y);
        if (((r.getTag() & CgConst.TAG_MARK) != 0) & showProfilMarker) {
            Marker m = new ValueMarker(x);
            m.setPaint(Color.GRAY);
            m.setLabelFont(new Font("SansSerif", Font.PLAIN, 10));
            m.setLabel(String.valueOf(cmpt));
            m.setLabelOffset(new RectangleInsets(5, 0, 0, 2));
            m.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
            m.setLabelTextAnchor(TextAnchor.TOP_LEFT);
            plot.addDomainMarker(m);
            cmpt++;
        }
    }
    datasetProfil.addSeries(serie1);
    if (track.getMaxElev(settings.Unit) > track.getMinElev(settings.Unit)) {
        // XYPlot plot = chart.getXYPlot();
        ValueAxis axisY = plot.getRangeAxis();
        axisY.setRange(Math.floor(track.getMinElev(settings.Unit) / 100.0) * 100.0, Math.ceil(track.getMaxElev(settings.Unit) / 100.0) * 100.0);
    }
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) XYPlot(org.jfree.chart.plot.XYPlot) ValueAxis(org.jfree.chart.axis.ValueAxis) RectangleInsets(org.jfree.ui.RectangleInsets) ValueMarker(org.jfree.chart.plot.ValueMarker) Marker(org.jfree.chart.plot.Marker) ValueMarker(org.jfree.chart.plot.ValueMarker) CgData(course_generator.CgData) Font(java.awt.Font)

Aggregations

ValueMarker (org.jfree.chart.plot.ValueMarker)15 Marker (org.jfree.chart.plot.Marker)7 JFreeChart (org.jfree.chart.JFreeChart)5 BasicStroke (java.awt.BasicStroke)3 Color (java.awt.Color)3 NumberAxis (org.jfree.chart.axis.NumberAxis)3 CategoryPlot (org.jfree.chart.plot.CategoryPlot)3 Font (java.awt.Font)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 XYTextAnnotation (org.jfree.chart.annotations.XYTextAnnotation)2 CategoryAxis (org.jfree.chart.axis.CategoryAxis)2 ValueAxis (org.jfree.chart.axis.ValueAxis)2 XYPlot (org.jfree.chart.plot.XYPlot)2 BarRenderer (org.jfree.chart.renderer.category.BarRenderer)2 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)2 Minute (org.jfree.data.time.Minute)2 TimeSeries (org.jfree.data.time.TimeSeries)2 RectangleInsets (org.jfree.ui.RectangleInsets)2