Pregled:
(UPDATE 12/04/07: Dodao još jedan zanimljiv resurs na kraju povezuje s drugom blogu koji se bavi to putem vrlo zanimljivog web-dijela)
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.
Ukupna pristup je sljedeći:
- Napravite popis ili biblioteku dokumenata koja sadrži podatke koje želite graf.
- Postavite pridružene knjižnicu dokument / prilagođeni popis na stranicu i pretvoriti ga u web podataka pogled dijelu (DVWP).
- Izmjena DVWP je XSL za generiranje HTML-a na kojima se vidi kao graf.
Poslovni Scenarij / Postava:
Ja sam stvorio prilagođeni popis sa standardnim Naslov stupca i jednu dodatnu kolonu, "Status". This models (Vrlo pojednostavljeno) an "Authorization For Expense" Scenarij u kojem naslov predstavlja projekt i status vrijednost s popisa:
- Predloženi
- U procesu
- Zastoju
Cilj je proizvesti interaktivni šipkom graf koji pokazuje ta oznaka stanja.
Ja sam naseljena popisa i to izgleda ovako:
Stvaranje podataka za web-dio Pogled:
Napravite DVWP dodavanjem prilagođeni popis na stranici (stranica stranica u mom slučaju) i slijedite upute ovdje (http://paulgalvin.spaces.live.com/blog/cns!1CC1EDB3DAA9B8AA!395.entry).
Uz jednostavno stvaranje DVWP, we also need to set the paging property to show all available rows. Za mene je, to izgleda ovako:
U ovom trenutku, 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.
Izmjena XSLT:
Sada je vrijeme za izmjenu XSLT.
I always use visual studio for this. (Vidjeti ovdje za važnu napomenu o INTELLISENSE koji će vam pomoći puno).
I stvoriti prazna projekt dodati četiri nove datoteke (replacing the words "Original" and "New" po potrebi):
- Original.xslt
- New.xslt
- Izvorni Params.xml
- Novi Params.xml
U mom slučaju, to izgleda ovako:
Modify the web part and copy the params and XSL to the "Original" Verzija u Visual Studio.
Cilj je da se ovdje izazvati XSL transformirati rezultate smo dobili natrag od DVWP upita u HTML-a koji čini kao graf.
U tom cilju, it helps to first consider what the HTML should look like before we get confused by the insanity that is known as "XSL". (Da bude jasno, Sljedeći je samo primjer; 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:
Odgovarajući HTML:
<html> <tijelo> <centar> <širina tablice = 80%> <tr><td><centar>Vodoravna traka Grafikon</td></tr> <tr> <td align="center"> <table border="1" Širina = 80%> <tr> <td width = 10%>Otvoreno</td> <td><Tablica cellpadding ="0" cellspacing ="0" border = 0 width = 50%><tr bgcolor = crvena><td> </td></tr></stol></td> </tr> <tr> <td width = 10%>Zatvoreno</td> <td><Tablica cellpadding ="0" cellspacing ="0" border = 0 width = 25%><tr bgcolor = crvena><td> </td></tr></stol></td> </tr> <tr> <td width = 10%>Zastoju</td> <td><Tablica cellpadding ="0" cellspacing ="0" border = 0 width = 25%><tr bgcolor = crvena><td> </td></tr></stol></td> </tr> </stol> </td> </tr> </stol> </tijelo> </html> |
I used a dead simple approach to creating my bars by setting the background color of a row to "red".
Take-away ovdje je to: Na kraju, Svi mi radimo je stvaranje HTML s redaka i stupaca.
Predložak 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:
- Počeo sam sa zadanim XSL koji SharePoint Designer mi dao kad sam prvi put stvorio DVWP.
- Bio sam u mogućnosti smanjiti ovaj dolje od SPD-a 657 linije za 166 lines.
- Nisam zabrljati okolo sa spisom parametara XML (koji je odvojen od XSL i znat ćete što mislim kad idete mijenjati DVWP sama; postoje dvije datoteke možete izmijeniti). Međutim, kako bi se pojednostaviti, 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. Tada, remove my calls and insert your own calls to "ShowBar".
- Spustite se radi stvaranjem <href> ovako: http://server/List?FilterField1=fieldname&FilterValue1=actualFilterValue. This technique may be of value in other contexts. Na početku, Mislila sam da ću morati odgovarati na složenije formatu: 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.
Ovdje je:
<XSL:stilovima verzija="1.0" uključuju-rezultat-prefiksi="RS z oa je ddwrt DT msxsl" |
U Rezultati:
XSL odozgor generira ovaj graf:
Spustite se do temeljnih podataka klikom na statusnoj koda:
Završne misli:
Može li ovo biti generalizirani?
Volim ovaj koncept grafičkim, 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, molimo zabilježite u komentarima ili elektronička pošta mene.
Vertikalni Grafikoni:
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, molim javite mi i rado ću link na svoj blog 🙂
Mislim da je izazov s vertikalnom graf je da su naljepnice za grafu su teže upravljati, ali svakako ne i nemoguće.
Naziv polja Ulovio je:
Postoje najmanje dvije stvari koje treba paziti s nazivima polja.
Prvi, a field name with a space has to be escaped in the XSL. This will probably be an issue here:
<XSL:varijabla ime="totalProposed"
odabrati="brojati(/dsQueryResponse / Redovi / Row[normalizirati-prostor(@ Status) = 'Prijedlog'])" />
If your "Status" column is actually named "Status Code" then you need to reference it as "Status_x0020_Code":
<XSL:varijabla ime="totalProposed"
odabrati="brojati(/dsQueryResponse / Redovi / Row[normalizirati-prostor(@ Status_x0020_Code) = 'Prijedlog'])" />Drugi, i ja sam malo fuzzy na ovo, but you also need to be on the alert for field name changes. If you name your field "Status Code" i onda kasnije, 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" linkovi mogu pomoći u dijagnosticiranju i ispraviti ovu vrstu problema.
O toj boji:
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. Na primjer, if the percentage of "stalled" AFE-a je > 10% tada prikazati u crveno, otherwise show it in black. Koristiti <XSL:izabrati> da to postigne.
Ostali resursi:
- Odredite unutarnji ime (i drugih dobrih info) za podatke u popisu: http://paulgalvin.spaces.live.com/blog/cns!1CC1EDB3DAA9B8AA!134.entry
- Pokaži sve podatke koje SharePoint (sirovo XML): http://paulgalvin.spaces.live.com/blog/cns!1CC1EDB3DAA9B8AA!190.entry
- Nabavite XPath izraz određenog stupca: http://paulgalvin.spaces.live.com/blog/cns!1CC1EDB3DAA9B8AA!155.entry
- Drugi pristup pomoću OWA(?). I have not dug into it, ali izgleda obećavajuće, posebno za dijagrama: http://www.waka.dk/Blog/PermaLink,guid,e2532e71-d774-4ac9-8f25-883964b830f4.aspx
Sretan pretvarajući!
<kraj />