30 lines
1.3 KiB
Smalltalk
30 lines
1.3 KiB
Smalltalk
|
accessing
|
||
|
exportHistogramFor: aDictionary By: aTypeString
|
||
|
"TODO: quotes and retweets"
|
||
|
| messagesByTimeSpan histogram diagram tempMessages |
|
||
|
tempMessages := self perform: (aDictionary at: 'messagesType') asSymbol.
|
||
|
tempMessages ifEmpty: [ self exportEmptyHistogramNamed:
|
||
|
(aDictionary at: 'messagesType'), '-histogram' ].
|
||
|
aTypeString isNumber ifTrue: [ messagesByTimeSpan := tempMessages splitBytimeSpansOf: aTypeString ].
|
||
|
(aTypeString = 'day' or: [ aTypeString = 'days' ])
|
||
|
ifTrue: [ messagesByTimeSpan := tempMessages splitByDays ].
|
||
|
(aTypeString = 'week' or: [ aTypeString = 'weeks' ])
|
||
|
ifTrue: [ messagesByTimeSpan := tempMessages splitByWeeks ].
|
||
|
|
||
|
histogram := RSChart new.
|
||
|
histogram extent: (aDictionary at: 'extent').
|
||
|
diagram := RSBarPlot new
|
||
|
y: (messagesByTimeSpan values collect: [ :collection | collection size ]).
|
||
|
"diagram color: (Color r:(91/255) g:(131/255) b:(222/255))."
|
||
|
diagram color: (aDictionary at: 'color').
|
||
|
histogram addPlot: diagram.
|
||
|
histogram addDecoration: (RSHorizontalTick new
|
||
|
fromNames: messagesByTimeSpan keys;
|
||
|
labelRotation: 0;
|
||
|
fontSize: 68 /messagesByTimeSpan size;
|
||
|
yourself).
|
||
|
histogram addDecoration: (RSVerticalTick new
|
||
|
integer;
|
||
|
fontSize: 68 /messagesByTimeSpan size).
|
||
|
histogram build.
|
||
|
^ histogram canvas exportAsFileNamed: (aDictionary at: 'messagesType'), '-histogram' into: self folder
|