2

Trying to show value of label on hover of bar in Graph View. There is a method called

setOnHoverListener(new View.OnHoverListener() {
    @Override
    public boolean onHover(View v, MotionEvent event) {
        switch (event.getAction()) {
            case MotionEvent.ACTION_HOVER_ENTER:

                break;
            case MotionEvent.ACTION_HOVER_MOVE:

                break;
            case MotionEvent.ACTION_HOVER_EXIT:

                break;
        }
        return false;
    }
});

But the method works on graph view . I need to implemnet on each bar of Graph represented by distinguish labels and values. I have 1000 of bars in graph whose data is fetched from server.Implementing graph view in android o.s. using GraphView-3.1.3.jar . Also implemented achartengine library but not found any solution to this .

Implementation on click or hover on a single bar

Yuvraj Kakkar
  • 1,123
  • 1
  • 11
  • 24

1 Answers1

0

I found a lot but unable to handle the required functionality i.e I want a info dialog to be shown when either on hover or on click event is fired on each bar of graph.

I followed Googles Geomap & Geocharts to implement graph view in android instead of using GraphView-3.1.3.jar and achartengine( both has limitations).

Google Geomap AND GeoChart

The document provided on above two links will guide about generation of charts, graphs , maps etc. I integrated it in android by using weview. I put a following file as html in assets folder and load it in webview -

    <html>
<head>
  <script type='text/javascript' src='https://www.google.com/jsapi'></script>
  <script type='text/javascript'>
   google.load('visualization', '1', {'packages': ['geomap']});
   google.setOnLoadCallback(drawMap);

    function drawMap() {
      var data = google.visualization.arrayToDataTable([
        ['Country', 'Attendees'],
['United States', 150],
['Belgium', 67],
['Germany', 61],
['South Korea', 49],
['United Kingdom', 42],
['Singapore', 39],
['Spain', 37],
['Nigeria', 34],
['Japan', 27],
['France', 25],
['Italy', 24],
['Netherlands', 23],
['Turkey', 22],
['South Africa', 22],
['Portugal', 19],
      ]);

      var options = {};
      options['dataMode'] = 'regions';
      options['width'] = '630';
      options['height' ] = '350';
      var container = document.getElementById('map_canvas');
      var geomap = new google.visualization.GeoMap(container);
      geomap.draw(data, options);
  };
  </script>

</head>

<body>
  <div  id='map_canvas'></div>
  <br />


</body>

</html>

I hope it will work for you also.

Yuvraj Kakkar
  • 1,123
  • 1
  • 11
  • 24