JFreeChart 折线图 热点问题, 急等 谢谢了。
如题,我用jfreechart做折线图,明明已经添加了显示热点的代码,而且在jsp页面右键查看源文件时,也能看到map信息,但是鼠标放到折线上,就是没有信息出现。请各位高人给看看怎么回事儿吧。
我是在jsp里面直接形成图片的,我现在把jsp里面的代码贴出来:
XYSeriesCollection xySeriesCollection = new XYSeriesCollection();
XYDataset xydataset = (XYDataset)xySeriesCollection;
xySeriesCollection.addSeries(xyseries1);
xySeriesCollection.addSeries(xyseries2);
xySeriesCollection.addSeries(xyseries3);
xySeriesCollection.addSeries(xyseries4);
JFreeChart chart = ChartFactory.createXYLineChart(
"正压力图表显示", // chart title
"井深(m)", // domain axis label
"正压力(N)", // range axis label
xydataset, // dataset
PlotOrientation.HORIZONTAL, // orientation
true, // include legend
true,
false
);
// set the background color for the chart...
Font font = new Font("SimSun",Font.BOLD,20);
Font font2 = new Font("SimSun",Font.BOLD,14);
TextTitle tt = chart.getTitle();
tt.setFont(font);
chart.setBackgroundPaint(new Color(0xCC, 0xFF, 0xCC));
LegendTitle legend = (LegendTitle) chart.getSubtitle(0);
legend.setPosition(RectangleEdge.BOTTOM);
legend.setItemFont(font2);
// get a reference to the plot for further customisation...
XYPlot plot = (XYPlot) chart.getPlot();
plot.setDomainAxisLocation(AxisLocation.TOP_OR_LEFT);
plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
plot.getDomainAxis().setLabelFont(font2);
plot.getRangeAxis().setLabelFont(font2);
XYLineAndShapeRenderer xylinerenderer=(XYLineAndShapeRenderer)plot.getRenderer();
xylinerenderer.setSeriesPaint(0, new Color(255, 0 ,0));
xylinerenderer.setSeriesPaint(1, new Color(0 ,0, 255));
xylinerenderer.setSeriesPaint(2, new Color(255, 0 ,0));
xylinerenderer.setSeriesPaint(3, new Color(0 ,0, 255));
NumberAxis numAxis = (NumberAxis)plot.getDomainAxis();
numAxis.setTickUnit(new NumberTickUnit(2)); //0.5为一个间隔单位
plot.getRenderer().setSeriesStroke(2, new BasicStroke(2.0F, 1, 1, 1.0F, new float[] {6F, 6F}, 0.0F));
plot.getRenderer().setSeriesStroke(3, new BasicStroke(2.0F, 1, 1, 1.0F, new float[] {6F, 6F}, 0.0F));
StandardEntityCollection sec = new StandardEntityCollection();
ChartRenderingInfo info = new ChartRenderingInfo(sec);
filename2 = ServletUtilities.saveChartAsPNG(chart, 800, 390, info, request.getSession());
PrintWriter out2 = response.getWriter();
PrintWriter w = new PrintWriter(out2);//输出MAP信息
ChartUtilities.writeImageMap(w, "mapx", info, false);
w.flush();
graphURL = request.getContextPath() + "/servlet/DisplayChart?filename=" + filename2;
<td><div><img src="<%=graphURL%>" usemap="#mapx"></div></td>
在jsp页面右键查看源代码:
<map id="mapx" name="mapx">
<area shape="poly" coords="76,150,75,152,73,153,71,152,70,150,71,148,73,147,75,148,76,150,76,150" title="前次分析: (-0, 100)" alt="" nohref="nohref"/>
<area shape="poly" coords="77,159,76,161,74,162,72,161,71,159,72,157,74,156,76,157,77,159,77,159" title="前次分析: (-0.05, 110)" alt="" nohref="nohref"/>
<area shape="poly" coords="78,164,77,166,75,167,72,166,72,164,72,162,75,161,77,162,78,164,78,164" title="前次分析: (-0.1, 115)" alt="" nohref="nohref"/>
。。。。。。
</map>
<td><div><img src="/fpm/servlet/DisplayChart?filename=jfreechart-19796.png" usemap="#mapx"></div></td>
谢谢了。