Showing posts with label Tips. Show all posts
Showing posts with label Tips. Show all posts

Saturday, April 11, 2009

Dynamic Charts & Graphs in SharePoint (Part II)




SharePoint allows you to define list views that calculate Sum, Average, Min, Max, Standard Dev, etc. on the items, whenever your list has at least one numeric field or column.

The script below, combined with such a list view, will plot a Google Chart showing those totals dynamically. The chart scale is automatically adjusted with the maximum value to be charted so it fits the designated size in the script.

Once implemented, you can hide the list view web part so only the chart will render on the page. You can also play around with chart parameters within the script, to change chart type, style, size, colors or even build more complex charts. Take a look at the Google Chart API page for reference.

Hope this could be useful.

Here a step-by-step screen capture series:






















<div id="jLoadMe" class="content"></div>



<script src="/jquery/jquery.js" type="text/javascript">

// To load jQuery (redefine the path if necessary)

</script>



<script type="text/javascript">

/*

* Google Chart for list column totals

* By Claudio Cabaleyro (2009)

*/



Array.prototype.max = function() { // function to get the maximum value of Y axis

var max = this[0];

var len = this.length;

for (var i = 1; i < len; i++) if (this[i] > max) max = this[i];

return max;

}



function BuildChartURL(Data, Names) // Adjust Chart Properties below - See Google Charts API for reference

{

MaxData= Math.round(1.1*Data.max()).toString();

var DataPoints= "&amp;chd=t:"+Data.join(",");

var DataTitles= "&amp;chl="+Names.join("|");

var ChType= "cht=bvs"; // Vertical bars type

var ChSize = "&amp;chs=300x200"; //HeighxWidth in px

var ChScale = "&amp;chds=0,"+MaxData; //Vertical scale: 0 through 10% over max series value

var ChLabels ="&amp;chm=N,000000,0,-1,11,-1";

return ("<p><IMG src='http://chart.apis.google.com/chart?"+ChType+ChSize+DataPoints+DataTitles+ChScale+ChLabels+"'/></p>");

}





var ArrayTitle= $('.ms-unselectedtitle:html'); //find all columns in titles row

var TitleTxt = new (Array);

$.each(ArrayTitle, function(i,e)

{

TitleTxt[i] = $(e).text(); // Store ALL column titles in TitleTxt

});



var ArrayTotal= $('.ms-vb2', $('#aggr')); //find all columns in totals row

var TotalTxt = new (Array);

$.each(ArrayTotal, function(i,e)

{

TotalTxt[i] = $(e).text().substr($(e).text().indexOf("= ")+2); // Store ALL column totals in TotalTxt

});



var Titles = new (Array);

var Totals = new (Array);

$.each(TitleTxt, function(i,e) // clear empty elements in totals row

{

if (TotalTxt[i] != "" && TotalTxt[i] != null)

{

Titles.push(TitleTxt[i]);

Totals.push(parseFloat(TotalTxt[i].replace(',','')));

}

});



$("#jLoadMe").append(BuildChartURL(Totals, Titles))

</script>

Saturday, September 27, 2008

Crear Permisos de acceso customizados

Situación
Cuando se necesita que determinado grupo de usuarios pueda agregar documentos a una biblioteca o items a una lista, pero no que pueda editarlos o borrarlos. En otras palabras, los permisos standard que provee el sistema son en algún caso o muy restrictivos ("Read Only") o habilitan más cosas que las necesarias.

Solución
Se pueden definir "Niveles de Permisos" customizados y luego asignar uno de estos niveles a los grupo de usuarios que se necesite.
Tomando como ejemplo una lista a la cual queremos que un grupo pueda agregar items, debemos proceder del siguiente modo:

1) En Home/ Site Settings/ Permissions/ Permision Levels se puede seleccionar Edit Permission Level o New Permission level se define por ejemplo un nivel "AddToList" y se le asignan las opciones de Add items y Read items.

2) Una vez creado este nivel de permisos, se le asigna al grupo en el cual estamos interesados, ingresando en Home/ Site Settings/ People and Groups

3) Por último, en la lista a la cual queremos que ese grupo acceda, en List Settings/ List Permissions, agregamos el grupo, cuyos derechos aparecerán automáticamente asignados.

Tuesday, September 23, 2008

Menú de navegación con íconos y texto

Situación
Deseamos crear un menú de navegación con íconos "subtitulados".

Solución
La Content Editor Web Part nos habilita esta posibilidad. Se debe insertar una tabla HTML (se puede hacer usando el Rich Text Editor) que es la que contendrá un ícono y su respectivo texto en cada celda.

Para lograr el efecto de pasar el mouse sobre el ícono se resalte el texto bajo el mismo, el código dentro de cada celda de la tabla debe tener el siguiente formato:

_____________________________________________________________________________________

<TD width=150 height=121>
<STRONG>
<A title="" href="http://MyPagePath.aspx" target="">
<P align=center>
<IMG style="BORDER-RIGHT: 0px solid; BORDER-TOP: 0px solid; BORDER-LEFT: 0 px solid; WIDTH: 50px; BORDER-BOTTOM: 0px solid" src="http://MyImagePath.jpg" border=0>
</P>
<P align=center><STRONG>MYTITLE</STRONG></P>
</A>
<P align=center></STRONG>&nbsp;</P>
</TD>

____________________________________________________________________________________

Monday, August 25, 2008

Tips varios sobre Listas SharePoint

muchos de estos son a partir del aprendizaje por prueba y error...

* Para definir "Content Types" basados en columnaas de una lista:
- Todas las columnas del "Content Type" deben ser "Site Columns", por lo que conviene primero planificar y definir éstas y luego armar el Content Type

* Para definir KPIs:
Las columnas sobre las cuales se pueden obtener los KPI DEBEN ESTAR PRESENTES EN LA VISTA DEFINIDA COMO DEFAULT. Los valores que se obtengan de la columna elegida se tomarán DESDE LA VISTA INCLUIDA EN LA DEFINICION DEL KPI, que no necesariamente serán los de la vista default.

* La flexibilidad para definir vistas en una lista puede marearnos: si la estructura de columnas no es lo suficientemente estable, los cambios que vamos introduciendo afectan las vistas que hayamos definido y generan retrabajo. Conviene postergar el armado de esas vistas hasta último momento.

* Para que una biblioteca de imágenes o documentos esté disponible en todo el Site Collection deben ser guardadas en las carpetas correspondientes, de lo contrario pueden no estar disponibles cuando se las necesita en algún sub-site.