Report Application Series--Chart Jfreechart: 3rd Chapter Pie Chart

Source: Internet
Author: User

3.1. Simple pie chart

Pie charts must use Defaultpiedataset to provide data for the chart.

DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Spring Security", 100);
dataset.setValue("jBPM 4", 200);
dataset.setValue("Ext JS", 300);
dataset.setValue("JFreeChart", 100);

This time we use SetValue to add data to the dataset, the first parameter is the name of the data, and the second data is the value of the data.

This exposes a problem with Jfreechart, and cannot use the unified DataSet interface to set the data.

The next step is to create a pie chart by using the Charfactory Createpiechart method.

JFreeChart chart = ChartFactory.createPieChart(
   "chart", // 标题
   dataset, // 数据
   true, // 是否使用legend
   false, // 是否使用tooltip
   false // 是否使用url链接
);

Finally, use Charutilities to export Jfreechart as a picture.

Figure 3.1. Simple pie chart

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.