Issue in customizing default tooltip text of PieChart using gwt-visualization 1.1.2 API

房东的猫 提交于 2019-12-11 18:25:37

问题


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.

Code:

JSNI:

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

DataTable:

 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;
          }


回答1:


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

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

http://jsfiddle.net/d9tezLL3/

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.

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)




回答2:


I found this link https://gist.github.com/alexrainman/bb8d49357250df0859c0 to customize my tooltip and it worked out perfectly. Hope this helps someone to save their time!!



来源:https://stackoverflow.com/questions/26529573/issue-in-customizing-default-tooltip-text-of-piechart-using-gwt-visualization-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!