i was trying to get rid of the gaps(weekends) from a candlestick chart, by
((DateAxis) plot.getDomainAxis()).setTimeline(SegmentedTimeline.newMondayThroughFridayTimeline());
it ran into busy loop or something when the dataset size is more than 70-80. did i miss something or this might be a potential issue with the SegmentedTimeline class? it all works if i don't apply the newMondayThroughFridayTimeline thing.
thanks for your help.
Jeff
candlestick and MondayThroughFridayTimeline
Re: candlestick and MondayThroughFridayTimeline
there seems to be a bug in DateAxis.java, at least in my case. i filed a bug to sourceforge.
the following line may adjust the date to a previous hidden date, which can lead to infinite loop.
tickDate = correctTickDateForPosition(tickDate, unit, this.tickMarkPosition);
the following line may adjust the date to a previous hidden date, which can lead to infinite loop.
tickDate = correctTickDateForPosition(tickDate, unit, this.tickMarkPosition);
Code: Select all
protected List refreshTicksHorizontal(Graphics2D g2,
Rectangle2D dataArea, RectangleEdge edge) {
List result = new java.util.ArrayList();
Font tickLabelFont = getTickLabelFont();
g2.setFont(tickLabelFont);
if (isAutoTickUnitSelection()) {
selectAutoTickUnit(g2, dataArea, edge);
}
DateTickUnit unit = getTickUnit();
Date tickDate = calculateLowestVisibleTickValue(unit);
Date upperDate = getMaximumDate();
while (tickDate.before(upperDate)) {
// could add a flag to make the following correction optional...
tickDate = correctTickDateForPosition(tickDate, unit,
this.tickMarkPosition);
long lowestTickTime = tickDate.getTime();
long distance = unit.addToDate(tickDate, this.timeZone).getTime()
- lowestTickTime;
int minorTickSpaces = getMinorTickCount();
if (minorTickSpaces <= 0) {
minorTickSpaces = unit.getMinorTickCount();
}
for (int minorTick = 1; minorTick < minorTickSpaces; minorTick++) {
long minorTickTime = lowestTickTime - distance
* minorTick / minorTickSpaces;
if (minorTickTime > 0 && getRange().contains(minorTickTime)
&& (!isHiddenValue(minorTickTime))) {
result.add(new DateTick(TickType.MINOR,
new Date(minorTickTime), "", TextAnchor.TOP_CENTER,
TextAnchor.CENTER, 0.0));
}
}
if (!isHiddenValue(tickDate.getTime())) {
// work out the value, label and position
String tickLabel;
DateFormat formatter = getDateFormatOverride();
if (formatter != null) {
tickLabel = formatter.format(tickDate);
}
else {
tickLabel = this.tickUnit.dateToString(tickDate);
}
TextAnchor anchor = null;
TextAnchor rotationAnchor = null;
double angle = 0.0;
if (isVerticalTickLabels()) {
anchor = TextAnchor.CENTER_RIGHT;
rotationAnchor = TextAnchor.CENTER_RIGHT;
if (edge == RectangleEdge.TOP) {
angle = Math.PI / 2.0;
}
else {
angle = -Math.PI / 2.0;
}
}
else {
if (edge == RectangleEdge.TOP) {
anchor = TextAnchor.BOTTOM_CENTER;
rotationAnchor = TextAnchor.BOTTOM_CENTER;
}
else {
anchor = TextAnchor.TOP_CENTER;
rotationAnchor = TextAnchor.TOP_CENTER;
}
}
Tick tick = new DateTick(tickDate, tickLabel, anchor,
rotationAnchor, angle);
result.add(tick);
long currentTickTime = tickDate.getTime();
tickDate = unit.addToDate(tickDate, this.timeZone);
long nextTickTime = tickDate.getTime();
for (int minorTick = 1; minorTick < minorTickSpaces;
minorTick++){
long minorTickTime = currentTickTime
+ (nextTickTime - currentTickTime)
* minorTick / minorTickSpaces;
if (getRange().contains(minorTickTime)
&& (!isHiddenValue(minorTickTime))) {
result.add(new DateTick(TickType.MINOR,
new Date(minorTickTime), "",
TextAnchor.TOP_CENTER, TextAnchor.CENTER,
0.0));
}
}
}
else {
tickDate = unit.rollDate(tickDate, this.timeZone);
continue;
}
}
return result;
}
Re: candlestick and MondayThroughFridayTimeline
Its a known bug. See this thread for more info and some possible workarounds
http://www.jfree.org/phpBB2/viewtopic.p ... inite+loop
http://www.jfree.org/phpBB2/viewtopic.p ... inite+loop
Re: candlestick and MondayThroughFridayTimeline
it ran into busy loop or something when the dataset size is more than 70-80. did i miss something or this might be a potential issue with the SegmentedTimeline class? it all works if i don't apply the newMondayThroughFridayTimeline thing.
_________________________
SEO Manchester
_________________________
SEO Manchester
Re: candlestick and MondayThroughFridayTimeline
I also wanted to apply MondayThroughFridayTimeline in my project but when i use it hangs.
and if i remove it everything works fine.
Is there any solution to it?
and if i remove it everything works fine.
Is there any solution to it?