Creare Bar graphs in SharePoint

Overview:

(UPDATE 12/04/07: Accessit aliud interesting resource fine ad alterum conjunctio blog quod hoc est per aliquam partem valde interesting)

This blog entry describes how to create a bar graph in SharePoint. This works in both WSS and MOSS environments as it only depends upon the data view web part.

Altiore adventu est ut sequitur:

  1. Partum a album vel documenti library quod continet notitia vis F.
  2. Pone adiunctam document bibliotheca / vectigal elencho onto et convertam page ad a notitia ex parte sententia telam (DVWP).
  3. Temperare scriptor DVWP p generare HTML quod ostendit F.

Negotium Missionem / PRAEFIXUS:

Ego creavi consuetudo album vexillum Title agmine uno addito agmen, "Status". This models (ipsa simplistically) an "Authorization For Expense" quo titulo missionis project repraesentat et status ex numero aestimanda:

  • Proposuerat
  • Evolutis
  • Stabulari

Propositum est ad producendum horizontali bar Lorem ipsum his patet, quod status codicibus F.

Ego similis hoc genus hominum album:

imaginem

Data partum Textus View Parte:

DVWP addendo ad paginam creare consuetudinem album (site pagina causam meam) et sequi mandatis hic (http://paulgalvin.spaces.live.com/blog/cns!1CC1EDB3DAA9B8AA!395.entry).

Praeter simpliciter partum DVWP, we also need to set the paging property to show all available rows. Enim me, hoc spectat huic simile:

imaginem

Ad hoc, I always close SPD and the browser. I then re-open the page using the browser. This avoids accidentally mucking up the web part layout on the page.

Temperare XSLT:

Suus 'iam tempus ad modify XSLT.

I always use visual studio for this. (Videte hic nam circa insigniore note intellisense quod multum proderit).

Fasciculi novi addunt quatuor project ego creo inani (replacing the words "Original" and "New" ut conveniens):

  • Original.xslt
  • New.xslt
  • Original Params.xml
  • New Params.xml

In meam, is vultus amo is:

imaginem

Modify the web part and copy the params and XSL to the "Original" version in Visual Bulla.

Objectum est causa p transfigurare nobis impetro tergum consequitur query in a DVWP HTML reddentis quasi F.

Ad hunc finem, it helps to first consider what the HTML should look like before we get confused by the insanity that is known as "XSL". (Patere, haec est simpliciter exemplum; don’t type it or copy/paste into visual studio. I provide a full blow starting point for that later in the write-up). The following sample graph is rendered as per the HTML immediately following:

Sample Bar Aliquam lacinia purus

Debita HTML:

<html>
<corpus>
<centrum>
<mensam width = LXXX%>
<tr><td><centrum>Aliquam lacinia purus eros Talea</td></tr>
<tr>
<td align="center">
<table border="1" width = LXXX%>
<tr>
<width = p X%>Aperi</td>
<td><mensam cellpadding ="0" cellspacing ="0" border = 0 width = L%><tr = rubrum bgcolor><td>&nbsp;</td></tr></mensamque></td>
</tr>
<tr>
<width = p X%>Concluserat</td>
<td><mensam cellpadding ="0" cellspacing ="0" border = 0% XXV width =><tr = rubrum bgcolor><td>&nbsp;</td></tr></mensamque></td>
</tr>
<tr>
<width = p X%>Stabulari</td>
<td><mensam cellpadding ="0" cellspacing ="0" border = 0% XXV width =><tr = rubrum bgcolor><td>&nbsp;</td></tr></mensamque></td>
</tr>
</mensamque>
</td>
</tr>
</mensamque>
</corpus>
</html>

I used a dead simple approach to creating my bars by setting the background color of a row to "red".

In hac hic accipere-a: In finem, porticus et columnas cum loquimur omnia creavit HTML.

Template XSLT:

I’ve copied the XSLT that generates a horizontal bar graph. It’s fairly well commented so I won’t add much here except for these notes:

  • Coepi cum eo p defaltam SharePoint Designer dedit mihi primo creavit DVWP.
  • EGO eram validus ut interficiam de isto SPD scriptor 657 lineas 166 lines.
  • Non tatam circa ambitum file pron (Et scies quod est separatum a p dico cum ad se temperare DVWP; duo ordines commutare potest). Autem, ut eam simpliciorem, I did remove nearly all of them from the XSL. This means that if you want to make use of those parameters, you just need to add their variable definitions back to the XSL. That will be easy since you will have the original XSL variable definitions in your visual studio project.
  • You ought to be able to copy and paste this directly into your visual studio project. Igitur, remove my calls and insert your own calls to "ShowBar".
  • Ad EXERCITATIO operatur creando <a href> sicut est hodie: http://server/List?FilterField1=fieldname&FilterValue1=actualFilterValue. This technique may be of value in other contexts. Primo, Putabam me opus conformare ad magis complexu format: http://server/List/AllItems.aspx?View={guid}&FilterField1=blah&FilterValue1=blah, but in my environment that is not necessary. The List’s URL is passed to us by SharePoint so this is quite easy to generalize.

Hic est:

<p:stylesheet version="1.0" excludere, unde praemittit,="Rs z o s ddwrt dt msxsl" 
xmlns:msxsl="Urna:Microsoft-schemas com-:xslt" xmlns:p="http://www.w3.org/1999/XSL/Transform"
xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer"
xmlns:áspidis="http://schemas.microsoft.com/ASPNET/20" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
xmlns:O="Urna:Microsoft-schemas com-:muneris" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:Rs="Urna:Microsoft-schemas com-:rowset" xmlns:z="#RowsetSchema"
xmlns:ddwrt2="Urna:frontpage:internum"
> <p:output methodo="html" indent="nulla" /> <p:decimales format- Nan="" /> <p:param nomen="ListUrlDir"></p:param> <!-- Hac-tenus EGO postulo suffrago terebra. --> <p:Template match="/" xmlns:SharePoint="Microsoft.SharePoint.WebControls"
xmlns:__designer=http://schemas.microsoft.com/WebParts/v2/DataView/designer xmlns:áspidis="http://schemas.microsoft.com/ASPNET/20"
> <p:variabilis nomen="dvt_StyleName">Mensam</p:variabilis> <p:variabilis nomen="Deambulacra" elige="/dsQueryResponse / ordinibus / Row" /> <p:variabilis nomen="dvt_RowCount" elige="Numerabitis($Deambulacra)" /> <p:variabilis nomen="IsEmpty" elige="$dvt_RowCount = 0" /> <p:variabilis nomen="dvt_IsEmpty" elige="$dvt_RowCount = 0" /> <p:elegerit> <p:cum test="$dvt_IsEmpty"> Nulla notitia F!<br/> </p:cum> <p:alioqui> <!-- Interesting effercio hic incipitur. Oportet definire par variabilium pro singulis ordinibus in F: Numerus           . --> <p:variabilis nomen="totalProposed" elige="Numerabitis(/dsQueryResponse / ordinibus / Row[normalize spatium-(@ Status) = 'Propositum'])" /> <p:variabilis nomen="percentProposed" elige="$totalProposed p $ dvt_RowCount" /> <p:variabilis nomen="totalInProcess" elige="Numerabitis(/dsQueryResponse / ordinibus / Row[normalize spatium-(@ Status) = 'Processu'])" /> <p:variabilis nomen="percentInProcess" elige="$totalInProcess p $ dvt_RowCount" /> <p:variabilis nomen="totalStalled" elige="Numerabitis(/dsQueryResponse / ordinibus / Row[normalize spatium-(@ Status) = 'Stabulari'])" /> <p:variabilis nomen="percentStalled" elige="$totalStalled p $ dvt_RowCount" /> <!-- Noster hie definimus mensam HTML. Im mutuatus nonnullos signiferos           . Puto colet           . --> <mensamque latitudo="100%" cellspacing="0" cellpadding="2" style="FINIS-IURE: 1 # solidum C0C0C0; FINIS-SOLUM: 1 # solidum C0C0C0; FINIS-sinistram-stilo: solida; FINIS-amplitudo sinistram-: 1; FINIS-stilo summo-: solida; FINIS-width summo-: 1;"> <tr> <td align="centrum"> <mensamque border="1" latitudo="100%"> <!-- Uterque enim status volumus F, we call the "ShowBar" Template. Nos transire,: 1. Nam in versu pittacium. Hoc est permutatum a Hyperlink. 2. In sentio (variabilis desursum). 3. Ipso nomine agro Codicis a subiecta album. Hoc                      . 4. Pro pretio agri matched #3. 5. Summa Codicis status hujus items (Non omnes eu wisi                      ). Emittit <tr></tr> et linea horizontali bar F. Hoc enim ipsum dicimus unicuique ordini Codicis uolumus considerate. --> <p:Template voca- nomen="ShowBar"> <p:cum param- nomen="BarDisplayLabel" elige="'Propositum'"/> <p:cum param- nomen="BarPercent" elige="$percentProposed"/> <p:cum param- nomen="QueryFilterFieldName" elige=""Status""/> <p:cum param- nomen="QueryFilterFieldValue" elige="'Propositum'"/> <p:cum param- nomen="TotalItems" elige="$totalProposed"></p:cum param-> </p:Template voca-> <p:Template voca- nomen="ShowBar"> <p:cum param- nomen="BarDisplayLabel" elige="'Stabulari'"/> <p:cum param- nomen="BarPercent" elige="$percentStalled"/> <p:cum param- nomen="QueryFilterFieldName" elige=""Status""/> <p:cum param- nomen="QueryFilterFieldValue" elige="'Stabulari'"/> <p:cum param- nomen="TotalItems" elige="$totalStalled"></p:cum param-> </p:Template voca-> <p:Template voca- nomen="ShowBar"> <p:cum param- nomen="BarDisplayLabel" elige="'Processu'"/> <p:cum param- nomen="BarPercent" elige="$percentInProcess"/> <p:cum param- nomen="QueryFilterFieldName" elige=""Status""/> <p:cum param- nomen="QueryFilterFieldValue" elige="'Processu'"/> <p:cum param- nomen="TotalItems" elige="$totalInProcess"></p:cum param-> </p:Template voca-> </mensamque> </td> </tr> </mensamque> </p:alioqui> </p:elegerit> </p:Template> <!-- Template hoc facit opus ostentans singulis linearum in bar F. Youll 'forsit plerique vestrum tweaking hie. --> <p:Template nomen="ShowBar"> <p:param nomen="BarDisplayLabel" /> <!-- Pittacium ostendere --> <p:param nomen="BarPercent"/> <!-- Cento totalis. --> <p:param nomen="QueryFilterFieldName"/> <!-- Usus ad salire ad query & spurcamen --> <p:param nomen="QueryFilterFieldValue"/> <!-- Usus ad salire ad query & spurcamen --> <p:param nomen="TotalItems" /> <!-- totam comitis hoc barlabel --> <tr> <!-- Bar ipsum pittacium. --> <td genus="ms-formbody" latitudo="30%"> <!-- Sequenti statuto de hac quaestione sententias aedificat filo sino           . Hic utimur pauca: 1. Possumus transire ad elenchum FilterValue1 FilterField1 et in columna ut spurcamen. 2. SharePoint transiret a key parameter ad nos, ListUrlDir that points to the underlying list against which this DVWP is "running". Est non fun p? --> <p:text disable-output-erepta="Imo"> <![CDATA[<a href ="]]></p:text> <p:valor ex- elige="$ListUrlDir"/> <p:text disable-output-erepta="Imo"><![CDATA[?FilterField1 =]]></p:text> <p:valor ex- elige="$QueryFilterFieldName"/> <p:text disable-output-erepta="Imo"><![CDATA[&FilterValue1 =]]></p:text> <p:valor ex- elige="$QueryFilterFieldValue"/> <p:text disable-output-erepta="Imo"><![CDATA[">]]></p:text> <p:valor ex- elige="$BarDisplayLabel"/> <p:text disable-output-erepta="Imo"><![CDATA[</a>]]></p:text> <!-- Sequenti frenum ostendit aliqui numeri in format: "(totalis / % totalis)" --> (<p:valor ex- elige="$TotalItems"/> / <!-- Hoc facit a nice pro cento nos label. Gratias, Microsoft! --> <p:Template voca- nomen="percentformat"> <p:cum param- nomen="sentio" elige="$BarPercent"/> </p:Template voca->) </td> <!-- Tandem, emittere <td> tag pro se bar.--> <td> <mensamque cellpadding="0" cellspacing="0" border="0" latitudo="{rotundum($C: * BarPercent)+1}%"> <tr bgcolor="red"> <p:text disable-output-erepta="Imo"><![CDATA[&nbsp;]]></p:text> </tr> </mensamque> </td> </tr> </p:Template> <!-- Hoc accipitur immediate ab aliquo p inveni in MS template. --> <p:Template nomen="percentformat"> <p:param nomen="sentio"/> <p:elegerit> <p:cum test="numerum format-($sentio, "@, 0 @ #%;-#,##0%')= "Nan"">0%</p:cum> <p:alioqui> <p:valor ex- elige="numerum format-($sentio, "@, 0 @ #%;-#,##0%')" /> </p:alioqui> </p:elegerit> </p:Template> </p:stylesheet>

Eventus:

Et p hoc de generat supra F:

imaginem

EXERCITATIO ad subjectam strepitando in notitia status Code:

imaginem

Decernentes Cogitata:

Hoc potest esse generativus?

Hoc amo conceptus graphing, but I hate the fact that I have to go in and do so much hand-coding. I’ve given a little thought to whether it can be generalized and I’m optimistic, but I’m also a little fearful that there may be a brick wall somewhere along the path that won’t offer any work-around. If anyone has some good ideas on this, Nibh vel a note in ineo email me.

Verticalis graphs:

This is a horizontal bar graph. It’s certainly possible to create a vertical graph. We just need to change the HTML. I would start the same way: Create an HTML representation of a vertical bar graph and then figure out how to get that via XSL. If anyone is interested in that, I could be persuaded to try it out and work out the kinks. If someone has already done that, Et commodo sciam quod libenter link to vestri blog 🙂

Puto provocatio cum verticali F est titulus pro F sunt procreare difficilius, profecto inpossibilia.

Agro nomen Gotcha scriptor:

Ad minus duo nomina agro tuo quaerere.

Primum, a field name with a space has to be escaped in the XSL. This will probably be an issue here:

        <p:variabilis nomen="totalProposed" 
elige="Numerabitis(/dsQueryResponse / ordinibus / Row[normalize spatium-(@ Status) = 'Propositum'])" />

If your "Status" column is actually named "Status Code" then you need to reference it as "Status_x0020_Code":

   <p:variabilis nomen="totalProposed" 
elige="Numerabitis(/dsQueryResponse / ordinibus / Row[normalize spatium-(@ Status_x0020_Code) = 'Propositum'])" />

Secundo, et sum adhuc, quamquam in hac, but you also need to be on the alert for field name changes. If you name your field "Status Code" et tunc postea, rename it to "AFE Status", the "internal name" does not change. The internal name will still be "Status Code" and must be referenced as "Status_x0020_Code". The "other resources" potest auxilium egritudo links et corrigere hujusmodi Problema.

Circa colorem:

I picked "red" because it’s pleasing to me at the moment. It would not be a big deal to show different colors so as to provide more than just a visual description of a number, but to also provide a useful KPI. Verbigratia, if the percentage of "stalled" AFE est scriptor > 10% deinde ostendere rubro, otherwise show it in black. Utor <p:elegerit> perficerent.

Aliaque:

Beatus transformans!

<Finis />

Scribet ad mea blog!

17 cogitationes on "Creare Bar graphs in SharePoint

  1. B Chris

    Lorem ipsum dolor quaerere munus consummarentur.

    Habeo coetus vult uti SharePoint Survey album facere septimanis tondere. Aucupium? Mauris ut nolint… Vel mutet, quoties ratio mittunt tondere (consilium a septimanis update).

    Atque hanc potui, ut vestibulum diam in defensione, et creans agmine F. Quod non possum praedicere quamvis titulus et bona sunt quæ egebunt incedendo. Ad hoc respondet magis minusve mihi praesto sunt, per singulas hebdomadas.

    Alio modo, si videbo, sed quis inveniatur quodammodo creare ordines et nibh fundatur off of bene available et vitaliter numerum duros coding statuentes hisce potius quam exspectata valores?

  2. Greg Laushine

    Paulus gratias. Valde benevolens. Gratias opus vestrum, Potui adiicere F bar agmine existente DVWP (e.g. munia) facillime cum paucis lineis tui Code.
    Excogitatoris in SharePoint, Et hoc titulo inseruit et eros % perfecta a columnis negotium album. Et thalamum uno posui clicca Cursor. Ego lego inserito agmine ad dexteram. In codice visum, Inveni <td> et substituti <p:text elementum intus in cella tua Code:
    <mensam cellpadding ="0" cellspacing ="0" border ="0"
    width="{rotundum(@ PercentComplete C *)+1}%">
    <tr style="background-color:red">
    <p:text disable-output-escaping="yes"><![CDATA[&nbsp;]]></p:text>
    </tr>
    </mensamque>

    Note I changed the row color code from bgcolor="red" to style="background-color:red"
    Quoque, Duis quis turpis in columna possit (@ PercentComplete) in place of "$BarPercent"
    Greg

  3. Wolfgang
    Paulus, Gratias enim hoc! Exactam eam creavi ego exemplar quod tibi fecerunt, et pene perfecta ópera. There was one tiny issue in row the 2nd paragraph of your code:
    <p:template match="/" xmlns:SharePoint="Microsoft.SharePoint.WebControls"
    xmlns:__designer =http://schemas.microsoft.com/WebParts/v2/DataView/designer xmlns:áspidis ="http://schemas.microsoft.com/ASPNET/20"&gt;
    Corrigi quod operatur sicut et ego post leporem! Nunc at accommodare ad ius meum certo scio, non erit album et duros. (Ego stipes eventus)
    Gratias iterum
    ~ Wolle
  4. Non nomen
    quaestio –
    Quod si in mea F, sed status quidam variabilis volui numerare non arbitror plures?
    Ita, quid, si, verbigratia —
    <p:variable name="RequestsInitialized"
    select="count(/dsQueryResponse / ordinibus / Row[normalize spatium-(@ Status)=’WIP’])" />
    –Res, Volo eam numerare instances of 'Squibb', sed etiam velle aliquid aliud simile est variabilis numerare 'Review nibh.. Quam ut faciam istud?
    Gratias!
  5. Murty Srirangam
    HI Paulus,
    Iam realiter conatus est realiter magnus a vobis. Placeat vobis explicare possunt Unde mihi hoc stipes codicem. Ego creavi a prjoect cum novas quattuor quaternionibus. Quid faciam tibi plenius ostendam potest.
    Gratias agimus tibi
    Murty
  6. Andreas Carrington
    HI, Studeo hoc leviter mitigare ut praesentat F munia contra user notitia in negotium album. @ AssignedTo utitur agmen dicitur, quod sit praesentia agmen user. EGO can adepto is ut propono semel redditur HTML sed cant 'adepto is computare et expandent valores.
    Ideas?
    Gratias
    Andy
  7. Lucas scripsit Patrik:
    HI Paulus,
    post multa!
    Interrogatio:
    Ut agros duabus simul filter: quam potest hoc fieri?
    Verbigratia, unus vestro variabiles vocatur totalStalled et super @ Status Filters.
    Ut rediit filter plures simul tradit reducere alterum agrum meum.
    Et quomodo iam inventum est, ut 'VEL', sed administrare donnot invenire quod 'AND’
    An, OR’ sicut hoc potest fieri:
    <p:variable name="totalStalled" select="count(/dsQueryResponse / ordinibus / Row[normalize spatium-(@ Status) = 'Stalled'] | /dsQueryResponse / ordinibus / Row[normalize spatium-(@ ExtraFilterField) =, Valorem,])" />
  8. Frank

    Ego autem, Using Dashboards in SharePoint’ quaestio. We are a military hospital using MOSS standard for our Intranet and would like to build a dashboard for our Command Group to see ‘real time’ si fieri potest,. Unum principalis prospiceres puncta in realis tempus current workload in facilitate et custodirent eam litteram mutant et descendit (ut habeatis ad click “retrahe”/F5).

    Gratias tibi in progressus,

Aliquam

Tua inscriptio electronica non editis. Velit sunt insignis *