Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6780733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:32:27+00:00 2026-05-26T16:32:27+00:00

From what I can tell DateTickUnitType is an enumeration that cannot be extended or

  • 0

From what I can tell DateTickUnitType is an enumeration that cannot be extended or changed outside of outright replacement and it only specifies units for DAY, MONTH, YEAR, MINUTE, HOUR, SECOND, and MILLISECOND, but not WEEK despite there being a Week type of TimePeriod.

The problem this causes is when I am forced to use the DAY tick unit to plot a single data point for a week which leaves my bar width quite narrow as compared to plotting a daily point on a DAY tick unit or a monthly data point on a MONTH tick unit.

Depending on the range of my data (which I calculate programmatically), I create the TimeSeriesDataItem with the most appropriate TimePeriod:

// create the correct TimeSeriesDataItem based on the gap of this data set
switch (gap) {
case WEEK:
    item = new TimeSeriesDataItem(new Week(targetDate.getTime()), dataPoint);
    break;
case DAY:
    item = new TimeSeriesDataItem(new Day(targetDate.getTime()), dataPoint);
    break;
case MONTH:
default:
    item = new TimeSeriesDataItem(new Month(targetDate.getTime()), dataPoint);
    break;
}

And then after the chart is built, I try to customize it to make the bars as wide as possible for each data point. If the data are days, the tick units are days. If the data are months, the tick units are months. But if the data are weeks, then I’m forced to either go with days or months since there is no week tick unit.

JFreeChart barChart = ChartFactory.createXYBarChart(
    model.getTitle(), 
    model.getDomainTitle(), 
    true,
    model.getRangeTitle(), 
    dataset, 
    model.getOrientation() == SimpleBarChartModel.Orientation.VERTICAL ? PlotOrientation.VERTICAL : PlotOrientation.HORIZONTAL, 
    model.getShowLegend(), 
    false, 
    false);

// ...

DateAxis domainAxis = (DateAxis)plot.getDomainAxis();
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
if (model.getDomainLabels() != null && model.getDomainLabels().size() > 1) {
    // create three different sets of TickUnits for the three ranges (day, week, month)
    // JFreeChart will select the smallest unit that doesn't overlap labels.
    TickUnits tickUnits = new TickUnits();
    tickUnits.add(new DateTickUnit(DateTickUnitType.MONTH, 1, new SimpleDateFormat("MMM")));
    tickUnits.add(new DateTickUnit(DateTickUnitType.DAY, 7, dateFormat));
    tickUnits.add(new DateTickUnit(DateTickUnitType.DAY, 1, dateFormat));
    domainAxis.setStandardTickUnits(tickUnits);
}
domainAxis.setAutoRange(true);
domainAxis.setVerticalTickLabels(true);
domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);

The former creates very thin bars since it’s plotting 7 columns per tick unit.

Is there any way for me to make a custom DateTickUnitType for WEEK that would allow me to plot only one point per week instead of 7 (since I only have one data point)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:32:28+00:00Added an answer on May 26, 2026 at 4:32 pm

    For DynamicTimeSeriesCollection you can add WEEK using the approach shown here for MILLISECOND. See also this followup thread, which mentions multiples of the chosen period.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From what I can tell, the difference between PyList_SetItem and PyList_SETITEM is that PyList_SetItem
From the question you can probably tell that I don't know much about code!
Can anybody tell how to retrieve data from database like that of Facebook's notification
From what I can tell, .NET 4.0 still lacks read-only lists. Why does the
From what I can tell, Passenger can only be configured to use one version
In .NET, is there any way that I can tell from the HttpContext or
so from what i can tell, you have to specify artifacts and working directory
I have a (from what I can tell) perfectly working Linux setup (Ubuntu 8.04)
NSDecimalNumber is a subclass of NSNumber, and from what I can tell, it implements
i have invoked blackberry calender from my application can anyone tell me how to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.