本文介绍了使用gwt-visualization 1.1.2 API自定义PieChart的默认工具提示文本时出现的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难自定义PieChart的默认工具提示文本,这里是API的详细信息:gwt-visualization 1.1.2,Gwt2.0和Gxt 2.1.1. 这是我所拥有的链接 ,但是没有运气.

I am having difficulty in customizing default tool tip text of PieChart.Here are the details of of API: gwt-visualization 1.1.2, Gwt2.0 and Gxt 2.1.1. Here is the link what i have followed , but there is no luck.

代码:

JSNI:

    private native DataTable addTooltipColumn(DataTable data) /*-{
        data.addColumn({type: 'string', role: 'tooltip'});
        return data;
    }-*/;

数据表:

 private AbstractDataTable createTable() {
          DataTable data = DataTable.create();
          data.addColumn(ColumnType.STRING, "Task");
          data.addColumn(ColumnType.NUMBER, "Hours per Day");

//Assigning the variable

      data = addTooltipColumn(data);

            List<Integer> asList = Arrays.asList(34,12,34,32,67,21,2,45,2,4,28,5,78);
            data.addRows(asList.size());
            int i=0;
            for (Integer integer : asList) {
                data.setValue(i, 0, "Work"+i);
                data.setValue(i, 1, integer);
                data.setValue(i, 2, "....Tool Tip Txt...");
                i++;
            }
            return data;
          }

推荐答案

Piecharts当前似乎不支持工具提示(请参见此处以供参考).

It seems that tooltips are currently not supported in Piecharts (see here for reference).

我也在纯JavaScript中进行了测试,并且Piecharts中未显示工具:

I tested it also in pure javascript and tools are not displayed in Piecharts:

http://jsfiddle.net/d9tezLL3/

如果在上面的示例中将PieChart更改为ColumnChart,它将显示工具提示.
您所能做的就是使用PieChart创建静态工具提示操作.

If you change in the above example from PieChart to ColumnChart it will display the tooltips.
All you can do is create a static tooltip actions with PieChart.

通常,我建议使用非正式的 gwt-charts 而不是官方gwt-visualization库,因为前者已更新并支持现成的功能和图表(DataRoles,工具提示等)

In general I would recommend to use the inofficial gwt-charts instead of the official gwt-visualization library because the former is updated and supports recent features and charts out of the box (DataRoles, tooltips, etc)

这篇关于使用gwt-visualization 1.1.2 API自定义PieChart的默认工具提示文本时出现的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 03:36