List of usage examples for org.jfree.chart.renderer.category GanttRenderer setBaseItemLabelsVisible
public void setBaseItemLabelsVisible(boolean visible)
From source file:org.jfree.chart.demo.GanttDemo3.java
private static JFreeChart createChart(IntervalCategoryDataset intervalcategorydataset) { JFreeChart jfreechart = ChartFactory.createGanttChart("Gantt Chart Demo", "Task", "Date", intervalcategorydataset, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.getDomainAxis().setMaximumCategoryLabelWidthRatio(10F); DateAxis dateaxis = (DateAxis) categoryplot.getRangeAxis(); dateaxis.setUpperMargin(0.20000000000000001D); GanttRenderer ganttrenderer = (GanttRenderer) categoryplot.getRenderer(); ganttrenderer.setDrawBarOutline(false); ganttrenderer.setBaseItemLabelGenerator(new MyLabelGenerator(new SimpleDateFormat("d-MMM"))); ganttrenderer.setBaseItemLabelsVisible(true); ganttrenderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT)); return jfreechart; }
From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.java
/** * *//*w w w. j a v a 2 s .c o m*/ protected JFreeChart createGanttChart() throws JRException { //FIXMECHART legend/tooltip/url should come from plot? ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createGanttChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRBarPlot) getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRBarPlot) getPlot()).getValueAxisLabelExpression()), (GanttCategoryDataset) getDataset(), isShowLegend(), true, //FIXMECHART tooltip: I guess BarPlot is not the best for gantt false); configureChart(jfreeChart); CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot(); //plot.setNoDataMessage("No data to display"); JRBarPlot barPlot = (JRBarPlot) getPlot(); boolean isShowTickMarks = barPlot.getShowTickMarks() == null ? true : barPlot.getShowTickMarks(); boolean isShowTickLabels = barPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels(); boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels(); categoryPlot.getDomainAxis().setTickMarksVisible(isShowTickMarks); categoryPlot.getDomainAxis().setTickLabelsVisible(isShowTickLabels); // Handle the axis formating for the category axis configureAxis(categoryPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(), barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(), barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(), barPlot.getCategoryAxisVerticalTickLabels(), barPlot.getCategoryAxisLineColor(), false, null, null); ((DateAxis) categoryPlot.getRangeAxis()).setTickMarksVisible(isShowTickMarks); ((DateAxis) categoryPlot.getRangeAxis()).setTickLabelsVisible(isShowTickLabels); // Handle the axis formating for the value axis configureAxis(categoryPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(), barPlot.getValueAxisLabelColor(), barPlot.getValueAxisTickLabelFont(), barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(), barPlot.getValueAxisVerticalTickLabels(), barPlot.getValueAxisLineColor(), true, (Comparable<?>) evaluateExpression(barPlot.getRangeAxisMinValueExpression()), (Comparable<?>) evaluateExpression(barPlot.getRangeAxisMaxValueExpression())); GanttRenderer categoryRenderer = (GanttRenderer) categoryPlot.getRenderer(); categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator()); categoryRenderer.setBaseItemLabelsVisible(isShowLabels); categoryRenderer.setShadowVisible(false); return jfreeChart; }