JFreeChart File Interface - JFreeChart

What is File Interface in JFreeChart?

Till now we studied creating different types of charts using JFreeChart APIs using static data. But in production environment, data will be provided in the form of text file with a predefined format, or it will directly come from the database.

This chapter will give you detailed description on how to read simple data from a given text file, from a given location and then use JFreeChart for creating a chart of your choice.

Business Data

For example, consider a file named mobile.txt, which has different mobile brands and their sale (units per day) separated by a simple comma (,)

Chart Generation Based on File

Below is the code for creating a Pie Chart based on the information provided in mobile.txt

Keep the above Java code in PieChart_File.java file, and then compile and run it from the command prompted as

If everything is working fine, it will compile and run to create a JPEG image file named PieChart.jpeg that contains below chart.

piechart_file.jpg

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

JFreeChart Topics