[英]Tooltips not working in jfree chart in struts 2
I am generating a bar graph in my struts 2 application using JFreeChart
; 我正在使用JFreeChart
在我的struts 2应用程序中生成JFreeChart
; but even if I have enabled the tooltips, they don't work in the bar graph generated. 但是即使我启用了工具提示,它们也无法在生成的条形图中使用。 I am not able to figure out how to make the tooltips work? 我不知道如何使工具提示起作用? This is my code: 这是我的代码:
public class ChartAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private JFreeChart chart;
public JFreeChart getChart() {
return chart;
}
public String createRBar() throws Exception {
// chart creation logic..
System.out.println("IN CHART ACTION");
try
{
BarChart barChart=new BarChart();
{
chart=barChart.generateRegionBar();
return SUCCESS;
}
}catch(Exception e)
{
e.printStackTrace();
}
return "error";
}
}
public class BarChart {
public JFreeChart generateRegionBar(){
try{
DefaultCategoryDataset dataset =new DefaultCategoryDataset();
dataset.setValue(80, "marks1", "student1");
dataset.setValue(20, "marks2", "student2");
dataset.setValue(50, "marks3", "student3");
dataset.setValue(70, "marks4", "student4");
JFreeChart chart=ChartFactory.createBarChart("student graph","student name", "student marks",dataset, PlotOrientation.VERTICAL, true, true, true);
return chart;
}catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
This is my struts.xml: 这是我的struts.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd ">
<struts>
<package name="jfree" extends="jfreechart-default">
<action name="generateRPGraph" class="gr3.jfree.controller.ChartAction"
method="createRBar">
<result name="success" type="chart">
<param name="width">550</param>
<param name="height">300</param>
</result>
</action>
</package>
</struts>
Tooltips are a feature of Swing JComponent
; 工具提示是Swing JComponent
的功能; support is available to charts displayed in a ChartPanel
, a subclass of JPanel
. 对JPanel
的子类ChartPanel
显示的图表提供支持。 In a client-server environment, consider these alternatives: 在客户端服务器环境中,请考虑以下替代方法:
CategoryItemLabelGenerator
, seen here . CategoryItemLabelGenerator
,请参见此处 。
Java Web Start , suggested here . Java Web Start的 ,建议在这里 。
ImageMapUtilities
for creating an HTML image map. 用于创建HTML图像地图的ImageMapUtilities
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.