List of usage examples for java.text NumberFormat getPercentInstance
public static final NumberFormat getPercentInstance()
From source file:net.droidsolutions.droidcharts.core.label.AbstractCategoryItemLabelGenerator.java
/** * Creates a label generator with the specified date formatter. * * @param labelFormat the label format string (<code>null</code> not * permitted).//from w ww. j a v a2s.c o m * @param formatter the date formatter (<code>null</code> not permitted). */ protected AbstractCategoryItemLabelGenerator(String labelFormat, DateFormat formatter) { if (labelFormat == null) { throw new IllegalArgumentException("Null 'labelFormat' argument."); } if (formatter == null) { throw new IllegalArgumentException("Null 'formatter' argument."); } this.labelFormat = labelFormat; this.numberFormat = null; this.percentFormat = NumberFormat.getPercentInstance(); this.dateFormat = formatter; this.nullValueString = "-"; }
From source file:org.squale.squaleweb.util.graph.PieChartMaker.java
/** * Factorisation du code commun la gnration du graphe * /* www . j av a2 s . com*/ * @param pRequest la requte * @return graphe de type Bubble */ private JFreeChart getCommonChart(HttpServletRequest pRequest) { JFreeChart chart = ChartFactory.createPieChart3D(mTitle, mDataSet, false, false, false); PiePlot3D pieplot3d = (PiePlot3D) chart.getPlot(); final double startAngle = 290D; pieplot3d.setStartAngle(startAngle); final float depthFactor = 0.1f; pieplot3d.setDepthFactor(depthFactor); pieplot3d.setDirection(Rotation.CLOCKWISE); final float foregroundAlpha = 0.5f; pieplot3d.setForegroundAlpha(foregroundAlpha); // Si on est en anglais, on laisse les nombre formates avec des "," pour sparer les milliers // Si on est en francais on remplace les "," par des points NumberFormat numberFormat = SqualeWebActionUtils.getNumberFormat(pRequest); // Pour le formatter de %, on laisse celui par dfaut pieplot3d.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} = {1} loc ({2})", numberFormat, NumberFormat.getPercentInstance())); return chart; }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.others.CumulativeCurveChart.java
public JFreeChart createChart(DatasetMap datasetMap) { CategoryDataset datasetValue = (CategoryDataset) datasetMap.getDatasets().get("1"); CategoryDataset datasetCumulative = (CategoryDataset) datasetMap.getDatasets().get("2"); JFreeChart chart = ChartFactory.createBarChart(name, // chart title xLabel, // domain axis label yLabel, // range axis label datasetValue, // data PlotOrientation.VERTICAL, true, // include legend true, false);/* w w w . j a v a 2 s. c o m*/ chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setLowerMargin(0.02); domainAxis.setUpperMargin(0.02); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); LineAndShapeRenderer renderer2 = new LineAndShapeRenderer(); NumberAxis axis2 = new NumberAxis("Percent"); axis2.setNumberFormatOverride(NumberFormat.getPercentInstance()); plot.setRangeAxis(1, axis2); plot.setDataset(1, datasetCumulative); plot.setRenderer(1, renderer2); plot.mapDatasetToRangeAxis(1, 1); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); return chart; }
From source file:com.newatlanta.bluedragon.XYItemLabelGenerator.java
protected Object[] createItemArray(XYDataset dataset, int series, int item) { Object[] result = new Object[5]; result[0] = dataset.getSeriesKey(series).toString(); double x = dataset.getXValue(series, item); if (Double.isNaN(x) && dataset.getX(series, item) == null) { result[1] = "null"; //this.nullXString; } else {/*from ww w .j a va 2 s . c om*/ if (this.getXDateFormat() != null) { result[1] = this.getXDateFormat().format(new Date((long) x)); } else { result[1] = this.getXFormat().format(x); } } double y = dataset.getYValue(series, item); if (Double.isNaN(y) && dataset.getY(series, item) == null) { result[2] = "null"; //this.nullYString; } else { if (this.getYDateFormat() != null) { result[2] = this.getYDateFormat().format(new Date((long) y)); } else { result[2] = this.getYFormat().format(y); } double total = calculateYTotal(dataset, series); double percent = y / total; result[3] = NumberFormat.getPercentInstance().format(percent); if (this.getYFormat() != null) { result[4] = this.getYFormat().format(total); } else if (this.getYDateFormat() != null) { //result[4] = this.getDateFormat().format(total); } } return result; }
From source file:pcgen.gui2.dialog.PrintPreviewDialog.java
private <E> void initComponents() { setTitle("Print Preview"); sheetBox.setRenderer(new DefaultListCellRenderer() { @Override/*from w w w . j a va2 s . co m*/ public Component getListCellRendererComponent(JList<? extends Object> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value != null) { setToolTipText(value.toString()); } return this; } }); sheetBox.setActionCommand(SHEET_COMMAND); sheetBox.addActionListener(this); pageBox.addItem("0 of 0"); pageBox.setActionCommand(PAGE_COMMAND); pageBox.addActionListener(this); zoomBox.addItem(0.25); zoomBox.addItem(0.50); zoomBox.addItem(0.75); zoomBox.addItem(1.00); zoomBox.setSelectedItem(0.75); zoomBox.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<? extends Object> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { NumberFormat format = NumberFormat.getPercentInstance(); String formattedValue = format.format(value); return super.getListCellRendererComponent(list, formattedValue, index, isSelected, cellHasFocus); } }); zoomBox.setEditable(true); zoomBox.setEditor(new PercentEditor(zoomBox)); zoomBox.setActionCommand(ZOOM_COMMAND); zoomBox.addActionListener(this); zoomInButton.setIcon(Icons.ZoomIn16.getImageIcon()); zoomInButton.setActionCommand(ZOOM_IN_COMMAND); zoomInButton.addActionListener(this); zoomOutButton.setIcon(Icons.ZoomOut16.getImageIcon()); zoomOutButton.setActionCommand(ZOOM_OUT_COMMAND); zoomOutButton.addActionListener(this); printButton.setText("Print"); printButton.setActionCommand(PRINT_COMMAND); printButton.addActionListener(this); cancelButton.setText("Cancel"); cancelButton.setActionCommand(CANCEL_COMMAND); cancelButton.addActionListener(this); enableEditGroup(false); Utility.installEscapeCloseOperation(this); }
From source file:com.projity.pm.graphic.chart.TimeChartPanel.java
protected JFreeChart buildChart() { JFreeChart newChart = ChartHelper.createChart(chartInfo.getModel().getDataset(), chartInfo.isHistogram(), chartInfo.getModel().getSecondDataset()); NumberFormat numberFormat = NumberFormat.getPercentInstance(); // default Object[] traces = chartInfo.getTraces(); // chartInfo.getModel().dumpDataset(traces); if (!chartInfo.isSimple() && (traces.length > 0 && traces[0] instanceof Field)) { Field field = (Field) traces[0]; if (field.isMoney()) { numberFormat = new NumberFormat() { @Override/* w w w.ja v a 2 s.c o m*/ public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) { return toAppendTo.append(Money.formatCurrency(number, true)); } @Override public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) { // TODO Auto-generated method stub return null; } @Override public Number parse(String source, ParsePosition parsePosition) { // TODO Auto-generated method stub return null; } }; } else { Format format = field.getFormat(); if (format instanceof NumberFormat) numberFormat = (NumberFormat) format; else numberFormat = NumberFormat.getNumberInstance(); } } ((NumberAxis) newChart.getXYPlot().getRangeAxis()).setNumberFormatOverride(numberFormat); return newChart; }
From source file:org.hxzon.demo.jfreechart.PieDatasetDemo2.java
private static JFreeChart createPieChart(PieDataset dataset, PieDataset previousDataset) { final boolean greenForIncrease = true; final boolean subTitle = true; final boolean showDifference = true; int percentDiffForMaxScale = 20; PiePlot plot = new PiePlot(dataset); plot.setLabelGenerator(new StandardPieSectionLabelGenerator()); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator()); }// ww w.ja va 2s . c om if (urls) { plot.setURLGenerator(new StandardPieURLGenerator()); } @SuppressWarnings({ "rawtypes", "unchecked" }) List<Comparable> keys = dataset.getKeys(); DefaultPieDataset series = null; if (showDifference) { series = new DefaultPieDataset(); } double colorPerPercent = 255.0 / percentDiffForMaxScale; for (@SuppressWarnings("rawtypes") Comparable key : keys) { Number newValue = dataset.getValue(key); Number oldValue = previousDataset.getValue(key); if (oldValue == null) { if (greenForIncrease) { plot.setSectionPaint(key, Color.green); } else { plot.setSectionPaint(key, Color.red); } if (showDifference) { series.setValue(key + " (+100%)", newValue); } } else { double percentChange = (newValue.doubleValue() / oldValue.doubleValue() - 1.0) * 100.0; double shade = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255 : Math.abs(percentChange) * colorPerPercent); if (greenForIncrease && newValue.doubleValue() > oldValue.doubleValue() || !greenForIncrease && newValue.doubleValue() < oldValue.doubleValue()) { plot.setSectionPaint(key, new Color(0, (int) shade, 0)); } else { plot.setSectionPaint(key, new Color((int) shade, 0, 0)); } if (showDifference) { series.setValue( key + " (" + (percentChange >= 0 ? "+" : "") + NumberFormat.getPercentInstance().format(percentChange / 100.0) + ")", newValue); } } } if (showDifference) { plot.setDataset(series); } JFreeChart chart = new JFreeChart("Pie Chart Demo 2", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); if (subTitle) { TextTitle subtitle = null; subtitle = new TextTitle("Bright " + (greenForIncrease ? "red" : "green") + "=change >=-" + percentDiffForMaxScale + "%, Bright " + (!greenForIncrease ? "red" : "green") + "=change >=+" + percentDiffForMaxScale + "%", new Font("SansSerif", Font.PLAIN, 10)); chart.addSubtitle(subtitle); } plot.setNoDataMessage("No data available"); return chart; }
From source file:StopWatch.java
/** * Return a string with a table describing all tasks performed. * For custom reporting, call getTaskInfo() and use the task info directly. *///from w ww .j a v a 2 s. c om public String prettyPrint() { StringBuffer sb = new StringBuffer(shortSummary()); sb.append('\n'); if (!this.keepTaskList) { sb.append("No task info kept"); } else { TaskInfo[] tasks = getTaskInfo(); sb.append("-----------------------------------------\n"); sb.append("ms % Task name\n"); sb.append("-----------------------------------------\n"); NumberFormat nf = NumberFormat.getNumberInstance(); nf.setMinimumIntegerDigits(5); nf.setGroupingUsed(false); NumberFormat pf = NumberFormat.getPercentInstance(); pf.setMinimumIntegerDigits(3); pf.setGroupingUsed(false); for (int i = 0; i < tasks.length; i++) { sb.append(nf.format(tasks[i].getTimeMillis()) + " "); sb.append(pf.format(tasks[i].getTimeSeconds() / getTotalTimeSeconds()) + " "); sb.append(tasks[i].getTaskName() + "\n"); } } return sb.toString(); }
From source file:weka.gui.beans.JFreeChartOffscreenChartRenderer.java
/** * Render histogram(s) (numeric attribute) or bar chart (nominal attribute). * Some implementations may not be able to render more than one histogram/bar * on the same chart - the implementation can either throw an exception or * just process the first series in this case. * //from w w w. j a va 2s . com * @param width the width of the resulting chart in pixels * @param height the height of the resulting chart in pixels * @param series a list of Instances - one for each series to be plotted * @param attsToPlot the attribute to plot corresponding to the Instances in * the series list * @param optionalArgs optional arguments to the renderer (may be null) * * @return a BufferedImage containing the chart * @throws Exception if there is a problem rendering the chart */ public BufferedImage renderHistogram(int width, int height, List<Instances> series, String attToPlot, List<String> additionalArgs) throws Exception { String plotTitle = "Bar Chart"; String userTitle = getOption(additionalArgs, "-title"); plotTitle = (userTitle != null) ? userTitle : plotTitle; String colorAtt = getOption(additionalArgs, "-color"); String pareto = getOption(additionalArgs, "-pareto"); boolean doPareto = false; if (pareto != null && pareto.length() == 0 && series.size() == 1) { doPareto = true; } if (series.size() == 1 && colorAtt != null && colorAtt.length() > 0) { int colIndex = getIndexOfAttribute(series.get(0), colorAtt); if (colIndex >= 0 && series.get(0).attribute(colIndex).isNominal() && !doPareto) { // split single series out into multiple instances objects - one // per class series = splitToClasses(series.get(0), colIndex); for (Instances insts : series) { insts.setClassIndex(colIndex); } } } Instances masterInstances = series.get(0); int attIndex = getIndexOfAttribute(masterInstances, attToPlot); if (attIndex < 0) { attIndex = 0; } if (!(series.get(0).attribute(attIndex).isNominal() || series.get(0).attribute(attIndex).isRelationValued())) { doPareto = false; } // Do a pareto chart if (doPareto) { final DefaultKeyedValues data = new DefaultKeyedValues(); AttributeStats attStats = masterInstances.attributeStats(attIndex); double[] attValFreqs = attStats.nominalWeights; for (int i = 0; i < attValFreqs.length; i++) { Number freq = new Double(attValFreqs[i]); data.addValue(masterInstances.attribute(attIndex).value(i), freq); } data.sortByValues(SortOrder.DESCENDING); final KeyedValues cumulative = DataUtilities.getCumulativePercentages(data); final CategoryDataset dataset = DatasetUtilities .createCategoryDataset(masterInstances.attribute(attIndex).name(), data); final JFreeChart chart = ChartFactory.createBarChart(plotTitle, masterInstances.attribute(attIndex).name(), "Fequency/weight mass", dataset, PlotOrientation.VERTICAL, true, false, false); final CategoryPlot plot = chart.getCategoryPlot(); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setLowerMargin(0.02); domainAxis.setUpperMargin(0.02); LineAndShapeRenderer renderer2 = new LineAndShapeRenderer(); CategoryDataset dataset2 = DatasetUtilities.createCategoryDataset("Cumulative", cumulative); final NumberAxis axis2 = new NumberAxis("Percent"); axis2.setNumberFormatOverride(NumberFormat.getPercentInstance()); // plot. plot.setRangeAxis(1, axis2); plot.setDataset(1, dataset2); plot.setRenderer(1, renderer2); plot.mapDatasetToRangeAxis(1, 1); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); chart.setBackgroundPaint(java.awt.Color.white); BufferedImage image = chart.createBufferedImage(width, height); return image; } boolean seriesAreClasses = false; int classIndex = masterInstances.classIndex(); if (classIndex >= 0 && !masterInstances.attribute(classIndex).isNumeric() && !masterInstances.attribute(classIndex).isRelationValued() && masterInstances.attributeStats(classIndex).distinctCount == 1) { // series correspond to class labels (assume that subsequent series only // contain instances of one class)... seriesAreClasses = true; } // bar chart for a nominal attribute if (masterInstances.attribute(attIndex).isNominal() || masterInstances.attribute(attIndex).isString()) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); // do the master series String masterSeriesTitle = masterInstances.relationName(); if (seriesAreClasses) { for (int i = 0; i < masterInstances.numInstances(); i++) { Instance current = masterInstances.instance(i); if (!current.isMissing(classIndex)) { masterSeriesTitle = current.stringValue(classIndex); break; } } } AttributeStats attStats = masterInstances.attributeStats(attIndex); double[] attValFreqs = attStats.nominalWeights; for (int i = 0; i < attValFreqs.length; i++) { Number freq = new Double(attValFreqs[i]); dataset.addValue(freq, masterSeriesTitle, masterInstances.attribute(attIndex).value(i)); } // any subsequent series for (int i = 1; i < series.size(); i++) { Instances nextSeries = series.get(i); String seriesTitle = nextSeries.relationName(); if (seriesAreClasses) { for (int j = 0; j < nextSeries.numInstances(); j++) { Instance current = nextSeries.instance(j); if (!current.isMissing(classIndex)) { seriesTitle = current.stringValue(classIndex); break; } } attStats = nextSeries.attributeStats(attIndex); attValFreqs = attStats.nominalWeights; for (int j = 0; j < attValFreqs.length; j++) { Number freq = new Double(attValFreqs[j]); dataset.addValue(freq, seriesTitle, nextSeries.attribute(attIndex).value(j)); } } } JFreeChart chart = null; if (series.size() == 1) { chart = ChartFactory.createBarChart(plotTitle, masterInstances.attribute(attIndex).name(), "Fequency/weight mass", dataset, PlotOrientation.VERTICAL, true, false, false); } else { chart = ChartFactory.createStackedBarChart(plotTitle, masterInstances.attribute(attIndex).name(), "Fequency/weight mass", dataset, PlotOrientation.VERTICAL, true, false, false); } chart.setBackgroundPaint(java.awt.Color.white); BufferedImage image = chart.createBufferedImage(width, height); return image; } else { // histogram for numeric attributes HistogramDataset dataset = new HistogramDataset(); // combine all series in order to get overall std dev, and range Instances temp = new Instances(masterInstances); for (int i = 1; i < series.size(); i++) { Instances additional = series.get(i); for (Instance tempI : additional) { temp.add(tempI); } } AttributeStats stats = temp.attributeStats(attIndex); Stats numericStats = stats.numericStats; double intervalWidth = 3.49 * numericStats.stdDev * StrictMath.pow(temp.numInstances(), (-1.0 / 3.0)); double range = numericStats.max - numericStats.min; int numBins = StrictMath.max(1, (int) StrictMath.round(range / intervalWidth)); // do the master series String masterSeriesTitle = masterInstances.relationName(); if (seriesAreClasses) { for (int i = 0; i < masterInstances.numInstances(); i++) { Instance current = masterInstances.instance(i); if (!current.isMissing(current.classAttribute())) { masterSeriesTitle = current.stringValue(current.classAttribute()); break; } } } // have to set min, max and num bins (using heuristic from AttSummPanel). // Make sure // to set series length to num instances - num missing values for att stats = masterInstances.attributeStats(attIndex); /* * numericStats = stats.numericStats; //numericStats.calculateDerived(); * intervalWidth = StrictMath.max(1, 3.49 * numericStats.stdDev * * StrictMath.pow(masterInstances.numInstances(), (-1.0/3.0))); */ double[] seriesVals = new double[masterInstances.numInstances() - stats.missingCount]; int count = 0; for (int i = 0; i < masterInstances.numInstances(); i++) { Instance current = masterInstances.instance(i); if (!current.isMissing(attIndex)) { seriesVals[count++] = current.value(attIndex); } } dataset.addSeries(masterSeriesTitle, seriesVals, numBins, numericStats.min, numericStats.max); // any subsequent series for (int i = 1; i < series.size(); i++) { Instances nextSeries = series.get(i); String seriesTitle = nextSeries.relationName(); if (seriesAreClasses) { for (int j = 0; j < nextSeries.numInstances(); j++) { Instance current = nextSeries.instance(j); if (!current.isMissing(nextSeries.classAttribute())) { seriesTitle = current.stringValue(nextSeries.classAttribute()); break; } } } stats = nextSeries.attributeStats(attIndex); /* * numericStats = stats.numericStats; // * numericStats.calculateDerived(); intervalWidth = StrictMath.max(1, * 3.49 * numericStats.stdDev * * StrictMath.pow(masterInstances.numInstances(), (-1.0/3.0))); range = * numericStats.max - numericStats.min; numBins = StrictMath.max(1, * (int) StrictMath.round(range / intervalWidth)); */ seriesVals = new double[nextSeries.numInstances() - stats.missingCount]; count = 0; for (int j = 0; j < nextSeries.numInstances(); j++) { Instance current = nextSeries.instance(j); if (!current.isMissing(attIndex)) { seriesVals[count++] = current.value(attIndex); } } dataset.addSeries(seriesTitle, seriesVals, numBins, numericStats.min, numericStats.max); } JFreeChart chart = ChartFactory.createHistogram(plotTitle, masterInstances.attribute(attIndex).name(), null, dataset, PlotOrientation.VERTICAL, true, false, false); // chart.setBackgroundPaint(java.awt.Color.white); XYPlot xyplot = (XYPlot) chart.getPlot(); xyplot.setForegroundAlpha(0.50F); XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setDrawBarOutline(false); xybarrenderer.setShadowVisible(false); BufferedImage image = chart.createBufferedImage(width, height); return image; } }
From source file:org.tolven.analysis.bean.PercentTimeSeriesBean.java
private JFreeChart getChart(String dataSeriesTitle, String targetSeriesTitle, List<MenuData> snapshots, Date fromDate, Date toDate, Class<?> intervalUnitClass) { TimeSeries dataTimeSeries = new TimeSeries(dataSeriesTitle); TimeSeries targetTimeSeries = null;//from w ww .j a v a 2s . c o m if (targetSeriesTitle != null) { targetTimeSeries = new TimeSeries(targetSeriesTitle); } for (MenuData snapshot : snapshots) { Date snapshotDate = snapshot.getDate01(); long nSnapshotresultsNumerator = snapshot.getLongField("normCount"); long nSnapshotresultsDenominator = snapshot.getLongField("allCount"); Double value = null; if (nSnapshotresultsDenominator == 0) { value = 0d; } else { value = 1d * nSnapshotresultsNumerator / nSnapshotresultsDenominator; } RegularTimePeriod regTimePeriod = RegularTimePeriod.createInstance(intervalUnitClass, snapshotDate, TimeZone.getDefault()); dataTimeSeries.addOrUpdate(regTimePeriod, value); if (targetTimeSeries != null) { Double targetPercent = snapshot.getDoubleField("targetPercent") / 100; targetTimeSeries.addOrUpdate(regTimePeriod, targetPercent); } } TimeSeriesCollection timeSeriesCollection = new TimeSeriesCollection(); timeSeriesCollection.addSeries(dataTimeSeries); if (targetTimeSeries != null) { timeSeriesCollection.addSeries(targetTimeSeries); } XYDataset xyDataset = (XYDataset) timeSeriesCollection; JFreeChart chart = ChartFactory.createTimeSeriesChart(null, // title null, // x-axis label null, // y-axis label xyDataset, // data true, // create legend? false, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.BLACK); plot.setDomainGridlinesVisible(false); XYItemRenderer r = plot.getRenderer(); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setSeriesShape(0, new Ellipse2D.Double(-3, -3, 6, 6)); renderer.setSeriesPaint(0, Color.BLUE); renderer.setSeriesShape(1, new Rectangle2D.Double(-3, -3, 6, 6)); renderer.setSeriesPaint(1, Color.RED); NumberAxis vaxis = (NumberAxis) plot.getRangeAxis(); vaxis.setAutoRange(true); vaxis.setAxisLineVisible(true); vaxis.setNumberFormatOverride(NumberFormat.getPercentInstance()); vaxis.setTickMarksVisible(true); DateAxis daxis = (DateAxis) plot.getDomainAxis(); daxis.setRange(fromDate, toDate); if (intervalUnitClass == Month.class) { DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(); dateFormatSymbols .setShortMonths(new String[] { "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D" }); daxis.setDateFormatOverride(new SimpleDateFormat("MMM", dateFormatSymbols)); } return chart; }