Jfreechart bar chart for Java Study Notes

Source: Internet
Author: User
Package COM. mengya. test. jfreechart; import Java. AWT. font; import javax. swing. jpanel; import Org. jfree. chart. chartfactory; import Org. jfree. chart. chartpanel; import Org. jfree. chart. jfreechart; import Org. jfree. chart. axis. categoryaxis; import Org. jfree. chart. plot. categoryplot; import Org. jfree. chart. plot. plotorientation; import Org. jfree. chart. title. texttitle; import Org. jfree. data. category. categorydataset; import Org. jfree. data. category. defaultcategorydataset; import Org. jfree. UI. applicationframe;/*** jfreechart bar chart in the swing format ** @ author **/@ suppresswarnings ("serial") public class jfreecharttest2 extends applicationframe {public jfreecharttest2 (String title) {super (title); this. setcontentpane (createpanel ();} Private Static categorydataset createdataset () {defacategcategorydataset dataset = new defaultcategorydataset (); // dataset. setvalue (10, "", "Administrator"); // dataset. setvalue (15, "", "market personnel"); // dataset. setvalue (35, "", "Developer"); // dataset. setvalue (12, "", "other personnel"); dataset. setvalue (10, "AA", "Administrator"); dataset. setvalue (15, "BB", "market personnel"); dataset. setvalue (35, "cc", "Developer"); dataset. setvalue (12, "DD", "other personnel"); Return dataset;} Private Static jfreechart createjfreechart (categorydataset dataset) {/*** construct jfreechart * // jfreechart // = chartfactory. createbarchart ("organization chart of a company", "Personnel Distribution", "number of personnel", dataset, plotorientation. vertical, false); // jfreechart // = chartfactory. createbarchart ("organization chart of a company", "Personnel Distribution", "number of personnel", dataset, plotorientation. vertical, true, false, false); jfreechart = chartfactory. createbarchart3d ("organization chart of a company", "Personnel Distribution", "number of personnel", dataset, plotorientation. vertical, true, false, false);/*** set jfreechart attributes */jfreechart. settitle (New texttitle ("organizational structure of a company", new font ("", Font. bold + font. italic, 20); categoryplot plot = (categoryplot) jfreechart. getplot (); categoryaxis = plot. getdomainaxis (); categoryaxis. setlabelfont (new font ("", Font. roman_baseline, 12); Return jfreechart;} public static jpanel createpanel () {jfreechart chart = createjfreechart (createdataset (); return New chartpanel (Chart );} public static void main (string [] ARGs) {jfreecharttest2 chart = new jfreecharttest2 ("organization chart of a company"); chart. pack (); chart. setvisible (true );}}

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.