Hello, I’m telling you my problem!
I need capture one event (click in one point of chart) to tick this point in a Jtable. But domain are dates….
double xx = plot.getDomainCrosshairValue(); How could I capture the dates?
Here I put a piece of my code:
public void chartProgress(ChartProgressEvent event) {
if (event.getType() != ChartProgressEvent.DRAWING_FINISHED) { return;}
if (this.chartPanel != null) {
JFreeChart c = this.chartPanel.getChart();
if (c != null) {
XYPlot plot = (XYPlot) c.getPlot();
XYDataset dataset = plot.getDataset();
Comparable seriesKey = dataset.getSeriesKey(0);
double xx = plot.getDomainCrosshairValue();
//¿Capture row? Domain are dates
/*Rectangle r =getCellRect(row, column, true);
this.pnlScroll.getViewport().scrollRectToVisible(r); */
}
}
}
Could somebody help me?
CLICK IN CHART- CAPTURE DATA
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
If your x-values are dates, you should interpret the crosshair value ('xx' in your code) as "milliseconds since 1-Jan-1970".
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


Thank you very much!
OK, but now I need index of every date in dataset.
I've a problem, I can't use series.getIndex(RegularPeriod) because my XYdataset was obtain like JDBCXYDataset.
How I could do it?
public void chartProgress(ChartProgressEvent event) {
if (event.getType() != ChartProgressEvent.DRAWING_FINISHED) { return;}
if (this.chartPanel != null) {
JFreeChart c = this.chartPanel.getChart();
if (c != null) {
XYPlot plot = (XYPlot) c.getPlot();
XYDataset dataset = plot.getDataset();
Comparable seriesKey = dataset.getSeriesKey(0);
double xx = plot.getDomainCrosshairValue();
long millis = (long) xx;
Date d= new Date(millis);
Minute m=new Minute(d);
/*Rectangle r =getCellRect(row, column, true);
this.pnlScroll.getViewport().scrollRectToVisible(r); */
}
}
}
OK, but now I need index of every date in dataset.
I've a problem, I can't use series.getIndex(RegularPeriod) because my XYdataset was obtain like JDBCXYDataset.
How I could do it?
public void chartProgress(ChartProgressEvent event) {
if (event.getType() != ChartProgressEvent.DRAWING_FINISHED) { return;}
if (this.chartPanel != null) {
JFreeChart c = this.chartPanel.getChart();
if (c != null) {
XYPlot plot = (XYPlot) c.getPlot();
XYDataset dataset = plot.getDataset();
Comparable seriesKey = dataset.getSeriesKey(0);
double xx = plot.getDomainCrosshairValue();
long millis = (long) xx;
Date d= new Date(millis);
Minute m=new Minute(d);
/*Rectangle r =getCellRect(row, column, true);
this.pnlScroll.getViewport().scrollRectToVisible(r); */
}
}
}