Android Venn Diagram Tutorial

Using Google Chart API we can draw Charts in app.This api provide all chart such as VennDiagram,Pie chart,Line Chart,Radar chart,Scatter plot,Map chart,Radar chart,QR codes,Google O-Meter chart..




Google Chart API with venn diagram chart type.

venn diagram have circles that intersects with each others.So here add different int value for intersects circles.when add  different value for intersects then using http get request we can get image from url.


First url for getting image using google chart api is ,http://chart.apis.google.com.then you can add your parameters as per user enter in edittext.

after main url you have to learn about Data Formats.there are  different type for different chart type.here we have venn diagram so use type=v.and  different color for each circle you can do using syntax.chco=<color_1>,...,<color_n>.here color in hexadecimal format. like,#00FF00.

google chart api provide various type of styles chart .you can add title,margins and various backgrounds.

So,URL for venn diagram is ...My Venn Diagram.

From url you can get Bitmap of charts.

public static Bitmap loadChart(String urlRqs) {
  Bitmap bm = null;
  InputStream inputStream = null;
  try {
   inputStream = OpenHttpConnection(urlRqs);
   bm = BitmapFactory.decodeStream(inputStream);
   if(null!=inputStream)
   inputStream.close();
  } catch (IOException e) {
           e.printStackTrace();
  }
  return bm;
 }

public static InputStream OpenHttpConnection(String strURL)throws IOException {
   InputStream is = null;
   URL url = new URL(strURL);
   URLConnection urlConnection = url.openConnection();
   try {
     HttpURLConnection httpConn = (HttpURLConnection) urlConnection;
     httpConn.setRequestMethod("GET");
     httpConn.connect();
 
     if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
   is = httpConn.getInputStream();
  }
       }catch (Exception ex) {
                  ex.printStackTrace();
  }
 return is;
    }

then set Bitmap to ImageView.

imageView.setImageBitmap(yourbitmap);


Download Full Source Code From Here.
       DownLoad Source Code

1 comment:

  1. Such a nice post about android development tutorial, thanks for sharing such nice information

    Offshore Software Development Company | android developer for hire

    ReplyDelete

Android Testing App