List of usage examples for org.jfree.chart.axis CategoryAxis setTickMarksVisible
public void setTickMarksVisible(boolean flag)
From source file:edu.ku.brc.specify.toycode.BugParse.java
/** * @param lines/*from w ww . ja va 2 s. c o m*/ */ protected void createChart(final List<String> lines, final String engineer) { int[] mins = new int[lines.size() - 1]; for (int index = 1; index < lines.size(); index++) { String line = lines.get(index); String[] values = StringUtils.splitPreserveAllTokens(line, ","); int inx = 0; while (inx < values.length && values[inx].equals("0")) { inx++; } mins[index - 1] = inx < values.length ? inx : Integer.MAX_VALUE; System.err.println(mins[index - 1]); } int startInx = Integer.MAX_VALUE; for (int min : mins) { startInx = Math.min(startInx, min); System.out.println(min + " " + startInx); } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); String[] headers = StringUtils.split(lines.get(0), ","); int len = headers.length - startInx; System.out.println(headers.length + " " + len); List<double[]> valArray = new Vector<double[]>(); for (int i = 1; i < lines.size(); i++) { String[] values = StringUtils.splitPreserveAllTokens(lines.get(i), ","); double[] vals = new double[len]; int inx = 0; double prev = -1; for (int j = startInx; j < headers.length; j++) { if (StringUtils.isNotEmpty(values[j])) { prev = Double.parseDouble(values[j]); vals[inx++] = prev; } else { vals[inx++] = 0.0; } } valArray.add(vals); } double[] vals = valArray.get(0); for (int i = 0; i < vals.length; i++) { dataset.addValue(vals[i], "Bugs", headers[i + startInx]); } vals = valArray.get(1); for (int i = 0; i < vals.length; i++) { dataset.addValue(vals[i], "Resolved", headers[i + startInx]); } vals = valArray.get(2); for (int i = 0; i < vals.length; i++) { dataset.addValue(vals[i], "Open", headers[i + startInx]); } JFreeChart chart = ChartFactory.createLineChart("Bugs - " + engineer, "Time", "Bugs", dataset, PlotOrientation.VERTICAL, true, true, false); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); //plot.setBackgroundPaint(Color.lightGray); //plot.setRangeGridlinePaint(Color.white); // customise the range axis... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setAxisLineVisible(true); CategoryAxis catAxis = plot.getDomainAxis(); catAxis.setAxisLineVisible(true); catAxis.setTickMarksVisible(true); ChartFrame frame = new ChartFrame("", chart, false); frame.setBackground(Color.WHITE); frame.setSize(500, 500); frame.setVisible(true); }
From source file:org.oscarehr.web.OcanReportingAction.java
private JFreeChart generateChart(String title, String needType, String clientNeedType, List<IndividualNeedsOverTimeChartBean> chartBeanList) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (IndividualNeedsOverTimeChartBean chartBean : chartBeanList) { dataset.addValue(chartBean.getNeedsCountMap().get(needType), "Staff", chartBean.getLabel()); }// w ww . ja v a2 s.c o m for (IndividualNeedsOverTimeChartBean chartBean : chartBeanList) { dataset.addValue(chartBean.getNeedsCountMap().get(clientNeedType), "Consumer", chartBean.getLabel()); } JFreeChart chart = ChartFactory.createLineChart(title, // chart title "OCANs", // x axis label "# of " + WordUtils.capitalize(needType) + " Needs", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); LineAndShapeRenderer renderer = new LineAndShapeRenderer(); plot.setRenderer(renderer); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setTickMarksVisible(true); return chart; }
From source file:org.bhavaya.ui.view.ChartView.java
private JFreeChart createStackedVerticalBarChart() { JFreeChart chart;//from w w w. ja v a2s. com if (isPlot3D()) { chart = ChartFactory.createStackedBarChart3D(getName(), getDomainName(), getRangeName(), tableModelDataSet, PlotOrientation.VERTICAL, true, true, false); } else { chart = ChartFactory.createStackedBarChart(getName(), getDomainName(), getRangeName(), tableModelDataSet, PlotOrientation.VERTICAL, true, true, false); } NumberAxis rangeAxis = (NumberAxis) chart.getCategoryPlot().getRangeAxis(); rangeAxis.setAutoTickUnitSelection(true); CategoryAxis domainAxis = (CategoryAxis) chart.getCategoryPlot().getDomainAxis(); domainAxis.setTickMarksVisible(true); return chart; }
From source file:org.bhavaya.ui.view.ChartView.java
private JFreeChart createVerticalBarChart() { JFreeChart chart;/*from w ww .j a va2 s.co m*/ if (isPlot3D()) { chart = ChartFactory.createBarChart3D(getName(), getDomainName(), getRangeName(), tableModelDataSet, PlotOrientation.VERTICAL, true, true, false); } else { chart = ChartFactory.createBarChart(getName(), getDomainName(), getRangeName(), tableModelDataSet, PlotOrientation.VERTICAL, true, true, false); } NumberAxis rangeAxis = (NumberAxis) chart.getCategoryPlot().getRangeAxis(); rangeAxis.setAutoTickUnitSelection(true); CategoryAxis domainAxis = (CategoryAxis) chart.getCategoryPlot().getDomainAxis(); domainAxis.setTickMarksVisible(true); return chart; }
From source file:org.jfree.eastwood.ChartEngine.java
/** * Processes a string that indicates the axes that should be visible on * the plot.//from w ww . j a v a 2s. c om * * @param plot the plot. * @param axisStr the axis specification. * @param axes a list that will be populated with any axes added to the * plot. */ private static void processAxisStrH(CategoryPlot plot, String axisStr, List axes) { int xAxisCount = 0; int yAxisCount = 0; for (int i = 0; i < axisStr.length(); i++) { char c = axisStr.charAt(i); if (c == 'y') { if (yAxisCount == 0) { CategoryAxis axis = plot.getDomainAxis(); axis.setTickLabelsVisible(true); axes.add(axis); yAxisCount++; } else { GCategoryAxis axis = new GCategoryAxis(); axis.setAxisLineVisible(false); plot.setDomainAxis(yAxisCount, axis); plot.setDomainAxisLocation(xAxisCount, AxisLocation.BOTTOM_OR_LEFT); axes.add(axis); yAxisCount++; } } else if (c == 'x') { if (xAxisCount == 0) { Axis axis = plot.getRangeAxis(); axis.setTickLabelsVisible(true); axis.setTickMarksVisible(true); axes.add(axis); xAxisCount++; } else { GValueAxis axis = new GValueAxis(); axis.setAxisLineVisible(false); plot.setRangeAxis(xAxisCount, axis); plot.setRangeAxisLocation(xAxisCount, AxisLocation.BOTTOM_OR_LEFT); axes.add(axis); xAxisCount++; } } else if (c == 't') { GValueAxis axis = new GValueAxis(); plot.setRangeAxis(xAxisCount, axis); plot.setRangeAxisLocation(yAxisCount, AxisLocation.TOP_OR_LEFT); axes.add(axis); xAxisCount++; } else if (c == 'r') { GCategoryAxis axis = new GCategoryAxis(); plot.setDomainAxis(yAxisCount, axis); plot.setDomainAxisLocation(xAxisCount, AxisLocation.BOTTOM_OR_RIGHT); axes.add(axis); yAxisCount++; } else if (c == ',') { // nothing to do } else { throw new RuntimeException("Bad character " + c); } } }