Hi,
domainAxis.setTimeline(SegmentedTimeline.newMondayThroughFridayTimeline()); has no effect on my chart, the saturday and sunday are always displayed on domainaxis.
has anyone experienced this issue?
Thanks.
Emanuele
SegmentedTimeline
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: SegmentedTimeline
This ode works as expected. The tick labels on the x axis do not show an entry for august 7th.
Code: Select all
public class DateAxisPlot {
public static void main(String[] args) {
int count = 500;
int series = 5;
DefaultXYDataset dataset = new DefaultXYDataset();
long start = System.currentTimeMillis();
long increment = 1000*60*60; //20 min
for(int s = 0; s < series; s++){
double[][] data = new double[2][count];
for(int i = 0; i < count; i++){
data[0][i] = start + increment * i;
data[1][i] = (s + 1)*i;
}
dataset.addSeries("Series " + s, data);
}
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM");
DateAxis xAxis = new DateAxis("Date axis");
xAxis.setTimeline(SegmentedTimeline.newMondayThroughFridayTimeline());
xAxis.setDateFormatOverride(sdf);
NumberAxis yAxis = new NumberAxis("y axis");
XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true);
renderer.setUseOutlinePaint(true);
Shape shape = new Ellipse2D.Double(-4, -4, 8, 8);
for(int i = 0; i < series; i++){
renderer.setSeriesShape(i, shape);
renderer.setSeriesOutlinePaint(i, Color.black);
}
XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
JFreeChart chart = new JFreeChart(plot);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new ChartPanel(chart));
frame.pack();
frame.setVisible(true);
}
}
Re: SegmentedTimeline
Hi paradoxoff and thks for your reply,
This is my code and it doesn't work.
This is my code and it doesn't work.
Code: Select all
SegmentedTimeline timeline = new SegmentedTimeline(MINUTE_SEGMENT_SIZE, (7 * 60) + 30, (24 * 60) - ((7 * 60) + 30));
timeline.setBaseTimeline(new SegmentedTimeline(DAY_SEGMENT_SIZE, 5, 2));
timeline.setStartTime(FIRST_MONDAY_AFTER_1900 + (9 * 60) * timeline.getSegmentSize());
domainAxis0 = new DateAxis();
domainAxis0.setTimeline( timeline );
volumeAxis = new NumberAxis();
priceAxis = new NumberAxis();
rndLine = new XYLineAndShapeRenderer();
rndArea = new XYAreaRenderer();
rndBar = new ClusteredXYBarRenderer(0.9, true);
StandardXYBarPainter bp = new StandardXYBarPainter();
rndBar.setBarPainter(bp);
plotPrice = new XYPlot(null, domainAxis0, priceAxis, null);
plotPrice.setRenderer(0, rndArea);
plotPrice.setRenderer(1, rndLine);
plotPrice.setDataset(0, dataset);
plotPrice.setDataset(1, dataset);
plotVol = new XYPlot(null, domainAxis0, volumeAxis, rndBar);
plotVol.setDataset(datasetVol);
cPlot = new CombinedDomainXYPlot(domainAxis0);
cPlot.add(plotPrice, 3);
cPlot.add(plotVol, 1);
JFreeChart chart = new JFreeChart("", new Font("arial", Font.BOLD, 15), cPlot, false);
...