customising date on x-axis in JFreeChart

Discussion in 'Java' started by ameyas, Jan 29, 2007.

  1. ameyas

    ameyas Guest

    hi

    i am generating 3D bar chart. i am using CategoryAxis as x-axis.
    the graph represents weekly statistics.
    now due to space issues i would like to have date format on x-axis as
    "dd" whereas in the tooltip i would like to display the entire date
    yyyy-MM-dd.

    how do i acheieve this?

    i can create StandardCategoryToolTipGenerator but if i pass DateFormat
    in this, it is applied to the value axis which is actually plain
    numbers. i want to apply this format to domain (x) axis.

    if i use date directly on the x-axis, i am facing space issues as the
    label is not displayed properly.

    so basically if the date is 29 Jan 2007 i want to display it as
    on x-axis : 29
    in tooltip : 2007-01-29


    any clues ?

    thanks & regards
    amey
     
    ameyas, Jan 29, 2007
    #1
    1. Advertising

  2. ameyas

    dnx Guest

    On 29 Sty, 08:15, "ameyas" <> wrote:
    > hi
    >
    > i am generating 3D bar chart. i am using CategoryAxis as x-axis.
    > the graph represents weekly statistics.
    > now due to space issues i would like to have date format on x-axis as
    > "dd" whereas in the tooltip i would like to display the entire date
    > yyyy-MM-dd.
    >
    > how do i acheieve this?
    >
    > i can create StandardCategoryToolTipGenerator but if i pass DateFormat
    > in this, it is applied to the value axis which is actually plain
    > numbers. i want to apply this format to domain (x) axis.
    >
    > if i use date directly on the x-axis, i am facing space issues as the
    > label is not displayed properly.
    >
    > so basically if the date is 29 Jan 2007 i want to display it as
    > on x-axis : 29
    > in tooltip : 2007-01-29
    >
    > any clues ?
    >
    > thanks & regards
    > amey



    Something like this should work:

    ((DateAxis) plot.getDomainAxis()).setDateFormatOverride(new
    SimpleDateFormat("dd"));

    DNX
     
    dnx, Jan 29, 2007
    #2
    1. Advertising

  3. ameyas

    ameyas Guest

    now wouldn't that throw ClassCastException ?


    On Jan 29, 2:25 pm, "dnx" <> wrote:
    > On 29 Sty, 08:15, "ameyas" <> wrote:
    > ((DateAxis) plot.getDomainAxis()).setDateFormatOverride(new
    > SimpleDateFormat("dd"));
    >
    > DNX
     
    ameyas, Jan 29, 2007
    #3
  4. ameyas

    dnx Guest

    On 29 Sty, 10:45, "ameyas" <> wrote:
    > now wouldn't that throw ClassCastException ?
    >



    yes... :/
    sorry, i haven't noticed what is your x-axis
     
    dnx, Jan 29, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wh1974
    Replies:
    0
    Views:
    2,492
    wh1974
    Jan 12, 2005
  2. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,379
    Michael Borgwardt
    May 30, 2004
  3. Avatar Viper

    Customized axis value in JFreeChart

    Avatar Viper, Oct 27, 2004, in forum: Java
    Replies:
    5
    Views:
    11,585
    John B. Matthews
    Oct 29, 2004
  4. Replies:
    0
    Views:
    1,000
  5. David
    Replies:
    3
    Views:
    532
    Kenneth P. Turvey
    Nov 12, 2006
Loading...

Share This Page