WordPress.org

Plugin Directory

Changeset 1548875


Ignore:
Timestamp:
12/08/16 07:58:40 (7 months ago)
Author:
Elvin.Haci
Message:

1.0.5 fixes

Location:
sql-chart-builder/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sql-chart-builder/trunk/functions.php

    r1383031 r1548875  
    157157<h4>Arguments</h4> 
    158158<p> 
    159 Label for Y axis: <br><input type="text" name="guaven_sqlcharts_xarg_l" id="guaven_sqlcharts_xarg_l" value="<?php 
     159Label for X axis: <br><input type="text" name="guaven_sqlcharts_xarg_l" id="guaven_sqlcharts_xarg_l" value="<?php 
    160160    echo get_post_meta($post->ID, 'guaven_sqlcharts_xarg_l', true); 
    161161?>"></p> 
    162162    <p> 
    163 SQL field name of Y axis (Write corresponding SQL field name here, which has a number value. f.e. post_count):  
     163SQL field name of X axis (Write corresponding SQL field name here. f.e. diplay_name):  
    164164<br> 
    165165<input type="text" name="guaven_sqlcharts_xarg_s" id="guaven_sqlcharts_xarg_s" value="<?php 
     
    169169 
    170170<p> 
    171 Label for X axis: <br><input type="text" name="guaven_sqlcharts_yarg_l" id="guaven_sqlcharts_yarg_l" value="<?php 
     171Label for Y axis: <br><input type="text" name="guaven_sqlcharts_yarg_l" id="guaven_sqlcharts_yarg_l" value="<?php 
    172172    echo get_post_meta($post->ID, 'guaven_sqlcharts_yarg_l', true); 
    173173?>"></p><p> 
    174 SQL field name of X axis (Write corresponding SQL field name here, which usually has a string value. f.e. display_name):  
     174SQL field name of Y axis (Write corresponding SQL field name here. f.e. post_count):  
    175175<br> 
    176176<input type="text" name="guaven_sqlcharts_yarg_s" id="guaven_sqlcharts_yarg_s" value="<?php 
     
    321321    else { 
    322322        ob_start(); 
     323        global $sqlcharts_inserted_script; 
     324    if (empty($sqlcharts_inserted_script)) $sqlcharts_inserted_script=1;        
     325 
     326       if ($sqlcharts_inserted_script==1) { 
     327          
    323328?> 
    324329<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> 
    325    
     330  <?php } ?> 
    326331     <script type="text/javascript">; 
    327332       google.charts.load('current', {'packages':[<?php 
     
    330335        echo gvn_schart_libloads($tip_g, 'packages'); 
    331336?>]}); 
    332       google.charts.setOnLoadCallback(drawChart); 
    333       function drawChart() { 
     337      google.charts.setOnLoadCallback(drawChart_<?php echo $sqlcharts_inserted_script;?>); 
     338      csv_data='';csv_title=''; 
     339      function drawChart_<?php echo $sqlcharts_inserted_script;?>() { 
    334340    <?php 
    335341        $html_temp = ''; 
    336          
     342        $csv_temp =''; 
    337343        $post_g = get_post($atts['id']); 
    338344        $xarg_s = get_post_meta($atts['id'], 'guaven_sqlcharts_xarg_s', true); 
     
    353359        foreach ($fvs as $fv) { 
    354360            $html_temp .= "['{$fv->$yarg_s}', {$fv->$xarg_s}, '#b87333'],"; 
     361            $csv_temp .= addslashes($fv->$yarg_s).",".addslashes($fv->$xarg_s)."<br>"; 
    355362             
    356363        } 
    357          
    358 ?> 
     364        ?> 
     365        csv_data='<?php echo $csv_temp;?>'; 
     366        csv_title='<?php echo ''.$yarg_l.','.$xarg_l.'';  ?><br>'; 
    359367      var data = google.visualization.arrayToDataTable([ 
    360368         ['<?php 
     
    372380        echo $tip_g == '3dpie' ? "is3D: true," : ''; 
    373381?> 
    374           chart: { 
     382          chart_<?php echo $sqlcharts_inserted_script;?>: { 
    375383            title: '<?php 
    376384        echo $post_g->post_title; 
     
    379387        }; 
    380388 
    381 var chart = new google.visualization.<?php 
     389var chart_<?php echo $sqlcharts_inserted_script;?> = new google.visualization.<?php 
    382390        echo gvn_schart_libloads(get_post_meta($atts['id'], 'guaven_sqlcharts_graphtype', true), 'charts'); 
    383 ?>(document.getElementById('columnchart_material')); 
    384         chart.draw(data, options); 
     391?>(document.getElementById('columnchart_material_<?php echo $sqlcharts_inserted_script;?>')); 
     392 
     393 
     394      var my_div = document.getElementById('chart_div_<?php echo $sqlcharts_inserted_script;?>'); 
     395       google.visualization.events.addListener(chart_<?php echo $sqlcharts_inserted_script;?>, 'ready', function () { 
     396      my_div.innerHTML = '<img src="' + chart_<?php echo $sqlcharts_inserted_script;?>.getImageURI() + '">'; 
     397    }); 
     398 
     399        chart_<?php echo $sqlcharts_inserted_script;?>.draw(data, options); 
    385400      } 
    386401 
     402 
     403 
     404  function saveaspng(id){ 
     405window.open(jQuery("#"+id+" img").attr('src')); 
     406  } 
     407 
     408   function exportcsv(){ 
     409var csvFile=csv_title+csv_data; 
     410csvFile=csvFile.replaceAll("<br>","\n"); 
     411filename="mycsv.csv"; 
     412var blob = new Blob([csvFile], { type: 'text/csv;charset=utf-8;' }); 
     413        if (navigator.msSaveBlob) { // IE 10+ 
     414            navigator.msSaveBlob(blob, filename); 
     415        } else { 
     416            var link = document.createElement("a"); 
     417            if (link.download !== undefined) { // feature detection 
     418                // Browsers that support HTML5 download attribute 
     419                var url = URL.createObjectURL(blob); 
     420                link.setAttribute("href", url); 
     421                link.setAttribute("download", filename); 
     422                link.style.visibility = 'hidden'; 
     423                document.body.appendChild(link); 
     424                link.click(); 
     425                document.body.removeChild(link); 
     426            } 
     427        } 
     428 
     429//window.open().document.write(csv_title+csv_data); 
     430  } 
     431 
     432String.prototype.replaceAll = function(search, replacement) { 
     433    var target = this; 
     434    return target.replace(new RegExp(search, 'g'), replacement); 
     435}; 
    387436    </script> 
    388  
    389 <div id="columnchart_material" style="width:<?php 
     437<div id="chart_div_<?php echo $sqlcharts_inserted_script;?>" style="display:none"></div> <a href="javascript://" onclick="saveaspng('chart_div_<?php echo $sqlcharts_inserted_script;?>')">Save as PNG</a> 
     438<a href="javascript://" onclick="exportcsv()">Export CSV</a> 
     439<div id="columnchart_material_<?php echo $sqlcharts_inserted_script;?>" style="width:<?php 
    390440        echo $graph_width > 0 ? intval($graph_width) : '500'; 
    391441?>px; 
     
    394444?>px"></div> 
    395445<?php 
     446$sqlcharts_inserted_script++; 
     447 
    396448        return ob_get_clean(); 
    397449    } 
     
    425477 
    426478        var options = { 
    427           chart: { 
     479          chart_<?php echo $sqlcharts_inserted_script;?>: { 
    428480            title: 'Company Performance', 
    429481            subtitle: 'Sales, Expenses, and Profit: 2014-2017', 
  • sql-chart-builder/trunk/guaven_sqlcharts.php

    r1383031 r1548875  
    44 * Plugin URI:        http://guaven.com/updatepusher 
    55 * Description:       Turn your SQL queries to Google Charts 
    6  * Version:           1.0.3 
     6 * Version:           1.0.5 
    77 * Author:            Guaven Labs 
    88 * Author URI:        http://guaven.com/ 
  • sql-chart-builder/trunk/initial_data.php

    r1383195 r1548875  
    55  'Posts by year', 
    66  'Popular users/publishers', 
    7    'Popular categories', 
    87  ); 
    98 
     
    1817where a.post_status="publish" 
    1918group by a.post_author order by pcount desc limit 10', 
    20  
    21 'select b.name name ,a.count acount from wp_term_taxonomy a inner join wp_terms b on a.term_id=b.term_id  where a.taxonomy="category" order by acount desc', 
    2219  ); 
    2320 
     
    2926 
    3027array('Post count','pcount','Display name','dname',500,400,'3dpie'), 
    31  
    32 array('Post count','acount','Category name','name',500,400,'3dpie'), 
    3328 
    3429 
  • sql-chart-builder/trunk/readme.txt

    r1383031 r1548875  
    11=== SQL Chart Builder === 
    2 Contributors: elvinhaci 
    3 Donate link: http://guaven.com/donate 
     2Contributors: Elvin Haci 
    43Tags: graph,charts,sql charts,mysql charts,visualizer,sql visualizer,sql reports,mysql reports,google charts,google chart,mysql to chart,mysql to graph 
    54Requires at least: 3.9.0 
    6 Tested up to: 4.5.0 
    7 Stable tag: 1.0.3 
     5Tested up to: 4.7.0 
     6Stable tag: 1.0.5 
    87License: GPLv2 or later 
    98License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    5756== Changelog == 
    5857 
    59 = 1.0.3= 
    60 * One more new report added. + Some little fixes. 
    61  
    62 = 1.0.2= 
    63 * Added some screenshots 
    64  
    6558= 1.0.0= 
    6659* Uploaded to Wordpress.org 
Note: See TracChangeset for help on using the changeset viewer.