JFree Chart Orientation

Hello,
I am new to JFree chart . I am using Time series valuels for X axis,
but now I want Time series on Y axis or as legends,
any one give an idia .pls
thanks.

i think you'll get a lot better help here:
http://www.jfree.org/phpBB2/index.php
that is unless you aren't cross posting. ;-)

Similar Messages

  • How To use JFree chart in Oracle Forms 11g ?

    Hi all
    I had a graph in oracle forms6i I would like to convert them to 11g forms as graph builder is not supported by oracle forms 11g while goggling came to knew that there is Jfree chart through which we can develop the same as 6i graph..but unable to find any demo or Document Can any one help me regarding this please..?
    thanks in advance

    Hello,
    Oracle has the FormsGraph Bean, that you can take from the forms10g or forms11g demo pack (see the Forms home page on OTN).
    Francois

  • JFree Charts .... Anyone Can help

    hi,
    Does anyone kno how to use JFree Charts ? i am trying to make an application using JSP to show graphs like Line and Bar graphs ...
    Please Help !!
    thanks

    hi,
    i m using tomcat..using cewolf..and pasting all the jar files from cewolf to tomcat/common/lib....in these jar files there is jar file for jfree also..but i m getting an exception : org.apache.jasper.jasperexception
    ..wht shud i do?

  • JFree Charts (to make graphs ).. Can anyone Help ?

    hi,
    Does anyone kno how to use JFree Charts ? i am trying to make an application using JSP to show graphs like Line and Bar graphs ...
    Please Help !!

    http://cs.gmu.edu/~eclab/projects/mason/extensions/webtutorial1/
    http://www.javaworld.com/javaworld/jw-12-2002/jw-1227-opensourceprofile.html
    http://www.sideofsoftware.com/reports_ChartExample.htm
    Good work.
    M

  • Jfree Charts Driving me crazy!!!!!

    Hey there.... As you have to pay for the developers documentation for Jfree.. this rules me out of getting aany help whatsoever!!!
    All the examples and samples i have found so far are for old versions and none of them seem to be able to compile.... Not one person has replied to posts on their forums either!!!!
    All i want to do is a simple line graph displaying an x,y dataset!!!
    Anyone have an example of the latest version (1.0.0) or a more convienient way of doing this??
    many thanks

    import java.awt.Dimension;
    import javax.swing.JPanel;
    import org.jfree.chart.*;
    import org.jfree.chart.plot.PlotOrientation;
    import org.jfree.data.xy.*;
    import org.jfree.ui.ApplicationFrame;
    import org.jfree.ui.RefineryUtilities;
    public class XYSeriesDemo1 extends ApplicationFrame
        public XYSeriesDemo1(String s)
            super(s);
            XYDataset xydataset = createDataset();
            JFreeChart jfreechart = createChart(xydataset);
            ChartPanel chartpanel = new ChartPanel(jfreechart);
            chartpanel.setPreferredSize(new Dimension(500, 270));
            setContentPane(chartpanel);
        private static JFreeChart createChart(XYDataset xydataset)
            JFreeChart jfreechart = ChartFactory.createXYLineChart("XY Series Demo", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false);
            return jfreechart;
        private static XYDataset createDataset()
            XYSeries xyseries = new XYSeries("Random Data");
            xyseries.add(1.0D, 500.2);
            xyseries.add(5D, 694.1);
            xyseries.add(4D, 100D);
            xyseries.add(12.5D, 734.4);
            xyseries.add(17.3, 453.2);
            xyseries.add(21.2, 500.2);
            xyseries.add(21.9, null);
            xyseries.add(25.6, 734.4);
            xyseries.add(30D, 453.2);
            return new XYSeriesCollection(xyseries);
        public static JPanel createDemoPanel()
            JFreeChart jfreechart = createChart(createDataset());
            return new ChartPanel(jfreechart);
        public static void main(String args[])
            XYSeriesDemo1 xyseriesdemo1 = new XYSeriesDemo1("XY Series Demo");
            xyseriesdemo1.pack();
            RefineryUtilities.centerFrameOnScreen(xyseriesdemo1);
            xyseriesdemo1.setVisible(true);
    }

  • JFree CHARTS... Does any one know?

    hi,
    Does anyone kno how to use JFree Charts ? i am trying to make an application using JSP to show graphs like Line and Bar graphs ...
    Please Help !!

    Bloody spammer: http://forum.java.sun.com/thread.jspa?threadID=599311&tstart=0

  • Title for the Legend in jfree charts

    Hi,
    I want to give the Legend a Header i.e a block above the legend stating the name of the Legend. I am unable to find a method that would help me with this.M using jfree1.0.2
    (a small example could be helpful)

    Hi Manish,
    Can try like this:
    Standard Field >> Do F1, Take the Data Element.
    Go to CMOD, on that screen Click Goto >> Text enhancements>> Keywords >> Change.
    Type the Data Element name noted earlier. Press Enter.
    A screen with several fields will be displayed. They contain the various descriptions for the data element selected. Depending on what screen/layout this data element is used the system will use one of the short, medium or long description fields.
    The Heading field, as its name suggests, will be used in the list header row of a layout. The Short Description field will be used when you select the function key F1 (help) on that field.
    The length of each field is :
    - Short field label: 10 characters
    - Medium field label: 20 characters
    - Long field label: 40 characters
    - Heading: 55 characters
    - Short Description: 60 characters
    Replace the texts with those that you want to appear. Save your changes (This will be a Customising Request). Note that this is a cross client change.
    Please note that F1 Help will still display the standard help, with only the First Line changed as per your corrections (Custom Field Name).
    Regards
    Saurabh

  • Problem After writing the Jfree chart into pdf

    Hi All,
    I am writing the Jfreechart object with my company logo into JSP and and setting the content type as "application/pdf". I am getting the error as
    java.lang.IllegalStateException: getOutputStream() has already been called for this response.
    I have searched for it in the google as well as sun forums for so many hours and i implements so many suggested solutions but i am unable to remove the exception.
    The problem might be using response.getOutputStream() to get the output stream to in the response.
    But while debugging the code I observed that I am getting the error after complete execution of the code ie. after displaying the pdf.
    I am using JSF with JBoss portlets.
    Could any one help me in solving this problem as soon as possible..
    Thanks in advance.

    I am using the fallowing code to write into response. After execution of all the code and after displaying pdf its throughing the exception
    *OutputStream outStream = response.getOutputStream()*
    //To get the logo path from propeties file
    ResourceBundle resourceBundle = ResourceBundle.getBundle("imagepath");
                      String imagePath = resourceBundle.getString("imagepath");
                      Image image2 = Image.getInstance(imagePath);
                        image2.scaleToFit(100, 100);
                        PdfPTable pdfPTable =  new PdfPTable(2);
                        pdfPTable.getDefaultCell().setBorder(0);
                        PdfPCell cell = new PdfPCell(image2);
                        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
                        cell.setBorder(0);
                        pdfPTable.addCell(cell);
                        pdfPTable.addCell("");
                      //get the Pdf writer object
                   PdfWriter     writer = PdfWriter.getInstance(document, outStream);
                       document.open();
                   document.add(pdfPTable);
                      PdfContentByte contentByte = writer.getDirectContent();
                      PdfTemplate template = contentByte.createTemplate(1200, 750);
                      Graphics2D graphics2d = template.createGraphics(600, 750, new DefaultFontMapper());
                      Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, 540, 700);
                      jfreechart.draw(graphics2d, rectangle2d);
                      graphics2d.dispose();
                      contentByte.addTemplate(template, 50, 25);
                      //setOldchartObject(chartInfoBean);
                      System.out.println("This is before closing th edocument.");
                      document.close();

  • Please help how to execute jfree......

    please help how to execute[b] jfree  programs
    step by step procedure.....
    package org.jfree.chart.demo;
    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.axis.CategoryLabelPosition;
    import org.jfree.chart.axis.CategoryLabelPositions;
    import org.jfree.chart.axis.CategoryLabelWidthType;
    import org.jfree.chart.plot.CategoryPlot;
    import org.jfree.chart.plot.PlotOrientation;
    import org.jfree.data.category.CategoryDataset;
    import org.jfree.data.category.DefaultCategoryDataset;
    import org.jfree.text.TextBlockAnchor;
    import org.jfree.ui.ApplicationFrame;
    import org.jfree.ui.RectangleAnchor;
    import org.jfree.ui.RefineryUtilities;
    import org.jfree.ui.TextAnchor;
    import org.jfree.util.Log;
    import org.jfree.util.PrintStreamLogTarget;
    * A simple demonstration application showing how to create a horizontal 3D bar chart using data
    * from a {@link CategoryDataset}.
    public class BarChart3DDemo2 extends ApplicationFrame {
        // * JFREECHART DEVELOPER GUIDE                                               *
        // * The JFreeChart Developer Guide, written by David Gilbert, is available   *
        // * to purchase from Object Refinery Limited:                                *
        // * http://www.object-refinery.com/jfreechart/guide.html                     *
        // * Sales are used to provide funding for the JFreeChart project - please    *
        // * support us so that we can continue developing free software.             *
         * Creates a new demo.
         * @param title  the frame title.
        public BarChart3DDemo2(final String title) {
            super(title);
            // create the chart...
            final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
            dataset.addValue(23.0, "Series 1", "London");
            dataset.addValue(14.0, "Series 1", "New York");
            dataset.addValue(14.0, "Series 1", "Istanbul");
            dataset.addValue(14.0, "Series 1", "Cairo");
            dataset.addValue(13.0, "Series 2", "London");
            dataset.addValue(19.0, "Series 2", "New York");
            dataset.addValue(19.0, "Series 2", "Istanbul");
            dataset.addValue(19.0, "Series 2", "Cairo");
            dataset.addValue(7.0, "Series 3", "London");
            dataset.addValue(9.0, "Series 3", "New York");
            dataset.addValue(9.0, "Series 3", "Istanbul");
            dataset.addValue(9.0, "Series 3", "Cairo");
            final JFreeChart chart = createChart(dataset);
            // add the chart to a panel...
            final ChartPanel chartPanel = new ChartPanel(chart);
            chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
            setContentPane(chartPanel);
         * Creates a chart.
         * @param dataset  the dataset.
         * @return The chart.
        private JFreeChart createChart(final CategoryDataset dataset) {
            final JFreeChart chart = ChartFactory.createBarChart3D(
                "3D Bar Chart Demo 2",       // chart title
                "Category",                  // domain axis label
                "Value",                     // range axis label
                dataset,                     // data
                PlotOrientation.HORIZONTAL,  // orientation
                true,                        // include legend
                true,                        // tooltips
                false                        // urls
            final CategoryPlot plot = chart.getCategoryPlot();
            plot.setForegroundAlpha(1.0f);
            // left align the category labels...
            final CategoryAxis axis = plot.getDomainAxis();
            final CategoryLabelPositions p = axis.getCategoryLabelPositions();
            final CategoryLabelPosition left = new CategoryLabelPosition(
                RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT,
                TextAnchor.CENTER_LEFT, 0.0,
                CategoryLabelWidthType.RANGE, 0.30f
            axis.setCategoryLabelPositions(CategoryLabelPositions.replaceLeftPosition(p, left));
            return chart;       
         * Starting point for the demonstration application.
         * @param args  ignored.
        public static void main(final String[] args) {
            Log.getInstance().addTarget(new PrintStreamLogTarget());
            final BarChart3DDemo2 demo = new BarChart3DDemo2("3D Bar Chart Demo 2");
            demo.pack();
            RefineryUtilities.centerFrameOnScreen(demo);
            demo.setVisible(true);
    }this is the first time i'm trying to execute jfree programs...
    regards,
    R.Raghavan

    here's error message
    E:\raghav>javac BarChart3DDemo2.java
    BarChart3DDemo2.java:3: cannot find symbol
    symbol : class ChartFactory
    location: package org.jfree.chart
    import org.jfree.chart.ChartFactory;
    ^
    BarChart3DDemo2.java:4: cannot find symbol
    symbol : class ChartPanel
    location: package org.jfree.chart
    import org.jfree.chart.ChartPanel;
    ^
    BarChart3DDemo2.java:5: cannot find symbol
    symbol : class JFreeChart
    location: package org.jfree.chart
    import org.jfree.chart.JFreeChart;
    ^
    BarChart3DDemo2.java:6: package org.jfree.chart.axis does not exist
    import org.jfree.chart.axis.CategoryAxis;
    ^
    BarChart3DDemo2.java:7: package org.jfree.chart.axis does not exist
    import org.jfree.chart.axis.CategoryLabelPosition;
    ^
    BarChart3DDemo2.java:8: package org.jfree.chart.axis does not exist
    import org.jfree.chart.axis.CategoryLabelPositions;
    ^
    BarChart3DDemo2.java:9: package org.jfree.chart.axis does not exist
    import org.jfree.chart.axis.CategoryLabelWidthType;
    ^
    BarChart3DDemo2.java:10: package org.jfree.chart.plot does not exist
    import org.jfree.chart.plot.CategoryPlot;
    ^
    BarChart3DDemo2.java:11: package org.jfree.chart.plot does not exist
    import org.jfree.chart.plot.PlotOrientation;
    ^
    BarChart3DDemo2.java:12: package org.jfree.data.category does not exist
    import org.jfree.data.category.CategoryDataset;
    ^
    BarChart3DDemo2.java:13: package org.jfree.data.category does not exist
    import org.jfree.data.category.DefaultCategoryDataset;
    ^
    BarChart3DDemo2.java:14: package org.jfree.text does not exist
    import org.jfree.text.TextBlockAnchor;
    ^
    BarChart3DDemo2.java:15: package org.jfree.ui does not exist
    import org.jfree.ui.ApplicationFrame;
    ^
    BarChart3DDemo2.java:16: package org.jfree.ui does not exist
    import org.jfree.ui.RectangleAnchor;
    ^
    BarChart3DDemo2.java:17: package org.jfree.ui does not exist
    import org.jfree.ui.RefineryUtilities;
    ^
    BarChart3DDemo2.java:18: package org.jfree.ui does not exist
    import org.jfree.ui.TextAnchor;
    ^
    BarChart3DDemo2.java:19: package org.jfree.util does not exist
    import org.jfree.util.Log;
    ^
    BarChart3DDemo2.java:20: package org.jfree.util does not exist
    import org.jfree.util.PrintStreamLogTarget;
    ^
    BarChart3DDemo2.java:27: cannot find symbol
    symbol: class ApplicationFrame
    public class BarChart3DDemo2 extends ApplicationFrame {
    ^
    BarChart3DDemo2.java:80: cannot find symbol
    symbol : class CategoryDataset
    location: class org.jfree.chart.demo.BarChart3DDemo2
    private JFreeChart createChart(final CategoryDataset dataset) {
    ^
    BarChart3DDemo2.java:80: cannot find symbol
    symbol : class JFreeChart
    location: class org.jfree.chart.demo.BarChart3DDemo2
    private JFreeChart createChart(final CategoryDataset dataset) {
    ^
    BarChart3DDemo2.java:50: cannot find symbol
    symbol : class DefaultCategoryDataset
    location: class org.jfree.chart.demo.BarChart3DDemo2
    final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    ^
    BarChart3DDemo2.java:50: cannot find symbol
    symbol : class DefaultCategoryDataset
    location: class org.jfree.chart.demo.BarChart3DDemo2
    final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    ^
    BarChart3DDemo2.java:64: cannot find symbol
    symbol : class JFreeChart
    location: class org.jfree.chart.demo.BarChart3DDemo2
    final JFreeChart chart = createChart(dataset);
    ^
    BarChart3DDemo2.java:67: cannot find symbol
    symbol : class ChartPanel
    location: class org.jfree.chart.demo.BarChart3DDemo2
    final ChartPanel chartPanel = new ChartPanel(chart);
    ^
    BarChart3DDemo2.java:67: cannot find symbol
    symbol : class ChartPanel
    location: class org.jfree.chart.demo.BarChart3DDemo2
    final ChartPanel chartPanel = new ChartPanel(chart);
    ^
    BarChart3DDemo2.java:82: cannot find symbol
    symbol : class JFreeChart
    location: class org.jfree.chart.demo.BarChart3DDemo2
    final JFreeChart chart = ChartFactory.createBarChart3D(
    ^
    BarChart3DDemo2.java:87: cannot find symbol
    symbol : variable PlotOrientation
    location: class org.jfree.chart.demo.BarChart3DDemo2
    PlotOrientation.HORIZONTAL, // orientation
    ^
    BarChart3DDemo2.java:82: cannot find symbol
    symbol : variable ChartFactory
    location: class org.jfree.chart.demo.BarChart3DDemo2
    final JFreeChart chart = ChartFactory.createBarChart3D(
    ^
    BarChart3DDemo2.java:93: cannot find symbol
    symbol : class CategoryPlot
    location: class org.jfree.chart.demo.BarChart3DDemo2
    final CategoryPlot plot = chart.getCategoryPlot();
    ^
    BarChart3DDemo2.java:97: cannot find symbol
    symbol : class CategoryAxis
    location: class org.jfree.chart.demo.BarChart3DDemo2
    final CategoryAxis axis = plot.getDomainAxis();
    ^
    BarChart3DDemo2.java:98: cannot find symbol
    symbol : class CategoryLabelPositions
    location: class org.jfree.chart.demo.BarChart3DDemo2
    final CategoryLabelPositions p = axis.getCategoryLabelPositions();
    ^
    BarChart3DDemo2.java:100: cannot find symbol
    symbol : class CategoryLabelPosition
    location: class org.jfree.chart.demo.BarChart3DDemo2
    final CategoryLabelPosition left = new CategoryLabelPosition(
    ^
    BarChart3DDemo2.java:100: cannot find symbol
    symbol : class CategoryLabelPosition
    location: class org.jfree.chart.demo.BarChart3DDemo2
    final CategoryLabelPosition left = new CategoryLabelPosition(
    ^
    BarChart3DDemo2.java:101: cannot find symbol
    symbol : variable RectangleAnchor
    location: class org.jfree.chart.demo.BarChart3DDemo2
    RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT,
    ^
    BarChart3DDemo2.java:101: cannot find symbol
    symbol : variable TextBlockAnchor
    location: class org.jfree.chart.demo.BarChart3DDemo2
    RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT,
    ^
    BarChart3DDemo2.java:102: cannot find symbol
    symbol : variable TextAnchor
    location: class org.jfree.chart.demo.BarChart3DDemo2
    TextAnchor.CENTER_LEFT, 0.0,
    ^
    BarChart3DDemo2.java:103: cannot find symbol
    symbol : variable CategoryLabelWidthType
    location: class org.jfree.chart.demo.BarChart3DDemo2
    CategoryLabelWidthType.RANGE, 0.30f
    ^
    BarChart3DDemo2.java:105: cannot find symbol
    symbol : variable CategoryLabelPositions
    location: class org.jfree.chart.demo.BarChart3DDemo2
    axis.setCategoryLabelPositions(CategoryLabelPositions.replaceLeftPosition(p, left));
    ^
    BarChart3DDemo2.java:118: cannot find symbol
    symbol : class PrintStreamLogTarget
    location: class org.jfree.chart.demo.BarChart3DDemo2
    Log.getInstance().addTarget(new PrintStreamLogTarget());
    ^
    BarChart3DDemo2.java:118: cannot find symbol
    symbol : variable Log
    location: class org.jfree.chart.demo.BarChart3DDemo2
    Log.getInstance().addTarget(new PrintStreamLogTarget());
    ^
    BarChart3DDemo2.java:120: cannot find symbol
    symbol : method pack()
    location: class org.jfree.chart.demo.BarChart3DDemo2
    demo.pack();
    ^
    BarChart3DDemo2.java:121: cannot find symbol
    symbol : variable RefineryUtilities
    location: class org.jfree.chart.demo.BarChart3DDemo2
    RefineryUtilities.centerFrameOnScreen(demo);
    ^
    BarChart3DDemo2.java:122: cannot find symbol
    symbol : method setVisible(boolean)
    location: class org.jfree.chart.demo.BarChart3DDemo2
    demo.setVisible(true);
    ^
    44 errors

  • 3D Pie Chart

    Hi all,
    Just wondering if anyone can point my sniffer in the right direction. I am looking for some way be it an applet or some other method to produce a 3D pie chart using Java. I have seen some impressive examples by doing a search on google but the blood suckers want around 150euro for a licence, no way am i paying that, ill do it myself

    JFreeChart is very good:
    http://www.jfree.org/jfreechart/
    Take a look at the org.jfree.chart.demo.PieChart3DDemo1 / PieChart3DDemo2 / PieChart3DDemo3 and PieChart3DDemo4 classes ( you can see an example on the samples page: http://www.jfree.org/jfreechart/samples.html )

  • While Loop in Gantt Chart Value

    the problem is in the "createDataset" method whereby i want to do a while loop where i can check the data inside the database that i just inserted. after that i want to pass in all the data that is needed to generate the Gantt Chart. can anyone help me on this?
    thanks
    package ericTest;
    import java.io.BufferedReader;
    import java.io.DataInputStream;
    import java.io.File;
    import java.io.FileReader;
    import java.io.IOException;
    import java.text.ParseException;
    import java.util.StringTokenizer;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.Calendar;
    import java.util.Date;
    import org.jfree.chart.ChartFactory;
    import org.jfree.chart.ChartPanel;
    import org.jfree.chart.JFreeChart;
    import org.jfree.data.category.IntervalCategoryDataset;
    import org.jfree.data.gantt.Task;
    import org.jfree.data.gantt.TaskSeries;
    import org.jfree.data.gantt.TaskSeriesCollection;
    import org.jfree.data.time.SimpleTimePeriod;
    import org.jfree.ui.ApplicationFrame;
    import org.jfree.ui.RefineryUtilities;
    import com.db4o.Db4o;
    import com.db4o.ObjectContainer;
    import com.db4o.ObjectSet;
    public class GanttDemo3 extends ApplicationFrame {
       public GanttDemo3(final String title) {
            super(title);
            final IntervalCategoryDataset dataset = createDataset();
            final JFreeChart chart = createChart(dataset);
            // add the chart to a panel...
            final ChartPanel chartPanel = new ChartPanel(chart);
            chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
            setContentPane(chartPanel);
             public final static String filename = "C:\\KLGCC Mock Up.yap";
             private static ObjectContainer db;
             private static String day;
             private static String month;
             private static String year;
             private static String task;
             private static String startDate;
             private static String endDate;
             private static String startDay;
             private static String startMonth;
             private static String startYear;
             public static int startDay1;
             public static int startMonth1;
             public static int startYear1;
             public static String endDay;
             public static String endMonth;
             public static String endYear;
             public static int endDay1;
             public static int endMonth1;
             public static int endYear1;
             DataInputStream dis = null;
             String fileRecord = null;
             public void storeData() throws IOException{
                  new File(filename).delete();
                  db = Db4o.openFile(filename);
                       File f = new File("C:\\KLGCC Mock Up.txt");
                       FileReader fis = new FileReader(f);
                       BufferedReader bis = new BufferedReader(fis);
                       while((fileRecord = bis.readLine()) != null){
                                 StringTokenizer st = new StringTokenizer(fileRecord,",");
                                 task = st.nextToken();
                                 startDate = st.nextToken();
                                 endDate = st.nextToken();
                                 System.out.println(task+ " - " +startDate+ " - " +endDate);
                                 Country c = new Country(task, startDate, endDate);
                                 db.set(c);               
                       db.close();
             public void storeStartDate() throws ParseException{
                  db = Db4o.openFile(filename);
                  Country c = new Country();
                  ObjectSet result = db.get(c);
                  while(result.hasNext()){
                       Country obj = (Country)result.next();
                       String sDate = obj.getStartDate();
                       StringTokenizer str = new StringTokenizer(sDate, "/");
                       startMonth = str.nextToken();
                       startDay = str.nextToken();
                       startYear = str.nextToken();
                       System.out.println(startYear);
                       int startMonth1 = Integer.parseInt(startMonth);
                       int startDay1 = Integer.parseInt(startDay);
                       int startYear1 = Integer.parseInt(startYear);
                       //startMonth1 = startMonth1 + 1;
                       ArrayList<Integer> startDay2 = new ArrayList<Integer>();
                       startDay2.add(startDay1);
                       ArrayList<Integer> startMonth2 = new ArrayList<Integer>();
                       startMonth2.add(startMonth1);
                       ArrayList<Integer> startYear2 = new ArrayList<Integer>();
                       startYear2.add(startYear1);
                       System.out.println("Heloo" +startDay2+ "/" +startMonth2+ "/" +startYear2);
                  db.close();          
        public void storeEndDate() throws ParseException{
                  db = Db4o.openFile(filename);
                  Country c = new Country();
                  ObjectSet result = db.get(c);
                  while(result.hasNext()){
                       Country obj = (Country)result.next();
                       String sEndDate = obj.getEndDate();
                       StringTokenizer str1 = new StringTokenizer(sEndDate, "/");
                       endMonth = str1.nextToken();
                       endDay = str1.nextToken();
                       endYear = str1.nextToken();
                       int endMonth1 = Integer.parseInt(endMonth);
                       int endDay1 = Integer.parseInt(endDay);
                       int endYear1 = Integer.parseInt(endYear);
                       ArrayList<Integer> endDay2 = new ArrayList<Integer>();
                       endDay2.add(startDay1);
                       ArrayList<Integer> endMonth2 = new ArrayList<Integer>();
                       endMonth2.add(endMonth1);
                       ArrayList<Integer> endYear2 = new ArrayList<Integer>();
                       endYear2.add(endYear1);
                       System.out.println("END" +endDay2+ "/" +endMonth2+ "/" +endYear2);
                  db.close();
        public static IntervalCategoryDataset createDataset() {
             final TaskSeries s1 = new TaskSeries("Scheduled");
             //Country chart = new Country();
             ArrayList ar = new Arraylist;
             Iterator it = ar.iterator();
             while it.hasNext();{
             s1.add(new Task("abc",
                   new SimpleTimePeriod(date(startDay1, startMonth1, startYear1),
                                        date(endDay1, endMonth1, endYear1))));
                    final TaskSeriesCollection collection = new TaskSeriesCollection();
            collection.add(s1);
            return collection;
         * Utility method for creating <code>Date</code> objects.
         * @param day  the date.
         * @param month  the month.
         * @param year  the year.
         * @return a date.
        private static Date date(final int day, final int month, final int year) {
            final Calendar calendar = Calendar.getInstance();
            calendar.set(year, month, day);
            final Date result = calendar.getTime();
            return result;
         * Creates a chart.
         * @param dataset  the dataset.
         * @return The chart.
        private JFreeChart createChart(final IntervalCategoryDataset dataset) {
            final JFreeChart chart = ChartFactory.createGanttChart(
                "Gantt Chart Demo",  // chart title
                "Task",              // domain axis label
                "Date",              // range axis label
                dataset,             // data
                true,                // include legend
                true,                // tooltips
                false                // urls
    //        chart.getCategoryPlot().getDomainAxis().setMaxCategoryLabelWidthRatio(10.0f);
            return chart;   
        public static void main(final String[] args) throws IOException, ParseException
            final GanttDemo3 demo = new GanttDemo3("Gantt Chart Demo 1");
            demo.storeData();
            demo.storeStartDate();
            demo.storeEndDate();
            demo.pack();
            RefineryUtilities.centerFrameOnScreen(demo);
            demo.setVisible(true);
    }

    sorry. i know it's kinda blurr.
    i did some modification on this part of the code
    public static IntervalCategoryDataset createDataset() {
             final TaskSeries s1 = new TaskSeries("Scheduled");
             //Country chart = new Country();
             ArrayList ar = new ArrayList();
             for (Iterator it = ar.iterator(); it.hasNext();)
             s1.add(new Task(task,
                   new SimpleTimePeriod(date(startDay1, startMonth1, startYear1),
                                        date(endDay1, endMonth1, endYear1))));
             System.out.println(task);
            final TaskSeriesCollection collection = new TaskSeriesCollection();
            collection.add(s1);
            return collection;
             }the problem is the gantt chart after i have generated couldn't come out any value. is it because i never executed some methods?
    thanks

  • Increase dpi of a image (Chart , process )

    Hi All,
        I am getting the generated image of Charts , processes etc from Java(JFree Charts) to Flex.
    But my requirement is to increase dpi of those charts in flex.
    How to do that ...is there any solution for that??
    thanks in Advance..

    Hi All ,
        I am getting the generated image of Charts , processes etc from Java(JFree Charts) to Flex.
    But my requirement is to increase dpi of those charts in flex or   Increase resolution of charts and process diagrams..
    My code is like ::
    private var image:Image;
    image = new Image();
    image.source = "Some url .. which generates chart in Java" ;
    At this point .. after getting image in Flex .. i want to increase resolution of that image in AS3 .. i Heard about JPGEncoder
    How to do that ...is there any solution for that??
    Thanks..

  • How to use XY chart of JFreeChart? Or any other choice?!

    Like the title, THX!

    import java.awt.*;
    import java.text.*;
    import javax.swing.*;
    import org.jfree.chart.*;
    import org.jfree.chart.axis.*;
    import org.jfree.chart.labels.*;
    import org.jfree.chart.plot.*;
    import org.jfree.chart.plot.*;
    import org.jfree.chart.renderer.xy.*;
    import org.jfree.chart.title.*;
    import org.jfree.data.time.*;
    import org.jfree.data.xy.*;
    import org.jfree.ui.*;
    public class XYBarChartDemo1 extends ApplicationFrame{
        public XYBarChartDemo1(String s){
            super(s);
            IntervalXYDataset intervalxydataset = createDataset();
            JFreeChart jfreechart = createChart(intervalxydataset);
            ChartPanel chartpanel = new ChartPanel(jfreechart);
            chartpanel.setPreferredSize(new Dimension(500, 300));
            setContentPane(chartpanel);
        private static JFreeChart createChart(IntervalXYDataset intervalxydataset){
            JFreeChart jfreechart = ChartFactory.createXYBarChart("State Executions - USA", "Year", true, "Number of People", intervalxydataset, PlotOrientation.VERTICAL, true, false, false);
            jfreechart.addSubtitle(new TextTitle("Source: http://www.amnestyusa.org/abolish/listbyyear.do"));
            jfreechart.setBackgroundPaint(Color.white);
            XYPlot xyplot = jfreechart.getXYPlot();
            XYItemRenderer xyitemrenderer = xyplot.getRenderer();
            StandardXYToolTipGenerator standardxytooltipgenerator = new StandardXYToolTipGenerator("{1} = {2}", new SimpleDateFormat("yyyy"), new DecimalFormat("0"));
            xyitemrenderer.setToolTipGenerator(standardxytooltipgenerator);
            xyplot.setBackgroundPaint(Color.lightGray);
            xyplot.setRangeGridlinePaint(Color.white);
            DateAxis dateaxis = (DateAxis)xyplot.getDomainAxis();
            dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
            dateaxis.setLowerMargin(0.01D);
            dateaxis.setUpperMargin(0.01D);
            return jfreechart;
        private static IntervalXYDataset createDataset(){
            TimeSeries timeseries = new TimeSeries("Executions", "Year", "Count", org.jfree.data.time.Year.class);
            try{
                timeseries.add(new Year(1976), new Integer(0));
                timeseries.add(new Year(1977), new Integer(1));
                timeseries.add(new Year(1978), new Integer(0));
                timeseries.add(new Year(1979), new Integer(2));
                timeseries.add(new Year(1980), new Integer(0));
                timeseries.add(new Year(1981), new Integer(1));
                timeseries.add(new Year(1982), new Integer(2));
                timeseries.add(new Year(1983), new Integer(5));
                timeseries.add(new Year(1984), new Integer(21));
                timeseries.add(new Year(1985), new Integer(18));
                timeseries.add(new Year(1986), new Integer(18));
                timeseries.add(new Year(1987), new Integer(25));
                timeseries.add(new Year(1988), new Integer(11));
                timeseries.add(new Year(1989), new Integer(16));
                timeseries.add(new Year(1990), new Integer(23));
                timeseries.add(new Year(1991), new Integer(14));
                timeseries.add(new Year(1992), new Integer(31));
                timeseries.add(new Year(1993), new Integer(38));
                timeseries.add(new Year(1994), new Integer(31));
                timeseries.add(new Year(1995), new Integer(56));
                timeseries.add(new Year(1996), new Integer(45));
                timeseries.add(new Year(1997), new Integer(74));
                timeseries.add(new Year(1998), new Integer(68));
                timeseries.add(new Year(1999), new Integer(98));
                timeseries.add(new Year(2000), new Integer(85));
                timeseries.add(new Year(2001), new Integer(66));
                timeseries.add(new Year(2002), new Integer(71));
                timeseries.add(new Year(2003), new Integer(65));
            catch(Exception exception){
                System.err.println(exception.getMessage());
            TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(timeseries);
            timeseriescollection.setDomainIsPointsInTime(false);
            return timeseriescollection;
        public static JPanel createDemoPanel(){
            return new ChartPanel(createChart(createDataset()));
        public static void main(String args[]){
            XYBarChartDemo1 xybarchartdemo1 = new XYBarChartDemo1("State Executions - USA");
            xybarchartdemo1.pack();
            RefineryUtilities.centerFrameOnScreen(xybarchartdemo1);
            xybarchartdemo1.setVisible(true);
    }

  • I wanna dots instead of displaying it as a whole line in Linechart

    Hi Folks,
    I had one small doubt in the output of this program. The program is related to LineChart..Actually, Im getting the output as Line in the chart, but my requirement is to display only dots instead of displaying as a line...
    I just want only displaying as dots at particular name, insteading of getting that whole line from beginning to end...
    First of all whether its posiible to get dots or not?? and if it is possible, how??
    Here is the code:
    package com.home.practise.streams;
    import java.awt.BasicStroke;
    import java.awt.Color;
    import java.awt.Polygon;
    import java.awt.Shape;
    import java.awt.geom.Rectangle2D;
    import org.jfree.chart.ChartFactory;
    import org.jfree.chart.ChartPanel;
    import org.jfree.chart.JFreeChart;
    import org.jfree.chart.axis.NumberAxis;
    import org.jfree.chart.plot.CategoryPlot;
    import org.jfree.chart.plot.DefaultDrawingSupplier;
    import org.jfree.chart.plot.DrawingSupplier;
    import org.jfree.chart.plot.PlotOrientation;
    import org.jfree.chart.renderer.category.LineAndShapeRenderer;
    import org.jfree.data.category.CategoryDataset;
    import org.jfree.data.category.DefaultCategoryDataset;
    import org.jfree.ui.ApplicationFrame;
    import org.jfree.ui.RefineryUtilities;
    public class LineChartDemo5 extends ApplicationFrame {
        public LineChartDemo5(final String title) {
            super(title);
            final CategoryDataset dataset = createDataset();
            final JFreeChart chart = createChart(dataset);
            final ChartPanel chartPanel = new ChartPanel(chart);
            chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
            setContentPane(chartPanel);
        private CategoryDataset createDataset() {
            // row keys...
            final String series1 = "First";
            final String series2 = "Second";
            final String series3 = "Third";
            // column keys...
            final String type1 = "Hari";
            final String type2 = "Chary";
            final String type3 = "Trinetra";
            final String type4 = "Naveen";
            final String type5 = "Type 5";
            final String type6 = "Type 6";
            final String type7 = "Type 7";
            final String type8 = "Type 8";
            // create the dataset...
            final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
            dataset.addValue(0, series1, type1);
            dataset.addValue(0, series1, type2);
            dataset.addValue(1, series1, type3);
            dataset.addValue(1, series1, type4);
            /*dataset.addValue(5.0, series1, type5);
            dataset.addValue(7.0, series1, type6);
            dataset.addValue(7.0, series1, type7);
            dataset.addValue(8.0, series1, type8);*/
            /*dataset.addValue(5.0, series2, type1);
            dataset.addValue(7.0, series2, type2);
            dataset.addValue(6.0, series2, type3);
            dataset.addValue(8.0, series2, type4);
            dataset.addValue(4.0, series2, type5);
            dataset.addValue(4.0, series2, type6);
            dataset.addValue(2.0, series2, type7);
            dataset.addValue(1.0, series2, type8);
            dataset.addValue(4.0, series3, type1);
            dataset.addValue(3.0, series3, type2);
            dataset.addValue(2.0, series3, type3);
            dataset.addValue(3.0, series3, type4);
            dataset.addValue(6.0, series3, type5);
            dataset.addValue(3.0, series3, type6);
            dataset.addValue(4.0, series3, type7);
            dataset.addValue(3.0, series3, type8);*/
            return dataset;
        private JFreeChart createChart(final CategoryDataset dataset) {
            final JFreeChart chart = ChartFactory.createLineChart(
                "visualization",      // chart title
                "Names",                   // domain axis label
                "Gender",                  // range axis label
                dataset,                  // data
                PlotOrientation.VERTICAL, // orientation
                true,                     // include legend
                true,                     // tooltips
                false                     // urls
    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
      //      legend.setDisplaySeriesShapes(true);
            final Shape[] shapes = new Shape[3];
            int[] xpoints;
            int[] ypoints;
            // right-pointing triangle
            xpoints = new int[] {-3, 3, -3};
            ypoints = new int[] {-3, 0, 3};
            shapes[0] = new Polygon(xpoints, ypoints, 3);
            // vertical rectangle
            shapes[1] = new Rectangle2D.Double(-2, -3, 3, 6);
            // left-pointing triangle
            xpoints = new int[] {-3, 3, 3};
            ypoints = new int[] {0, -3, 3};
            shapes[2] = new Polygon(xpoints, ypoints, 3);
            final DrawingSupplier supplier = new DefaultDrawingSupplier(
                DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE,
                DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
                DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
                DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
                shapes
            final CategoryPlot plot = chart.getCategoryPlot();
            plot.setDrawingSupplier(supplier);
            chart.setBackgroundPaint(Color.yellow);
            // set the stroke for each series...
            plot.getRenderer().setSeriesStroke(
                0,
                new BasicStroke(
                    2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
                    1.0f, new float[] {10.0f, 6.0f}, 0.0f
            plot.getRenderer().setSeriesStroke(
                1,
                new BasicStroke(
                    2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
                    1.0f, new float[] {6.0f, 6.0f}, 0.0f
            plot.getRenderer().setSeriesStroke(
                2,
                new BasicStroke(
                    2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
                    1.0f, new float[] {2.0f, 6.0f}, 0.0f
            // customise the renderer...
            final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    //        renderer.setDrawShapes(true);
            renderer.setItemLabelsVisible(true);
         //   renderer.setSeriesLinesVisible(0, false);
       //     renderer.setBaseLinesVisible(false);
      //      renderer.setBaseShapesVisible(true);
      //      renderer.setSeriesLinesVisible(1, true);
      //      renderer.setLabelGenerator(new StandardCategoryLabelGenerator());
            // customise the range axis...
            final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
            rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            rangeAxis.setAutoRangeIncludesZero(false);
            rangeAxis.setUpperMargin(0.12);
            return chart;
        public static void main(final String[] args) {
            final LineChartDemo5 demo = new LineChartDemo5("Line Chart Demo 5");
            demo.pack();
            RefineryUtilities.centerFrameOnScreen(demo);
            demo.setVisible(true);
    }And here is the link, I have just used the above program from this link only
    http://www.java2s.com/Code/Java/Chart/JFreeChartLineChartDemo5showingtheuseofacustomdrawingsupplier.htm

    It looks like you're using BasicStrokes to create dashed lines
    plot.getRenderer().setSeriesStroke(
        0,
        new BasicStroke(
            2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
            1.0f, new float[] {10.0f, 6.0f}, 0.0f
    plot.getRenderer().setSeriesStroke(
        1,
        new BasicStroke(
            2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
            1.0f, new float[] {6.0f, 6.0f}, 0.0f
    plot.getRenderer().setSeriesStroke(
        2,
        new BasicStroke(
            2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
            1.0f, new float[] {2.0f, 6.0f}, 0.0f
    ); Is this not what you want? If you want points instead of dashes you just specify *1f* for first argument in the float array
    new BasicStroke(...,...,...,...,new float[]{1f,6f},....); That indicates that you want the dashed regions to be ~1 pixel long - that is, a point - and the empty regions between the dashes to be ~6 pixels long.

  • Date/Time on X-Axis with JFreeChart

    Hi guys,
    I've asked this question on the JFreeChart forums, but got no response.
    If anyone has any experience with JFreeChart, help would be most appreaciated.
    I am drawing a XY Line Chart to display CPU usage retrieved from a database. The user can search with specific dates/times (eg: from: 24/2/2005 to: 16/4/2005) - and then these results would be graphed.
    My question is, how do I use dates/times on the X-axis using JFreeChart?
    The results I am getting from the DB would be a time-stamp and CPU usage.
    Here is my current code, but it wont work with a time-stamp:
    public static class ChartTest   {
        public ChartTest()
            // create a dataset...FOR LOOP
            XYSeries dataSet = new XYSeries("CPU Usage");
            TimeSeries closing = new TimeSeries( "Closing Value", Day.class );
         for(int h=0; h < newArray[0].length; h++)
            for(int i=0; i < newArray.length; i++)
               dataSet.add(newArray[i][h], newArray[i][h++]);
            XYDataset xyDataset = new XYSeriesCollection(dataSet);
            // create a chart...
            JFreeChart lineGraph = ChartFactory.createXYLineChart
                        ("Mitch's CPU Usage Test",  // Title
                          "Time",           // X-Axis label
                          "CPU Load",           // Y-Axis label
                          xyDataset,          // Dataset
                          PlotOrientation.VERTICAL,        //Plot orientation
                          true,                //show legend
                          true,                // Show tooltips
                          false               //url show
            // create and display a frame...
            ChartFrame frame = new ChartFrame("CPU Usage Test", lineGraph);
            frame.pack();
            frame.setVisible(true);
        }

    The JFreeChard demo should give you the idea
    package demo;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.text.SimpleDateFormat;
    import javax.swing.JPanel;
    import org.jfree.chart.*;
    import org.jfree.chart.axis.DateAxis;
    import org.jfree.chart.plot.XYPlot;
    import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
    import org.jfree.data.time.*;
    import org.jfree.data.xy.XYDataset;
    import org.jfree.ui.*;
    public class TimeSeriesDemo1 extends ApplicationFrame
        public TimeSeriesDemo1(String s)
            super(s);
            XYDataset xydataset = createDataset();
            JFreeChart jfreechart = createChart(xydataset);
            ChartPanel chartpanel = new ChartPanel(jfreechart, false);
            chartpanel.setPreferredSize(new Dimension(500, 270));
            chartpanel.setMouseZoomable(true, false);
            setContentPane(chartpanel);
        private static JFreeChart createChart(XYDataset xydataset)
            JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", "Date", "Price Per Unit", xydataset, true, true, false);
            jfreechart.setBackgroundPaint(Color.white);
            XYPlot xyplot = (XYPlot)jfreechart.getPlot();
            xyplot.setBackgroundPaint(Color.lightGray);
            xyplot.setDomainGridlinePaint(Color.white);
            xyplot.setRangeGridlinePaint(Color.white);
            xyplot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
            xyplot.setDomainCrosshairVisible(true);
            xyplot.setRangeCrosshairVisible(true);
            org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer();
            if(xyitemrenderer instanceof XYLineAndShapeRenderer)
                XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer)xyitemrenderer;
                xylineandshaperenderer.setDefaultShapesVisible(true);
                xylineandshaperenderer.setDefaultShapesFilled(true);
            DateAxis dateaxis = (DateAxis)xyplot.getDomainAxis();
            dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
            return jfreechart;
        private static XYDataset createDataset()
            TimeSeries timeseries = new TimeSeries("L&G European Index Trust", org.jfree.data.time.Month.class);
            timeseries.add(new Month(2, 2001), 181.8);
            timeseries.add(new Month(3, 2001), 167.3);
            timeseries.add(new Month(4, 2001), 153.8);
            timeseries.add(new Month(5, 2001), 167.6);
            timeseries.add(new Month(6, 2001), 158.8);
            timeseries.add(new Month(7, 2001), 148.3);
            timeseries.add(new Month(8, 2001), 153.9);
            timeseries.add(new Month(9, 2001), 142.7);
            timeseries.add(new Month(10, 2001), 123.2);
            timeseries.add(new Month(11, 2001), 131.8);
            timeseries.add(new Month(12, 2001), 139.6);
            timeseries.add(new Month(1, 2002), 142.9);
            timeseries.add(new Month(2, 2002), 138.7);
            timeseries.add(new Month(3, 2002), 137.3);
            timeseries.add(new Month(4, 2002), 143.9);
            timeseries.add(new Month(5, 2002), 139.8);
            timeseries.add(new Month(6, 2002), 137.0);
            timeseries.add(new Month(7, 2002), 132.8);
            TimeSeries timeseries1 = new TimeSeries("L&G UK Index Trust", org.jfree.data.time.Month.class);
            timeseries1.add(new Month(2, 2001), 129.6);
            timeseries1.add(new Month(3, 2001), 123.2);
            timeseries1.add(new Month(4, 2001), 117.2);
            timeseries1.add(new Month(5, 2001), 124.1);
            timeseries1.add(new Month(6, 2001), 122.6);
            timeseries1.add(new Month(7, 2001), 119.2);
            timeseries1.add(new Month(8, 2001), 116.5);
            timeseries1.add(new Month(9, 2001), 112.7);
            timeseries1.add(new Month(10, 2001), 101.5);
            timeseries1.add(new Month(11, 2001), 106.1);
            timeseries1.add(new Month(12, 2001), 110.3);
            timeseries1.add(new Month(1, 2002), 111.7);
            timeseries1.add(new Month(2, 2002), 111.0);
            timeseries1.add(new Month(3, 2002), 109.6);
            timeseries1.add(new Month(4, 2002), 113.2D);
            timeseries1.add(new Month(5, 2002), 111.6);
            timeseries1.add(new Month(6, 2002), 108.8);
            timeseries1.add(new Month(7, 2002), 101.6);
            TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
            timeseriescollection.addSeries(timeseries);
            timeseriescollection.addSeries(timeseries1);
            timeseriescollection.setDomainIsPointsInTime(true);
            return timeseriescollection;
        public static JPanel createDemoPanel()
            JFreeChart jfreechart = createChart(createDataset());
            return new ChartPanel(jfreechart);
        public static void main(String args[])
            TimeSeriesDemo1 timeseriesdemo1 = new TimeSeriesDemo1("Time Series Demo 1");
            timeseriesdemo1.pack();
            RefineryUtilities.centerFrameOnScreen(timeseriesdemo1);
            timeseriesdemo1.setVisible(true);
    }

Maybe you are looking for