List of usage examples for org.jfree.chart.axis CategoryAxis setMaximumCategoryLabelWidthRatio
public void setMaximumCategoryLabelWidthRatio(float ratio)
From source file:org.amanzi.awe.charts.builder.CategoryChartBuilder.java
@Override protected CategoryAxis configDomainAxis(String domainAxisName) { CategoryAxis domainAxis = new CategoryAxis(domainAxisName); domainAxis.setMaximumCategoryLabelWidthRatio(MAXIMUM_CATEGORY_LABEL_WIDTH); domainAxis.setMaximumCategoryLabelLines(MAXIMUM_CATEGORY_LABEL_LINES); domainAxis.setLabel(domainAxisName); domainAxis.setTickLabelFont(getDefaulTickLabelFont()); domainAxis.setLabelFont(getDefaultAxisFont()); return domainAxis; }
From source file:org.sakaiproject.evaluation.tool.reporting.EvalLikertChartBuilder.java
@SuppressWarnings("deprecation") public JFreeChart makeLikertChart() { DefaultCategoryDataset likertDataset = new DefaultCategoryDataset(); for (int i = 0; i < responses.length; i++) { likertDataset.addValue(values[i], "Responses", responses[i]); }/*from w w w. jav a 2 s . c o m*/ JFreeChart chart = ChartFactory.createBarChart(null, // "Likert Chart", // Chart title null, // "Choices", // domain axis label null, // "# of Responses", // range axis label likertDataset, PlotOrientation.HORIZONTAL, false, // show legend false, // show tooltips false // show URLs ); // Set the background colours chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); // Configure the bar colors and display BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, new Color(244, 252, 212)); renderer.setDrawBarOutline(true); renderer.setOutlinePaint(new Color(34, 35, 237)); renderer.setOutlineStroke(new BasicStroke(0.5f)); renderer.setBaseItemLabelsVisible(true); if (showPercentages) { renderer.setBaseItemLabelGenerator(new LikertPercentageItemLabelGenerator(this.responseCount)); } else { renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); } // Turn off the Top Value Axis ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setVisible(false); rangeAxis.setUpperMargin(0.35); rangeAxis.resizeRange(1.1f); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setMaximumCategoryLabelWidthRatio(0.4f); domainAxis.setMaximumCategoryLabelLines(2); // Set the font for the labels Font labelFont = new Font("Serif", Font.PLAIN, 6); CategoryItemRenderer itemRenderer = plot.getRenderer(); itemRenderer.setBaseItemLabelFont(labelFont); plot.setOutlinePaint(null); domainAxis.setLabelFont(labelFont); domainAxis.setTickLabelFont(labelFont); rangeAxis.setLabelFont(labelFont); rangeAxis.setTickLabelFont(labelFont); return chart; }
From source file:Interface.ResultadoJanela.java
public JFreeChart gerarGrafico(CategoryDataset dataSet) { JFreeChart chart = ChartFactory.createBarChart3D("Resultado da Localizao de Defeitos", //Titulo " ", // Eixo X "Probabilidade (%)", //Eixo Y dataSet, // Dados para o grafico PlotOrientation.VERTICAL, //Orientacao do grafico true, true, true); // exibir: legendas, tooltips, url chart.setBackgroundPaint(Color.getHSBColor(0, 0, (float) 0.835)); // Set the background colour of the chart CategoryPlot p = chart.getCategoryPlot(); // Get the Plot object for a bar graph p.setBackgroundPaint(Color.white); // Modify the plot background p.setRangeGridlinePaint(Color.BLACK); CategoryAxis axis = p.getDomainAxis(); axis.setTickLabelFont(new Font("Helvetica", Font.PLAIN, 10)); axis.setMaximumCategoryLabelWidthRatio(1.0f); axis.setMaximumCategoryLabelLines(2); p.setDomainAxis(axis);/*from w w w . j av a 2s . c o m*/ return chart; }
From source file:com.att.aro.main.FileTypesChartPanel.java
/** * Initializes the File Type chart./*from w w w . ja va2s.c o m*/ */ private void initialize() { JFreeChart chart = ChartFactory.createBarChart(rb.getString("chart.filetype.title"), null, rb.getString("simple.percent"), null, PlotOrientation.HORIZONTAL, false, false, false); chart.setBackgroundPaint(this.getBackground()); chart.getTitle().setFont(AROUIManager.HEADER_FONT); this.plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setMaximumCategoryLabelWidthRatio(.5f); domainAxis.setLabelFont(AROUIManager.LABEL_FONT); domainAxis.setTickLabelFont(AROUIManager.LABEL_FONT); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setRange(0.0, 100.0); rangeAxis.setTickUnit(new NumberTickUnit(10)); rangeAxis.setLabelFont(AROUIManager.LABEL_FONT); rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT); BarRenderer renderer = new StackedBarRenderer(); renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR); renderer.setAutoPopulateSeriesPaint(false); renderer.setBaseItemLabelGenerator(new PercentLabelGenerator()); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelPaint(Color.black); // Make second bar in stack invisible renderer.setSeriesItemLabelsVisible(1, false); renderer.setSeriesPaint(1, new Color(0, 0, 0, 0)); renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() { @Override public String generateToolTip(CategoryDataset dataset, int row, int column) { FileTypeSummary summary = content.get(column); return MessageFormat.format(rb.getString("chart.filetype.tooltip"), NumberFormat.getIntegerInstance().format(summary.getBytes())); } }); ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT); renderer.setBasePositiveItemLabelPosition(insideItemlabelposition); ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition); BarPainter painter = new StandardBarPainter(); renderer.setBarPainter(painter); renderer.setShadowVisible(false); renderer.setMaximumBarWidth(0.1); plot.setRenderer(renderer); plot.getDomainAxis().setMaximumCategoryLabelLines(2); ChartPanel chartPanel = new ChartPanel(chart, WIDTH, HEIGHT, 400, ChartPanel.DEFAULT_MINIMUM_DRAW_HEIGHT, ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH, ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT, USER_BUFFER, PROPERTIES, COPY, SAVE, PRINT, ZOOM, TOOL_TIPS); chartPanel.setDomainZoomable(false); chartPanel.setRangeZoomable(false); this.add(chartPanel, BorderLayout.CENTER); }
From source file:com.att.aro.main.ProperSessionTerminationPanel.java
/** * Initializes the Panel for Proper Session Termination plot. *///from w w w. ja va2 s. c om private void initialize() { JFreeChart chart = ChartFactory.createBarChart(rb.getString("overview.sessionoverview.title"), null, null, createDataset(null), PlotOrientation.HORIZONTAL, false, false, false); chart.setBackgroundPaint(this.getBackground()); chart.getTitle().setFont(AROUIManager.HEADER_FONT); this.plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setMaximumCategoryLabelWidthRatio(1.0f); domainAxis.setMaximumCategoryLabelLines(2); domainAxis.setLabelFont(AROUIManager.LABEL_FONT); domainAxis.setTickLabelFont(AROUIManager.LABEL_FONT); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLabel(rb.getString("analysisresults.percentage")); rangeAxis.setRange(0.0, 100.0); rangeAxis.setTickUnit(new NumberTickUnit(10)); rangeAxis.setLabelFont(AROUIManager.LABEL_FONT); rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT); BarRenderer renderer = new StackedBarRenderer(); renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR); renderer.setAutoPopulateSeriesPaint(false); renderer.setBaseItemLabelGenerator(new PercentLabelGenerator()); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelPaint(Color.black); // Make second bar in stack invisible renderer.setSeriesItemLabelsVisible(1, false); renderer.setSeriesPaint(1, new Color(0, 0, 0, 0)); ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT); renderer.setBasePositiveItemLabelPosition(insideItemlabelposition); ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition); renderer.setBarPainter(new StandardBarPainter()); renderer.setShadowVisible(false); renderer.setMaximumBarWidth(BAR_WIDTH_PERCENT); renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() { @Override public String generateToolTip(CategoryDataset arg0, int arg1, int arg2) { String sessionInfo = ""; switch (arg2) { case SESSION_TERMINATION: sessionInfo = rb.getString("tooltip.sessionTermination"); break; case SESSION_TIGHT_CONN: sessionInfo = rb.getString("tooltip.sessionTightConn"); break; case SESSION_BURST: sessionInfo = rb.getString("tooltip.sessionBurst"); break; case SESSION_LONG_BURST: sessionInfo = rb.getString("tooltip.sessionLongBurst"); break; } return sessionInfo; } }); plot.setRenderer(renderer); plot.getDomainAxis().setMaximumCategoryLabelLines(2); ChartPanel chartPanel = new ChartPanel(chart, WIDTH, HEIGHT, ChartPanel.DEFAULT_MINIMUM_DRAW_WIDTH + 100, 100, ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH, ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT, USER_BUFFER, PROPERTIES, COPY, SAVE, PRINT, ZOOM, TOOL_TIPS); chartPanel.setDomainZoomable(false); chartPanel.setRangeZoomable(false); this.add(chartPanel, BorderLayout.CENTER); }
From source file:com.att.aro.main.TraceOverviewPanel.java
/** * Initializes the Main panel and its various components. *//* ww w. j ava2s.co m*/ private void initialize() { JFreeChart chart = ChartFactory.createBarChart(rb.getString("overview.traceoverview.title"), null, null, createDataset(null), PlotOrientation.HORIZONTAL, false, true, false); chart.setBackgroundPaint(this.getBackground()); chart.getTitle().setFont(AROUIManager.HEADER_FONT); this.plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); CategoryAxis valueRangeAxis = plot.getDomainAxis(); valueRangeAxis.setMaximumCategoryLabelWidthRatio(1.0f); valueRangeAxis.setMaximumCategoryLabelLines(2); valueRangeAxis.setLabelFont(AROUIManager.LABEL_FONT); valueRangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLabel(rb.getString("analysisresults.percentile")); rangeAxis.setRange(0.0, 100.0); rangeAxis.setTickUnit(new NumberTickUnit(10)); rangeAxis.setLabelFont(AROUIManager.LABEL_FONT); rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT); BarRenderer renderer = new StackedBarRenderer(); renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR); renderer.setAutoPopulateSeriesPaint(false); renderer.setBaseItemLabelGenerator(new PercentLabelGenerator()); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelPaint(Color.black); // Make second bar in stack invisible renderer.setSeriesItemLabelsVisible(1, false); renderer.setSeriesPaint(1, new Color(0, 0, 0, 0)); ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT); renderer.setBasePositiveItemLabelPosition(insideItemlabelposition); ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition); renderer.setBarPainter(new StandardBarPainter()); renderer.setShadowVisible(false); renderer.setMaximumBarWidth(BAR_WIDTH_PERCENT); renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() { @Override public String generateToolTip(CategoryDataset arg0, int arg1, int arg2) { String traceInfo = ""; switch (arg2) { case TRACE_AVERAGE: traceInfo = rb.getString("tooltip.traceAnalysis.avg"); break; case TRACE_ENERGY: traceInfo = rb.getString("tooltip.traceAnalysis.engy"); break; case TRACE_OVERHEAD: traceInfo = rb.getString("tooltip.traceAnalysis.ovrhd"); break; } return traceInfo; } }); plot.setRenderer(renderer); plot.getDomainAxis().setMaximumCategoryLabelLines(2); ChartPanel chartPanel = new ChartPanel(chart, WIDTH, HEIGHT, ChartPanel.DEFAULT_MINIMUM_DRAW_WIDTH + 100, 100, ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH, ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT, USER_BUFFER, PROPERTIES, COPY, SAVE, PRINT, ZOOM, TOOL_TIPS); chartPanel.setDomainZoomable(false); chartPanel.setRangeZoomable(false); this.add(chartPanel, BorderLayout.CENTER); }
From source file:com.att.aro.ui.view.overviewtab.FileTypesChartPanel.java
private JFreeChart initializeChart() { JFreeChart chart = ChartFactory.createBarChart( ResourceBundleHelper.getMessageString("chart.filetype.title"), null, ResourceBundleHelper.getMessageString("simple.percent"), null, PlotOrientation.HORIZONTAL, false, false, false);/*from w w w .j a v a 2 s . c o m*/ //chart.setBackgroundPaint(fileTypePanel.getBackground()); chart.setBackgroundPaint(this.getBackground()); chart.getTitle().setFont(AROUIManager.HEADER_FONT); this.cPlot = chart.getCategoryPlot(); cPlot.setBackgroundPaint(Color.white); cPlot.setDomainGridlinePaint(Color.gray); cPlot.setRangeGridlinePaint(Color.gray); cPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); CategoryAxis domainAxis = cPlot.getDomainAxis(); domainAxis.setMaximumCategoryLabelWidthRatio(.5f); domainAxis.setLabelFont(AROUIManager.LABEL_FONT); domainAxis.setTickLabelFont(AROUIManager.LABEL_FONT); NumberAxis rangeAxis = (NumberAxis) cPlot.getRangeAxis(); rangeAxis.setRange(0.0, 100.0); rangeAxis.setTickUnit(new NumberTickUnit(10)); rangeAxis.setLabelFont(AROUIManager.LABEL_FONT); rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT); BarRenderer renderer = new StackedBarRenderer(); renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR); renderer.setAutoPopulateSeriesPaint(false); renderer.setBaseItemLabelGenerator(new PercentLabelGenerator()); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelPaint(Color.black); // Make second bar in stack invisible renderer.setSeriesItemLabelsVisible(1, false); renderer.setSeriesPaint(1, new Color(0, 0, 0, 0)); renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() { @Override public String generateToolTip(CategoryDataset dataset, int row, int column) { FileTypeSummary summary = fileTypeContent.get(column); return MessageFormat.format(ResourceBundleHelper.getMessageString("chart.filetype.tooltip"), NumberFormat.getIntegerInstance().format(summary.getBytes())); } }); ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT); renderer.setBasePositiveItemLabelPosition(insideItemlabelposition); ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition); BarPainter painter = new StandardBarPainter(); renderer.setBarPainter(painter); renderer.setShadowVisible(false); renderer.setMaximumBarWidth(0.1); cPlot.setRenderer(renderer); cPlot.getDomainAxis().setMaximumCategoryLabelLines(2); return chart; }
From source file:com.att.aro.ui.view.overviewtab.TraceBenchmarkChartPanel.java
private JFreeChart initializeChart() { JFreeChart chart = ChartFactory.createBarChart( ResourceBundleHelper.getMessageString("overview.traceoverview.title"), null, null, createDataset(), PlotOrientation.HORIZONTAL, false, true, false); chart.setBackgroundPaint(this.getBackground()); chart.getTitle().setFont(AROUIManager.HEADER_FONT); this.plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); CategoryAxis valueRangeAxis = plot.getDomainAxis(); valueRangeAxis.setMaximumCategoryLabelWidthRatio(1.0f); valueRangeAxis.setMaximumCategoryLabelLines(2); valueRangeAxis.setLabelFont(AROUIManager.LABEL_FONT); valueRangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLabel(ResourceBundleHelper.getMessageString("analysisresults.percentile")); rangeAxis.setRange(0.0, 100.0);/*w w w .j a v a 2s. c o m*/ rangeAxis.setTickUnit(new NumberTickUnit(10)); rangeAxis.setLabelFont(AROUIManager.LABEL_FONT); rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT); BarRenderer renderer = new StackedBarRenderer(); renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR); renderer.setAutoPopulateSeriesPaint(false); renderer.setBaseItemLabelGenerator(new PercentLabelGenerator()); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelPaint(Color.black); // Make second bar in stack invisible renderer.setSeriesItemLabelsVisible(1, false); renderer.setSeriesPaint(1, new Color(0, 0, 0, 0)); ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT); renderer.setBasePositiveItemLabelPosition(insideItemlabelposition); ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition); renderer.setBarPainter(new StandardBarPainter()); renderer.setShadowVisible(false); renderer.setMaximumBarWidth(BAR_WIDTH_PERCENT); renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() { @Override public String generateToolTip(CategoryDataset arg0, int arg1, int arg2) { String traceInfo = ""; switch (arg2) { case TRACE_AVERAGE: traceInfo = ResourceBundleHelper.getMessageString("tooltip.traceAnalysis.avg"); break; case TRACE_ENERGY: traceInfo = ResourceBundleHelper.getMessageString("tooltip.traceAnalysis.engy"); break; case TRACE_OVERHEAD: traceInfo = ResourceBundleHelper.getMessageString("tooltip.traceAnalysis.ovrhd"); break; default: break; } return traceInfo; } }); plot.setRenderer(renderer); plot.getDomainAxis().setMaximumCategoryLabelLines(2); return chart; }
From source file:com.att.aro.ui.view.overviewtab.ConnectionStatisticsChartPanel.java
public JFreeChart initializeChart() { JFreeChart chart = ChartFactory.createBarChart( ResourceBundleHelper.getMessageString("overview.sessionoverview.title"), null, null, createDataset(), PlotOrientation.HORIZONTAL, false, false, false); chart.setBackgroundPaint(this.getBackground()); chart.getTitle().setFont(AROUIManager.HEADER_FONT); this.plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setMaximumCategoryLabelWidthRatio(1.0f); domainAxis.setMaximumCategoryLabelLines(2); domainAxis.setLabelFont(AROUIManager.LABEL_FONT); domainAxis.setTickLabelFont(AROUIManager.LABEL_FONT); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLabel(ResourceBundleHelper.getMessageString("analysisresults.percentage")); rangeAxis.setRange(0.0, 100.0);/*from ww w . j a v a 2 s. co m*/ rangeAxis.setTickUnit(new NumberTickUnit(10)); rangeAxis.setLabelFont(AROUIManager.LABEL_FONT); rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT); BarRenderer renderer = new StackedBarRenderer(); renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR); renderer.setAutoPopulateSeriesPaint(false); renderer.setBaseItemLabelGenerator(new PercentLabelGenerator()); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelPaint(Color.black); // Make second bar in stack invisible renderer.setSeriesItemLabelsVisible(1, false); renderer.setSeriesPaint(1, new Color(0, 0, 0, 0)); ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT); renderer.setBasePositiveItemLabelPosition(insideItemlabelposition); ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition); renderer.setBarPainter(new StandardBarPainter()); renderer.setShadowVisible(false); renderer.setMaximumBarWidth(BAR_WIDTH_PERCENT); renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() { @Override public String generateToolTip(CategoryDataset arg0, int arg1, int arg2) { String sessionInfo = ""; switch (arg2) { case SESSION_TERMINATION: sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionTermination"); break; case SESSION_TIGHT_CONN: sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionTightConn"); break; case SESSION_BURST: sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionBurst"); break; case SESSION_LONG_BURST: sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionLongBurst"); break; default: break; } return sessionInfo; } }); plot.setRenderer(renderer); plot.getDomainAxis().setMaximumCategoryLabelLines(2); return chart; }
From source file:com.pureinfo.srm.reports.impl.CategoryChartBuilder.java
/** * @see com.pureinfo.srm.reports.IChartBuilder#buildChart(java.util.List, * int, java.lang.String)//from w ww. ja v a 2 s. c om */ public JFreeChart buildChart() { CategoryDataset dataset = createDataset(); JFreeChart jfreechart = MyChartFactory.createBarChart3D(null, m_sXAxisName, m_sYXxisName, dataset, PlotOrientation.VERTICAL, false, false, false); CategoryPlot categoryplot = jfreechart.getCategoryPlot(); jfreechart.setBackgroundPaint(Color.white); categoryplot.setDomainGridlinesVisible(false); categoryplot.setRangeGridlinesVisible(true); categoryplot.setForegroundAlpha(0.8f); categoryplot.setDrawingSupplier(new DefaultDrawingSupplier(MyPaintMgr.getPaints(), DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); CategoryAxis categoryAxisX = categoryplot.getDomainAxis(); categoryAxisX.setTickLabelsVisible(true); categoryAxisX.setLabel(null); categoryAxisX.setMaximumCategoryLabelWidthRatio(.8f); ValueAxis categoryAxisY = categoryplot.getRangeAxis(); categoryAxisY.setVerticalTickLabels(false); // categoryplot.setDrawSharedDomainAxis(false); categoryAxisX.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(0.39269908169872414D)); BarRenderer3D barrenderer3d = (BarRenderer3D) categoryplot.getRenderer(); barrenderer3d.setDrawBarOutline(false); barrenderer3d.setItemLabelsVisible(true); barrenderer3d.setBaseItemLabelsVisible(false); barrenderer3d.setSeriesVisible(Boolean.FALSE); //CategoryPlot categoryPlot = jfreechart.getCategoryPlot(); // categoryPlot.setBackgroundPaint(Color.lightGray); // categoryPlot.setDomainGridlinePaint(Color.white); // categoryPlot.setRangeGridlinePaint(Color.white); // // BarRenderer barRenderer = (BarRenderer) categoryPlot.getRenderer(); // barRenderer.setDrawBarOutline(false); // barRenderer.setMaxBarWidth(0.03); // GradientPaint gradientPaint = new GradientPaint(0.0F, 0.0F, // Color.red, 0.0F, 0.0F, new Color(64, 0, 0)); // barRenderer.setSeriesPaint(0, gradientPaint); DecimalFormat format = null; if (m_dblMaxData > 1) { format = new DecimalFormat("#,###"); } else { StringBuffer sb = new StringBuffer(); sb.append("0.00#"); for (double i = m_dblMaxData; i != 0 && i < 1; i *= 10f) { sb.append("#"); } format = new DecimalFormat(sb.toString()); } fillChartInfo(dataset, format); barrenderer3d.setMaxBarWidth(8.0 / m_ChartInfo.getChartSize().x); NumberAxis numberAxis = (NumberAxis) categoryplot.getRangeAxis(0); numberAxis.setUpperMargin(0.149999999999D); numberAxis.setNumberFormatOverride(format); categoryAxisX.setCategoryLabelPositions(CategoryLabelPositions.UP_45); NumberAxis dataNumberAxis = (NumberAxis) categoryplot.getRangeAxisForDataset(0); dataNumberAxis.setUpperMargin(0.149999999999D); dataNumberAxis.setNumberFormatOverride(format); // CategoryItemRenderer renderer = categoryPlot.getRenderer(); // CategoryItemLabelGenerator generator = new StandardCategoryItemLabelGenerator("{2}", format); // renderer.setItemLabelGenerator(generator); // renderer.setItemLabelFont(new Font("Serif", 0, 9)); // renderer.setItemLabelsVisible(true); return jfreechart; }