Plugin Directory

Changeset 725837


Ignore:
Timestamp:
06/12/2013 06:37:01 PM (13 years ago)
Author:
harshaperla
Message:

Updating to version 0.4

Location:
iced-visualization-charts/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • iced-visualization-charts/trunk/iced-visualization-chart.php

    r723030 r725837  
    3434add_action('init', 'iced_chart_addbuttons');
    3535add_shortcode('chart','iced_chart_display');
    36 
     36$chart_id = 0;
    3737function iced_chart_display($atts, $content = null)
    3838{
     39    global $chart_id;
    3940    wp_enqueue_script('google-visualization', 'http://www.google.com/jsapi', array('jquery'), '1.0', true);
    4041    wp_enqueue_script('iced-visualization', plugins_url('iced-visualization.js', __FILE__), array('google-visualization'), '1.0', true);
    41       $options = shortcode_atts( array(
    42             'width' => "400px",
    43             'height' => "300px",
    44             'title' => "Graph",
    45            
    46             //By default the axis titles are empty
    47             'h_title' => "",
    48             'v_title' => "",
    49 
    50             //By default there are no scale button
    51             'scale_button' => "false",
    52            
    53             //By default give iterated id to the graph
    54             'id' => "graph_" . count($graph_ids),
    55         ), $atts );
    56         ?>
    57     <div id="chart_div"></div>
     42    $type = $atts['type'];
     43    ?> 
     44    <div id="chart_div_<?php echo $chart_id; ?>"></div>
    5845    <script type="text/javascript">
    59     var iced_chart_content = [<?php echo str_replace(array('<br/>', '<br />'), '', $content); ?>];
     46    var chart_id = <?php echo $chart_id; ?>;
     47    if (typeof(iced_chart_options) == "undefined"){ var iced_chart_options = new Array()};
     48    if (typeof(iced_chart_content) == "undefined"){ var iced_chart_content = new Array()};
     49    if (typeof(iced_chart_type) == "undefined"){ var iced_chart_type = new Array()};
     50    iced_chart_options[chart_id] = {
     51    width: 500, height: 350,
     52    animation:{   duration: 2000, easing: 'out' },
     53    };
     54    iced_chart_content[chart_id] = [<?php echo str_replace(array('<br/>', '<br />'), '', $content); ?>];
     55    iced_chart_type[chart_id] = "<?php echo $type;?>";
    6056    </script>
    6157    <?php
     58    $chart_id ++;
    6259}
    6360
  • iced-visualization-charts/trunk/iced-visualization.js

    r723030 r725837  
    11google.load('visualization', '1', {packages: ['corechart']});
    2 
    3 var options = {
    4     width: 500, height: 350,
    5     animation:{   duration: 2000, easing: 'out' },
    6 };
     2var options, data, chart;
    73
    84function intit_icedchart(){
    9     var data = google.visualization.arrayToDataTable(iced_chart_content);
    10     var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
    11     chart.draw(data, options);
     5    for(var i=0; i <= chart_id; i++){
     6           
     7        options = iced_chart_options[i];
     8
     9        data = google.visualization.arrayToDataTable(iced_chart_content[i]);
     10        var iced_chart = iced_chart_type[i];
     11        chart = new google.visualization[iced_chart](document.getElementById('chart_div_' + i ));
     12        chart.draw(data, options);
     13    }
    1214}
    1315
    14  
    15 
    1616google.setOnLoadCallback(intit_icedchart);
  • iced-visualization-charts/trunk/insert-chart.js

    r723030 r725837  
    1 
    21var  iced_chart_rows;
     2var iced_chart_columns;
    33function closethis(){
    4     var shortcode = "[chart]['x','y']";
    5     for(var i = 0; i < iced_chart_rows; i++){
    6         shortcode += ',["' + document.getElementById('r_' + i + '_c0').value;       
    7         shortcode += '",' + document.getElementById('r_' + i + '_c1').value + ']';
     4    var shortcode = '[chart type="' + document.getElementById('charttype').value + '"';
     5    shortcode += ']["' + document.getElementById('r_0_c_0').value + '"'
     6    for(var c = 1; c <= iced_chart_columns; c++){
     7        shortcode += ',"' + document.getElementById('r_0_c_' + c).value + '"';
    88    }
    9     shortcode += '[/chart]';
     9    for(var r = 1; r <= iced_chart_rows; r++){
     10        shortcode += '],["' + document.getElementById('r_' + r + '_c_0').value + '"'
     11        for(var c = 1; c <= iced_chart_columns; c++){
     12            shortcode += ',' + document.getElementById('r_' + r + '_c_' + c).value;
     13           
     14        }
     15    }
     16    shortcode += '][/chart]';
    1017    tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
    1118    tb_remove();
     
    4653        // creates a form to be displayed everytime the button is clicked
    4754        // you should achieve this using AJAX instead of direct html code like this
    48         var form = jQuery('<div id="chart-form"><table id="mygallery-table" class="form-table">\
     55        var form = jQuery('<div id="chart-form"><table id="icedchart-table" class="form-table">\
    4956            <tr>\
    50                 <th><label for="chart-columns">Values</label></th>\
    51                 <td><input type="text" id="chartcolumns" name="columns" value="3" /><br />\
    52                 <small>specify the number of values.</small>    </td><td>   <p class="submit">\
    53             <input type="button" id="mygallery-submit" class="button-primary" value="Add values" name="submit" /></td>\
     57                <td><label for="charttype">Chart Type:</label><select id="charttype" name="charttype"><option value="BarChart">Bar Chart</option> \
     58                <option value="PieChart">Pie Chart</option>  <option value="ColumnChart">Column Chart</option></select>\
     59                </td><td></td></tr><tr><td><label for="chart-columns">Rows</label>\
     60                <input type="text" id="chartrows" name="chartrows" value="3" /><br /><small>specify the number of data sets.</small>\
     61                </td><td><label for="chartcolumns">Columns</label>\
     62                <input type="text" id="chartcolumns" name="chartcolumns" value="1" /><br />\
     63                <small>specify the number of values.</small>    </td></tr><tr><td>  <p class="submit">\
     64            <input type="button" id="icedchart-submit" class="button-primary" value="Add values" name="submit" /></td>\
    5465            </tr>\
    5566                </table>\
     
    5970        var table = form.find('table');
    6071        form.appendTo('body').hide();
    61         form.find('#mygallery-submit').click(function(){
    62             iced_chart_rows = document.getElementById("chartcolumns").value;
    63             var tablecontent = '<form><table><tr><th>Title</th><th>Value</th></tr>';
    64             for(var i = 0; i < iced_chart_rows; i++){
    65                 tablecontent += '<tr><td><input id="r_' + i + '_c0"/></td><td><input id="r_' + i + '_c1"/></td></tr>';
     72        form.find('#icedchart-submit').click(function(){
     73            iced_chart_columns = document.getElementById("chartcolumns").value;
     74            iced_chart_rows = document.getElementById("chartrows").value;
     75            var tablecontent = '<form><table><tr><th><input id="r_0_c_0" value="Label" /></th>'
     76            for(var c = 1; c <= iced_chart_columns; c++){
     77                tablecontent += '<th><input id="r_0_c_' + c + '" value="Column ' + c + '"/></th>';         
    6678            }
     79            for(var r = 1; r <= iced_chart_rows; r++){
     80                tablecontent += '</tr><tr>'
     81                for(var c = 0; c <= iced_chart_columns; c++){
     82                    tablecontent += '<td><input id="r_' + r + '_c_' + c +'"/></td>';
     83                }
     84            }
     85            tablecontent += '</tr>';
    6786            tablecontent += '</table></form>';
    6887            tablecontent += '<input type="buttom" id="chart-submit" class="button-primary" value="Insert Chart" name="submit" onclick="closethis();"/>';
  • iced-visualization-charts/trunk/readme.txt

    r723056 r725837  
    1 === Iced Visualization Chart ===
    2 Contributors: Harsha
     1=== Iced Visualization Charts ===
     2Contributors: harshaperla
    33Donate link: http://icedapp.com/
    44Tags: google visualization, google charts, graphs, piechart, tinymce button, shortcode
    55Requires at least: 2.9
    66Tested up to: 3.5.1
    7 Stable tag: 0.2
     7Stable tag: 0.4
    88
    99Allows you to insert a  Google Visualisation chart by clicking button in TinyMCE and entering the data.
     
    1111== Description ==
    1212
    13 Have you ever wanted an easy way to insert Google charts to posts? With this plugin you can easily add a PieChart by clicking a button in the editor and inputing data.
     13Have you ever wanted an easy way to insert Google charts to posts? With this plugin you can easily add a Visualization (Currently supports PieChart, BarChart, ColumnChart) by clicking a button in the editor and inputing data. The UI inserts shortcode as placeholders for charts.
     14
     15This plugin loads the Google Visualization API JavaScript in the footer, only in the pages where chart is inserted.
     16
    1417For more details, visit plugin homepage: [IcedApp](http://icedapp.com/plugin-iced-visualization-charts-for-inserting-google-charts/ "Cool technical items!")
    1518
     
    2730= I wanted other type of the chart :( =
    2831
    29 Sorry. In this version, You will be able to add only PieChart. Other options will be added in the next release, soon!
     32Sorry. In this version, You will be able to add only PieChart, BarChart and ColumnChart. Other options will be added in the next release, soon!
     33
     34= How to configure? I don't see any settings page! =
     35
     36There is no settings or configuration provided as of now. Everything you can do is available in post editor.
    3037
    3138== Screenshots ==
     
    33401. How to add data to chart after clicking on the icon (see screenshot 2)
    34412. This is where you need to click for adding the chart
     42
     43== Changelog ==
     44
     45= 0.4 =
     46* Now support Bar Chart and Column Chart along with Pie Chart
     47* Now you can display multiple charts in a same page/post
     48
     49
Note: See TracChangeset for help on using the changeset viewer.