Orokorra:
(UPDATE 12/04/07: Added interesgarri beste baliabide amaieran blog beste helbideak lotura errotula bat web oso interesgarria parte bidez)
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.
Planteamendu orokorra honako hau da:
- Sortu zerrenda bat edo liburutegian dokumentu hori du datuak grafikoan nahi duzu.
- Jarri elkartuak Dokumentu liburutegia / Ohiko orri batean zerrenda eta bihurtu datuak ikuspegi web parte (DVWP).
- Aldatzeko DVWP en XSL HTML duten grafiko bat erakusten sortzeko.
Mailako eszenatokia / Setup:
Sortu ditut Izenburua estandarra zutabe bat eta osagarriak zutabe zerrenda pertsonalizatu bat, "Status". This models (Oso simplistically) an "Authorization For Expense" agertokia, non izenburua proiektua eta Egoera-zerrendaren balio bat adierazten du:
- Proposatu
- Prozesuan
- Moteldu da ia izozterarte
Helburua da interaktiboa barra horizontal grafikoan erakusten duen egoera kodeak horiek ekoizteko.
Bizi izan dut zerrenda eta itxura hau atsegin du:
Sortu Datu Ikusi Web Taldea:
Sortu DVWP pertsonalizatua zerrendan gehituz orri bat (gune nire kasuan orria) eta jarraitu argibideak hemen (http://paulgalvin.spaces.live.com/blog/cns!1CC1EDB3DAA9B8AA!395.entry).
Besterik DVWP sortzeko gain, we also need to set the paging property to show all available rows. Niretzat, hau bezalako zerbaiten:
Puntu honetan, 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.
Aldatzeko XSLT:
Orain dela denbora XSLT aldatzeko.
I always use visual studio for this. (Ikusi hemen intellisense buruzko ohar garrantzitsu bat eman duzula asko lagunduko die).
Hutsik proiektu bat gehi lau fitxategiak sortu dut (replacing the words "Original" and "New" egokiak):
- Original.xslt
- New.xslt
- Original Params.xml
- New Params.xml
Nire kasuan, itxura hau atsegin du:
Modify the web part and copy the params and XSL to the "Original" Visual Studio bertsioa.
Helburua da hemen XSL emaitzak bueltan eraldatzeko HTML DVWP kontsulta hori grafiko bat bezala errendatzen batetik sor.
Horretarako, it helps to first consider what the HTML should look like before we get confused by the insanity that is known as "XSL". (Argi izan behar, hau da, besterik gabe, adibide bat; 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:
Dagokion HTML:
<html> <gorputza> <zentro> <taula zabalera = 80%> <tr><td><zentro>Horizontala Bar grafikoa</td></tr> <tr> <td align="center"> <table border="1" width = 80%> <tr> <td width = 10%>Ireki</td> <td><taula = cellpadding"0" = Gelaxka"0" border = 0 width = 50%><tr bgcolor = gorria><td> </td></tr></taula></td> </tr> <tr> <td width = 10%>Itxita</td> <td><taula = cellpadding"0" = Gelaxka"0" border = 0 width = 25%><tr bgcolor = gorria><td> </td></tr></taula></td> </tr> <tr> <td width = 10%>Moteldu da ia izozterarte</td> <td><taula = cellpadding"0" = Gelaxka"0" border = 0 width = 25%><tr bgcolor = gorria><td> </td></tr></taula></td> </tr> </taula> </td> </tr> </taula> </gorputza> </html> |
I used a dead simple approach to creating my bars by setting the background color of a row to "red".
Hartu-hemendik da hau: Azkenean, guztiak egiten ari gara da HTML sortzeko errenkada eta zutabe.
Txantiloi 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:
- Hasi lehenetsi XSL batera I SharePoint Designer eman zidan denean sortu nuen DVWP du.
- Gai hau moztu behera SPD en izan dut 657 lerroak 166 lines.
- I ez du mezurik inguruan parametro XML fitxategi (hau da, XSL aparte, eta ez dakit zer esan nahi izango dituzu denean DVWP aldatzeko bera joan; bi fitxategi alda ditzakezu). Hala eta guztiz ere, ditu errazteko, 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. Gero, remove my calls and insert your own calls to "ShowBar".
- Zulagailu behera bat sortzeko lanak <href bat> hau bezalako: http://server/List?FilterField1=fieldname&FilterValue1=actualFilterValue. This technique may be of value in other contexts. Lehen begiratuan, Behar konplexuagoa formatu bat egokitzen dut pentsatu nuen: 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.
Hemen dago:
<xsl:Estilo orria bertsioa="1.0" baztertzen-emaitza-aurrizkiak="RS z o s ddwrt dt msxsl" |
Emaitzak:
Goitik XSL grafikoaren hau sortzen:
Zulatzeko behera azpiko datuen egoera kodea klik eginez:
Amaitu Pensamientos:
Daiteke hori Generalized?
Graphing kontzeptu hau maite dut, 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, mesedez, ohar bat, iruzkinak edo email me.
Bertikala Grafikoak:
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, please let me know and I’ll gladly link to your blog 🙂
Bertikal grafikoan dituzten erronka dela, grafikoan etiketa direla zailagoa kudeatzeko uste dut, baina, zalantzarik gabe, ez da ezinezkoa.
Eremuaren izena Gotcha en:
Badira gutxienez bi gauzak begiratu zure Eremu izen batekin.
Lehen, a field name with a space has to be escaped in the XSL. This will probably be an issue here:
<xsl:aldagai izena="totalProposed"
hautatu="zenbatu(/dsQueryResponse / Lerroak / Fila[normalizatzeko-espazioa(@ Egoera) = 'Proposamena'])" />
If your "Status" column is actually named "Status Code" then you need to reference it as "Status_x0020_Code":
<xsl:aldagai izena="totalProposed"
hautatu="zenbatu(/dsQueryResponse / Lerroak / Fila[normalizatzeko-espazioa(@ Status_x0020_Code) = 'Proposamena'])" />Bigarren, eta honen inguruan zalantza txiki bat naiz, but you also need to be on the alert for field name changes. If you name your field "Status Code" eta, ondoren, geroago, 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" loturak diagnostikatu eta konpondu arazo hau lagun dezake.
Kolore hori buruz:
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. Adibidez, if the percentage of "stalled" AFE en da > 10% erakutsiko da, gero gorria, otherwise show it in black. Erabili <xsl:aukeratu> hau betetzeko.
Beste baliabide:
- Zehazteko, barne-izena (eta beste ona info) Zerrenda bateko datuen: http://paulgalvin.spaces.live.com/blog/cns!1CC1EDB3DAA9B8AA!134.entry
- Erakutsi SharePoint emandako datu guztiak (gordinak XML): http://paulgalvin.spaces.live.com/blog/cns!1CC1EDB3DAA9B8AA!190.entry
- Talde bat berariazko zutabe espresioa XPath du: http://paulgalvin.spaces.live.com/blog/cns!1CC1EDB3DAA9B8AA!155.entry
- Agindu OWA erabiliz(?). I have not dug into it, baina itxura itxaropentsua, bereziki pie charts for: http://www.waka.dk/Blog/PermaLink,guid,e2532e71-d774-4ac9-8f25-883964b830f4.aspx
Zoriontsu eraldatzen!
<amaieran />