Showing posts with label WebGuru. Show all posts
Showing posts with label WebGuru. Show all posts

Monday, March 12, 2012

.htaccess in php

RewriteEngine on
Options +FollowSymlinks

RewriteEngine on

RewriteRule /id/(.*)/pageid/(.*)/ mlp.php?id=$1&pageid=$2
RewriteRule ^([0-9]+)/(.*)$ mlp.php/$1/$2



RewriteEngine On
RewriteRule /page/(.*)$ /page/page.php?id=$1

This basically tells your website that any request for your page should be re-written. Doing this will mean that your addresses will become further simplified to the following:
www.mysite.com/page/3
 

My SQL viva questions

What’s MySQL ?
MySQL (pronounced “my ess cue el”) is an open source relational database management system (RDBMS) that uses Structured Query Language (SQL), the most popular language for adding, accessing, and processing data in a database. Because it is open source, anyone can download MySQL and tailor it to their needs in accordance with the general public license. MySQL is noted mainly for its speed, reliability, and flexibility. …

What is DDL, DML and DCL ?
If you look at the large variety of SQL commands, they can be divided into three large subgroups. Data Definition Language deals with database schemas and descriptions of how the data should reside in the database, therefore language statements like CREATE TABLE or ALTER TABLE belong to DDL. DML deals with data manipulation, and therefore includes most common SQL statements such SELECT, INSERT, etc. Data Control Language includes commands such as GRANT, and mostly concerns with rights, permissions and other controls of the database system.

How do you get the number of rows affected by query?
SELECT COUNT (user_id) FROM users would only return the number of user_id?s.

If the value in the column is repeatable, how do you find out the unique values?
Use DISTINCT in the query, such as SELECT DISTINCT user_firstname FROM users; You can also ask for a number of distinct values by saying SELECT COUNT (DISTINCT user_firstname) FROM users;

How do you return the a hundred books starting from 25th?
SELECT book_title FROM books LIMIT 25, 100. The first number in LIMIT is the offset, the second is the number.

You wrote a search engine that should retrieve 10 results at a time, but at the same time you?d like to know how many rows there?re total. How do you display that to the user?
SELECT SQL_CALC_FOUND_ROWS page_title FROM web_pages LIMIT 1,10; SELECT FOUND_ROWS(); The second query (not that COUNT() is never used) will tell you how many results there?re total, so you can display a phrase “Found 13,450,600 results, displaying 1-10″. Note that FOUND_ROWS does not pay attention to the LIMITs you specified and always returns the total number of rows affected by query.

How would you write a query to select all teams that won either 2, 4, 6 or 8 games?
SELECT team_name FROM teams WHERE team_won IN (2, 4, 6, 8 )

How would you select all the users, whose phone number is null?
SELECT user_name FROM users WHERE ISNULL(user_phonenumber);

What does this query mean: SELECT user_name, user_isp FROM users LEFT JOIN isps USING (user_id) ?
It?s equivalent to saying SELECT user_name, user_isp FROM users LEFT JOIN isps WHERE users.user_id=isps.user_id

What does ?i-am-a-dummy flag to do when starting MySQL?
Makes the MySQL engine refuse UPDATE and DELETE commands where the WHERE clause is not present.

On executing the DELETE statement I keep getting the error about foreign key constraint failing. What do I do?
What it means is that so of the data that you?re trying to delete is still alive in another table. Like if you have a table for universities and a table for students, which contains the ID of the university they go to, running a delete on a university table will fail if the students table still contains people enrolled at that university. Proper way to do it would be to delete the offending data first, and then delete the university in question. Quick way would involve running SET foreign_key_checks=0 before the DELETE command, and setting the parameter back to 1 after the DELETE is done. If your foreign key was formulated with ON DELETE CASCADE, the data in dependent tables will be removed automatically.

When would you use ORDER BY in DELETE statement?
When you?re not deleting by row ID. Such as in DELETE FROM techinterviews_com_questions ORDER BY timestamp LIMIT 1. This will delete the most recently posted question in the table techinterviews_com_questions.

How can you see all indexes defined for a table?
SHOW INDEX FROM techinterviews_questions;

How would you change a column from VARCHAR(10) to VARCHAR(50)?
ALTER TABLE techinterviews_questions CHANGE techinterviews_content techinterviews_CONTENT VARCHAR(50).

How would you delete a column?
ALTER TABLE techinterviews_answers DROP answer_user_id.

How would you change a table to InnoDB?
ALTER TABLE techinterviews_questions ENGINE innodb;

When you create a table, and then run SHOW CREATE TABLE on it, you occasionally get different results than what you typed in. What does MySQL modify in your newly created tables?
1. VARCHARs with length less than 4 become CHARs
2. CHARs with length more than 3 become VARCHARs.
3. NOT NULL gets added to the columns declared as PRIMARY KEYs
4. Default values such as NULL are specified for each column

How do I find out all databases starting with ?tech? to which I have access to?
SHOW DATABASES LIKE ?tech%?;

How do you concatenate strings in MySQL?
CONCAT (string1, string2, string3)

How do you get a portion of a string?
SELECT SUBSTR(title, 1, 10) from techinterviews_questions;

What?s the difference between CHAR_LENGTH and LENGTH?
The first is, naturally, the character count. The second is byte count. For the Latin characters the numbers are the same, but they?re not the same for Unicode and other encodings.

What do % and _ mean inside LIKE statement?
% corresponds to 0 or more characters, _ is exactly one character.

What does + mean in REGEXP?
At least one character. Appendix G. Regular Expressions from MySQL manual is worth perusing before the interview.

How do you get the month from a timestamp?
SELECT MONTH(techinterviews_timestamp) from techinterviews_questions;

How do you offload the time/date handling to MySQL?
SELECT DATE_FORMAT(techinterviews_timestamp, ?%Y-%m-%d?) from techinterviews_questions; A similar TIME_FORMAT function deals with time.

How do you add three minutes to a date?
ADDDATE(techinterviews_publication_date, INTERVAL 3 MINUTE)

What?s the difference between Unix timestamps and MySQL timestamps?
Internally Unix timestamps are stored as 32-bit integers, while MySQL timestamps are stored in a similar manner, but represented in readable YYYY-MM-DD HH:MM:SS format.

How do you convert between Unix timestamps and MySQL timestamps?
UNIX_TIMESTAMP converts from MySQL timestamp to Unix timestamp, FROM_UNIXTIME converts from Unix timestamp to MySQL timestamp.

What are ENUMs used for in MySQL?
You can limit the possible values that go into the table. CREATE TABLE months (month ENUM ?January?, ?February?, ?March?,?); INSERT months VALUES (?April?);

How are ENUMs and SETs represented internally?
As unique integers representing the powers of two, due to storage optimizations.

How do you start and stop MySQL on Windows?
net start MySQL, net stop MySQL

Explain the difference between mysql and mysql interfaces in PHP?
mysqli is the object-oriented version of mysql library functions.
What’s the default port for MySQL Server?
3306
What does tee command do in MySQL?
tee followed by a filename turns on MySQL logging to a specified file. It can be stopped by command note.
Can you save your connection settings to a conf file?
Yes, and name it ~/.my.conf. You might want to change the permissions on the file to 600, so that it’s not readable by others.
How do you change a password for an existing user via mysqladmin?
mysqladmin -u root -p password “newpassword”
Use mysqldump to create a copy of the database?
mysqldump -h mysqlhost -u username -p mydatabasename > dbdump.sql
Have you ever used MySQL Administrator and MySQL Query Browser?
Describe the tasks you accomplished with these tools.
What are some good ideas regarding user security in MySQL?
There is no user without a password. There is no user without a user name. There is no user whose Host column contains % (which here indicates that the user can log in from anywhere in the network or the Internet). There are as few users as possible (in the ideal case only root) who have unrestricted access.
What are HEAP tables in MySQL?
HEAP tables are in-memory. They are usually used for high-speed temporary storage. No TEXT or BLOB fields are allowed within HEAP tables. You can only use the comparison operators = and <=>. HEAP tables do not support AUTO_INCREMENT. Indexes must be NOT NULL.
How do you control the max size of a HEAP table?
MySQL config variable max_heap_table_size.
What are CSV tables?
Those are the special tables, data for which is saved into comma-separated values files. They cannot be indexed.
Explain federated tables. ?
Introduced in MySQL 5.0, federated tables allow access to the tables located on other databases on other servers.
What is SERIAL data type in MySQL?
BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT
What happens when the column is set to AUTO INCREMENT and you reach the maximum value for that table?
It stops incrementing. It does not overflow to 0 to prevent data losses, but further inserts are going to produce an error, since the key has been used already.
Explain the difference between BOOL, TINYINT and BIT. ?
Prior to MySQL 5.0.3: those are all synonyms. After MySQL 5.0.3: BIT data type can store 8 bytes of data and should be used for binary data.
Explain the difference between FLOAT, DOUBLE and REAL. ?
FLOATs store floating point numbers with 8 place accuracy and take up 4 bytes. DOUBLEs store floating point numbers with 16 place accuracy and take up 8 bytes. REAL is a synonym of FLOAT for now.
MySQL is a relational database management system.
A relational database stores data in separate tables rather than putting all the data in one big storeroom. This adds speed and flexibility. The tables are linked by defined relations making it possible to combine data from several tables on request. The SQL part of MySQL stands for “Structured Query Language” – the most common standardized language used to access databases.
MySQL is Open Source Software.
Open source means that it is possible for anyone to use and modify. Anybody can download MySQL from the Internet and use it without paying anything. Anybody so inclined can study the source code and change it to fit their needs. MySQL uses the GPL (GNU General Public License) http://www.gnu.org, to define what you may and may not do with the software in different situations. If you feel uncomfortable with the GPL or need to embed MySQL into a commercial application you can buy a commercially licensed version from us.
Why use MySQL?
MySQL is very fast, reliable, and easy to use. If that is what you are looking for, you should give it a try. MySQL also has a very practical set of features developed in very close cooperation with our users. You can find a performance comparison of MySQL to some other database managers on our benchmark page. See section 12.7 Using Your Own Benchmarks. MySQL was originally developed to handle very large databases much faster than existing solutions and has been successfully used in highly demanding production environments for several years. Though under constant development, MySQL today offers a rich and very useful set of functions. The connectivity, speed, and security make MySQL highly suited for accessing databases on the Internet.
The technical features of MySQL
For advanced technical information, see section 7 MySQL Language Reference. MySQL is a client/server system that consists of a multi-threaded SQL server that supports different backends, several different client programs and libraries, administrative tools, and a programming interface. We also provide MySQL as a multi-threaded library which you can link into your application to get a smaller, faster, easier to manage product. MySQL has a lot of contributed software available.

Saturday, March 10, 2012

JavaScript form Inline Valiation

function Validateform()
{
    name=Trim(document.getElementById("Name").value) ;
    email=Trim(document.getElementById("Email").value) ;
    contact=Trim(document.getElementById("ContactNo").value) ;
    company=Trim(document.getElementById("Company").value) ;
    querytype=Trim(document.getElementById("QueryType").value) ;
    var str="";
    flag=true;
    //str=str+ "please enter your e-mail";
            if(name=='Please enter your Name' || name=='Please enter Alphabets only' || name=='')
            {
                str="Please enter your Name\n";
                document.getElementById("Name").focus();
                flag=false;
                //return false;
            }
            if(email=='Please enter your E-mail' || email=='Enter valid E-mail eg name@yahoo.com' || email=='')
            {
                str+="Please enter your E-mail Address\n";
                document.getElementById("Email").focus();
                flag=false;
                //return false;
            }
            if(contact=='Please enter your Contact Number' || contact=='Enter valid Contact Number' || contact=='')
            {
                str+="Please enter your Contact Number\n";
                document.getElementById("ContactNo").focus();
                flag=false;
                //return false;
            }
          
            if(company=='Please enter your Company Name' || company=='Enter valid Company Name' || company=='')
            {
                str+="Please enter your Company Name\n";
                document.getElementById("Company").focus();
                flag=false;
                //return false;
            }
              
              
            if(querytype=='Query Type' || querytype=='' || querytype=='Query Type')
            {
                str+="Please select QueryType\n";
                document.getElementById("QueryType").focus();
                flag=false;
                //return false;
            }
              
          
          
            if(flag==false)
            {
                alert(str);
                return false;
            }
            else
                return true;
}
      
        function name_check()
        {
            name=Trim(document.getElementById("Name").value) ;
          
          
            if(name=='Please enter your Name' || name=='Please enter Alphabets only')
            {
                document.getElementById("Name").value ='';
            return false;
          
            }
            return true;
        }
      
        function email_check()
        {
          
            email=Trim(document.getElementById("Email").value) ;
          
            if(email=='Please enter your E-mail' || email=='Enter valid E-mail eg name@yahoo.com')
            {
            document.getElementById("Email").value ='';
            return false;
          
            }
            return true;
        }
      
      
        function contact_check()
        {
          
            contact=Trim(document.getElementById("ContactNo").value) ;
            if(contact=='Please enter your Contact Number' || contact=='Enter valid Contact Number')
            {
            document.getElementById("ContactNo").value ='';
            return false;
          
        }
            return true;
        }
          
          
            function Company_check()
        {
          
            contact=Trim(document.getElementById("Company").value) ;
            if(contact=='Please enter your Company Name' || contact=='Please Enter valid Company Name')
            {
            document.getElementById("Company").value ='';
            return false;
          
        }
            return true;
        }
      
      
      
      
          
          
          
        //for errors
      
        function name_error()
        {
        obj=document.getElementById("formId");
            name_obj=Trim(obj.Name.value);
            //alert(name_obj);
            if(name_obj=='Name' || name_obj=='')
            {
                document.getElementById("Name").value="Please enter your Name" ;
                return false;
            }
            else
            {
              
                var regexLetter = /^[a-zA-Z-/\s]+$/;
                if(!regexLetter.test(name_obj))
                {
                document.getElementById("Name").value="Please enter Alphabets only";
                return false;
                }
            }
            return true;
            }
          
          
          
    function email_error()
        {
        obj=document.getElementById("formId");
            email_obj=Trim(obj.Email.value);
            //alert(name_obj);
            if(email_obj=='E-mail' || email_obj=='')
            {
                document.getElementById("Email").value="Please enter your E-mail" ;
                return false;
            }
            else
            {
          
                var regexLetter =  /^[a-zA-Z]+[a-zA-Z0-9._-]*\@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$/;
                if(!regexLetter.test(email_obj))
                {
                document.getElementById("Email").value="Enter valid E-mail eg name@yahoo.com";
                return false;
                }
            }
            return true;
            }
          
          
            function contact_error()
        {
        obj=document.getElementById("formId");
            contact_obj=Trim(obj.ContactNo.value);
            //alert(name_obj);
            if(contact_obj=='Contact' || contact_obj=='')
            {
                document.getElementById("ContactNo").value="Please enter your Contact Number" ;
                return false;
            }
            else
            {
          
                var regexLetter =/^\d{10}\d*$/;

    
                if(!regexLetter.test(contact_obj))
                {
                document.getElementById("ContactNo").value="Enter valid Contact Number";
                return false;
                }
            }
            return true;
            }
          
          
            function Company_error()
        {
        obj=document.getElementById("formId");
            company_obj=Trim(obj.Company.value);
            //alert(name_obj);
            if(company_obj=='Company' || company_obj=='')
            {
                document.getElementById("Company").value="Please enter your Company Name" ;
                return false;
            }
            else
            {
              
                var regexLetter = /^[0-9a-zA-Z-/\s]+$/;
                if(!regexLetter.test(company_obj))
                {
                document.getElementById("Company").value="Please Enter valid Company Name";
                return false;
                }
            }
            return true;
            }
          
          
      
</script>

<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" id="formId" enctype="multipart/form-data" onsubmit="return Validateform();">
                                     <div class="login_lft">
                                            <div class="login_txt">Name<span class="red">*</span></div>
                                            <div class="login_field">
                                            <label>
                                            <input name="Name" type="text"  class="field" id="Name" maxlength="30" value='Please enter your Name' onblur="return name_error();" onclick="return name_check();" onfocus="return name_check();" tabindex="1" maxlength="50"/>
                                            </label>
                                            </div>
                                           
                                            <div class="login_txt">E-mail Id<span class="red">*</span></div>
                                            <div class="login_field">
                                            <label>
                                            <input name="Email" type="text" class="field" id="Email"  value="Please enter your E-mail" onblur="return email_error();" onclick="return email_check();" onfocus="return email_check();" tabindex="3" maxlength="100"/>
                                            </label>
                                          </div>
                                           
                                        
                                           
                                            <div class="login_field">
                                            <label></label>
                                    </div>
                                      <div class="login_txt">Query Type<span class="red">*</span></div>
                                      <div class="login_field">
                                            <label>
                                            <select name="QueryType" class="field" id="QueryType" tabindex="5" >
                                             <option value="Query Type" selected="selected">Query Type</option>
                                            <option value="Application Development & Design">Application Development & Design</option>
                                            <option value="AMC">AMC</option>
                                            <option value="Application Migration">Application Migration</option>
                                            <option value="Data Centre">Data Centre</option>
                                            <option value="FLMS Demo">FLMS Demo</option>
                                            <option value="Mobile Application">Mobile Application</option>
                                            <option value="Network">Network</option>
                                          
                                            <option value="Remote infrastrucher Management">Remote infrastrucher Management</option>
                                            <option value="Testing">Testing</option>
                                            <option value="TIMS Demo">TIMS Demo</option>
                                            <option value="Other Query">Other Query</option>
                                            </select>
                                            </label>
                                      </div>
                                          
                                           
                                  </div>
                                   
                                    <div class="login_rgt">
                                            <!--<div class="login_txt">Subject<span class="red">*</span></div>
                                            <div class="login_field">
                                            <label>
                                            <input name="Subject" type="text" class="field" id="Subject" value="please enter Subject" onblur="return Subject_error();" onclick="return Subject_check();" onfocus="return Subject_check();" maxlength="50"/>
                                            </label>
                                            </div>-->
                                           
                                               <div class="login_txt">Company Name<span class="red">*</span></div>
                                            <div class="login_field">
                                            <label>
                                            <input name="Company" type="text" class="field" id="Company" value="Please enter your Company Name" onblur="return Company_error();" onclick="return Company_check();" onfocus="return Company_check();" tabindex="2" maxlength="200"/>
                                            </label>
                                            </div>
                                           
                                            <div class="login_txt">Contact Number<span class="red">*</span></div>
                                            <div class="login_field">
                                            <label>
                                            <input name="ContactNo" type="text" class="field" id="ContactNo" maxlength="11" value="Please enter your Contact Number" onblur="return contact_error();" onclick="return contact_check();" onfocus="return contact_check();" tabindex="4" />
                                            </label>
                                          </div>
                                          
                                           <!-- <div class="login_txt">Website URL</div>
                                      <div class="login_field">
                                            <label>
                                            <input name="WebsiteURL" type="text" class="field" id="WebsiteURL" />
                                            </label>
                                      </div>-->
                                           
                                     <div class="login_txt">Attach File</div>
                                            <div class="login_field">
                                            <label>
                                            <input type="file" name="ContactFile" id="ContactFile" tabindex="6" />
                                            </label>
                                            </div>
                                      <div class="login_field"></div>
                                          
                                           
                                  </div>
                                <div class="clear"></div>
                                <div class="div_adjust">
                             
                                </div>
                               
                                <div class="div_adjust">
                                <div class="login_txt">Message<br /></div>
                                  <label>
                                  <textarea name="Description" class="field3" id="Description" cols="45" rows="5" tabindex="7" maxlength="100"></textarea>
                                  </label>
                               
                                <div class="clear"></div>
                                </div><br />
                               

                                <div>
                               
                                <table width="60%" border="0">
  <tr>
    <td><input name="button" type="submit" id="button" value="Submit"  class="input_button"  tabindex="8" /></td>
    <td>Fields marked with <span class="red2"> * </span> are mandatory.</td>
  </tr>
</table>

                                </div>
                              
                                </form>
                                </div>
         
          </div>
            <?php } ?>

Friday, March 9, 2012

Online scan qr code

Best 5 Free Online QR Code Readers

Online QR Code ReaderThe black-and-white image in the right of this post is a classical QR code, do you know what it means?
Today, it’s common that you can see different QR codes in magazines, websites, business cards and many other places, so how to decode them and tell their meanings?
You can check out the following 5 free online QR code readers, whether with a computer browser or a mobile browser:

1. ZXing Decoder Online

Online QR Code Reader ZXing
On the ZXing Decoder Online website, you can enter a URL of any online QR code or upload a QR code image from your computer, and click the “Submit Query” button, then you will see the decode result in a new page.

2. MiniQR

Online QR Code Reader Miniqr
On the MiniQR website, you can enter a URL of any online QR code, or snap a QR code with your webcam, after upload, you will see the decode content in a new page, on which you can also view the QR code image, share the result to Twitter and Facebook, or download the decode as a PDF or DOC file.

3. Online Barcode Reader

Online QR Code Reader onlinebarcodereader.com
With Online Barcode Reader, you can upload a QR code file in PNG, JPG, GIF, TIFF or BMP format up to 1 MB from your computer, and click the “Send file” button, then you will get the decode result in the same page.

4. Patrick Wied QR Generator

Online QR Code Reader Patrick Wied
On the Patrick Wied QR Generator website, you can upload a QR code file and get the decode result in the same page.
Besides to decode, this website is also available for you to generate QR codes with text.

5. QR Code Generator and Recovery

Online QR Code Reader Good Survery
With QR Code Generator and Recovery, you can upload a QR code image from your computer, click the “Recover” button, then you will see the decode under the button.
Besides, this website is also available for you to generate QR codes with text, URLs, email addresses and some other information types.
Conclusion:
Among the above 5 free online QR code readers, only MiniQR is available for you to decode QR codes via webcams, both ZXing Decoder Online and MiniQR are available for you to decode QR codes with URLs, ZXing Decoder Online and the last three are available for you to decode QR codes from your computer.
By the way, have you found out the meaning of the QR code in the beginning of this post? Share the decode with us by leaving a comment. :-)

Monday, March 5, 2012

Using Media Query to Declare CSS for iPhone

To improve the experience of users visiting your website from an iPhone, it is necessary to evaluate how your content will display on these devices. This will allow you to identify areas in which your content can be optimized more effectively.
For example, increasing the font size and breaking content and navigation into more appropriately formatted blocks will increase usability. In fact, its possible to deliver an iPhone friendly version of your website without the need to maintain separate copies of your content. This can be accomplished by using an external style sheet to stylize your current website for iPhone visitors.
Media Query
We’ve covered the topic of detection in some detail in previous articles using PHP, JavaScript and even .htaccess but today we will cover a similar effect using a CSS media query, as recommended by Apple.
Step 1: Add the following declaration to the head of your index.html file
<!--[if !IE]>-->
<link type="text/css" rel="stylesheet" media="only screen and (max-device-width: 480px)"
 href="iPhone.css">
<!--<![endif]-->
This will instruct the browser to use this style sheet for devices with a maximum width of 480 pixels. Browsers that do not support the only keywored will ignore the rule. The IE conditional statement is added to safeguard against IE6/7 rendering inconsistencies believe it or not.
Step 2: Create the style sheet
Here we create iPhone.css and define a simple class, foo, with the following attributes:
.foo{
color:#ff0000;
font-size:18px;
font-family: Arial;
}
Step 3: Reference the class from your content
<div class="foo">
Example of stylizing content for iPhone and iPod touch. This text will render in red
 as 18 pt Arial on the iPhone, and without styles applied for other visitors.
</div>
If you are looking to begin serving optimized content to your iPhone and iPod touch visitors, this is an effective way to control presentation of your content with a simple modification to the original site source code-and a little elbow grease.

Sunday, March 4, 2012

Generate Pie, Bar, Line Charts using Google Chart API

Reporting tools have became so pervasive today that a lot of applications around today’s IT world has these types of tools that reports a lot of complex data in a simple and understandable way. Pie charts, Bar graph, Line charts have became a standard way of representing data in a good and understandable way.
There are lots of Reporting tools available that can be leverage to create such kind of charts. Google Chart API is one of such online tool that can be used to generate complex charts for visual data representation.

What is Google Chart API?

The Google Chart API is an extremely simple tool that lets you easily create a chart from some data and embed it in a webpage. You embed the data and formatting parameters in an HTTP request, and Google returns a PNG image of the chart. Many types of chart are supported, and by making the request into an image tag you can simply include the chart in a webpage.
Google had created these API’s for their internal use to generate charts in applications like finance. But soon they realised these API’s will be of great use and hence they launched Google Chart API.

Supported Charts

Currently following are the charts that are being supported by Google Charts API.
  1. Line Chart
  2. Pie Chart
  3. Bar Chart
  4. Radar Chart
  5. Venn Diagrams
  6. Scatter Plots
  7. Sparklines
  8. Maps
  9. Google-o-meter
  10. QR Codes

How does it works?

Google Chart API works by sending a HTTP request using URL. All what we have to do is to create a URL that specifies all arguments and other information and send it using HTTP. Google Chart will return us the image of the Chart that we requested.

Live Examples

Following are few examples in each of the Chart types that you can generate using Google Chart APIs.

Pie Chart

Hello World Pie Chart.
1http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World
google-pie-chart-hello-world
Two dimensional pie chart.
1http://chart.apis.google.com/chart?cht=p&chd=s:Uf9a&chs=200x100&chl=January|February|March|April
Concentric pie charts.
1http://chart.apis.google.com/chart?cht=pc&chd=s:Helo,Wrld&chs=200x100

Bar Charts

Horizontal bar chart, with stacked bars.
1http://chart.apis.google.com/chart?cht=bhs&chs=200x125&chd=s:ello&chco=4d89f9
Vertical bar chart, with stacked bars.
1http://chart.apis.google.com/chart?cht=bvs&chs=200x125&chd=t:10,50,60,80,40|50,60,100,40,20&chco=4d89f9,c6d9fd&chbh=20&chds=0,160
Horizontal bar chart, with grouped bars.
1http://chart.apis.google.com/chart?cht=bhg&chs=200x125&chd=s:el,or&chco=4d89f9,c6d9fd

Line Charts

Chart of type LC.
1http://chart.apis.google.com/chart?cht=lc&chs=200x125&chd=t:40,60,60,45,47,75,70,72
Line charts of type ls are also known as sparklines.
1http://chart.apis.google.com/chart?chs=200x125&cht=ls&chco=0077CC&chd=t:27,25,60,31,25,39,25,31,26,28,80,28,27,31,27,29,26,35,70,25
For charts of type lxy, a pair of data sets is required for each line.
1http://chart.apis.google.com/chart?cht=lxy&chs=200x125&chd=t:10,20,40,80,90,95,99|20,30,40,50,60,70,80|-1|5,25,45,65,85&chco=3072F3,ff0000,00aaaa&chls=2,4,1&chm=s,FF0000,0,-1,5|s,0000ff,1,-1,5|s,00aa00,2,-1,5

Venn diagrams

1http://chart.apis.google.com/chart?cht=v&chs=200x100&chd=t:100,80,60,30,25,20,10

Scatter plots

1http://chart.apis.google.com/chart?cht=s&chd=t:12,87,75,41,23,96,68,71,34,9|98,60,27,34,56,79,58,74,18,76|84,23,69,81,47,94,60,93,64,54&chxt=x,y&chxl=0:|0|20|30|40|50|60|70|80|90|10|1:|0|25|50|75|100&chs=200x125

Radar charts

1http://chart.apis.google.com/chart?cht=r&chs=200x200&chd=t:10,20,30,40,50,60,70,80,90
1http://chart.apis.google.com/chart?cht=r&chs=200x200&chd=t:77,66,15,0,31,48,100,77|20,36,100,2,0,100&chco=FF0000,FF9900&chls=2.0,4.0,0.0|2.0,4.0,0.0&chxt=x&chxl=0:|0|45|90|135|180|225|270|315&chxr=0,0.0,360.0
1http://chart.apis.google.com/chart?cht=rs&chs=200x200&chd=s:voJATd9v,MW9BA9&chco=FF0000,FF9900&chls=2.0,4.0,0.0|2.0,4.0,0.0&chxt=x&chxl=0:|0|45|90|135|180|225|270|315&chxr=0,0.0,360.0&chg=25.0,25.0,4.0,4.0&chm=B,FF000080,0,1.0,5.0|B,FF990080,1,1.0,5.0|h,0000FF,0,1.0,4.0|h,3366CC80,0,0.5,5.0|V,00FF0080,0,1.0,5.0|V,008000,0,5.5,5.0|v,00A000,0,6.5,4

Maps

1http://chart.apis.google.com/chart?cht=t&chs=440x220&chd=s:_&chtm=world
1http://chart.apis.google.com/chart?cht=t&chs=440x220&chd=t:0,100,50,32,60,40,43,12,14,54,98,17,70,76,18,29&chco=FFFFFF,FF0000,FFFF00,00FF00&chld=DZEGMGAOBWNGCFKECGCVSNDJTZGHMZZM&chtm=africa&chf=bg,s,EAF7FE

Google-o-meters

1http://chart.apis.google.com/chart?chs=225x125&cht=gom&chd=t:70&chl=Hello

Popular Posts