0

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

Default text on mouse over:

Community
  • 1
  • 1
Jagadeesh
  • 2,730
  • 6
  • 30
  • 45
  • Is there an error message or don't you see any tooltip how does it look like ? – Ümit Oct 27 '14 at 09:23
  • @Ümit - No JS error on console. What ever i am trying to change is not getting reflected on hover. You can see the default text on hover in the attached image. – Jagadeesh Oct 27 '14 at 09:31
  • hmm and you are display normal text not a HTML tooltip ? – Ümit Oct 27 '14 at 09:34
  • @Ümit I have observed one more thing that--- data.getColumnLabel(2) --- is not returning any label text, it is empty. Which means that the tooltip column is not getting added through JSNI method. Anything wrong in the above code? – Jagadeesh Oct 27 '14 at 09:37
  • Code should be fine. Can you try to debug it (step through the method) and also you can try to assign the return value of your `addTooltipColumn` to your `DataTable` variable (in case the method makes a copy) – Ümit Oct 27 '14 at 09:41
  • @Ümit - Changed the code to assign DataTable, you can find the updated code above. Still no use. In debug i can see that the Jsni method is returning some JSObject. – Jagadeesh Oct 27 '14 at 09:54
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/63694/discussion-between-jagadeesh-and-umit). – Jagadeesh Oct 27 '14 at 09:56

1 Answers1

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)

Ümit
  • 17,379
  • 7
  • 55
  • 74
  • Thank you so much for your information. It helped me a lot. Since i have to support these charts on IOS(IPAD), don't know whether or not these gwt-charts are non-flash based one's. Is there anyway that i can achieve the tooltip for PieChart? – Jagadeesh Oct 27 '14 at 12:46
  • Most importantly you deserve my bounty. – Jagadeesh Oct 27 '14 at 12:47
  • `gwt-charts` is only a newer wrapper around the google charts library similar to `gwt-visualization`. The only difference is that is actively maintained. AFAIK the only flash based chart is `MotionChart` and the old `GeoMap`. Regarding tooltip for `PieChart` all you can is to manually create a `div` and handle the onHover event to display the div and disable the built in tooltip of the `PieChart` – Ümit Oct 27 '14 at 12:50
  • Same problem using gwt-charts api. ToolTip is working for other charts except PieChart. – Jagadeesh Oct 27 '14 at 16:25
  • again. `PieChart` doesn't support tooltips. So the gwt library doesn't make a difference. In general I recommend `gwt-charts` because it is actively maintained. – Ümit Oct 27 '14 at 16:27
  • Could you please put some code if you aware of how to get it working using static tooltip actions. – Jagadeesh Oct 27 '14 at 16:40