Changeset 725837
- Timestamp:
- 06/12/2013 06:37:01 PM (13 years ago)
- Location:
- iced-visualization-charts/trunk
- Files:
-
- 4 edited
-
iced-visualization-chart.php (modified) (1 diff)
-
iced-visualization.js (modified) (1 diff)
-
insert-chart.js (modified) (3 diffs)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
iced-visualization-charts/trunk/iced-visualization-chart.php
r723030 r725837 34 34 add_action('init', 'iced_chart_addbuttons'); 35 35 add_shortcode('chart','iced_chart_display'); 36 36 $chart_id = 0; 37 37 function iced_chart_display($atts, $content = null) 38 38 { 39 global $chart_id; 39 40 wp_enqueue_script('google-visualization', 'http://www.google.com/jsapi', array('jquery'), '1.0', true); 40 41 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> 58 45 <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;?>"; 60 56 </script> 61 57 <?php 58 $chart_id ++; 62 59 } 63 60 -
iced-visualization-charts/trunk/iced-visualization.js
r723030 r725837 1 1 google.load('visualization', '1', {packages: ['corechart']}); 2 3 var options = { 4 width: 500, height: 350, 5 animation:{ duration: 2000, easing: 'out' }, 6 }; 2 var options, data, chart; 7 3 8 4 function 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 } 12 14 } 13 15 14 15 16 16 google.setOnLoadCallback(intit_icedchart); -
iced-visualization-charts/trunk/insert-chart.js
r723030 r725837 1 2 1 var iced_chart_rows; 2 var iced_chart_columns; 3 3 function 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 + '"'; 8 8 } 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]'; 10 17 tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode); 11 18 tb_remove(); … … 46 53 // creates a form to be displayed everytime the button is clicked 47 54 // 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">\ 49 56 <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>\ 54 65 </tr>\ 55 66 </table>\ … … 59 70 var table = form.find('table'); 60 71 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>'; 66 78 } 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>'; 67 86 tablecontent += '</table></form>'; 68 87 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: Harsha1 === Iced Visualization Charts === 2 Contributors: harshaperla 3 3 Donate link: http://icedapp.com/ 4 4 Tags: google visualization, google charts, graphs, piechart, tinymce button, shortcode 5 5 Requires at least: 2.9 6 6 Tested up to: 3.5.1 7 Stable tag: 0. 27 Stable tag: 0.4 8 8 9 9 Allows you to insert a Google Visualisation chart by clicking button in TinyMCE and entering the data. … … 11 11 == Description == 12 12 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. 13 Have 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 15 This plugin loads the Google Visualization API JavaScript in the footer, only in the pages where chart is inserted. 16 14 17 For more details, visit plugin homepage: [IcedApp](http://icedapp.com/plugin-iced-visualization-charts-for-inserting-google-charts/ "Cool technical items!") 15 18 … … 27 30 = I wanted other type of the chart :( = 28 31 29 Sorry. In this version, You will be able to add only PieChart. Other options will be added in the next release, soon! 32 Sorry. 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 36 There is no settings or configuration provided as of now. Everything you can do is available in post editor. 30 37 31 38 == Screenshots == … … 33 40 1. How to add data to chart after clicking on the icon (see screenshot 2) 34 41 2. 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.