2 duxinglw duxinglw 于 2014.05.08 12:33 提问

struts2+jfreechart为什么没有鼠标事件

<%@ page language="java" import="java.util.*" pageEncoding="GBK" contentType="text/html; charset=GBK"%>
<%@ page import="org.jfree.chart.ChartFactory,org.jfree.chart.JFreeChart,org.jfree.chart.ChartPanel,
org.jfree.chart.plot.CategoryPlot,org.jfree.chart.ChartPanel,org.jfree.chart.axis.CategoryAxis,
org.jfree.chart.plot.PlotOrientation,org.jfree.chart.title.TextTitle,org.jfree.data.category.DefaultCategoryDataset,
org.jfree.ui.RefineryUtilities,org.jfree.chart.axis.CategoryLabelPositions,org.jfree.chart.axis.ValueAxis,
org.jfree.chart.labels.StandardCategoryToolTipGenerator,java.awt.Color,java.awt.Font,java.awt.Dimension,java.text.NumberFormat,
org.jfree.chart.labels.StandardCategoryItemLabelGenerator" %>
<%@page import="org.jfree.chart.servlet.ServletUtilities"%>
<%@page import="java.awt.Font"%>
<%@page import="java.io.PrintWriter"%>
<%@page import="org.jfree.chart.urls.StandardPieURLGenerator"%>
<%@page import="org.jfree.chart.entity.StandardEntityCollection"%>
<%@page import="org.jfree.chart.ChartRenderingInfo"%>
<%@page import="org.jfree.chart.ChartUtilities"%>
<%@page import="org.jfree.chart.labels.CategoryToolTipGenerator"%>
<%@page import="java.text.DecimalFormat"%>
<%@page import="org.jfree.chart.renderer.category.BarRenderer"%>
<%@page import="org.jfree.chart.urls.CustomCategoryURLGenerator"%>
<%@page import="org.test.utils.Outils"%>
<%@page import="org.jfree.chart.urls.StandardCategoryURLGenerator"%>

<%
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(520,"深圳","香蕉");
dataset.addValue(380,"深圳","橘子");
dataset.addValue(420,"深圳","橙子");
dataset.addValue(250,"深圳","桃子");
JFreeChart jfreechart = ChartFactory.createBarChart3D("水果销量统计图",//图表标题
"水果", //x轴标题
"销量", //y轴标题
dataset, //绘制图数据集
PlotOrientation.VERTICAL,//控制柱状图的绘制方向
false, //用于设定是否显示图例
false, //用于设定是否采用标准生成器器
false //用于设定是否包生成链接
);
//解决乱码问题
jfreechart.getTitle().setFont(new Font("宋体",Font.BOLD,16));

CategoryPlot plot =jfreechart.getCategoryPlot();//图形的绘制结构对象
//x轴
CategoryAxis domainAxis= plot.getDomainAxis();
domainAxis.setLabelFont(new Font("宋体",Font.PLAIN,12));//轴标题
domainAxis.setTickLabelFont(new Font("宋体",Font.PLAIN,12));//轴数值
domainAxis.setTickLabelPaint(Color.BLUE);//字体颜色
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);//横轴上的字体斜显示

    //y轴
    ValueAxis rangeAxis= plot.getRangeAxis();
    rangeAxis.setLabelFont(new Font("宋体",Font.PLAIN,12));
    rangeAxis.setTickLabelFont(new Font("宋体",Font.PLAIN,12));
    rangeAxis.setTickLabelPaint(Color.BLUE);
    //尝试解决柱状图上数据的显示

      BarRenderer  renderer =(BarRenderer)plot.getRenderer();
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
      renderer.setSeriesOutlinePaint(0, Color.BLACK);//边框为黑色
    renderer.setSeriesPaint(0,new Color(0,255,0));//实报柱子的颜色为绿色
    renderer.setSeriesOutlinePaint(0,Color.red);//实际柱子颜色为红色
    renderer.setBaseItemLabelsVisible(true);
    NumberFormat nf= NumberFormat.getNumberInstance();

//这里本该是热点显示设置的,为什么什么都不显示了,以窗体形式可以显示热区,以jsp时,就不显示了,为什么?
StandardCategoryToolTipGenerator generator= new StandardCategoryToolTipGenerator("{2}",new DecimalFormat("0.00"));

    renderer.setToolTipGenerator(generator);


    plot.setRenderer(renderer);
     PrintWriter pw = new PrintWriter(out);
     StandardEntityCollection sec = new StandardEntityCollection();
      //生成RenderingInfo实例,info参数就是图片的热点信息  
        ChartRenderingInfo info = new ChartRenderingInfo(sec);

    String filename = ServletUtilities.saveChartAsPNG(jfreechart, 800, 500, info, session);
    ChartUtilities.writeImageMap(pw, filename, info, false);

String graphURL =request.getContextPath() + "/abc/DisplayChart?filename=" +filename;

%>


Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!