2022-06-21 16:59:13 +00:00
|
|
|
accessing
|
|
|
|
exportHistogramFor: aDictionary By: aTypeString
|
|
|
|
"TODO: quotes and retweets"
|
2022-06-21 18:20:46 +00:00
|
|
|
| messagesDict histogram diagram tempMessages labels subtotals |
|
2022-06-21 16:59:13 +00:00
|
|
|
tempMessages := self perform: (aDictionary at: 'messagesType') asSymbol.
|
2022-06-21 18:20:46 +00:00
|
|
|
|
2022-06-21 16:59:13 +00:00
|
|
|
tempMessages ifEmpty: [ self exportEmptyHistogramNamed:
|
|
|
|
(aDictionary at: 'messagesType'), '-histogram' ].
|
2022-06-21 18:20:46 +00:00
|
|
|
|
|
|
|
((((aDictionary at: 'messagesType') = 'tweets') or: [(aDictionary at: 'messagesType') = 'replies'])
|
|
|
|
and: aTypeString isNumber)
|
|
|
|
ifTrue: [ messagesDict := tempMessages splitBytimeSpansOf: aTypeString ].
|
2022-06-21 16:59:13 +00:00
|
|
|
(aTypeString = 'day' or: [ aTypeString = 'days' ])
|
2022-06-21 18:20:46 +00:00
|
|
|
ifTrue: [ messagesDict := tempMessages splitByDays ].
|
2022-06-21 16:59:13 +00:00
|
|
|
(aTypeString = 'week' or: [ aTypeString = 'weeks' ])
|
2022-06-21 18:20:46 +00:00
|
|
|
ifTrue: [ messagesDict := tempMessages splitByWeeks ].
|
|
|
|
|
|
|
|
(((aDictionary at: 'messagesType') = 'retweets') or: [ (aDictionary at: 'messagesType') = 'quotes' ])
|
|
|
|
ifTrue: [
|
|
|
|
messagesDict := tempMessages asMessagesUserNamesSortedByOccurrences.
|
|
|
|
((aTypeString > messagesDict size) or: [ aTypeString = 1 ])
|
|
|
|
ifFalse: [ | keysToRemove |
|
|
|
|
keysToRemove := OrderedCollection new.
|
|
|
|
1 to: messagesDict size - aTypeString do:
|
|
|
|
[ :i | keysToRemove add: (messagesDict keys at: i + aTypeString) ].
|
|
|
|
messagesDict removeKeys: keysToRemove. ].
|
|
|
|
labels := messagesDict keys.
|
|
|
|
labels := labels collect: [ :profiles | ('@', profiles) ].
|
|
|
|
subtotals := messagesDict values
|
|
|
|
]
|
|
|
|
ifFalse: [ labels := messagesDict keys.
|
|
|
|
subtotals := (messagesDict values collect: [ :collection | collection size ])].
|
2022-06-21 16:59:13 +00:00
|
|
|
|
|
|
|
histogram := RSChart new.
|
|
|
|
histogram extent: (aDictionary at: 'extent').
|
|
|
|
diagram := RSBarPlot new
|
2022-06-21 18:20:46 +00:00
|
|
|
y: subtotals.
|
2022-06-21 16:59:13 +00:00
|
|
|
diagram color: (aDictionary at: 'color').
|
|
|
|
histogram addPlot: diagram.
|
|
|
|
histogram addDecoration: (RSHorizontalTick new
|
2022-06-21 18:20:46 +00:00
|
|
|
fromNames: labels;
|
2022-06-21 16:59:13 +00:00
|
|
|
labelRotation: 0;
|
2022-06-21 18:20:46 +00:00
|
|
|
fontSize: 68 /messagesDict size;
|
2022-06-21 16:59:13 +00:00
|
|
|
yourself).
|
|
|
|
histogram addDecoration: (RSVerticalTick new
|
|
|
|
integer;
|
2022-06-21 18:20:46 +00:00
|
|
|
fontSize: 68 /messagesDict size).
|
2022-06-21 16:59:13 +00:00
|
|
|
histogram build.
|
|
|
|
^ histogram canvas exportAsFileNamed: (aDictionary at: 'messagesType'), '-histogram' into: self folder
|