Template:PieChart: Difference between revisions
From FANTOM5_SSTAR
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 | 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 | var content_array = content.split(data_delimiter); | ||
var | var result_tmp = getDistinctElements(content_array); | ||
var data = []; | var data = []; | ||
for(var i=0, l= | |||
var tmp = | for(var i=0, l=result_tmp .length; i<l; i++){ | ||
data.push( | 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.