/** * Changes the font of {@link JFreeChart}s to Sans Serif. This method uses a * {@link StandardChartTheme} to do so, so any changes to the look of the chart must be done * after calling this method. * * @param chart * the chart to change fonts for */ protected static void setDefaultChartFonts(JFreeChart chart) { final ChartTheme chartTheme = StandardChartTheme.createJFreeTheme(); if (StandardChartTheme.class.isAssignableFrom(chartTheme.getClass())) { StandardChartTheme standardTheme = (StandardChartTheme) chartTheme; // The default font used by JFreeChart cannot render japanese etc symbols final Font oldExtraLargeFont = standardTheme.getExtraLargeFont(); final Font oldLargeFont = standardTheme.getLargeFont(); final Font oldRegularFont = standardTheme.getRegularFont(); final Font oldSmallFont = standardTheme.getSmallFont(); final Font extraLargeFont = new Font(Font.SANS_SERIF, oldExtraLargeFont.getStyle(), oldExtraLargeFont.getSize()); final Font largeFont = new Font(Font.SANS_SERIF, oldLargeFont.getStyle(), oldLargeFont.getSize()); final Font regularFont = new Font(Font.SANS_SERIF, oldRegularFont.getStyle(), oldRegularFont.getSize()); final Font smallFont = new Font(Font.SANS_SERIF, oldSmallFont.getStyle(), oldSmallFont.getSize()); standardTheme.setExtraLargeFont(extraLargeFont); standardTheme.setLargeFont(largeFont); standardTheme.setRegularFont(regularFont); standardTheme.setSmallFont(smallFont); standardTheme.apply(chart); } }
public void applyChartTheme() { final StandardChartTheme chartTheme = (StandardChartTheme) org.jfree.chart.StandardChartTheme .createJFreeTheme(); final Font oldExtraLargeFont = chartTheme.getExtraLargeFont(); final Font oldLargeFont = chartTheme.getLargeFont(); final Font oldRegularFont = chartTheme.getRegularFont(); final Font oldSmallFont = chartTheme.getSmallFont(); final Font extraLargeFont = new Font("Sans-serif", oldExtraLargeFont.getStyle(), oldExtraLargeFont.getSize()); final Font largeFont = new Font("Sans-serif", oldLargeFont.getStyle(), oldLargeFont.getSize()); final Font regularFont = new Font("Sans-serif", oldRegularFont.getStyle(), oldRegularFont.getSize()); final Font smallFont = new Font("Sans-serif", oldSmallFont.getStyle(), oldSmallFont.getSize()); chartTheme.setExtraLargeFont(extraLargeFont); chartTheme.setLargeFont(largeFont); chartTheme.setRegularFont(regularFont); chartTheme.setSmallFont(smallFont); chartTheme.apply(chart); }
/** * Changes the font of {@link JFreeChart}s to Sans Serif. This method uses a * {@link StandardChartTheme} to do so, so any changes to the look of the chart must be done * after calling this method. * * @param chart * the chart to change fonts for */ protected static void setDefaultChartFonts(JFreeChart chart) { final ChartTheme chartTheme = StandardChartTheme.createJFreeTheme(); if (StandardChartTheme.class.isAssignableFrom(chartTheme.getClass())) { StandardChartTheme standardTheme = (StandardChartTheme) chartTheme; // The default font used by JFreeChart cannot render japanese etc symbols final Font oldExtraLargeFont = standardTheme.getExtraLargeFont(); final Font oldLargeFont = standardTheme.getLargeFont(); final Font oldRegularFont = standardTheme.getRegularFont(); final Font oldSmallFont = standardTheme.getSmallFont(); final Font extraLargeFont = FontTools.getFont(Font.SANS_SERIF, oldExtraLargeFont.getStyle(), oldExtraLargeFont.getSize()); final Font largeFont = FontTools.getFont(Font.SANS_SERIF, oldLargeFont.getStyle(), oldLargeFont.getSize()); final Font regularFont = FontTools.getFont(Font.SANS_SERIF, oldRegularFont.getStyle(), oldRegularFont.getSize()); final Font smallFont = FontTools.getFont(Font.SANS_SERIF, oldSmallFont.getStyle(), oldSmallFont.getSize()); standardTheme.setExtraLargeFont(extraLargeFont); standardTheme.setLargeFont(largeFont); standardTheme.setRegularFont(regularFont); standardTheme.setSmallFont(smallFont); standardTheme.apply(chart); } }
public static StandardChartTheme initializeTheme() { String fontName = "Arial"; StandardChartTheme theme = (StandardChartTheme) org.jfree.chart.StandardChartTheme.createJFreeTheme(); theme.setExtraLargeFont(new Font(fontName, Font.PLAIN, 24)); // title theme.setLargeFont(new Font(fontName, Font.PLAIN, 20)); // axis-title theme.setRegularFont(new Font(fontName, Font.PLAIN, 16)); theme.setSmallFont(new Font(fontName, Font.PLAIN, 12)); theme.setRangeGridlinePaint(Color.decode("#C0C0C0")); theme.setPlotBackgroundPaint(Color.white); theme.setChartBackgroundPaint(Color.white); theme.setGridBandPaint(Color.red); theme.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); theme.setBarPainter(new StandardBarPainter()); theme.setAxisLabelPaint(Color.decode("#666666")); return theme; }
public static void setChartTheme() { StandardChartTheme chartTheme = new StandardChartTheme("CN"); chartTheme.setExtraLargeFont(FONT); chartTheme.setRegularFont(FONT); chartTheme.setLargeFont(FONT); chartTheme.setSmallFont(FONT); chartTheme.setTitlePaint(new Color(51, 51, 51)); chartTheme.setSubtitlePaint(new Color(85, 85, 85)); chartTheme.setLegendBackgroundPaint(Color.WHITE); chartTheme.setLegendItemPaint(Color.BLACK);// chartTheme.setChartBackgroundPaint(Color.WHITE); Paint[] OUTLINE_PAINT_SEQUENCE = new Paint[]{Color.WHITE}; DefaultDrawingSupplier drawingSupplier = new DefaultDrawingSupplier(CHART_COLORS, CHART_COLORS, OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE); chartTheme.setDrawingSupplier(drawingSupplier); chartTheme.setPlotBackgroundPaint(Color.WHITE); chartTheme.setPlotOutlinePaint(Color.WHITE); chartTheme.setLabelLinkPaint(new Color(8, 55, 114)); chartTheme.setLabelLinkStyle(PieLabelLinkStyle.CUBIC_CURVE); chartTheme.setAxisOffset(new RectangleInsets(5, 12, 5, 12)); chartTheme.setDomainGridlinePaint(new Color(192, 208, 224)); chartTheme.setRangeGridlinePaint(new Color(192, 192, 192)); chartTheme.setBaselinePaint(Color.WHITE); chartTheme.setCrosshairPaint(Color.BLUE); chartTheme.setAxisLabelPaint(new Color(51, 51, 51)); chartTheme.setTickLabelPaint(new Color(67, 67, 72)); chartTheme.setBarPainter(new StandardBarPainter()); chartTheme.setXYBarPainter(new StandardXYBarPainter()); chartTheme.setItemLabelPaint(Color.black); chartTheme.setThermometerPaint(Color.white); ChartFactory.setChartTheme(chartTheme); }
private JFreeChart createChart(String chartContent, String title, String yaxisName){ //创建时序图对象 XYSeries = new XYSeries(chartContent); XYSeriesCollection xySeriesCollection=new XYSeriesCollection(XYSeries); // 设置中文主题样式 解决乱码 StandardChartTheme chartTheme = new StandardChartTheme("CN"); // 设置标题字体 chartTheme.setExtraLargeFont(font); // 设置图例的字体 chartTheme.setRegularFont(font); // 设置轴向的字体 chartTheme.setLargeFont(font); chartTheme.setSmallFont(font); ChartFactory.setChartTheme(chartTheme); JFreeChart jfreechart = ChartFactory.createXYLineChart(title,"帧数",yaxisName,xySeriesCollection); XYPlot xyplot = jfreechart.getXYPlot(); //纵坐标设定 ValueAxis valueaxis = xyplot.getDomainAxis(); //自动设置数据轴数据范围 valueaxis.setAutoRange(true); //数据轴固定数据范围 30s //valueaxis.setFixedAutoRange(100); valueaxis = xyplot.getRangeAxis(); return jfreechart; }
/** * */ protected JFreeChart createAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createAreaChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRAreaPlot)getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRAreaPlot)getPlot()).getValueAxisLabelExpression()), (CategoryDataset)getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); JRAreaPlot areaPlot = (JRAreaPlot)getPlot(); // Handle the axis formating for the category axis configureAxis(((CategoryPlot)jfreeChart.getPlot()).getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(), false, (Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(((CategoryPlot)jfreeChart.getPlot()).getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(), true, (Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
protected JFreeChart createBubbleChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createBubbleChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRBubblePlot)getPlot()).getXAxisLabelExpression()), evaluateTextExpression(((JRBubblePlot)getPlot()).getYAxisLabelExpression()), (XYZDataset)getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); XYPlot xyPlot = (XYPlot)jfreeChart.getPlot(); JRBubblePlot bubblePlot = (JRBubblePlot)getPlot(); int scaleType = bubblePlot.getScaleTypeValue() == null ? ScaleTypeEnum.ON_RANGE_AXIS.getValue() : bubblePlot.getScaleTypeValue().getValue(); XYBubbleRenderer bubbleRenderer = new XYBubbleRenderer( scaleType ); xyPlot.setRenderer( bubbleRenderer ); // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), bubblePlot.getXAxisLabelFont(), bubblePlot.getXAxisLabelColor(), bubblePlot.getXAxisTickLabelFont(), bubblePlot.getXAxisTickLabelColor(), bubblePlot.getXAxisTickLabelMask(), bubblePlot.getXAxisVerticalTickLabels(), bubblePlot.getOwnXAxisLineColor(), false, (Comparable<?>)evaluateExpression(bubblePlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(bubblePlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), bubblePlot.getYAxisLabelFont(), bubblePlot.getYAxisLabelColor(), bubblePlot.getYAxisTickLabelFont(), bubblePlot.getYAxisTickLabelColor(), bubblePlot.getYAxisTickLabelMask(), bubblePlot.getYAxisVerticalTickLabels(), bubblePlot.getOwnYAxisLineColor(), true, (Comparable<?>)evaluateExpression(bubblePlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(bubblePlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
/** * * @param evaluation * @throws net.sf.jasperreports.engine.JRException */ protected JFreeChart createCandlestickChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createCandlestickChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRCandlestickPlot)getPlot()).getTimeAxisLabelExpression()), evaluateTextExpression(((JRCandlestickPlot)getPlot()).getValueAxisLabelExpression()), (DefaultHighLowDataset)getDataset(), isShowLegend() ); configureChart(jfreeChart, getPlot()); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); JRCandlestickPlot candlestickPlot = (JRCandlestickPlot)getPlot(); CandlestickRenderer candlestickRenderer = (CandlestickRenderer) xyPlot.getRenderer(); boolean isShowVolume = candlestickPlot.getShowVolume() == null ? true : candlestickPlot.getShowVolume().booleanValue(); candlestickRenderer.setDrawVolume(isShowVolume); // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), candlestickPlot.getTimeAxisLabelFont(), candlestickPlot.getTimeAxisLabelColor(), candlestickPlot.getTimeAxisTickLabelFont(), candlestickPlot.getTimeAxisTickLabelColor(), candlestickPlot.getTimeAxisTickLabelMask(), candlestickPlot.getTimeAxisVerticalTickLabels(), candlestickPlot.getOwnTimeAxisLineColor(), false, (Comparable<?>)evaluateExpression(candlestickPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(candlestickPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), candlestickPlot.getValueAxisLabelFont(), candlestickPlot.getValueAxisLabelColor(), candlestickPlot.getValueAxisTickLabelFont(), candlestickPlot.getValueAxisTickLabelColor(), candlestickPlot.getValueAxisTickLabelMask(), candlestickPlot.getValueAxisVerticalTickLabels(), candlestickPlot.getOwnValueAxisLineColor(), true, (Comparable<?>)evaluateExpression(candlestickPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(candlestickPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
/** * */ protected JFreeChart createStackedAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createStackedAreaChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRAreaPlot)getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRAreaPlot)getPlot()).getValueAxisLabelExpression()), (CategoryDataset)getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false ); configureChart(jfreeChart, getPlot()); JRAreaPlot areaPlot = (JRAreaPlot)getPlot(); // Handle the axis formating for the category axis configureAxis(((CategoryPlot)jfreeChart.getPlot()).getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(), false, (Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(((CategoryPlot)jfreeChart.getPlot()).getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(), true, (Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMaxValueExpression())); ((CategoryPlot)jfreeChart.getPlot()).getDomainAxis().setCategoryMargin(0); return jfreeChart; }
protected JFreeChart createXyAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createXYAreaChart( evaluateTextExpression(getChart().getTitleExpression() ), evaluateTextExpression(((JRAreaPlot)getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRAreaPlot)getPlot()).getValueAxisLabelExpression()), (XYDataset)getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false ); configureChart(jfreeChart, getPlot()); JRAreaPlot areaPlot = (JRAreaPlot)getPlot(); // Handle the axis formating for the category axis configureAxis(jfreeChart.getXYPlot().getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(), false, (Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(jfreeChart.getXYPlot().getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(), true, (Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
/** * */ protected JFreeChart createAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createAreaChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRAreaPlot)getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRAreaPlot)getPlot()).getValueAxisLabelExpression()), (CategoryDataset)getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); JRAreaPlot areaPlot = (JRAreaPlot)getPlot(); // Handle the axis formating for the category axis configureAxis(((CategoryPlot)jfreeChart.getPlot()).getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(), getDomainAxisSettings(), (Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMaxValueExpression()) ); // Handle the axis formating for the value axis configureAxis(((CategoryPlot)jfreeChart.getPlot()).getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), (Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMaxValueExpression()) ); return jfreeChart; }
/** * */ protected JFreeChart createStackedBarChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createStackedBarChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRBarPlot)getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRBarPlot)getPlot()).getValueAxisLabelExpression()), (CategoryDataset)getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false ); configureChart(jfreeChart, getPlot()); CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot(); JRBarPlot barPlot = (JRBarPlot)getPlot(); //plot.setNoDataMessage("No data to display"); boolean isShowTickMarks = barPlot.getShowTickMarks() == null ? true : barPlot.getShowTickMarks().booleanValue(); boolean isShowTickLabels = barPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels().booleanValue(); boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels().booleanValue(); categoryPlot.getDomainAxis().setTickMarksVisible(isShowTickMarks); categoryPlot.getDomainAxis().setTickLabelsVisible(isShowTickLabels); ((NumberAxis)categoryPlot.getRangeAxis()).setTickMarksVisible(isShowTickMarks); ((NumberAxis)categoryPlot.getRangeAxis()).setTickLabelsVisible(isShowTickLabels); BarRenderer categoryRenderer = (BarRenderer)categoryPlot.getRenderer(); categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator()); categoryRenderer.setBaseItemLabelsVisible(isShowLabels); categoryRenderer.setShadowVisible(false); // Handle the axis formating for the category axis configureAxis(categoryPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(), barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(), barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(), barPlot.getCategoryAxisVerticalTickLabels(), barPlot.getOwnCategoryAxisLineColor(), getDomainAxisSettings(), (Comparable<?>)evaluateExpression(barPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(barPlot.getDomainAxisMaxValueExpression()) ); // Handle the axis formating for the value axis configureAxis(categoryPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(), barPlot.getValueAxisLabelColor(), barPlot.getValueAxisTickLabelFont(), barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(), barPlot.getValueAxisVerticalTickLabels(), barPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), (Comparable<?>)evaluateExpression(barPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(barPlot.getRangeAxisMaxValueExpression()) ); return jfreeChart; }
protected JFreeChart createXyAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createXYAreaChart( evaluateTextExpression(getChart().getTitleExpression() ), evaluateTextExpression(((JRAreaPlot)getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRAreaPlot)getPlot()).getValueAxisLabelExpression()), (XYDataset)getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false ); configureChart(jfreeChart, getPlot()); JRAreaPlot areaPlot = (JRAreaPlot)getPlot(); // Handle the axis formating for the category axis configureAxis(jfreeChart.getXYPlot().getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(), getDomainAxisSettings(), (Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMaxValueExpression()) ); // Handle the axis formating for the value axis configureAxis(jfreeChart.getXYPlot().getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), (Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMaxValueExpression()) ); return jfreeChart; }
/** * */ protected JFreeChart createAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createAreaChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRAreaPlot)getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRAreaPlot)getPlot()).getValueAxisLabelExpression()), (CategoryDataset)getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart); JRAreaPlot areaPlot = (JRAreaPlot)getPlot(); // Handle the axis formating for the category axis configureAxis(((CategoryPlot)jfreeChart.getPlot()).getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getCategoryAxisLineColor(), false, (Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(((CategoryPlot)jfreeChart.getPlot()).getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getValueAxisLineColor(), true, (Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
protected JFreeChart createBubbleChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createBubbleChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRBubblePlot)getPlot()).getXAxisLabelExpression()), evaluateTextExpression(((JRBubblePlot)getPlot()).getYAxisLabelExpression()), (XYZDataset)getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart); XYPlot xyPlot = (XYPlot)jfreeChart.getPlot(); JRBubblePlot bubblePlot = (JRBubblePlot)getPlot(); int scaleType = bubblePlot.getScaleTypeValue() == null ? ScaleTypeEnum.ON_RANGE_AXIS.getValue() : bubblePlot.getScaleTypeValue().getValue(); XYBubbleRenderer bubbleRenderer = new XYBubbleRenderer( scaleType ); xyPlot.setRenderer( bubbleRenderer ); // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), bubblePlot.getXAxisLabelFont(), bubblePlot.getXAxisLabelColor(), bubblePlot.getXAxisTickLabelFont(), bubblePlot.getXAxisTickLabelColor(), bubblePlot.getXAxisTickLabelMask(), bubblePlot.getXAxisVerticalTickLabels(), bubblePlot.getXAxisLineColor(), false, (Comparable<?>)evaluateExpression(bubblePlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(bubblePlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), bubblePlot.getYAxisLabelFont(), bubblePlot.getYAxisLabelColor(), bubblePlot.getYAxisTickLabelFont(), bubblePlot.getYAxisTickLabelColor(), bubblePlot.getYAxisTickLabelMask(), bubblePlot.getYAxisVerticalTickLabels(), bubblePlot.getYAxisLineColor(), true, (Comparable<?>)evaluateExpression(bubblePlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(bubblePlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
/** * */ protected JFreeChart createCandlestickChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createCandlestickChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRCandlestickPlot)getPlot()).getTimeAxisLabelExpression()), evaluateTextExpression(((JRCandlestickPlot)getPlot()).getValueAxisLabelExpression()), (DefaultHighLowDataset)getDataset(), isShowLegend() ); configureChart(jfreeChart); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); JRCandlestickPlot candlestickPlot = (JRCandlestickPlot)getPlot(); CandlestickRenderer candlestickRenderer = (CandlestickRenderer) xyPlot.getRenderer(); boolean isShowVolume = candlestickPlot.getShowVolume() == null ? true : candlestickPlot.getShowVolume().booleanValue(); candlestickRenderer.setDrawVolume(isShowVolume); // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), candlestickPlot.getTimeAxisLabelFont(), candlestickPlot.getTimeAxisLabelColor(), candlestickPlot.getTimeAxisTickLabelFont(), candlestickPlot.getTimeAxisTickLabelColor(), candlestickPlot.getTimeAxisTickLabelMask(), candlestickPlot.getTimeAxisVerticalTickLabels(), candlestickPlot.getTimeAxisLineColor(), false, (Comparable<?>)evaluateExpression(candlestickPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(candlestickPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), candlestickPlot.getValueAxisLabelFont(), candlestickPlot.getValueAxisLabelColor(), candlestickPlot.getValueAxisTickLabelFont(), candlestickPlot.getValueAxisTickLabelColor(), candlestickPlot.getValueAxisTickLabelMask(), candlestickPlot.getValueAxisVerticalTickLabels(), candlestickPlot.getValueAxisLineColor(), true, (Comparable<?>)evaluateExpression(candlestickPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(candlestickPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
/** * */ protected JFreeChart createStackedAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createStackedAreaChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRAreaPlot)getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRAreaPlot)getPlot()).getValueAxisLabelExpression()), (CategoryDataset)getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false ); configureChart(jfreeChart); JRAreaPlot areaPlot = (JRAreaPlot)getPlot(); // Handle the axis formating for the category axis configureAxis(((CategoryPlot)jfreeChart.getPlot()).getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getCategoryAxisLineColor(), false, (Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(((CategoryPlot)jfreeChart.getPlot()).getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getValueAxisLineColor(), true, (Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMaxValueExpression())); ((CategoryPlot)jfreeChart.getPlot()).getDomainAxis().setCategoryMargin(0); return jfreeChart; }
protected JFreeChart createXyAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createXYAreaChart( evaluateTextExpression(getChart().getTitleExpression() ), evaluateTextExpression(((JRAreaPlot)getPlot()).getCategoryAxisLabelExpression() ), evaluateTextExpression(((JRAreaPlot)getPlot()).getValueAxisLabelExpression()), (XYDataset)getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false ); configureChart(jfreeChart); JRAreaPlot areaPlot = (JRAreaPlot)getPlot(); // Handle the axis formating for the category axis configureAxis(jfreeChart.getXYPlot().getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getCategoryAxisLineColor(), false, (Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(jfreeChart.getXYPlot().getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getValueAxisLineColor(), true, (Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
public StandardChartTheme getStandardChartTheme() { StandardChartTheme standardChartTheme = new StandardChartTheme(""); standardChartTheme.setExtraLargeFont(new Font("微软雅黑", Font.PLAIN, 16));// 可以改变轴向的字体 standardChartTheme.setRegularFont(new Font("微软雅黑", Font.PLAIN, 16));// 可以改变图例的字体 standardChartTheme.setLargeFont(new Font("宋体", Font.PLAIN, 16)); // 可以改变图标的标题字体 return standardChartTheme; }
/** * Creates a sample chart. * * @param dataset the dataset. * * @return A sample chart. */ private JFreeChart createPolarPlot(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createPolarChart( "Satellite Locations", dataset, false, //lengend true, // tooltips false // url ); final PolarPlot plot = (PolarPlot) chart.getPlot(); chart.setBackgroundPaint(new Color(220,220,220)); ChartTheme dark = StandardChartTheme.createDarknessTheme(); dark.apply(chart); plot.setOutlinePaint(Color.BLACK); //final DefaultPolarItemRenderer renderer = (DefaultPolarItemRenderer) plot.getRenderer(); // set renderer - using my custom one SctterPlotItemGPSRenderer rend = new SctterPlotItemGPSRenderer(); plot.setRenderer(rend); // set horizon = 0-90 ValueAxis axis = plot.getAxis(); axis.setRange(0.0,90.0); // set tick spacing //axis.getRange(). //axis.setAutoTickUnitSelection(false); //axis.setAutoRangeMinimumSize(3); TickUnits tu = new TickUnits(); tu.add( new NumberTickUnit(15)); axis.setStandardTickUnits( tu ); return chart; }
private static void notSoUglyPlease(JFreeChart chart) { String fontName = "Lucida Sans"; StandardChartTheme theme = (StandardChartTheme)org.jfree.chart.StandardChartTheme.createJFreeTheme(); theme.setTitlePaint( Color.decode("#4572a7") ); theme.setExtraLargeFont(new Font(fontName, Font.BOLD, 14)); //title theme.setLargeFont(new Font(fontName, Font.BOLD, 15)); //axis-title theme.setRegularFont(new Font(fontName, Font.PLAIN, 11)); theme.setRangeGridlinePaint(Color.decode("#C0C0C0")); theme.setPlotBackgroundPaint(Color.white); theme.setChartBackgroundPaint(Color.white); theme.setGridBandPaint(Color.red); theme.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); theme.setBarPainter(new StandardBarPainter()); theme.setAxisLabelPaint(Color.decode("#666666")); theme.apply(chart); chart.getCategoryPlot().setOutlineVisible(false); chart.getCategoryPlot().getRangeAxis().setAxisLineVisible(false); chart.getCategoryPlot().getRangeAxis().setTickMarksVisible(false); chart.getCategoryPlot().setRangeGridlineStroke(new BasicStroke()); chart.getCategoryPlot().getRangeAxis().setTickLabelPaint(Color.decode("#666666")); chart.getCategoryPlot().getDomainAxis().setTickLabelPaint(Color.decode("#666666")); chart.setTextAntiAlias(true); chart.setAntiAlias(true); BarRenderer rend = (BarRenderer) chart.getCategoryPlot().getRenderer(); rend.setShadowVisible(true); rend.setShadowXOffset(2); rend.setShadowYOffset(0); rend.setShadowPaint(Color.decode("#C0C0C0")); rend.setMaximumBarWidth(0.1); }
/** * Helper method that returns the JFreeChart to an output stream written in JPEG format. * * @param chartName a {@link java.lang.String} object. * @param out a {@link java.io.OutputStream} object. * @throws org.exolab.castor.xml.MarshalException if any. * @throws org.exolab.castor.xml.ValidationException if any. * @throws java.io.IOException if any. * @throws java.sql.SQLException if any. */ public static void getBarChartPNG(String chartName, OutputStream out) throws MarshalException, ValidationException, IOException, SQLException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); BarChart chartConfig = getBarChartConfigByName(chartName); JFreeChart chart = getBarChart(chartName); if(chartConfig.getChartBackgroundColor() != null) { setChartBackgroundColor(chartConfig, chart); } if(chartConfig.getPlotBackgroundColor() != null) { setPlotBackgroundColor(chartConfig, chart); } ImageSize imageSize = chartConfig.getImageSize(); int hzPixels; int vtPixels; if (imageSize == null) { hzPixels = 400; vtPixels = 400; } else { hzPixels = imageSize.getHzSize().getPixels(); vtPixels = imageSize.getVtSize().getPixels(); } ChartUtilities.writeChartAsPNG(out, chart, hzPixels, vtPixels, false, 6); }
private static JFreeChart createBarChart(ADCDataset dataset) { AutoSubCategoryAxis categoryAxis = new AutoSubCategoryAxis(dataset); categoryAxis.setCategoryLabelPositionOffset(0); categoryAxis.setLabel(dataset.get(Attribute.X_AXIS_LABEL)); CategoryDataset fixedDataset = categoryAxis.getFixedDataset(); PartitionedNumberAxis vAxis = new PartitionedNumberAxis( dataset.get(Attribute.Y_AXIS_LABEL)); CategoryPlot plot = new CategoryPlot(fixedDataset, categoryAxis, vAxis, new Renderer(fixedDataset)); plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart(dataset.get(Attribute.TITLE), JFreeChart.DEFAULT_TITLE_FONT, plot, false); final LegendItemCollection items = new LegendItemCollection(); for(Condition c : Condition.values()) { if(c != Condition.NOT_EVALUATED) { items.add(new LegendItem(c.getLabel(), null, null, null, new Rectangle2D.Double(-6.0, -6.0, 10.0,10.0), c.getColor())); } } LegendTitle legend = new LegendTitle(new LegendItemSource() { @Override public LegendItemCollection getLegendItems() { return items; }}); legend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0)); legend.setBackgroundPaint(Color.white); legend.setPosition(RectangleEdge.BOTTOM); chart.addLegend(legend); new StandardChartTheme("JFree").apply(chart); return chart; }
private static JFreeChart createStackBarChart(ADCDataset dataset,String title) { AutoSubCategoryAxis dAxis = new AutoSubCategoryAxis(dataset); dAxis.setCategoryLabelPositionOffset(0); dAxis.setLabel(dataset.get(Attribute.X_AXIS_LABEL)); PartitionedNumberAxis vAxis = new PartitionedNumberAxis( dataset.get(Attribute.Y_AXIS_LABEL)); CategoryPlot plot = new CategoryPlot(dAxis.getFixedDataset(), dAxis, vAxis, new Renderer()); plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false); new StandardChartTheme("JFree").apply(chart); return chart; }
public TopNChartTableBuilder() { ChartTheme chartTheme = new StandardChartTheme("sansserif"); ChartFactory.setChartTheme(chartTheme); }
public CasesByAgeGroupChartTableBuilder() { ChartTheme chartTheme = new StandardChartTheme("sansserif"); ChartFactory.setChartTheme(chartTheme); }
/** * * @param evaluation * @throws JRException */ protected JFreeChart createHighLowChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createHighLowChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRHighLowPlot)getPlot()).getTimeAxisLabelExpression()), evaluateTextExpression(((JRHighLowPlot)getPlot()).getValueAxisLabelExpression()), (DefaultHighLowDataset)getDataset(), isShowLegend() ); configureChart(jfreeChart, getPlot()); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); JRHighLowPlot highLowPlot = (JRHighLowPlot)getPlot(); HighLowRenderer hlRenderer = (HighLowRenderer) xyPlot.getRenderer(); boolean isShowOpenTicks = highLowPlot.getShowOpenTicks() == null ? false : highLowPlot.getShowOpenTicks().booleanValue(); boolean isShowCloseTicks = highLowPlot.getShowCloseTicks() == null ? false : highLowPlot.getShowCloseTicks().booleanValue(); hlRenderer.setDrawOpenTicks(isShowOpenTicks); hlRenderer.setDrawCloseTicks(isShowCloseTicks); // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), highLowPlot.getTimeAxisLabelFont(), highLowPlot.getTimeAxisLabelColor(), highLowPlot.getTimeAxisTickLabelFont(), highLowPlot.getTimeAxisTickLabelColor(), highLowPlot.getTimeAxisTickLabelMask(), highLowPlot.getTimeAxisVerticalTickLabels(), highLowPlot.getOwnTimeAxisLineColor(), false, (Comparable<?>)evaluateExpression(highLowPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(highLowPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), highLowPlot.getValueAxisLabelFont(), highLowPlot.getValueAxisLabelColor(), highLowPlot.getValueAxisTickLabelFont(), highLowPlot.getValueAxisTickLabelColor(), highLowPlot.getValueAxisTickLabelMask(), highLowPlot.getValueAxisVerticalTickLabels(), highLowPlot.getOwnValueAxisLineColor(), true, (Comparable<?>)evaluateExpression(highLowPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(highLowPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
protected JFreeChart createLineChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart freeChart = ChartFactory.createLineChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression( ((JRLinePlot)getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRLinePlot)getPlot()).getValueAxisLabelExpression()), (CategoryDataset)getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false); configureChart(freeChart, getPlot()); CategoryPlot categoryPlot = (CategoryPlot)freeChart.getPlot(); JRLinePlot linePlot = (JRLinePlot)getPlot(); LineAndShapeRenderer lineRenderer = (LineAndShapeRenderer)categoryPlot.getRenderer(); boolean isShowShapes = linePlot.getShowShapes() == null ? true : linePlot.getShowShapes().booleanValue(); boolean isShowLines = linePlot.getShowLines() == null ? true : linePlot.getShowLines().booleanValue(); lineRenderer.setBaseShapesVisible( isShowShapes );//FIXMECHART check this lineRenderer.setBaseLinesVisible( isShowLines ); //FIXME labels? // Handle the axis formating for the category axis configureAxis(categoryPlot.getDomainAxis(), linePlot.getCategoryAxisLabelFont(), linePlot.getCategoryAxisLabelColor(), linePlot.getCategoryAxisTickLabelFont(), linePlot.getCategoryAxisTickLabelColor(), linePlot.getCategoryAxisTickLabelMask(), linePlot.getCategoryAxisVerticalTickLabels(), linePlot.getOwnCategoryAxisLineColor(), false, (Comparable<?>)evaluateExpression(linePlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(linePlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(categoryPlot.getRangeAxis(), linePlot.getValueAxisLabelFont(), linePlot.getValueAxisLabelColor(), linePlot.getValueAxisTickLabelFont(), linePlot.getValueAxisTickLabelColor(), linePlot.getValueAxisTickLabelMask(), linePlot.getValueAxisVerticalTickLabels(), linePlot.getOwnValueAxisLineColor(), true, (Comparable<?>)evaluateExpression(linePlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(linePlot.getRangeAxisMaxValueExpression())); return freeChart; }
protected JFreeChart createScatterChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createScatterPlot( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRScatterPlot)getPlot()).getXAxisLabelExpression()), evaluateTextExpression(((JRScatterPlot)getPlot()).getYAxisLabelExpression()), (XYDataset)getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); XYLineAndShapeRenderer plotRenderer = (XYLineAndShapeRenderer) ((XYPlot)jfreeChart.getPlot()).getRenderer(); JRScatterPlot scatterPlot = (JRScatterPlot) getPlot(); boolean isShowLines = scatterPlot.getShowLines() == null ? true : scatterPlot.getShowLines().booleanValue(); boolean isShowShapes = scatterPlot.getShowShapes() == null ? true : scatterPlot.getShowShapes().booleanValue(); plotRenderer.setBaseLinesVisible(isShowLines); plotRenderer.setBaseShapesVisible(isShowShapes); // Handle the axis formating for the category axis configureAxis(jfreeChart.getXYPlot().getDomainAxis(), scatterPlot.getXAxisLabelFont(), scatterPlot.getXAxisLabelColor(), scatterPlot.getXAxisTickLabelFont(), scatterPlot.getXAxisTickLabelColor(), scatterPlot.getXAxisTickLabelMask(), scatterPlot.getXAxisVerticalTickLabels(), scatterPlot.getOwnXAxisLineColor(), false, (Comparable<?>)evaluateExpression(scatterPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(scatterPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(jfreeChart.getXYPlot().getRangeAxis(), scatterPlot.getYAxisLabelFont(), scatterPlot.getYAxisLabelColor(), scatterPlot.getYAxisTickLabelFont(), scatterPlot.getYAxisTickLabelColor(), scatterPlot.getYAxisTickLabelMask(), scatterPlot.getYAxisVerticalTickLabels(), scatterPlot.getOwnYAxisLineColor(), true, (Comparable<?>)evaluateExpression(scatterPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(scatterPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
/** * */ protected JFreeChart createStackedBar3DChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createStackedBarChart3D( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRBar3DPlot)getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRBar3DPlot)getPlot()).getValueAxisLabelExpression()), (CategoryDataset)getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false ); configureChart(jfreeChart, getPlot()); CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot(); JRBar3DPlot bar3DPlot = (JRBar3DPlot)getPlot(); StackedBarRenderer3D stackedBarRenderer3D = new StackedBarRenderer3D( bar3DPlot.getXOffsetDouble() == null ? StackedBarRenderer3D.DEFAULT_X_OFFSET : bar3DPlot.getXOffsetDouble().doubleValue(), bar3DPlot.getYOffsetDouble() == null ? StackedBarRenderer3D.DEFAULT_Y_OFFSET : bar3DPlot.getYOffsetDouble().doubleValue() ); stackedBarRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator()); stackedBarRenderer3D.setBaseItemLabelsVisible( bar3DPlot.getShowLabels() ); categoryPlot.setRenderer(stackedBarRenderer3D); // Handle the axis formating for the category axis configureAxis(categoryPlot.getDomainAxis(), bar3DPlot.getCategoryAxisLabelFont(), bar3DPlot.getCategoryAxisLabelColor(), bar3DPlot.getCategoryAxisTickLabelFont(), bar3DPlot.getCategoryAxisTickLabelColor(), bar3DPlot.getCategoryAxisTickLabelMask(), bar3DPlot.getCategoryAxisVerticalTickLabels(), bar3DPlot.getOwnCategoryAxisLineColor(), false, (Comparable<?>)evaluateExpression(bar3DPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(bar3DPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(categoryPlot.getRangeAxis(), bar3DPlot.getValueAxisLabelFont(), bar3DPlot.getValueAxisLabelColor(), bar3DPlot.getValueAxisTickLabelFont(), bar3DPlot.getValueAxisTickLabelColor(), bar3DPlot.getValueAxisTickLabelMask(), bar3DPlot.getValueAxisVerticalTickLabels(), bar3DPlot.getOwnValueAxisLineColor(), true, (Comparable<?>)evaluateExpression(bar3DPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(bar3DPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
/** * */ protected JFreeChart createStackedBarChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createStackedBarChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRBarPlot)getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRBarPlot)getPlot()).getValueAxisLabelExpression()), (CategoryDataset)getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false ); configureChart(jfreeChart, getPlot()); CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot(); JRBarPlot barPlot = (JRBarPlot)getPlot(); //plot.setNoDataMessage("No data to display"); boolean isShowTickMarks = barPlot.getShowTickMarks() == null ? true : barPlot.getShowTickMarks().booleanValue(); boolean isShowTickLabels = barPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels().booleanValue(); boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels().booleanValue(); categoryPlot.getDomainAxis().setTickMarksVisible(isShowTickMarks); categoryPlot.getDomainAxis().setTickLabelsVisible(isShowTickLabels); ((NumberAxis)categoryPlot.getRangeAxis()).setTickMarksVisible(isShowTickMarks); ((NumberAxis)categoryPlot.getRangeAxis()).setTickLabelsVisible(isShowTickLabels); BarRenderer categoryRenderer = (BarRenderer)categoryPlot.getRenderer(); categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator()); categoryRenderer.setBaseItemLabelsVisible(isShowLabels); categoryRenderer.setShadowVisible(false); // Handle the axis formating for the category axis configureAxis(categoryPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(), barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(), barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(), barPlot.getCategoryAxisVerticalTickLabels(), barPlot.getOwnCategoryAxisLineColor(), false, (Comparable<?>)evaluateExpression(barPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(barPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(categoryPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(), barPlot.getValueAxisLabelColor(), barPlot.getValueAxisTickLabelFont(), barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(), barPlot.getValueAxisVerticalTickLabels(), barPlot.getOwnValueAxisLineColor(), true, (Comparable<?>)evaluateExpression(barPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(barPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
/** * */ protected JFreeChart createXYBarChart() throws JRException { IntervalXYDataset tmpDataset = (IntervalXYDataset)getDataset(); boolean isDate = true; if ( getChart().getDataset().getDatasetType() == JRChartDataset.XY_DATASET ){ isDate = false; } ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createXYBarChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRBarPlot)getPlot()).getCategoryAxisLabelExpression()), isDate, evaluateTextExpression(((JRBarPlot)getPlot()).getValueAxisLabelExpression()), tmpDataset, getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false ); configureChart(jfreeChart, getPlot()); XYPlot xyPlot = (XYPlot)jfreeChart.getPlot(); //plot.setNoDataMessage("No data to display"); // ((XYPlot)plot.getDomainAxis()).setTickMarksVisible( // ((JRBarPlot)getPlot()).isShowTickMarks() // ); // ((CategoryAxis)plot.getDomainAxis()).setTickLabelsVisible( // ((JRBarPlot)getPlot()).isShowTickLabels() // ); // ((NumberAxis)plot.getRangeAxis()).setTickMarksVisible( // ((JRBarPlot)getPlot()).isShowTickMarks() // ); // ((NumberAxis)plot.getRangeAxis()).setTickLabelsVisible( // ((JRBarPlot)getPlot()).isShowTickLabels() // ); XYBarRenderer itemRenderer = (XYBarRenderer)xyPlot.getRenderer(); itemRenderer.setBaseItemLabelGenerator((XYItemLabelGenerator)getLabelGenerator()); itemRenderer.setShadowVisible(false); JRBarPlot barPlot = (JRBarPlot)getPlot(); boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels().booleanValue(); itemRenderer.setBaseItemLabelsVisible( isShowLabels ); // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(), barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(), barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(), barPlot.getCategoryAxisVerticalTickLabels(), barPlot.getOwnCategoryAxisLineColor(), false, (Comparable<?>)evaluateExpression(barPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(barPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(), barPlot.getValueAxisLabelColor(), barPlot.getValueAxisTickLabelFont(), barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(), barPlot.getValueAxisVerticalTickLabels(), barPlot.getOwnValueAxisLineColor(), true, (Comparable<?>)evaluateExpression(barPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(barPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
protected JFreeChart createXyLineChart() throws JRException { JRLinePlot linePlot = (JRLinePlot) getPlot(); ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createXYLineChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(linePlot.getCategoryAxisLabelExpression()), evaluateTextExpression(linePlot.getValueAxisLabelExpression()), (XYDataset)getDataset(), linePlot.getOrientationValue().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); // Handle the axis formating for the category axis configureAxis(jfreeChart.getXYPlot().getDomainAxis(), linePlot.getCategoryAxisLabelFont(), linePlot.getCategoryAxisLabelColor(), linePlot.getCategoryAxisTickLabelFont(), linePlot.getCategoryAxisTickLabelColor(), linePlot.getCategoryAxisTickLabelMask(), linePlot.getCategoryAxisVerticalTickLabels(), linePlot.getOwnCategoryAxisLineColor(), false, (Comparable<?>)evaluateExpression(linePlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(linePlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(jfreeChart.getXYPlot().getRangeAxis(), linePlot.getValueAxisLabelFont(), linePlot.getValueAxisLabelColor(), linePlot.getValueAxisTickLabelFont(), linePlot.getValueAxisTickLabelColor(), linePlot.getValueAxisTickLabelMask(), linePlot.getValueAxisVerticalTickLabels(), linePlot.getOwnValueAxisLineColor(), true, (Comparable<?>)evaluateExpression(linePlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(linePlot.getRangeAxisMaxValueExpression())); XYLineAndShapeRenderer lineRenderer = (XYLineAndShapeRenderer) jfreeChart.getXYPlot().getRenderer(); boolean isShowShapes = linePlot.getShowShapes() == null ? true : linePlot.getShowShapes().booleanValue(); boolean isShowLines = linePlot.getShowLines() == null ? true : linePlot.getShowLines().booleanValue(); lineRenderer.setBaseShapesVisible(isShowShapes); lineRenderer.setBaseLinesVisible(isShowLines); return jfreeChart; }
protected JFreeChart createTimeSeriesChart() throws JRException { String timeAxisLabel = evaluateTextExpression(((JRTimeSeriesPlot)getPlot()).getTimeAxisLabelExpression()); String valueAxisLabel = evaluateTextExpression(((JRTimeSeriesPlot)getPlot()).getValueAxisLabelExpression()); ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createTimeSeriesChart( evaluateTextExpression(getChart().getTitleExpression()), timeAxisLabel, valueAxisLabel, (TimeSeriesCollection)getDataset(), isShowLegend(), true, false ); configureChart(jfreeChart, getPlot()); XYPlot xyPlot = (XYPlot)jfreeChart.getPlot(); JRTimeSeriesPlot timeSeriesPlot = (JRTimeSeriesPlot)getPlot(); XYLineAndShapeRenderer lineRenderer = (XYLineAndShapeRenderer)xyPlot.getRenderer(); boolean isShowShapes = timeSeriesPlot.getShowShapes() == null ? true : timeSeriesPlot.getShowShapes().booleanValue(); boolean isShowLines = timeSeriesPlot.getShowLines() == null ? true : timeSeriesPlot.getShowLines().booleanValue(); lineRenderer.setBaseLinesVisible(isShowLines); lineRenderer.setBaseShapesVisible(isShowShapes); // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), timeSeriesPlot.getTimeAxisLabelFont(), timeSeriesPlot.getTimeAxisLabelColor(), timeSeriesPlot.getTimeAxisTickLabelFont(), timeSeriesPlot.getTimeAxisTickLabelColor(), timeSeriesPlot.getTimeAxisTickLabelMask(), timeSeriesPlot.getTimeAxisVerticalTickLabels(), timeSeriesPlot.getOwnTimeAxisLineColor(), false, (Comparable<?>)evaluateExpression(timeSeriesPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(timeSeriesPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), timeSeriesPlot.getValueAxisLabelFont(), timeSeriesPlot.getValueAxisLabelColor(), timeSeriesPlot.getValueAxisTickLabelFont(), timeSeriesPlot.getValueAxisTickLabelColor(), timeSeriesPlot.getValueAxisTickLabelMask(), timeSeriesPlot.getValueAxisVerticalTickLabels(), timeSeriesPlot.getOwnValueAxisLineColor(), true, (Comparable<?>)evaluateExpression(timeSeriesPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(timeSeriesPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
/** * */ 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, getPlot()); CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot(); //plot.setNoDataMessage("No data to display"); JRBarPlot barPlot = (JRBarPlot)getPlot(); boolean isShowTickMarks = barPlot.getShowTickMarks() == null ? true : barPlot.getShowTickMarks().booleanValue(); boolean isShowTickLabels = barPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels().booleanValue(); boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels().booleanValue(); 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.getOwnCategoryAxisLineColor(), 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.getOwnValueAxisLineColor(), true, (Comparable<?>)evaluateExpression(barPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(barPlot.getRangeAxisMaxValueExpression())); BarRenderer categoryRenderer = (BarRenderer)categoryPlot.getRenderer(); categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator()); categoryRenderer.setBaseItemLabelsVisible(isShowLabels); categoryRenderer.setShadowVisible(false); return jfreeChart; }
protected JFreeChart createBubbleChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createBubbleChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRBubblePlot)getPlot()).getXAxisLabelExpression()), evaluateTextExpression(((JRBubblePlot)getPlot()).getYAxisLabelExpression()), (XYZDataset)getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); XYPlot xyPlot = (XYPlot)jfreeChart.getPlot(); JRBubblePlot bubblePlot = (JRBubblePlot)getPlot(); int scaleType = bubblePlot.getScaleTypeValue() == null ? ScaleTypeEnum.ON_RANGE_AXIS.getValue() : bubblePlot.getScaleTypeValue().getValue(); XYBubbleRenderer bubbleRenderer = new XYBubbleRenderer( scaleType ); xyPlot.setRenderer( bubbleRenderer ); // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), bubblePlot.getXAxisLabelFont(), bubblePlot.getXAxisLabelColor(), bubblePlot.getXAxisTickLabelFont(), bubblePlot.getXAxisTickLabelColor(), bubblePlot.getXAxisTickLabelMask(), bubblePlot.getXAxisVerticalTickLabels(), bubblePlot.getOwnXAxisLineColor(), getDomainAxisSettings(), (Comparable<?>)evaluateExpression(bubblePlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(bubblePlot.getDomainAxisMaxValueExpression()) ); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), bubblePlot.getYAxisLabelFont(), bubblePlot.getYAxisLabelColor(), bubblePlot.getYAxisTickLabelFont(), bubblePlot.getYAxisTickLabelColor(), bubblePlot.getYAxisTickLabelMask(), bubblePlot.getYAxisVerticalTickLabels(), bubblePlot.getOwnYAxisLineColor(), getRangeAxisSettings(), (Comparable<?>)evaluateExpression(bubblePlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(bubblePlot.getRangeAxisMaxValueExpression()) ); return jfreeChart; }
/** * * @param evaluation * @throws net.sf.jasperreports.engine.JRException */ protected JFreeChart createCandlestickChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createCandlestickChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRCandlestickPlot)getPlot()).getTimeAxisLabelExpression()), evaluateTextExpression(((JRCandlestickPlot)getPlot()).getValueAxisLabelExpression()), (DefaultHighLowDataset)getDataset(), isShowLegend() ); configureChart(jfreeChart, getPlot()); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); JRCandlestickPlot candlestickPlot = (JRCandlestickPlot)getPlot(); CandlestickRenderer candlestickRenderer = (CandlestickRenderer) xyPlot.getRenderer(); boolean isShowVolume = candlestickPlot.getShowVolume() == null ? true : candlestickPlot.getShowVolume().booleanValue(); candlestickRenderer.setDrawVolume(isShowVolume); // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), candlestickPlot.getTimeAxisLabelFont(), candlestickPlot.getTimeAxisLabelColor(), candlestickPlot.getTimeAxisTickLabelFont(), candlestickPlot.getTimeAxisTickLabelColor(), candlestickPlot.getTimeAxisTickLabelMask(), candlestickPlot.getTimeAxisVerticalTickLabels(), candlestickPlot.getOwnTimeAxisLineColor(), getDomainAxisSettings(), (Comparable<?>)evaluateExpression(candlestickPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(candlestickPlot.getDomainAxisMaxValueExpression()) ); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), candlestickPlot.getValueAxisLabelFont(), candlestickPlot.getValueAxisLabelColor(), candlestickPlot.getValueAxisTickLabelFont(), candlestickPlot.getValueAxisTickLabelColor(), candlestickPlot.getValueAxisTickLabelMask(), candlestickPlot.getValueAxisVerticalTickLabels(), candlestickPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), (Comparable<?>)evaluateExpression(candlestickPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(candlestickPlot.getRangeAxisMaxValueExpression()) ); return jfreeChart; }
/** * * @param evaluation * @throws JRException */ protected JFreeChart createHighLowChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createHighLowChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRHighLowPlot)getPlot()).getTimeAxisLabelExpression()), evaluateTextExpression(((JRHighLowPlot)getPlot()).getValueAxisLabelExpression()), (DefaultHighLowDataset)getDataset(), isShowLegend() ); configureChart(jfreeChart, getPlot()); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); JRHighLowPlot highLowPlot = (JRHighLowPlot)getPlot(); HighLowRenderer hlRenderer = (HighLowRenderer) xyPlot.getRenderer(); boolean isShowOpenTicks = highLowPlot.getShowOpenTicks() == null ? false : highLowPlot.getShowOpenTicks().booleanValue(); boolean isShowCloseTicks = highLowPlot.getShowCloseTicks() == null ? false : highLowPlot.getShowCloseTicks().booleanValue(); hlRenderer.setDrawOpenTicks(isShowOpenTicks); hlRenderer.setDrawCloseTicks(isShowCloseTicks); // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), highLowPlot.getTimeAxisLabelFont(), highLowPlot.getTimeAxisLabelColor(), highLowPlot.getTimeAxisTickLabelFont(), highLowPlot.getTimeAxisTickLabelColor(), highLowPlot.getTimeAxisTickLabelMask(), highLowPlot.getTimeAxisVerticalTickLabels(), highLowPlot.getOwnTimeAxisLineColor(), getDomainAxisSettings(), (Comparable<?>)evaluateExpression(highLowPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(highLowPlot.getDomainAxisMaxValueExpression()) ); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), highLowPlot.getValueAxisLabelFont(), highLowPlot.getValueAxisLabelColor(), highLowPlot.getValueAxisTickLabelFont(), highLowPlot.getValueAxisTickLabelColor(), highLowPlot.getValueAxisTickLabelMask(), highLowPlot.getValueAxisVerticalTickLabels(), highLowPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), (Comparable<?>)evaluateExpression(highLowPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(highLowPlot.getRangeAxisMaxValueExpression()) ); return jfreeChart; }