List of usage examples for org.jfree.chart.plot CategoryPlot setDomainCrosshairPaint
public void setDomainCrosshairPaint(Paint paint)
From source file:com.mergano.core.AreaChart.java
private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createAreaChart("Order statistic", // chart title "Days", // domain axis label "Order Average", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend false, // tooltips false // urls );//from w ww . j a v a 2 s .com // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setAnchor(StandardLegend.SOUTH); chart.setBackgroundPaint(Color.white); chart.setAntiAlias(true); CategoryPlot plot = chart.getCategoryPlot(); plot.getRenderer().setSeriesPaint(0, new Color(0, 191, 165)); plot.setForegroundAlpha(0.75f); plot.setBackgroundPaint(Color.white); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); // disable this plot.setDomainGridlinesVisible(false); plot.setDomainGridlinePaint(new Color(240, 240, 240)); plot.setRangeGridlinesVisible(false); plot.setRangeGridlinePaint(new Color(240, 240, 240)); plot.setDomainCrosshairPaint(Color.MAGENTA); plot.setRangeCrosshairPaint(Color.CYAN); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.addCategoryLabelToolTip("Type 1", "The first type."); domainAxis.addCategoryLabelToolTip("Type 2", "The second type."); domainAxis.addCategoryLabelToolTip("Type 3", "The third type."); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLabelAngle(0 * Math.PI / 2.0); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:srvclientmonitor.frmMain.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed JPanel panel = new JPanel(); getContentPane().add(panel);/*from ww w. jav a2 s. c om*/ DefaultCategoryDataset data = new DefaultCategoryDataset(); //DefaultPieDataset data = new DefaultPieDataset(); //Para el Grafico PIE data.addValue(20, "OSP", "HOY"); data.addValue(99, "ETL", "HOY"); data.addValue(25, "LOR", "HOY"); data.addValue(12, "MOV", "HOY"); // Creando el Grafico //JFreeChart chart = ChartFactory.createPieChart( //JFreeChart chart = ChartFactory.createBarChart("Ejemplo Rapido de Grafico en un ChartFrame", "Mes", "Valor", data); JFreeChart chart = ChartFactory.createBarChart("", "", "", data, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.BLACK); chart.setTitle(""); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setRangePannable(true); plot.setRangeGridlinesVisible(false); plot.setBackgroundAlpha(1); plot.setBackgroundPaint(Color.BLACK); plot.setForegroundAlpha(1); plot.setDomainCrosshairPaint(Color.WHITE); plot.setNoDataMessagePaint(Color.WHITE); plot.setOutlinePaint(Color.WHITE); plot.setRangeCrosshairPaint(Color.WHITE); plot.setRangeMinorGridlinePaint(Color.WHITE); plot.setRangeZeroBaselinePaint(Color.WHITE); // Paint p = new GradientPaint(0, 0, Color.white, 1000, 0, Color.green); // plot.setBackgroundPaint(p); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLabelPaint(Color.WHITE); rangeAxis.setAxisLinePaint(Color.WHITE); rangeAxis.setTickLabelPaint(Color.WHITE); rangeAxis.setVerticalTickLabels(true); //ChartUtilities.applyCurrentTheme(chart); // Crear el Panel del Grafico con ChartPanel ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setSize(300, 150); chartPanel.setBackground(Color.BLACK); chartPanel.setOpaque(false); chartPanel.setDomainZoomable(true); this.jPanel1.setSize(300, 200); this.jPanel1.setBackground(Color.DARK_GRAY); this.jPanel1.add(chartPanel); }
From source file:msi.gama.outputs.layers.ChartLayerStatement.java
private void createChart(final IScope scope) { switch (type) { case SERIES_CHART: { chart = ChartFactory.createXYLineChart(getName(), "time", "", null, PlotOrientation.VERTICAL, true, false, false);//from w w w.j a v a 2 s . c o m break; } case PIE_CHART: { if (style.equals(IKeyword.THREE_D)) { chart = ChartFactory.createPieChart3D(getName(), null, false, true, false); } else if (style.equals(IKeyword.RING)) { chart = ChartFactory.createRingChart(getName(), null, false, true, false); } else if (style.equals(IKeyword.EXPLODED)) { chart = ChartFactory.createPieChart(getName(), null, false, true, false); exploded = true; } else { chart = ChartFactory.createPieChart(getName(), null, false, true, false); } break; } case HISTOGRAM_CHART: { if (style.equals(IKeyword.THREE_D)) { chart = ChartFactory.createBarChart3D(getName(), null, null, null, PlotOrientation.VERTICAL, true, true, false); } else if (style.equals(IKeyword.STACK)) { chart = ChartFactory.createStackedBarChart(getName(), null, null, null, PlotOrientation.VERTICAL, true, true, false); } else { chart = ChartFactory.createBarChart(getName(), null, null, null, PlotOrientation.VERTICAL, true, true, false); } break; } case XY_CHART: chart = ChartFactory.createXYLineChart(getName(), "", "", null, PlotOrientation.VERTICAL, true, false, false); break; case SCATTER_CHART: chart = ChartFactory.createXYLineChart(getName(), "", "", null, PlotOrientation.VERTICAL, true, false, false); break; case BOX_WHISKER_CHART: { chart = ChartFactory.createBoxAndWhiskerChart(getName(), "Time", "Value", (BoxAndWhiskerCategoryDataset) dataset, true); chart.setBackgroundPaint(new Color(249, 231, 236)); break; } } Plot plot = chart.getPlot(); chart.getTitle().setFont(getTitleFont()); if (backgroundColor == null) { plot.setBackgroundPaint(null); chart.setBackgroundPaint(null); chart.setBorderPaint(null); if (chart.getLegend() != null) { chart.getLegend().setBackgroundPaint(null); } } else { Color bg = backgroundColor; chart.setBackgroundPaint(bg); plot.setBackgroundPaint(bg); chart.setBorderPaint(bg); if (chart.getLegend() != null) { chart.getLegend().setBackgroundPaint(bg); } } // chart.getLegend().setItemPaint(axesColor); // chart.getLegend().setBackgroundPaint(null); if (plot instanceof CategoryPlot) { final CategoryPlot pp = (CategoryPlot) chart.getPlot(); pp.setDomainGridlinePaint(axesColor); pp.setRangeGridlinePaint(axesColor); // plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); // plot.setDomainCrosshairVisible(true); pp.setRangeCrosshairVisible(true); } else if (plot instanceof XYPlot) { final XYPlot pp = (XYPlot) chart.getPlot(); pp.setDomainGridlinePaint(axesColor); pp.setRangeGridlinePaint(axesColor); pp.setDomainCrosshairPaint(axesColor); pp.setRangeCrosshairPaint(axesColor); pp.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); pp.setDomainCrosshairVisible(true); pp.setRangeCrosshairVisible(true); } }