Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 9 of 9

Thread: JFreeChart XYLine

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default JFreeChart XYLine

    Dear All,
    I am using JFreeChart to plot an XYLine using XYSeries.
    i.e:
    int i=0;
    XYSeries series=new XYSeries(temperature);
    series.add(i, Integer.parseInt(RTemp));

    instead of "i", I want to put a string such that the x-axis would display a string and y-axis would display an integer.
    so instead of :

    series.add(int, int);

    i want to have:
    series.add(string, int);

    How can i do it?
    Thank you


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: JFreeChart XYLine

    I don't understand. XYSeries are supposed to be just that, with x and y numerical values. What sort of graph are you looking to create? Do you just want to change the X-axis display?

  3. #3
    Junior Member
    Join Date
    Oct 2010
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: JFreeChart XYLine

    Hey..
    I want to display the day n time i obtained from a database (2 strings concatenated) on the x-axis and the temperature on the y-axis.

  4. #4
    Junior Member
    Join Date
    Oct 2010
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: JFreeChart XYLine

    That is, I want to display the patient's temperature (y-axis) at different times of the day and on different days(x-axis)

  5. #5
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: JFreeChart XYLine

    See the following class to use as an alternative to an XYSeries:
    TimeSeries

  6. #6
    Junior Member
    Join Date
    Oct 2010
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: JFreeChart XYLine

    with the TimeSeries I managed to plot the date on the x-axis but not the date and time together. I converted the date i retrieve from the database into substrings:

    RDate=new String(RR.getString(2));
    n1=Integer.parseInt(RDate.substring(1,5));
    n2=Integer.parseInt(RDate.substring(6,8));
    n3=Integer.parseInt(RDate.substring(9,11));

    and then added it to the TimeSeries:

    s2.add(new Day(n1,n2,n3), Integer.parseInt(RTemp));

    Is there anything like TimeSeries or XYPlot that will allow me to plot (string s, int n)? so the x-axis arent values just names or strings and the y-axis are integers?
    Thank you very much for all the effort

  7. #7
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: JFreeChart XYLine

    Try looking at setting the x-axis of the chart with a DateAxis. You can then work on getting the display you wish by setting the DateFormat for this object, formatting the said DateFormat the way you wish to display the data.

  8. #8
    Junior Member
    Join Date
    Oct 2010
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: JFreeChart XYLine

    I am trying to get an example on SymbolAxis. I think it may replace the date with a string on the X-axis. Do you know where i could find such examples? thank you

  9. #9
    Junior Member
    Join Date
    Oct 2010
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: JFreeChart XYLine

    Thank you very much forall your effort, I managed to find a solution. Thanx

Similar Threads

  1. [SOLVED] Can't get JFreeChart to work
    By igniteflow in forum Java SE APIs
    Replies: 2
    Last Post: February 15th, 2011, 02:19 AM
  2. JFreechart
    By subhvi in forum Java Theory & Questions
    Replies: 0
    Last Post: February 24th, 2010, 05:36 AM
  3. Problem with JFreeChart TimeSeries
    By igniteflow in forum AWT / Java Swing
    Replies: 0
    Last Post: August 16th, 2009, 08:16 AM