Plugin Directory

Changeset 378832


Ignore:
Timestamp:
04/29/2011 03:24:51 PM (15 years ago)
Author:
dugbug
Message:

Checking in 1.1

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

Legend:

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

    r373269 r378832  
    2727                'title' => 'Chart Type',
    2828                'key' => 'DEF_TYPE',
    29                 'pick' => (object)array("horizbar","vertbar","pie","line","horizbarstack","vertbarstack", "horizbaroverlap", "vertbaroverlap"),
     29                'pick' => (object)array("horizbar","vertbar","pie","line","horizbarstack","vertbarstack", "horizbaroverlap", "vertbaroverlap", "scatter", "radar"),
    3030                'help' => 'The default chart type (type).  Remember, this is just the default.  You can always specify whatever chart type you want each time you instantiate the shortcode.'),
    3131            (object) array(
  • easy-chart-builder/trunk/easy-chart-builder.php

    r373269 r378832  
    22/*
    33Plugin Name: Easy Chart Builder
    4 Version: 1.0
     4Version: 1.1
    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.
  • easy-chart-builder/trunk/js/easy-chart-builder.js

    r373269 r378832  
    11/**
    22 * Handle: easyChartBuilder
    3  * Version: 1.0
     3 * Version: 1.2
    44 * Enqueue: true
    55 *
     
    8888    chartImg.src = url_src;
    8989};
    90    
    91    
    92  easyChartBuilder.prototype.groupChart = function(chartType, chartId, chartImg, chartWidth, chartHeight, chartHandle)
     90   
     91easyChartBuilder.prototype.scatterChart = function(chartId, chartImg, chartWidth, chartHeight, chartHandle)
    9392{
    9493    var chartTitle = chartHandle["title"];
     
    9998    var chartGroups = tempGroupNames.length;
    10099    var chartGroupNames = this.constructList(tempString, ",", "|",0, false);
     100
     101    tempString = chartHandle["groupcolors"];
     102    var chartColors = this.constructList(tempString, ",", "|",chartGroups, false);
     103    tempString = chartHandle["valuenames"];
     104    var chartValueNames = "|" + this.constructList(tempString, ",", "|",0, true);
     105
     106    var groupName;
     107    var chartValues = new Array(chartGroups);
     108    for (var i = 0; i < chartGroups; i++)
     109    {
     110        groupName = "group" + (i+1) + "values";
     111        tempString = chartHandle[groupName];
     112        chartValues[i] = this.extractValues(tempString, ",", 0);
     113    }
     114   
     115    var chartValuesX = new Array();
     116    chartValuesX[0] = new Array();
     117    var chartValuesY = new Array();
     118    chartValuesY[0] = new Array();
     119    //var chartValuesS = new Array();
     120    //chartValuesS[0] = new Array();
     121   
     122    // For each value supplied
     123    var vPoints = 0;
     124    for (var i=0;i<chartValues[0].length/2;i++)
     125    {
     126        for (var g=0;g<chartGroups;g++)
     127        {
     128            chartValuesX[0][vPoints] = chartValues[g][i*2];
     129            chartValuesY[0][vPoints] = chartValues[g][(i*2) + 1];
     130            //chartValuesS[0][vPoints] = chartValues[g][(i*3) + 2];
     131            vPoints++;
     132        }
     133    }
     134     
     135    var hideChartData = chartHandle["hidechartdata"];
     136    if (hideChartData == false)
     137    {
     138        var tblIdContainer = document.getElementById(chartId + "_data");
     139        var tblId = document.getElementById(chartId + "_dataTable");
     140        if (tblId == undefined && tblIdContainer != undefined)
     141        {
     142            tblId = document.createElement('div');
     143            tblId.setAttribute('id',chartId + '_dataTable'); 
     144                               
     145            tblId.innerHTML = this.buildChartXY(chartHandle, tempGroupNames, chartValuesX[0], chartValuesY[0]);
     146            tblIdContainer.appendChild(tblId);
     147        }
     148    }
     149         
     150    var chartValuesString =
     151    /*this.encodeValues(chartValuesX, ",") +
     152                    "|" + this.encodeValues(chartValuesY); */
     153                    chartValuesX[0].toString() + "|" + chartValuesY[0].toString();// + "|" + chartValuesS[0].toString();
     154   
     155    var chartColor = chartHandle["chartcolor"];
     156    var chartFadeColor = chartHandle["chartfadecolor"];
     157   
     158    var chartMarkers = this.buildMarkers(chartHandle, tempGroupNames.length);
     159   
     160    var url_src = null; 
     161    var common_parts = "chs=" + chartWidth + "x" + chartHeight +
     162        "&chma=10,10,10,40" +
     163        "&chf=c,lg,90," + chartColor + ",0.2," + chartFadeColor + ",0|bg,s,00000000" +
     164        "&chtt=" + chartTitle +
     165        "&chdl=" + chartGroupNames + "&chdlp=b" +
     166        "&chd=t:" + chartValuesString + "&chco=" + chartColors ;
     167   
     168    var gridOut = chartHandle["grid"]; 
     169    var gridGroups = 100.0 / chartGroups;
     170    var gridValues = 100.0 / 10.0;
     171   
     172    if (axisChoice != "none")
     173    {
     174        if (axisChoice == "values")
     175        {axisValues = "x";}
     176        else if (axisChoice == "names")
     177        {axisValues = "y";}
     178        else
     179        {axisValues = "x,y";}
     180    }
     181   
     182    url_src ="http://chart.apis.google.com/chart?cht=s&chbh=r,0.2,1.0&" + common_parts +
     183    "&chxt=" + axisValues
     184   
     185    if (gridOut == true)
     186        {url_src += "&chg=" + 0 + "," + gridValues + ",1,5";}
     187
     188    chartImg.src = url_src;
     189};
     190 
     191easyChartBuilder.prototype.radarChart = function(chartId, chartImg, chartWidth, chartHeight, chartHandle)
     192{
     193    var chartTitle = chartHandle["title"];
     194    var axisValues = "";
     195    var axisChoice = chartHandle["axis"];
     196    var tempString = chartHandle["groupnames"];
     197    var tempGroupNames = tempString.split(",");
     198    var chartGroups = tempGroupNames.length;
     199    var chartGroupNames = this.constructList(tempString, ",", "|",0, false);
    101200       
    102201    tempString = chartHandle["groupcolors"];
     
    104203   
    105204    tempString = chartHandle["valuenames"];
    106     var order = false;
    107     if (chartType == "horizbar" || chartType == "horizbarstack" || chartType == "horizbaroverlap") {order = true;}
    108     var chartValueNames = "|" + this.constructList(tempString, ",", "|",0, order);
     205    var chartValueNames = "|" + this.constructList(tempString, ",", "|",0, true);
    109206
    110207    var groupName;
     
    132229    }
    133230   
     231    var chartValuesString = "";
     232    for (var i=0;i<chartGroups;i++)
     233    {
     234        if (i)
     235        {chartValuesString = chartValuesString + "|";}
     236        chartValuesString = chartValuesString + chartValues[i].toString();
     237    }
     238
     239    var chartColor = chartHandle["chartcolor"];
     240    var chartFadeColor = chartHandle["chartfadecolor"];
     241   
     242    var chartMarkers = this.buildMarkers(chartHandle, tempGroupNames.length);
     243    var url_src = null; 
     244    var common_parts = "chs=" + chartWidth + "x" + chartHeight +
     245        "&chma=10,10,10,40" +
     246        "&chf=bg,lg,270," + chartColor + ",0," + chartColor + ",1" +
     247        "&chtt=" + chartTitle +
     248        "&chdl=" + chartGroupNames + "&chdlp=b=r" +
     249        "&chco=" + chartColors + "&chd=t:" + chartValuesString + "&chxl=1:" + chartValueNames +
     250        chartMarkers;
     251   
     252    var gridOut = chartHandle["grid"]; 
     253    var gridGroups = 100.0 / chartGroups;
     254    var gridValues = 100.0 / 10.0;
     255   
     256    if (axisChoice != "none")
     257    {
     258        if (axisChoice == "values")
     259        {axisValues = "x";}
     260        else if (axisChoice == "names")
     261        {axisValues = "y";}
     262        else
     263        {axisValues = "x,y";}
     264    }
     265
     266    url_src ="http://chart.apis.google.com/chart?cht=r&chbh=r,0.2,1.0&" + common_parts +
     267        "&chxt=" + axisValues;
     268   
     269    if (gridOut == true)
     270        {url_src += "&chg=" + 0 + "," + gridValues + ",1,5";}
     271    chartImg.src = url_src;
     272};
     273
     274 
     275easyChartBuilder.prototype.groupChart = function(chartType, chartId, chartImg, chartWidth, chartHeight, chartHandle)
     276{
     277    var chartTitle = chartHandle["title"];
     278    var axisValues = "";
     279    var axisChoice = chartHandle["axis"];
     280    var tempString = chartHandle["groupnames"];
     281    var tempGroupNames = tempString.split(",");
     282    var chartGroups = tempGroupNames.length;
     283    var chartGroupNames = this.constructList(tempString, ",", "|",0, false);
     284       
     285    tempString = chartHandle["groupcolors"];
     286    var chartColors = this.constructList(tempString, ",", ",",0, false);
     287   
     288    tempString = chartHandle["valuenames"];
     289    var order = false;
     290    if (chartType == "horizbar" || chartType == "horizbarstack" || chartType == "horizbaroverlap") {order = true;}
     291    var chartValueNames = "|" + this.constructList(tempString, ",", "|",0, order);
     292
     293    var groupName;
     294    var chartValues = new Array(chartGroups);
     295    for (var i = 0; i < chartGroups; i++)
     296    {
     297        groupName = "group" + (i+1) + "values";
     298        tempString = chartHandle[groupName];
     299        chartValues[i] = this.extractValues(tempString, ",", 0);
     300    }
     301   
     302    var hideChartData = chartHandle["hidechartdata"];
     303    if (hideChartData == false)
     304    {
     305        var tblIdContainer = document.getElementById(chartId + "_data");
     306        var tblId = document.getElementById(chartId + "_dataTable");
     307        if (tblId == undefined && tblIdContainer != undefined)
     308        {
     309            tblId = document.createElement('div');
     310            tblId.setAttribute('id',chartId + '_dataTable'); 
     311                               
     312            tblId.innerHTML = this.buildChartData(chartHandle, tempGroupNames, chartValues);
     313            tblIdContainer.appendChild(tblId);
     314        }
     315    }
     316   
    134317    var isStacked = false;
    135318    if (chartType == "horizbarstack" || chartType == "vertbarstack")
     
    146329        else {minAxis = "0";}
    147330    }
    148  
    149331       
    150332    tempString = chartHandle["watermark"];
     
    176358        {
    177359            if (axisChoice == "values")
    178             {
    179                 axisValues = "x";
    180             }
     360            {axisValues = "x";}
    181361            else if (axisChoice == "names")
    182             {
    183                 axisValues = "y";
    184             }
     362            {axisValues = "y";}
    185363            else
    186             {
    187                 axisValues = "x,y";
    188             }
     364            {axisValues = "x,y";}
    189365        }
    190366        else
    191367        {
    192368            if (axisChoice == "values")
    193             {
    194                 axisValues = "y";
    195             }
     369            {axisValues = "y";}
    196370            else if (axisChoice == "names")
    197             {
    198                 axisValues = "x";
    199             }
     371            {axisValues = "x";}
    200372            else
    201             {
    202                 axisValues = "y,x";
    203             }
     373            {axisValues = "y,x";}
    204374        }
    205375    }
     
    277447       
    278448        if (groupMarkStr == '')
    279         {
    280             continue;
    281         }
     449        {continue;}
    282450       
    283451        var marks = groupMarkStr.split(",");
    284452        if (marks.length == 0 || marks == '')
    285         {
    286             continue;
    287         }
     453        {continue;}
    288454       
    289455        for (var m = 0; m < marks.length; m++)
     
    293459           
    294460            if (letterIndex)
    295             {
    296                 markStr = markStr + "|" + prep;
    297             }
     461            {markStr = markStr + "|" + prep;}
    298462            else
    299             {
    300                 markStr = "&chem=" + prep;
    301             }
     463            {markStr = "&chem=" + prep;}
    302464           
    303465            letterIndex++;
     
    365527}
    366528
    367 easyChartBuilder.prototype.buildChartData = function(handle, headers, valueGrid)
     529easyChartBuilder.prototype.buildChartXY = function(handle, headers, valX, valY)
    368530{
    369531    var output;
     
    378540
    379541    if (precision != "")
    380     {
    381         precisionVal = parseInt(precision);
    382     }
     542    {precisionVal = parseInt(precision);}
     543   
     544    output = "<table class='" + css + "' border='0' style='text-align:center;' frame='box' align='center' bgcolor='FFFFFF'><thead><tr><td></td>";
     545
     546    for (var h=0;h<len;h++)
     547        {output = output + "<th>" + unescape(headers[h].trim()) + "</th>";}
     548    output = output + "</tr><tr style='height:4px;'><td></td>";
     549
     550    for (var i=0;i<len;i++)
     551        {output = output + "<th style='background: #FFFFFF; background-color:#" + headerColors[i].trim() + "'></th>";}
     552    output = output + "</tr></thead>";
     553           
     554    for (var t = 0; t < valX.length/2; t++)
     555    {       
     556        var tvalx = 0.0;
     557        var tvaly = 0.0;
     558        var tString;
     559       
     560        if (valueTitles[t] == undefined)
     561            {valueTitles[t] = "";}
     562        output = output + "<tr><th align='right'>" + unescape(valueTitles[t].trim()) + "</th>";
     563       
     564        if (precision == "")
     565           {tvalx = valX[t*2]; tvaly = valY[t*2];}
     566        else
     567           {tvalx = valX[t*2].toFixed(precisionVal); tvaly = valY[t*2].toFixed(precisionVal);}
     568               
     569        output = output + "<td>(" + tvalx + "," + tvaly+ ")</td>";
     570             
     571        if (precision == "")
     572           {tvalx = valX[(t*2)+1]; tvaly = valY[(t*2)+1];}
     573        else
     574           {tvalx = valX[(t*2)+1].toFixed(precisionVal); tvaly = valY[(t*2)+1].toFixed(precisionVal);}
     575                 
     576        output = output + "<td>(" + tvalx + "," + tvaly + ")</td>";
     577        output = output + "</tr>";
     578    }   
     579
     580    output = output + "</table>";
     581    return output;
     582};
     583
     584easyChartBuilder.prototype.buildChartData = function(handle, headers, valueGrid)
     585{
     586    var output;
     587    var len = headers.length;
     588
     589    var headerColors = handle["groupcolors"].split(",");
     590    var valueTitles = handle["valuenames"].split(",");
     591    var css = handle["datatablecss"];
     592    var currency = handle["currency"];
     593    var precision = handle["precision"];
     594    var precisionVal = 0;
     595
     596    if (precision != "")
     597    {precisionVal = parseInt(precision);}
    383598   
    384599    var commatize = false;
    385600    if (currency != "")
    386     {
    387         commatize = true;
    388     }
     601    {commatize = true;}
    389602                 
    390603    output = "<table class='" + css + "' border='0' style='text-align:center;' frame='box' align='center' bgcolor='FFFFFF'><thead><tr><td></td>";
     
    439652
    440653    if (precision != "")
    441     {
    442         precisionVal = parseInt(precision);
    443     }
     654    {precisionVal = parseInt(precision);}
    444655       
    445656    output = "<table  class='" + css + "' border='0' style='text-align:center;' frame='box' align='center' bgcolor='FFFFFF'><thead><tr><td></td>";
    446657
    447658    for (var h=0;h<len;h++)
    448         {output = output + "<th>" + unencode(headers[h].trim()) + "</th>";}
     659        {output = output + "<th>" + unescape(headers[h].trim()) + "</th>";}
    449660    output = output + "</tr><tr style='height:4px;'><td></td>";
    450661
     
    653864    var chartType = chartHandle["type"];
    654865    if (chartType == "pie")
    655     {
    656         this.pieChart(chartId, imgId, new_width, new_height, chartHandle);
    657     }
     866    {this.pieChart(chartId, imgId, new_width, new_height, chartHandle);}
     867    else if (chartType == "scatter")
     868    {this.scatterChart(chartId, imgId, new_width, new_height, chartHandle);}
     869    else if (chartType == "radar")
     870    {this.radarChart(chartId, imgId, new_width, new_height, chartHandle);}   
    658871    else
    659     {
    660         this.groupChart(chartType, chartId, imgId, new_width, new_height, chartHandle);
    661     }
     872    {this.groupChart(chartType, chartId, imgId, new_width, new_height, chartHandle);}
    662873
    663874};
  • easy-chart-builder/trunk/readme.txt

    r373276 r378832  
    55Tags: chart,graph,charts,graphs,line,review,rating,comparison,mobile,shortcode,dyerware
    66Requires at least: 2.8
    7 Tested up to: 3.1.1
    8 Stable tag: 1.0
     7Tested up to: 3.1.2
     8Stable tag: 1.1
    99
    1010This plugin allows you to easily create charts within your blog by use of shortcodes.
     
    7070
    7171== Upgrade Notice ==
     72
     73= 1.1 =
     74Added scatter plot chart type (type "scatter").  This one assumes the groupXvalues are xy pairs, so "x1,y1,x2,y2,(etc)".  This is different than the other chart types.
     75Added radar chart type (type "radar").
     76Improved unicode support for groupnames and valuenames.
    7277
    7378= 1.0 =
     
    122127
    123128== Changelog ==
     129
     130= 1.1 =
     131 * Added scatter plot chart type (type "scatter").  This one assumes the groupXvalues are xy pairs, so "x1,y1,x2,y2,(etc)".  This is different than the other chart types.
     132 * Added radar chart type (type "radar").
     133 * Improved unicode support for groupnames and valuenames.
    124134
    125135= 1.0 =
Note: See TracChangeset for help on using the changeset viewer.