Personal tools

Template:PieChart: Difference between revisions

From FANTOM5_SSTAR

Jump to: navigation, search
No edit summary
No edit summary
Line 96: Line 96:
The code below is for chart settings
The code below is for chart settings
*/
*/
var content = "</html>{{{data}}}<html>";
var data_delimiter  = "</html>{{{dataDelimiter}}}<html>";
var chart_title = "</html>{{{chartTitle}}}<html>";
var chart_title = "</html>{{{chartTitle}}}<html>";
var series = "</html>{{{series}}}<html>";
var series_name = "</html>{{{seriesName}}}<html>";
var chart_size  = "</html>{{{chartSize}}}<html>";
var chart_size  = "</html>{{{chartSize}}}<html>";
var render_to  = "</html>{{{renderTo}}}<html>";
var render_to  = "</html>{{{renderTo}}}<html>";
var plot_bg_color=
var plot_bg_color="";
var plot_border_width=
var plot_border_width="";
var plot_shadow=
var plot_shadow="";
var percentage_decimals=
var percentage_decimals="";
var allow_point_select=
var allow_point_select="";
var cursor=
var cursor="";
var dataLabels=
var dataLabels="";
var data_delimiter = series.split(",")[0];
 
var series_name = series.split(",")[1];
var content_array = content.split(data_delimiter);
var series_data = series.split(",")[2].split("data_delimiter");
var result_tmp = getDistinctElements(content_array);
 


var data = [];
var data = [];
for(var i=0, l=series_data .length; i<l; i++){
 
var tmp =series_data [i];
for(var i=0, l=result_tmp .length; i<l; i++){
data.push(tmp);
var tmp =result_tmp [i];
var counted = countItems(content,tmp);
var x = [tmp , counted];
data.push(x);
}
}
var chart;
var chart;
Line 155: Line 162:
});
});


}
function getDistinctElements(anArray) {
      var result = [];
      $.each(anArray, function(i,v){
          if ($.inArray(v, result) == -1) result.push(v);
      });
      return result;
    }
function countItems(arr, what){
    var count= 0, i;
    while((i= arr.indexOf(what, i))!= -1){
        ++count;
        ++i;
    }
    return count;
}
}



Revision as of 14:04, 12 June 2013

This is the "PieChart" template. It should be called in the following format:

{{PieChart
|data=
|chartTitle=
|series=
|chartSize=
|renderTo=
|plotBackgroundColor=
|plotBorderWidth=
|plotShadow=
|percentageDecimals=
|allowPointSelect=
|cursor=
|dataLabels=
}}

Edit the page to see the template text.