I have already written an article for implementing Geo Chart in ASP.NET. In this article I’m going to explain how to use custom colors and tooltip in Google Geo Chart.

In this demo I have implemented Geo chart for countries and percentage of world populations.  For that first we have to create table with following fields.

Implementing custom Color: & Tooltip

In google Geo Chart documentation they have given sample code for default Geo Chart without custom color and tooltip. But they have explained all properties which includes custom color and tooltip. Please follow the link,  

https://developers.google.com/chart/interactive/docs/gallery/geochart

You may be noticed that there’s a code

var options = {};

 

Here we need to add color property with custom color, for example

colorAxis: { colors: ['#4DB8FF'] }

 

For Tooltip we need to add following properties with necessary values

tooltip: { isHtml: tru e,  textStyle: { fontSize: 21  } }

 

Please go through the complete source code, because I have used HTML markup for creating tooltip in chart. Example

<div class="tooltip">

<table>

   <tr>

       <td>

         ...

        <td>

   </tr>

</table>

</div>

 

CSS class for tooltip:

 

     Also you can customize tooltip style by adding CSS class

 

       <style>

           .tooltip {

               width: 270px;

               min-height: 50px;

               font-family: Verdana;

               font-size: 11px;

           }   

           </style>

 

HTML source Code:

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">

     <script type="text/javascript" src="https://www.google.com/jsapi"></script>

    <title>List of countries by population</title>

       <style>

           .tooltip {

               width: 270px;

               min-height: 50px;

               font-family: Verdana;

               font-size: 11px;

           }   

           </style>       

</head>

<body>

    <form id="form1" runat="server">       

    <div>

        <div style="padding-left:150px; font-family:Arial; font-size:15px;">List of countries by population</div><br />

        <asp:Literal ID="lt1" runat="server"></asp:Literal>

      <div>

      <div id="Country_div" style="width: 500px; height: 300px;"></div>

        </div>

    </div>         

    </form>

</body>

</html>

 

C# Code:

 

    protected void BindData()

    {

        DataTable dt1 = new DataTable();

        DataTable dt2 = new DataTable();  

        try

        {

            dt1 = GetCountry();

 

            StringBuilder str = new StringBuilder();

            StringBuilder strData = new StringBuilder();

            StringBuilder str1 = new StringBuilder();

 

            str.Append(" <script type=*text/javascript*>  google.load(*visualization*, *1*, { packages: [*geochart*] });");

          str.Append(" google.setOnLoadCallback(drawRegionsMap); function drawRegionsMap() {");

          str.Append(" var data = google.visualization.arrayToDataTable([");

          str.Append(" ['Country', 'World Population', { role: 'tooltip', p: { html: true } }],");

 

            foreach (DataRow DR in dt1.Rows)

            {

                string Country = DR["Country"].ToString();

                string WorldPopulation = DR["WorldPopulation"].ToString();

                string TotalPopulation = DR["TotalPopulation"].ToString();

                string Source = DR["Source"].ToString();

 

              strData.Append(" ['" + Country + "', " + WorldPopulation + ", '<div class=*tooltip*> ");

                strData.Append("<div><hr />");

                strData.Append("<table>");

 

                strData.Append("<tr><td>Total Population</td><td>" + TotalPopulation + "</td></tr>");

                strData.Append("<tr><td>World of Population</td><td>" + WorldPopulation + "</td></tr>");

                strData.Append("<tr><td>Source</td><td>" + Source + "</td></tr>");                


                strData.Append("</table>");

                strData.Append("</div>");

                strData.Append("</div>'],");

            }

 

            str1.Append(" ]); var options = { legend: 'none', tooltip: { isHtml: true,  textStyle: { fontSize: 21  } },");

            str1.Append(" colorAxis: { colors: [ '#4DB8FF'] } };");

            str1.Append("  var chart = new google.visualization.GeoChart(document.getElementById('Country_div'));");

            str1.Append(" function selectHandler() { var selectedItem = chart.getSelection()[0]; if (selectedItem) {");

            str1.Append("  var topping = data.getValue(selectedItem.row, 0);");

            str1.Append(" alert('Selected Country is ' + topping);  } }");

            str1.Append(" google.visualization.events.addListener(chart, 'select', selectHandler);");

            str1.Append(" chart.draw(data, options);");

            str1.Append(" } </script>");

            lt1.Text = str.ToString().Replace('*', '"') + strData.ToString().TrimEnd(',').Replace('*', '"') + str1.ToString();

        }

        catch (Exception ex)

        {        }

    }

 

    protected DataTable GetCountry()

    {

        DataTable dt = new DataTable();

        string cmdstr = "select Id,Country,TotalPopulation,WorldPopulation,Source from Population;"

        conn.Open();

        SqlDataAdapter adp = new SqlDataAdapter(cmdstr, conn);

        adp.Fill(dt);

        conn.Close();

        return dt;

    }

 

cytotec abortion

http://www.extrageek.com/template/default.aspx?an-abortion-pill buy abortion pills online
medical abortion pill online cytotec abortion abortion pill


View demo Download
http://www.dotnetfox.com/Document/1117/geo-map.jpg

If you enjoyed this article, get email updates (it's free).


Related Articles
  • How to add edit delete update records in Grid view ASP.NET Introduction: In this article i'm going to explain how to add delete edit records in Grid view. Description: If we want to add delete edit records in grid view we should use following grid view events, 1. onrowcommand 2. onrowdeleting 3. onrowupdating 4. onrowcancelingedit 5. onrowediting Also we should use following template field in Grid View. 1.ItemTemplate : ItemTemplate is used to display rec...
  • How to insert edit delete update records in Grid view using WCF In this article i'm going to explain how to insert records using WCF. Windows Communication Foundation (WCF) is an extension of the .NET framework to build and run connected systems. Windows Communication Foundation provides a unified framework for building secure and reliable transacted Web services. Windows Communication Foundation combines and extends the capabilities of Distributed System...
  • File Upload in Gridview ASP.NETIn this article I’m going to explain how to use file upload control in grid view for uploading images or files to the server. The FileUpload control allows you to provide users with a way to send a file from their computer to the server. The control is useful for allowing users to upload images, text files or other files. Here I’ll show you how to use file upload control in gridview to upload the ...
  • Check or Uncheck all check box in ASP.NET Gridview using JavaScriptIn this article I’m going to explain how to add CheckBox control in Gridview to Check or Uncheck all checkbox using JavaScript. To implement this concept we have to add one Checkbox control in Gridview header template and one more checkbox control in Gridview item template. here we need to use javascript to avoid postback and change gridview row color if checkbox was checked or unchecked.
  • Insert delete update records in XML file -ASP.NET using c# In this article I’m going to explain how to insert delete update records in XML file using ASP.NET and C#. XML was created to structure, store and transport data. What is XML? XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to carry data, not to display data XML tags are not predefined. You must define your own tags
  • How to use DropDownList control to GridView in ASP.NET using c# In this article I’m going to explain how to use DropDownList control in ASP.NET using C#. ASP.NET allows you to use any server controls in GridView. In this article I’ll show you how to use DropDownList control in GridView. DropDownList can be used to select only one item at a time item. It’s very easy to use DropDownList control in GridView. We need to use OnRowDataBound event to bind DropDownLis...
  • Export GridView data to excel using ASP.NET and c# In this article I’m going to explain how to export GridView data to excel using ASP.NET and C#. Sometimes we need to export gridview data to excel. Here I’ll show you how to export GridView data to Excel by using RkLib ExportData. RKLib ExportData is a class library used to export data to excel. So here we have to create table and fetch the records to DataTable and we can export to excel.
  • How to use Ajax CalenderExtender in ASP.NET GridViewIn this article I’m going to explain how to use Ajax CalenderExtender in ASP.NET GridView. Today one of my blog subscriber asked me a question that’s how to use Ajax CalenderExtender in ASP.NET GridView. I hope you already know how to use Ajax CalenderExtender in normal page. There is no different to use Ajax CalenderExtender in normal page and GridView.
  • Create dynamic GridView or programmatically create ASP.NET GridView with dynamic BoundField In this article I’m going to explain how to create dynamic GridView or programmatically create GridView with dynamic BoundField in ASP.NET using C#. In some scenario it is necessary to create dynamic GridView with BoundField instead of static one. Here I’ll explain how to create dynamic GridView which includes dynamic BoundFiled, apply custom styles to header row and data row. After creating dyna...
  • How to export GridView data to PDF document in ASP.NET with C# using iTextSharpIn this article I’m going to explain how to export GridView to PDF document. Other articles related to iTextSharp. iTextSharp is a C# port of iText, and open source Java library for PDF generation and manipulation. It can be used to create PDF documents from scratch, to convert XML to PDF (using the extra XFA Worker DLL), to fill out interactive PDF forms, to stamp new content on existing PDF doc...

Comments
comments powered by Disqus

Thanks for downloading..!!

×
Subscribe via Email
    
message to display in fancybox