Setting label and value of the chart

The MessageFormat ArgumentIndex values correspond to the series name, domain and range. You can set a different generator for each series or for all series in the base. PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelGenerator(new StandardPieSectionLabelGenerator(“{0} {1} {2}”)); Addendum: For PiePlot, the values have a slightly different meaning—series name, value and percentage—as shown here.

Create jfreechart-1.5.3 JAR from source code

As illustrated here, you can clone the repository, check out the branch with the desired tag and use maven to build the release JARs. See also Migration from JFreeChart 1.0.x $ git clone https://github.com/jfree/jfreechart.git jfreechart $ pushd jfreechart $ git fetch –tags $ git tag –list … v1.5.3 $ git checkout v1.5.3 Note: switching to … Read more

Real time graph plotting starting time

The graph starts at 16 minutes and 40 seconds after midnight on the date used to construct the Second passed to setTimeBase(). This is the same 1000 intervals, each one second long, specified in the nMoments constructor parameter. Some possible alternatives to get a zero-based display, given a time set to midnight. Make nMoments a … Read more

JFreechart Loop through polar chart sectors

It looks like you were adding all six spirals on each iteration. Here’s my variation on your sscce. import java.awt.Color; import java.awt.Dimension; import java.util.ArrayList; import java.util.List; import javax.swing.JFrame; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.NumberTick; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.ChartProgressEvent; import org.jfree.chart.event.ChartProgressListener; import org.jfree.chart.plot.PolarPlot; import org.jfree.chart.renderer.DefaultPolarItemRenderer; import org.jfree.chart.renderer.PolarItemRenderer; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import … Read more

JFreeChart change data in an existing bar chart

Update the model and the listening view will follow. To animate the updates without blocking the event dispatch thread, use a javax.swing.Timer, as shown here; invoke stop() as needed. As tested: import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.event.ActionEvent; import java.util.Random; import javax.swing.AbstractAction; import javax.swing.JButton; import javax.swing.JFrame; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.PlotOrientation; … Read more

Add values to a specified series in a DynamicTimeSeriesCollection

Assuming you started from here, you’ve specified a dataset with two series, but you’re only appending one value with each tick of the Timer. You need two values for each tick. Here’s how I modified the original to get the picture below: final DynamicTimeSeriesCollection dataset = new DynamicTimeSeriesCollection(2, COUNT, new Second()); … dataset.addSeries(gaussianData(), 0, “Human”); … Read more

How can I change the tickLabel on a NumberAxis in JFreeChart?

The JFreeChart BarChartDemo1 shows how to use the setStandardTickUnits() method. NumberAxis has several handy static factories for this. To override the defaults, you can “create your own instance of TickUnits and then pass it to the setStandardTickUnits() method.” Addendum: The defaults mentioned above simply use a subclass of java.text.Format; you can supply your own for … Read more

Resize Vertical Tick Label Height (XYStepChart)

It’s not clear how you are formatting the dates now, but setDateFormatOverride in DateAxis allows you to specify a suitable SimpleDateFormat. If not already available, you should be able to override getShortMonths() in DateFormatSymbols for the Roman numerals. Addendum: For correct localization, it may be easier to do something like this: DateAxis axis = (DateAxis) … Read more

scatter plot in jfreechart from database

This complete example creates a suitable database table in memory, queries it into a JDBCXYDataset and displays the dataset in a scatter plot. Note how the first column becomes the domain, while successive columns become individual series. import java.awt.EventQueue; import java.sql.Connection; import java.sql.Date; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Statement; import java.util.Calendar; import java.util.Random; … Read more