PrimeFaces Piechart:工具提示未显示在我的本地环境中 [英] PrimeFaces Piechart: Tooltips are not displaying in my local environment

查看:18
本文介绍了PrimeFaces Piechart:工具提示未显示在我的本地环境中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我重新创建了primefaces展示中显示的示例页面:

I have recreated the example page shown in the primefaces showcase at:

http://www.primefaces.org/showcase/ui/chart/pie.xhtml

饼图成功显示,我能够为可用的 setter 和 getter 调整饼图模型,但是将鼠标悬停在饼图的一块上根本不显示任何工具提示.

The pie chart successfully display and I am able to tweak the pie chart model for available setters and getters, but hovering over a piece of the pie does not display any tooltip at all.

这不是浏览器问题,因为在演示站点上显示的工具提示在同一浏览器中.

This is not a browser issue, as in the same browser the tooltips display on the demo site.

jqplot-highlighter-tooltip div 显示在 html 源中,但它没有在悬停时更新.javascript 控制台中没有显示错误.

The jqplot-highlighter-tooltip div is showing in the html source, but it is not getting updated on hover. There are no errors shown in the javascript console.

我正在使用 5.2 maven 依赖,并且也尝试过 4.0 - 但没有任何变化.

I am using the 5.2 maven dependancy, and have also tried 4.0 - but with no change.

希望有任何想法.

谢谢.

托管bean的代码如下:

The code for the managed bean is as follows:

package org.primefaces.examples;

import org.primefaces.model.chart.PieChartModel;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import java.io.Serializable;

@ManagedBean
public class ChartView implements Serializable {

    private static final long serialVersionUID = 1075867144472594293L;

    private PieChartModel pieModel1;
    private PieChartModel pieModel2;

    @PostConstruct
    public void init() {
        createPieModels();
    }

    public PieChartModel getPieModel1() {
        return pieModel1;
    }

    public PieChartModel getPieModel2() {
        return pieModel2;
    }

    private void createPieModels() {
        createPieModel1();
        createPieModel2();
    }

    private void createPieModel1() {
        pieModel1 = new PieChartModel();

        pieModel1.set("Brand 1", 540);
        pieModel1.set("Brand 2", 325);
        pieModel1.set("Brand 3", 702);
        pieModel1.set("Brand 4", 421);

        pieModel1.setTitle("Simple Pie");
        pieModel1.setLegendPosition("w");
    }

    private void createPieModel2() {
        pieModel2 = new PieChartModel();

        pieModel2.set("Brand 1", 540);
        pieModel2.set("Brand 2", 325);
        pieModel2.set("Brand 3", 702);
        pieModel2.set("Brand 4", 421);

        pieModel2.setTitle("Custom Pie");
        pieModel2.setLegendPosition("e");
        pieModel2.setFill(false);
        pieModel2.setShowDataLabels(true);
        pieModel2.setDiameter(150);
    }

}

查看页面的代码是:

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui">

<h:head/>

<h:body>
    <p:chart type="pie" model="#{chartView.pieModel1}" style="width:400px;height:300px" />

    <p:chart type="pie" model="#{chartView.pieModel2}" style="width:400px;height:300px" />
</h:body>

</html>

推荐答案

我遇到了同样的问题.使用扩展器修复它:

I have faced the same problem. Using an extender fixed it :

  • 小面:

<script type="text/javascript">
    function pieExtender() {
        this.cfg.highlighter = {
            show: true,
            tooltipLocation: 'n',
            useAxesFormatters: false,
            formatString: '%s = %d'
        };
    }
</script>

  • 托管 Bean:

  • Managed Bean :

    pieModel.setExtender("pieExtender");
    

  • 更多调整见:http://www.jqplot.com/docs/files/plugins/jqplot-highlighter-js.html

    这篇关于PrimeFaces Piechart:工具提示未显示在我的本地环境中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆