Plugin Directory

Changeset 202637


Ignore:
Timestamp:
02/06/2010 04:50:55 PM (16 years ago)
Author:
dugbug
Message:

v0.7

Location:
easy-chart-builder/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • easy-chart-builder/trunk/easy-chart-builder.php

    r195604 r202637  
    22/*
    33Plugin Name: Easy Chart Builder
    4 Version: 0.6.1
     4Version: 0.7
    55Plugin URI: http://www.dyerware.com/main/easy-chart-builder
    66Description: Creates a chart directly in your post or page via shortcut.  Manages sizing of chart to support wptouch and other mobile themes.
     
    3333    {   
    3434        $jsDir = get_option('siteurl') . '/wp-content/plugins/easy-chart-builder/js/';
    35         wp_register_script('wpEasyCharts', "{$jsDir}easy-chart-builder.js", false, '0.8');       
     35        wp_register_script('wpEasyCharts', "{$jsDir}easy-chart-builder.js", false, '0.9');       
    3636    }
    3737
     
    4343   
    4444    }
    45    
     45       
    4646    public function output_scripts ()
    4747    {
    48        
    49        wp_enqueue_script('wpEasyCharts');
    50        
     48       wp_enqueue_script('wpEasyCharts');   
    5149    }
    5250 
     
    9088                'height' => '200',
    9189                'title' => '',
     90                'minaxis' => '',
    9291                'groupnames' => 'Group 1,Group 2,Group 3',
    93                 'groupcolors' => '0070C0,FFFF00,FF0000,00CC00,A3A3A3,007070,00FFFF,CC7000',
     92                'groupcolors' => '0070C0,FFFF00,FF0000,00CC00,A3A3A3,007070,00FFFF,CC7000,00CC70,CC0070,7000CC,A370CC',
    9493                'valuenames' => 'test1,test2,test3,test4,test5',
    9594                'group1values' => '0,0,0',
     
    101100                'group7values' => '0,0,0',
    102101                'group8values' => '0,0,0',
     102                'group9values' => '0,0,0',
     103                'group10values' => '0,0,0',
     104                'group11values' => '0,0,0',
     105                'group12values' => '0,0,0',
    103106                'imagealtattr' => 'dyerware',
    104107                'imagetitleattr' => '',
     
    125128                   
    126129        $this->chartNum++;
    127         $chartDiv = 'easyChartDiv' . $this->chartNum;
     130       
     131        $randomatic = mt_rand(0,0x7fff);
     132        $randomatic = $randomatic << 16;
     133        global $post;
     134        if ($post)
     135        {
     136            $randomatic = $randomatic | 0x8000;           
     137        }       
     138       
     139        $r = $randomatic | $this->chartNum;
     140        $chartDiv = 'easyChartDiv' . base_convert($r, 10, 16); 
     141       
     142               
     143        //$chartDiv = 'easyChartDiv' . $this->chartNum;
    128144        $chartImg = $chartDiv . '_img';
    129145        $tableDiv = $chartDiv . '_data';
     
    162178//<![CDATA[
    163179wpEasyChart.wpNewChart({$chartDiv}, {$json});
    164 function wpEasyChartToggle(id) {
    165     var e = document.getElementById(id);
    166     if(e.style.display == 'block')
    167         e.style.display = 'none';
    168     else
    169         e.style.display = 'block';
    170 }
    171180//]]>
    172181</script>
    173182ecbCode;
    174183   }
     184   
     185   
     186   // This is for support in widgets
     187   public function do_shortcode($content) {
     188        global $shortcode_tags;
     189   
     190        if (empty($shortcode_tags) || !is_array($shortcode_tags))
     191            return $content;
     192        $pattern = '(.?)\[(easychart)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)';
     193        return preg_replace_callback('/'.$pattern.'/s', 'do_shortcode_tag', $content);
     194    }
    175195
    176196
     
    184204add_action('wp_head', array($wpEasyCharts, 'addCSS'));
    185205add_action('wp_print_scripts', array($wpEasyCharts, 'output_scripts'));
     206
    186207add_shortcode('easychart',array($wpEasyCharts, 'process_shortcode'));
     208add_filter('widget_text', array($wpEasyCharts, 'do_shortcode'));
    187209?>
  • easy-chart-builder/trunk/js/easy-chart-builder.js

    r195604 r202637  
    11/**
    22 * Handle: easyChartBuilder
    3  * Version: 0.8
     3 * Version: 0.9
    44 * Enqueue: true
    55 *
     
    2020{   
    2121}
     22
     23function wpEasyChartToggle(id) {
     24    var e = document.getElementById(id);
     25    if(e.style.display == 'block')
     26        e.style.display = 'none';
     27    else
     28        e.style.display = 'block';
     29}
    2230   
    2331easyChartBuilder.prototype.pieChart = function(chartId, chartImg, chartWidth, chartHeight, chartHandle)
     
    6371
    6472   
    65     var maxMin = this.normalizeValues(chartValues);   
     73    var maxMin = this.normalizeValues(chartValues, false, chartHandle);   
    6674    var chartValuesString = this.encodeValues(chartValues, "");
    6775    var chartColor = chartHandle["chartcolor"];   
     
    117125    }
    118126   
    119     var maxMin = this.normalizeValues(chartValues);   
     127    var maxMin = this.normalizeValues(chartValues, true, chartHandle);   
     128    var minAxis = chartHandle["minaxis"];
     129    if (minAxis == "")
     130    {
     131        if (maxMin[1] < 0)
     132             {minAxis = maxMin[1];}
     133        else {minAxis = "0";}
     134    }
    120135   
    121136    tempString = chartHandle["watermark"];
     
    132147    "&chdl=" + chartGroupNames + "&chdlp=b" +
    133148    "&chco=" + chartColors + "&chd=e:" + chartValuesString +
    134     "&chxt=y,x&chxr=0,0," + maxMin[0] + "&chxl=1:" + chartValueNames + wmPrep;
     149    "&chxt=y,x&chxr=0," + minAxis + "," + maxMin[0] + "&chxl=1:" + chartValueNames + wmPrep;
    135150   
    136151    chartImg.src = url_src;
     
    159174        groupName = "group" + (i+1) + "values";
    160175        tempString = chartHandle[groupName];
    161        
    162176        chartValues[i] = this.extractValues(tempString, ",", 0);
    163177    }
     
    178192    }
    179193   
    180     var maxMin = this.normalizeValues(chartValues); 
     194    var maxMin = this.normalizeValues(chartValues, true, chartHandle); 
     195    var minAxis = chartHandle["minaxis"];
     196    if (minAxis == "")
     197    {
     198        if (maxMin[1] < 0)
     199             {minAxis = maxMin[1];}
     200        else {minAxis = "0";}
     201    }
     202       
    181203    tempString = chartHandle["watermark"];
    182204    var wmColor = chartHandle["watermarkcolor"];
     
    192214    "&chdl=" + chartGroupNames + "&chdlp=b" +
    193215    "&chco=" + chartColors + "&chd=e:" + chartValuesString +
    194     "&chxt=x,y&chxr=0,0," + maxMin[0] + "&chxl=1:" + chartValueNames + wmPrep;
     216    "&chxt=x,y&chxr=0," + minAxis + "," + maxMin[0] + "&chxl=1:" + chartValueNames + wmPrep;
    195217   
    196218    chartImg.src = url_src;
     
    238260   
    239261    // max,min,ratio
    240     var maxMin = this.normalizeValues(chartValues);   
     262    var maxMin = this.normalizeValues(chartValues, true, chartHandle);   
    241263    tempString = chartHandle["watermark"];
    242264    var wmColor = chartHandle["watermarkcolor"];
     
    246268    var chartColor = chartHandle["chartcolor"];
    247269    var chartFadeColor = chartHandle["chartfadecolor"];     
     270       
     271    var minAxis = chartHandle["minaxis"];
     272    if (minAxis == "")
     273    {
     274        if (maxMin[1] < 0)
     275             {minAxis = maxMin[1];}
     276        else {minAxis = "0";}
     277    }
    248278                   
    249279    var url_src ="http://chart.apis.google.com/chart?cht=lc&chs=" + chartWidth + "x" + chartHeight +
     
    253283    "&chdl=" + chartGroupNames + "&chdlp=b" +
    254284    "&chco=" + chartColors + "&chd=e:" + chartValuesString +
    255     "&chxt=y,x&chxr=0,0," + maxMin[0] + "&chxl=1:" + chartValueNames + wmPrep;
     285    "&chxt=y,x&chxr=0," + minAxis + "," + maxMin[0] + "&chxl=1:" + chartValueNames + wmPrep;
    256286   
    257287    chartImg.src = url_src;
     
    396426};
    397427     
    398 easyChartBuilder.prototype.normalizeValues = function(valueGrid)
     428easyChartBuilder.prototype.normalizeValues = function(valueGrid, hasAxis, chartHandle)
    399429{
    400430    var len = valueGrid.length;
    401431    var maxMin = new Array();
    402432    var t, v, ratio;
     433    var minAxis = chartHandle["minaxis"];
    403434   
    404435    maxMin[0] = valueGrid[0][0];
    405436    maxMin[1] = maxMin[0];
    406437    maxMin[2] = 0;
    407    
     438    scaleMax = 0;
     439   
     440           
    408441    for (t = 0; t < len; t++)
    409442    {
     
    415448    }
    416449   
    417     ratio = 4095 / maxMin[0];
     450    scaleMax = maxMin[0];
     451   
     452    if (hasAxis == true && minAxis != "")
     453    {
     454        var lowValue = parseInt(minAxis);
     455       
     456        for (t = 0; t < len; t++)
     457        {
     458            for (v = 0; v < valueGrid[t].length; v++)
     459                {
     460                    if (valueGrid[t][v] < lowValue)
     461                         {valueGrid[t][v]  = 0;}
     462                    else {valueGrid[t][v] -= lowValue;}
     463                }
     464        }     
     465       
     466        scaleMax -= lowValue;
     467    }
     468   
     469    ratio = 4095 / scaleMax;
    418470    maxMin[2] = ratio;
    419471   
     
    423475            {valueGrid[t][v] = parseFloat(valueGrid[t][v] * ratio);} //was parseInt
    424476    }           
    425    
     477       
    426478    return maxMin;
    427479};
  • easy-chart-builder/trunk/readme.txt

    r195614 r202637  
    33Contributors: dyerware
    44Donate link: http://www.dyerware.com/main/products/easy-chart-builder/easy-chart-builder-plugin-for-wordpress.html
    5 Tags: chart,graph,charts,graphs,review,rating,comparison,mobile,shortcode,dyerware
     5Tags: chart,graph,charts,graphs,line,review,rating,comparison,mobile,shortcode,dyerware
    66Requires at least: 2.8
    77Tested up to: 2.9.1
    8 Stable tag: 0.6.1
     8Stable tag: 0.7
    99
    1010This plugin allows you to easily create charts within your blog by use of shortcodes.
     
    1515This plugin allows you to easily insert charts into your blog, making use shortcodes. While multipurpose, the chart system is intended to make it easy for posting detailed review measurements of some sort, such as video card comparisons.  You specify the names of the devices being measured, the tests performed, and each device's measurements for said test.
    1616
    17 Graphs scale to meet the size of the end-user client display, and support mobile displays such as those rendered by the wptouch plugin.
     17The shortcode is supported on posts, pages, and in widgets.
    1818
    19 Charts supported are horizontal bar, vertical bar, and pie.  More can be added if desired.
     19Graphs scale to meet the size of the end-user client display, and support mobile displays such as those rendered by the wptouch plugin.
     20
     21Charts supported are horizontal bar, vertical bar, line graph, and pie.  More can be added if desired.
    2022
    2123PHP5 Required.
     
    6466== Upgrade Notice ==
    6567
     68= 0.7 =
     69Shortcode can now be used in widgets.  New optional parameter, "minaxis".  Now supports graphing up to 12 groups (formerly 8).
     70
    6671= 0.6.1 =
    6772Watermark glitch introduced in 0.6
     
    7580
    7681== Changelog ==
     82
     83= 0.7 =
     84 * The shortcode can now be used in widgets, for example on the sidebar.
     85 * New minaxis optional parameter can be used to set to the minimum axis value you wish the plot
     86   to start at.  This clips away uninteresting areas of a graph.
     87 * Upped number of groups from 8 to 12.
    7788
    7889= 0.6.1 =
Note: See TracChangeset for help on using the changeset viewer.