Saturday, May 23, 2015

Adding #Charts to a website using javascrip with DataBase connection

Problem:   
You have some data in your DataBase that you would like to explode with Charts to offer Analytics solution to your visitors.

Solution:    
One simple way is to use highcharts, a company that has a collection of utilities to paint Charts using a simple script and of course with data base connecction and much more.

Sample:
$dbcon = mysql_connect("localhost", "bartolo", "******");
mysql_select_db("DATABASE", $dbcon);
$result = mysql_query("SELECT * FROM table");
while ($row = mysql_fetch_array($result)) {
   $data[] = "['".$row['name']."',".$row['tot']."]";
}
?>

...
$(function () {
    $('#container').highcharts({
        chart: {
            type: 'pie',
            options3d: { enabled: true, alpha: 45, beta: 0 }
        },
        title: { text: 'Chosse the best Broker' },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
            pie: {  allowPointSelect: true, cursor: 'pointer', depth: 35,
                dataLabels: { enabled: true, format: '{point.name}' }}
        },
        series: [{
            type: 'pie',             name: 'Browser share',
            data: [  <?php echo join($data, ','); ?> ]
        }]
    });
});
  </script>

...
Source:

 

12 comments:

  1. Great post!! This can be one particular of the most useful blogs We’ve ever arrive across on this subject. Basically Wonderful. I am also a specialist in this topic so I can understand your hard work.

    Digital marketing company in Chennai

    ReplyDelete
  2. Somebody necessarily help to make severely posts I might state. This is the first time I frequented your website page and to this point? I surprised with the research you made to create this particular post extraordinary. Well done admin..

    Digital marketing company in Chennai

    ReplyDelete
  3. Awesome article. It is so detailed and well formatted that i enjoyed reading it as well as get some new information too.


    SAP HR Training in Chennai

    ReplyDelete
  4. I am very happy when read this blog post because blog post written in good manner and write on good topic. Thanks for sharing valuable information.
    Bangalore Web Designing Company, UI Designing Company Bangalore

    ReplyDelete
  5. I am always searching online for articles that can help me to improve my knowledge. There is clearly a lot to know about this. I think you made some good points in Features also. I don't have words to describe this blog. By the way you are running a great blog. So, please keep on update like this post.
    Engineering Colleges in Chennai, Mechanical Engineering Colleges in Chennai

    ReplyDelete
  6. I absolutely admired every bit of it and i additionally accept you book apparent to analysis out fresh things in your site.
    UI Designing Companies, Web Application Development in Bangalore

    ReplyDelete

  7. Its a wonderful post and very helpful, thanks for all this information. You are including better information regarding this topic in an effective way.Thank you so much

    Personal Installment Loans
    Title Car loan
    Cash Advance Loan

    ReplyDelete
  8. I think like I get a clear cut understanding while reading the content than anywhere else. Keep continuing this journey...!

    Pawn Shops in Montgomery

    Pawn Shops in Birmingham

    Pawn Shops in Mobile

    ReplyDelete
  9. Good work…unique site and interesting too… keep it up…looking forward for more updates.Good luck to all of you and thanks so much for your hard-work.
    Language Interpretation Services, Voice Over Services India


    ReplyDelete
  10. This is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article.
    Language Translation Services ,
    Subtitling Companies in Bangalore

    ReplyDelete
  11. I am very happy when read this blog post because blog post written in good manner and write on
    good topic. Thanks for sharing valuable information.

    School Information Management System,
    Online Fee Payment Integration
    College Management System

    Message

    ReplyDelete