List of usage examples for org.jfree.chart.axis NumberAxis setAxisLineVisible
public void setAxisLineVisible(boolean visible)
From source file:org.hxzon.demo.jfreechart.PolarChartDemo.java
private static JFreeChart createPolarChart(XYDataset dataset) { boolean legend = true; PolarPlot plot = new PolarPlot(); plot.setDataset(dataset);/*w w w.j a v a2 s. c o m*/ NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAxisLineVisible(false); rangeAxis.setTickMarksVisible(false); rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); plot.setAxis(rangeAxis); plot.setRenderer(new DefaultPolarItemRenderer()); JFreeChart chart = new JFreeChart("Polar Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setAngleGridlinesVisible(true); plot.setAngleLabelsVisible(true); plot.setAngleTickUnit(new NumberTickUnit(5)); return chart; }
From source file:jgnash.ui.budget.BudgetSparkline.java
public static Icon getSparklineImage(final List<BigDecimal> amounts) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); final boolean[] negate = new boolean[amounts.size()]; for (int i = 0; i < amounts.size(); i++) { dataset.addValue(amounts.get(i), CATEGORY, i); negate[i] = amounts.get(i).signum() == -1; }/*from w ww .j a va 2 s .c om*/ CategoryAxis xAxis = new CategoryAxis(); xAxis.setTickLabelsVisible(false); xAxis.setTickMarksVisible(false); xAxis.setAxisLineVisible(false); xAxis.setVisible(false); NumberAxis yAxis = new NumberAxis(); yAxis.setTickLabelsVisible(false); yAxis.setTickMarksVisible(false); yAxis.setAxisLineVisible(false); yAxis.setNegativeArrowVisible(false); yAxis.setPositiveArrowVisible(false); yAxis.setAutoRangeIncludesZero(true); yAxis.setAutoRange(true); yAxis.setVisible(false); BarRenderer renderer = new BarRenderer() { @Override public Paint getItemPaint(final int row, final int column) { return negate[column] ? Color.RED : Color.BLACK; } }; renderer.setShadowVisible(false); renderer.setBarPainter(new StandardBarPainter()); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); plot.setInsets(INSETS); plot.setDomainGridlinesVisible(false); plot.setDomainCrosshairVisible(false); plot.setRangeGridlinesVisible(false); plot.setRangeCrosshairVisible(false); plot.setBackgroundPaint(CLEAR); JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false); chart.setBorderVisible(false); chart.setBackgroundPaint(CLEAR); Icon icon = EMPTY_ICON; try { byte[] image = ENCODER .encode(chart.createBufferedImage(DEFAULT_WIDTH, DEFAULT_HEIGHT, BufferedImage.BITMASK, null)); icon = new ImageIcon(image); } catch (IOException ex) { Logger.getLogger(BudgetSparkline.class.getName()).log(Level.SEVERE, null, ex); } return icon; }
From source file:org.gwaspi.reports.PlinkReportLoaderCombined.java
private static void appendToCombinedRangePlot(CombinedRangeXYPlot combinedPlot, String chromosome, XYSeriesCollection tempChrData, boolean showlables) { XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesPaint(1, Color.red); renderer.setSeriesVisibleInLegend(0, showlables); renderer.setSeriesVisibleInLegend(1, showlables); //renderer.setBaseShape(new Ellipse2D.Float(0, 0, 2,2), false); if (combinedPlot.getSubplots().isEmpty()) { LogAxis rangeAxis = new LogAxis("P value"); rangeAxis.setBase(10);/*from w ww .j ava 2s . co m*/ rangeAxis.setInverted(true); rangeAxis.setNumberFormatOverride(GenericReportGenerator.FORMAT_P_VALUE); rangeAxis.setTickMarkOutsideLength(2.0f); rangeAxis.setMinorTickCount(2); rangeAxis.setMinorTickMarksVisible(true); rangeAxis.setAxisLineVisible(true); rangeAxis.setAutoRangeMinimumSize(0.0000005); rangeAxis.setLowerBound(1d); //rangeAxis.setAutoRangeIncludesZero(false); combinedPlot.setRangeAxis(0, rangeAxis); } JFreeChart subchart = ChartFactory.createScatterPlot("", "Chr " + chromosome, "", tempChrData, PlotOrientation.VERTICAL, true, false, false); XYPlot subplot = (XYPlot) subchart.getPlot(); subplot.setRenderer(renderer); subplot.setBackgroundPaint(null); final Marker thresholdLine = new ValueMarker(0.0000005); thresholdLine.setPaint(Color.red); if (showlables) { thresholdLine.setLabel("P = 510??"); } thresholdLine.setLabelAnchor(RectangleAnchor.TOP_RIGHT); thresholdLine.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); subplot.addRangeMarker(thresholdLine); NumberAxis chrAxis = (NumberAxis) subplot.getDomainAxis(); chrAxis.setAxisLineVisible(false); chrAxis.setTickLabelsVisible(false); chrAxis.setTickMarksVisible(false); chrAxis.setAutoRangeIncludesZero(false); //combinedPlot.setGap(0); combinedPlot.add(subplot, 1); }
From source file:org.gwaspi.reports.PlinkReportLoader.java
private static void appendToCombinedRangePlot(CombinedRangeXYPlot combinedPlot, String chromosome, XYSeriesCollection seriesCol) {/*from w ww. j a va 2 s.com*/ XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true); renderer.setSeriesPaint(0, Color.blue); JFreeChart subchart = ChartFactory.createScatterPlot("", "Chr " + chromosome, "", seriesCol, PlotOrientation.VERTICAL, true, false, false); XYPlot subplot = (XYPlot) subchart.getPlot(); subplot.setRenderer(renderer); subplot.setBackgroundPaint(null); subplot.setDomainGridlineStroke(new BasicStroke(0.0f)); subplot.setDomainMinorGridlineStroke(new BasicStroke(0.0f)); subplot.setDomainGridlinePaint(Color.blue); subplot.setRangeGridlineStroke(new BasicStroke(0.0f)); subplot.setRangeMinorGridlineStroke(new BasicStroke(0.0f)); subplot.setRangeGridlinePaint(Color.blue); NumberAxis chrAxis = (NumberAxis) subplot.getDomainAxis(); chrAxis.setAxisLineVisible(true); chrAxis.setTickLabelsVisible(true); chrAxis.setTickMarksVisible(true); chrAxis.setTickUnit(new NumberTickUnit(10000)); chrAxis.setAutoRangeIncludesZero(false); NumberAxis log10Axis = (NumberAxis) subplot.getRangeAxis(); log10Axis.setTickMarkInsideLength(2.0f); log10Axis.setTickMarkOutsideLength(2.0f); log10Axis.setMinorTickCount(2); log10Axis.setMinorTickMarksVisible(true); log10Axis.setAxisLineVisible(true); log10Axis.setAutoRangeIncludesZero(false); XYItemRenderer lblRenderer = subplot.getRenderer(); MySeriesItemLabelGenerator lblGenerator = new MySeriesItemLabelGenerator(4.0d, chromosome); lblRenderer.setSeriesItemLabelGenerator(0, lblGenerator); lblRenderer.setSeriesItemLabelGenerator(1, lblGenerator); lblRenderer.setSeriesItemLabelFont(0, new Font("Serif", Font.PLAIN, 12)); lblRenderer.setSeriesItemLabelFont(1, new Font("Serif", Font.PLAIN, 12)); lblRenderer.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.BOTTOM_LEFT, TextAnchor.TOP_LEFT, -Math.PI / 4.0)); lblRenderer.setSeriesPositiveItemLabelPosition(1, new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.BOTTOM_LEFT, TextAnchor.TOP_LEFT, -Math.PI / 4.0)); lblRenderer.setSeriesItemLabelsVisible(0, true); lblRenderer.setSeriesItemLabelsVisible(1, true); combinedPlot.add(subplot, 1); }
From source file:org.hxzon.demo.jfreechart.XYDatasetDemo2.java
private static JFreeChart createPolarChart(XYDataset dataset) { PolarPlot plot = new PolarPlot(); plot.setDataset(dataset);/*from w ww. j a v a2s . c o m*/ NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAxisLineVisible(false); rangeAxis.setTickMarksVisible(false); rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); plot.setAxis(rangeAxis); plot.setRenderer(new DefaultPolarItemRenderer()); JFreeChart chart = new JFreeChart("Polar Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); return chart; }
From source file:org.hxzon.demo.jfreechart.OtherDatasetDemo.java
private static JFreeChart createPolarChart(XYDataset dataset) { PolarPlot plot = new PolarPlot(); plot.setDataset(dataset);// ww w .j a va2s .com NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAxisLineVisible(false); rangeAxis.setTickMarksVisible(false); rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); plot.setAxis(rangeAxis); plot.setRenderer(new DefaultPolarItemRenderer()); JFreeChart chart = new JFreeChart("Polar Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setAngleGridlinesVisible(true); plot.setAngleLabelsVisible(true); plot.setAngleTickUnit(new NumberTickUnit(5)); return chart; }
From source file:org.cyberoam.iview.charts.CustomDomainAxis.java
public static JFreeChart getChart(int reportID, ResultSetWrapper rsw, HttpServletRequest request) { ReportBean reportBean = ReportBean.getRecordbyPrimarykey(reportID); JFreeChart chart = null;/*from www . j av a2 s . c om*/ // DefaultCategoryDataset dataset=null; CustomCategoryDataset datasetCustom = null; try { ReportColumnBean reportColumnBeanX = null; ReportColumnBean reportColumnBeanY = null; ReportColumnBean reportColumnBeanZ = null; GraphBean graphBean = null; graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getGraphId()); reportColumnBeanX = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getXColumnId());//getting ReportColumnBean For X Axis String xColumnDBname = reportColumnBeanX.getDbColumnName(); reportColumnBeanY = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getYColumnId()); String yColumnDBname = reportColumnBeanY.getDbColumnName(); String zColumnDBname = null; datasetCustom = new CustomCategoryDataset(); rsw.beforeFirst(); String data = ""; int count = -1; Boolean showLegend = false; if (graphBean.getZColumnId() == -1) { while (rsw.next()) { data = rsw.getString(xColumnDBname); datasetCustom.addValue(rsw.getLong(yColumnDBname), "", data); } } else { String zData; showLegend = true; reportColumnBeanZ = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getZColumnId()); zColumnDBname = reportColumnBeanZ.getDbColumnName(); while (rsw.next()) { data = rsw.getString(xColumnDBname); zData = rsw.getString(zColumnDBname); datasetCustom.addValue(rsw.getLong(yColumnDBname), zData, data); count++; } } chart = ChartFactory.createLineChart("", // chart title "", // domain axis label "", // range axis label datasetCustom, // data PlotOrientation.VERTICAL, // orientation showLegend, // include legend true, // tooltips false // urls ); LegendTitle legendTitle = chart.getLegend(); if (legendTitle != null) legendTitle.setItemFont(new Font("Vandara", Font.BOLD, 11)); chart.setBackgroundPaint(Color.white); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); rangeAxis.setTickLabelFont(new Font("Vandara", Font.CENTER_BASELINE, 10)); rangeAxis.setTickLabelInsets(new RectangleInsets(0, 0, 0, 5)); rangeAxis.setTickLabelsVisible(true); rangeAxis.setTickMarksVisible(false); rangeAxis.setAxisLineVisible(false); CustomDomainAxis catAxis = new CustomDomainAxis(); CustomDomainAxis.counter = 0; CustomDomainAxis.colCount = datasetCustom.getColumnCount(); catAxis.setTickLabelFont(new Font("Arial", Font.CENTER_BASELINE, 10)); catAxis.setTickMarksVisible(false); catAxis.setTickLabelInsets(new RectangleInsets(10, 15, 30, 10)); catAxis.setAxisLineVisible(false); catAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(20 * Math.PI / 180)); plot.setDomainAxis(catAxis); final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, Color.DARK_GRAY); if (count > 0) { Color[] colors = null; colors = new Color[5]; colors[0] = new Color(24, 112, 176); colors[1] = new Color(168, 192, 232); colors[2] = new Color(248, 120, 8); colors[3] = new Color(248, 184, 120); colors[4] = new Color(152, 216, 136); for (int i = 0; i < count && i < colors.length; i++) renderer.setSeriesPaint(i, colors[i]); } } catch (Exception e) { CyberoamLogger.appLog.debug("LineChart: " + e.getMessage(), e); } return chart; }
From source file:org.cyberoam.iview.charts.XYLine.java
/** * This method generates JFreeChart instance for XYLine chart with iView customization. * @param reportID specifies that for which report Chart is being prepared. * @param rsw specifies data set which would be used for the Chart * @param requeest used for Hyperlink generation from URL. * @return jfreechart instance with iView Customization. */// w w w . j a va2 s .co m public static JFreeChart getChart(int reportID, ResultSetWrapper rsw, HttpServletRequest request) { ReportBean reportBean = ReportBean.getRecordbyPrimarykey(reportID); JFreeChart chart = null; try { ReportColumnBean reportColumnBean = null; GraphBean graphBean = null; DataLinkBean dataLinkBean = null; XYDataset dataset = null; XYSeriesCollection seriesCollection = new XYSeriesCollection(); XYSeries series = new XYSeries(reportBean.getTitle()); graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getGraphId());//Getting GraphBean reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getXColumnId());//getting ReportColumnBean For X Axis String xColumnDBname = reportColumnBean.getDbColumnName(); String xColumnName = reportColumnBean.getColumnName(); //Wheather DataLink is Given For X Axis column if (reportColumnBean.getDataLinkId() != -1) { dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBean.getDataLinkId()); } reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getYColumnId()); String yColumnDBname = reportColumnBean.getDbColumnName(); String yColumnName = reportColumnBean.getColumnName(); //if DataLink is not Given For X Axis column then Check of Y Axis Column if (dataLinkBean == null && reportColumnBean.getDataLinkId() != -1) { dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBean.getDataLinkId()); } reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getZColumnId()); String zColumnDbname = reportColumnBean.getDbColumnName(); //Preparing DataSet String data = ""; rsw.beforeFirst(); while (rsw.next()) { data = rsw.getString(xColumnDBname); series.add(Long.parseLong((data).substring(data.length() - 2)), new Long(rsw.getLong(yColumnDBname)).longValue()); } seriesCollection.addSeries(series); dataset = seriesCollection; // create the chart... chart = ChartFactory.createXYLineChart("", // chart title "", // domain axis label "", seriesCollection, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips? false // URLs? ); /* * Additional iView Customization. */ //Set the background color for the chart... chart.setBackgroundPaint(Color.white); //Get a reference to the plot for further customisation... XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(new Color(245, 245, 245)); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setForegroundAlpha(0.7f); //Set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); if (reportColumnBean.getColumnFormat() == TabularReportConstants.BYTE_FORMATTING) { rangeAxis.setTickUnit(new ByteTickUnit(rangeAxis.getUpperBound() / 4)); } rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); rangeAxis.setTickLabelFont(new Font("Vandara", Font.CENTER_BASELINE, 10)); rangeAxis.setTickLabelsVisible(true); rangeAxis.setTickMarksVisible(false); rangeAxis.setAxisLineVisible(false); Axis domainAxis = plot.getDomainAxis(); domainAxis.setTickLabelFont(new Font("Vandara", Font.CENTER_BASELINE, 10)); domainAxis.setTickMarksVisible(false); domainAxis.setAxisLineVisible(false); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, Color.DARK_GRAY); renderer.setSeriesStroke(0, new BasicStroke(1)); } catch (Exception e) { e.printStackTrace(); } return chart; }
From source file:org.gwaspi.reports.GenericReportGenerator.java
private static void appendToCombinedRangeManhattanPlot(CombinedRangeXYPlot combinedPlot, String chromosome, XYSeriesCollection currChrSC, boolean showlables, double threshold, Color background, Color backgroundAlternative, Color main) { XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true); // Set dot shape of the currently appended Series renderer.setSeriesPaint(currChrSC.getSeriesCount() - 1, main); renderer.setSeriesVisibleInLegend(currChrSC.getSeriesCount() - 1, showlables); renderer.setSeriesShape(currChrSC.getSeriesCount() - 1, new Rectangle2D.Double(-1.0, -1.0, 2.0, 2.0)); // Set range axis if (combinedPlot.getSubplots().isEmpty()) { LogAxis rangeAxis = new LogAxis("P value"); rangeAxis.setBase(10);// w ww . j a v a2 s . co m rangeAxis.setInverted(true); rangeAxis.setNumberFormatOverride(FORMAT_P_VALUE); rangeAxis.setTickMarkOutsideLength(2.0f); rangeAxis.setMinorTickCount(2); rangeAxis.setMinorTickMarksVisible(true); rangeAxis.setAxisLineVisible(true); rangeAxis.setUpperMargin(0); TickUnitSource units = NumberAxis.createIntegerTickUnits(); rangeAxis.setStandardTickUnits(units); combinedPlot.setRangeAxis(0, rangeAxis); } // Build subchart JFreeChart subchart = ChartFactory.createScatterPlot("", "Chr " + chromosome, "", currChrSC, PlotOrientation.VERTICAL, false, false, false); // Get subplot from subchart XYPlot subplot = (XYPlot) subchart.getPlot(); subplot.setRenderer(renderer); subplot.setBackgroundPaint(null); // CHART BACKGROUD COLOR if (combinedPlot.getSubplots().size() % 2 == 0) { subplot.setBackgroundPaint(background); // Hue, saturation, brightness } else { subplot.setBackgroundPaint(backgroundAlternative); // Hue, saturation, brightness } // Add significance Threshold to subplot final Marker thresholdLine = new ValueMarker(threshold); thresholdLine.setPaint(Color.red); // Add legend to hetzyThreshold if (showlables) { thresholdLine.setLabel("P = " + FORMAT_P_VALUE.format(threshold)); } thresholdLine.setLabelAnchor(RectangleAnchor.TOP_RIGHT); thresholdLine.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); subplot.addRangeMarker(thresholdLine); // Chromosome Axis Labels NumberAxis chrAxis = (NumberAxis) subplot.getDomainAxis(); chrAxis.setLabelAngle(1.0); chrAxis.setAutoRangeIncludesZero(false); chrAxis.setAxisLineVisible(true); chrAxis.setTickLabelsVisible(false); chrAxis.setTickMarksVisible(false); // chrAxis.setNumberFormatOverride(Report_Analysis.FORMAT_SCIENTIFIC); // TickUnitSource units = NumberAxis.createIntegerTickUnits(); // chrAxis.setStandardTickUnits(units); //combinedPlot.setGap(0); combinedPlot.add(subplot, 1); }
From source file:org.cyberoam.iview.charts.CustomCategoryAxis.java
/** * This method generates JFreeChart instance for 3D Bar chart with iView customization. * @param reportID specifies that for which report Chart is being prepared. * @param rsw specifies data set which would be used for the Chart * @param requeest used for Hyperlink generation from uri. * @return jfreechart instance with iView Customization. *///from w w w. j av a 2 s .c om public static JFreeChart getChart(int reportID, ResultSetWrapper rsw, HttpServletRequest request) { JFreeChart chart = null; boolean isPDF = false; try { if (request == null) { isPDF = true; } /* * Create data set based on rsw object. */ ReportBean reportBean = ReportBean.getRecordbyPrimarykey(reportID); ReportColumnBean reportColumnBeanX, reportColumnBeanY = null; GraphBean graphBean = null; DataLinkBean dataLinkBean = null; DefaultCategoryDataset dataset = new DefaultCategoryDataset(); graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getGraphId());//Getting GraphBean reportColumnBeanX = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getXColumnId());//getting ReportColumnBean For X Axis if (reportColumnBeanX.getDataLinkId() != -1) { dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBeanX.getDataLinkId()); } reportColumnBeanY = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getYColumnId()); rsw.beforeFirst(); int i = 0; DecimalFormat placeHolder = new DecimalFormat("00"); String xData = null; String graphurl = ""; HashMap<Integer, String> urlmap = new HashMap<Integer, String>(); while (rsw.next()) { xData = rsw.getString(reportColumnBeanX.getDbColumnName()); if (dataLinkBean != null && request != null) { //datalink id is non -1 in tblcolumnreport table means another report is avaialble so set url // here multiple url possible bec multiple record so take hashmap and store url. // we have dataset but dataset is occupied. graphurl = dataLinkBean.generateURLForChart(rsw, request); urlmap.put(new Integer(i), graphurl); } //dataset second arugument use for bar line of graph and third argument give name of graph dataset.addValue(new Long(rsw.getLong(reportColumnBeanY.getDbColumnName())), "", placeHolder.format(i) + xData); i++; } // we define object of CustomURLGeneratorForBarChart and if datalinkid is not -1 then it object define for link CustomURLGeneratorForBarChart customURLGeneratorForBarChart = null; if (dataLinkBean != null && request != null) { customURLGeneratorForBarChart = new CustomURLGeneratorForBarChart( dataLinkBean.generateURLForChart(request), reportColumnBeanX.getDbColumnName()); customURLGeneratorForBarChart.setUrlMap(urlmap); } /* * Create the jfree chart object. */ String title = isPDF ? reportBean.getTitle() : ""; chart = ChartFactory.createBarChart3D(title, // chart title "", // domain axis label "", dataset, // data PlotOrientation.HORIZONTAL, // orientation false, // include legend true, // tooltips? false // URLs? ); /* *Setting additional customization to the chart. */ //Set background color chart.setBackgroundPaint(Color.white); //Get a reference to the plot for further customisation CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.DARK_GRAY); plot.setForegroundAlpha(0.8f); plot.setDomainGridlineStroke(new BasicStroke(2)); plot.setOutlineVisible(false); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); //Set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); if (reportColumnBeanY.getColumnFormat() == TabularReportConstants.BYTE_FORMATTING) { rangeAxis.setTickUnit(new ByteTickUnit(rangeAxis.getUpperBound() / 4)); } rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); rangeAxis.setTickLabelFont(new Font("Arial", Font.CENTER_BASELINE, 10)); rangeAxis.setTickLabelsVisible(true); rangeAxis.setTickMarksVisible(true); rangeAxis.setAxisLineVisible(false); rangeAxis.setLabel(reportColumnBeanY.getColumnName()); rangeAxis.setLabelFont(new Font("Arial", Font.CENTER_BASELINE, 12)); rangeAxis.setLabelPaint(new Color(35, 139, 199)); CustomCategoryAxis catAxis = new CustomCategoryAxis(); catAxis.setTickLabelFont(new Font("Arial", Font.CENTER_BASELINE, 10)); catAxis.setTickMarksVisible(false); catAxis.setAxisLineVisible(false); catAxis.setLabel(reportColumnBeanX.getColumnName()); catAxis.setLabelFont(new Font("Arial", Font.CENTER_BASELINE, 12)); catAxis.setLabelPaint(new Color(35, 139, 199)); catAxis.setLabelFormat(reportColumnBeanX.getColumnFormat()); plot.setDomainAxis(catAxis); //Set custom color for the chart. CategoryItemRenderer renderer = new CustomRenderer(new Paint[] { new Color(254, 211, 41), new Color(243, 149, 80), new Color(199, 85, 82), new Color(181, 105, 152), new Color(69, 153, 204), new Color(155, 212, 242), new Color(52, 172, 100), new Color(164, 212, 92), new Color(177, 155, 138), new Color(149, 166, 141) }); plot.setRenderer(renderer); BarRenderer renderer2 = (BarRenderer) plot.getRenderer(); renderer2.setDrawBarOutline(false); renderer2.setBaseItemLabelsVisible(true); renderer2.setMaximumBarWidth(0.04); if (dataLinkBean != null && request != null) { renderer.setBaseItemURLGenerator(customURLGeneratorForBarChart); //renderer.setBaseItemURLGenerator(new CustomURLGeneratorForBarChart(dataLinkBean.generateURLForChart(request),reportColumnBeanX.getDbColumnName())); } renderer.setBaseToolTipGenerator(new CustomToolTipGenerator()); renderer.setBaseToolTipGenerator(new CustomToolTipGenerator()); renderer.setBaseToolTipGenerator( new CustomToolTipGenerator("{2} " + reportColumnBeanY.getColumnName())); } catch (Exception e) { CyberoamLogger.appLog.debug("Bar3D.e:" + e, e); } return chart; }