rtLib — Notes Rich Text Management Library Documentation of rtLib — Notes Rich Text Management Library Download rtLib — Notes Rich Text Management Library FAQ of rtLib — Notes Rich Text Management Library Purchase rtLib — Notes Rich Text Management Library Feedback about rtLib — Notes Rich Text Management Library

Cookbook

Sort text (II) - bar chart

Start search Mail feedback Back to Description


rtHRule rtTable rtColor

add (rtContainer) addNewLine (rtContainer) addNewLine (rTextParagraph) Add (rtCollection) Add (rTextParagraph) Bold Cells Color (rtFontstyle) Color (rtHRule) Current (rTextParagraph) FirstLineLeftMargin Font FontSize hasParagraphBreak NotesColor (rtColor) NotesColor (rtFontstyle) NotesColor (rtHRule) Paragraph RuleHeight RuleWidth setRGB setTab sort Style Typeface

Code fragment from sample "Sort text (II) - bar chart"; see full running samples in downloadable help.
Dim sort As New sorter, text As String ' sorter is an internal class; its syntax and use can change. Just used to demonstrate how it could work
Dim words As Variant, uniqueWords List As Integer
Dim sorted As Variant, sortedVals As Variant

Dim hr As rtHRule

text
= doc.getFirstItem("Body").Text
words = tokenize(text)' internal function that splits up the text
Forall w In words
If w<>"," Then
If Iselement(uniqueWords(Lcase(w))) Then
uniqueWords(Lcase(w)) = uniqueWords(Lcase(w)) + 1
Else
uniqueWords(Lcase(w)) = 1
End If
End If
End Forall

sort.SortOrder=False' descending
Set style = New rtstyle(0)
Set style.Paragraph = New rtParagraphStyle (0)
style.Paragraph.setTab 0, style.Paragraph.firstLineLeftMargin +3*ONE_CM
Set style.Font = New rtFontStyle (0)
With style.Font
.FontSize=11
.Bold = True
.Typeface="Baskerville"
.NotesColor=NOTES_COLOR_DKBLUE
End With

Forall u In uniqueWords
If u>1 Then
Print Listtag(u) &" (" &u &")"
Set rtp = New rTextParagraph (Listtag(u) &" (" &u &")" &Chr(9) )
rtp.hasParagraphBreak = true' and must start with a break (before) !!
Set rtp.Style = style
sort.addObjectNode rtp, u
End If
End Forall

sorted = sort.getObjectValues
sortedVals = sort.getValues
Dim count As Integer, scale As Double
scale = sortedVals(0)/10

'let's put in bar chart first 10 words
dim table as New rtTable(2,10)

Forall rts In sorted

Set hr = New rtHRule(Cint(0.4*ONE_CM))
hr.RuleHeight = sortedVals(count) / scale * ONE_CM
hr.RuleWidth= ONE_CM
Set hr.Color = New rtColor(9)
hr.Color.setRGB (10000*Rnd) Mod 255, (10000*Rnd) Mod 255, (10000*Rnd) Mod 255

Count
= count+1

rts
.Current.breakBefore = True
Set rtp=New rtextParagraph("")' each cell must contain at least an empty paragraph
rtp.hasParagraphBreak = true' and must start with a break (before) !!
table.Cells (2,Count).add rtp
table.Cells (2,Count).add hr
table.Cells (1,Count).add rts
if Count>10 then exit forall
End Forall

' put table in paragraph - table needs it's own paragraph
ctxDump.addnewline 1
ctxDump.add table
ctxDump.addnewline 1