Thank for sharing this code. How can I set restoreAutoDomainBounds()
with Jfreechart's Chart viewer? I am using Javafx
AutoRange and Zoom
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: AutoRange and Zoom
That feature isn't in the ChartViewer yet, but I'll look at adding it.hmsj wrote:Thank for sharing this code. How can I set restoreAutoDomainBounds()
with Jfreechart's Chart viewer? I am using Javafx
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
Re: AutoRange and Zoom
Here's a complete code to include the override of restoreAutoRangeBounds().
Code: Select all
public class MyChartPanel extends ChartPanel
{
public MyChartPanel(JFreeChart chart)
{
super(chart);
}
@Override
public void restoreAutoDomainBounds()
{
super.restoreAutoDomainBounds();
// Set your desired range
DomainAxis.setRange(100000,270000);
}
@Override
public void restoreAutoRangeBounds()
{
super.restoreAutoRangeBounds();
// Set your desired range
Date minDate = new Date();
Date maxDate = new Date();
String dateFormat = "MM/dd/yyyy HH:mm";
//set min and max range date
Calendar cal = new GregorianCalendar();
cal.setTime(minDate);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
minDate = cal.getTime();
cal.set(Calendar.HOUR_OF_DAY, 9);
maxDate = cal.getTime();
RangeDateaxis.setRange(minDate, maxDate);
RangeDateaxis.setDateFormatOverride(new SimpleDateFormat(dateFormat));
}
}