jfreechart 线条图不能出现工具提示
以下这个函数是产生chart对象的,但显示出来后就是没有tooltip出现:
private JFreeChart createCurveChart(ArrayList lst){
XYDatasetCreator dsCreator=new XYDatasetCreator();
dsCreator.addSeriesToDataset(CommonSeries.AVERAGE_VALUE,lst);
dsCreator.addSeriesToDataset(CommonSeries.MAXIMUM_VALUE,lst);
dsCreator.addSeriesToDataset(CommonSeries.MINIMUM_VALUE,lst);
XYDataset dataset=dsCreator.getDs();
JFreeChart chart = ChartFactory.createTimeSeriesChart( " ", "时间 ", "数量 ",dataset,true,true,false);
XYPlot plot=chart.getXYPlot();
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
renderer.setShapesVisible(true);
renderer.setDrawOutlines(true);
renderer.setItemLabelsVisible(true);
//StandardXYToolTipGenerator tipCreator=new StandardXYToolTipGenerator( "{1},{2} ",new SimpleDateFormat(),new DecimalFormat( "0.00 "));
StandardXYToolTipGenerator tipCreator=new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,new SimpleDateFormat(),new DecimalFormat( "0.00 "));
renderer.setToolTipGenerator(tipCreator);
plot.getRangeAxis().setLabelAngle(Math.PI / 2);
ValueAxis domainAxis=plot.getDomainAxis();
if(domainAxis instanceof DateAxis){
if(dsCreator.getClassObj()==Day.class){
DateAxis axis=(DateAxis)domainAxis;
axis.setDateFormatOverride(new SimpleDateFormat( "yyyy-MM-dd "));
}
}
return chart;
}
------解决方案--------------------在你下载的JFreeChart包中有例题,可以借鉴一下.
------解决方案--------------------