We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23363
    • 43 Posts
    Hi,

    There is also a API for the Google’s visualisation
    http://code.google.com/apis/ajax/playground/?type=visualization#annotated_time_line

    The example underneat will work on any HTML page. I hope it helps you

    Best regards,

    Jeroen

    <!--
      copyright (c) 2009 Google inc.
    
      You are free to copy and use this sample.
      License can be found here: http://code.google.com/apis/ajaxsearch/faq/#license
    -->
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <meta http-equiv="content-type" content="text/html; charset=utf-8" />
      <title>Google Visualization API Sample</title>
      <script type="text/javascript" src="http://www.google.com/jsapi"></script>
      <script type="text/javascript">
        google.load('visualization', '1', {packages: ['annotatedtimeline']});
        function drawVisualization() {
          var data = new google.visualization.DataTable();
          data.addColumn('date', 'Date');
          data.addColumn('number', 'Sold Pencils');
          data.addColumn('string', 'title1');
          data.addColumn('string', 'text1');
          data.addColumn('number', 'Sold Pens');
          data.addColumn('string', 'title2');
          data.addColumn('string', 'text2');
          data.addRows(6);
          data.setValue(0, 0, new Date(2008, 1 ,1));
          data.setValue(0, 1, 30000);
          data.setValue(0, 4, 40645);
          data.setValue(1, 0, new Date(2008, 1 ,2));
          data.setValue(1, 1, 14045);
          data.setValue(1, 4, 20374);
          data.setValue(2, 0, new Date(2008, 1 ,3));
          data.setValue(2, 1, 55022);
          data.setValue(2, 4, 50766);
          data.setValue(3, 0, new Date(2008, 1 ,4));
          data.setValue(3, 1, 75284);
          data.setValue(3, 4, 14334);
          data.setValue(3, 5, 'Out of Stock');
          data.setValue(3, 6, 'Ran out of stock on pens at 4pm');
          data.setValue(4, 0, new Date(2008, 1 ,5));
          data.setValue(4, 1, 41476);
          data.setValue(4, 2, 'Bought Pens');
          data.setValue(4, 3, 'Bought 200k pens');
          data.setValue(4, 4, 66467);
          data.setValue(5, 0, new Date(2008, 1 ,6));
          data.setValue(5, 1, 33322);
          data.setValue(5, 4, 39463);
          
          var annotatedtimeline = new google.visualization.AnnotatedTimeLine(
              document.getElementById('visualization'));
          annotatedtimeline.draw(data, {'displayAnnotations': true});
        }
        
        google.setOnLoadCallback(drawVisualization);
      </script>
    </head>
    <body style="font-family: Arial;border: 0 none;">
    <div id="visualization" style="width: 800px; height: 400px;"></div>
    </body>
    </html>
    
    • I’ve seen that visualisation API but, recently, a new javascript charts libs appeared, not using flash, IE compatible, easy to setup and beautify: Higcharts

      I don’t like flash much so I think that i’ll try to do something with this one for Revolution. Don’t know about Evolution’s version though.

      • I’m getting this error:

        Division by zero in /home/.../assets/modules/ga-module/reports/thirty_day.report.php on line 29


        Also on lines 31 and 28

        MODx Evo: 1.0 (soon to be upgraded).
        PHP: 5.2.9
        MySQL: 5.0.45-community
          • 4310
          • 2,310 Posts
          That’s because one or more of the days did not have any visitors.
          The code needs some work to stop trying to do maths with nil results.
          Untested example below would need to be done for all of the calculations.
          <?php
          if($result->getPageviews()>= 1 && $result->getVisits() >= 1){
          $views_per_visit = number_format(($result->getPageviews()/$result->getVisits()), 2, '.', '');
          }
          else{
          $views_per_visit = 'N/A';
          }
            • 3689
            • 264 Posts
            Quote from: bunk58 at Dec 10, 2009, 12:39 AM

            That’s because one or more of the days did not have any visitors.
            The code needs some work to stop trying to do maths with nil results.
            Untested example below would need to be done for all of the calculations.
            <?php
            if($result->getPageviews()>= 1 && $result->getVisits() >= 1){
            $views_per_visit = number_format(($result->getPageviews()/$result->getVisits()), 2, '.', '');
            }
            else{
            $views_per_visit = 'N/A';
            }


            where would I put this? im gettin the same error
              • 4310
              • 2,310 Posts
              Just replace line 27 of thirty_day.report.php with the supplied code, without the <?php tag.
              As mentioned before this was more a proof of concept than a production ready module.
              I keep meaning to look at the Revo version to see if I could port it to Evo but time is always against me sad
                • 22840
                • 1,572 Posts
                Seems to be working great however i’m getting the following error:
                Warning: Division by zero in /home/campsite/public_html/assets/modules/ga-module/reports/thirty_day.report.php on line 28

                Warning: Division by zero in /home/campsite/public_html/assets/modules/ga-module/reports/thirty_day.report.php on line 29

                Warning: Division by zero in /home/campsite/public_html/assets/modules/ga-module/reports/thirty_day.report.php on line 31

                Tried the fix above but still getting the error, however not too fussed as it’s working grin

                Thanks for this great add-on
                  • 22840
                  • 1,572 Posts
                  Another little problem,

                  When I view my stats there are no styles associated to it and if I look at my 404’s a call to assets/modules/ga-module/style.css however that file wasn’t in the download, does anyone have a copy please grin
                    • 4310
                    • 2,310 Posts
                    Should have been in the .zip file, here’s a copy
                      • 22840
                      • 1,572 Posts
                      Quote from: bunk58 at Jan 23, 2010, 07:18 PM

                      Should have been in the .zip file, here’s a copy

                      Thanks David