Socialmetrica/Socialmetrica.package/NitterUser.class/instance/exportTweetsHistogramWithBars..st

46 lines
1.4 KiB
Smalltalk
Raw Normal View History

accessing
exportTweetsHistogramWithBars: aNumberOfBars
| tweetsByTimeSpan subtotals tweetsHistogram diagram |
2022-04-16 17:08:30 +00:00
self tweets ifEmpty: [
tweetsHistogram := RSChart new.
tweetsHistogram extent: 800@200.
tweetsHistogram build.
tweetsHistogram canvas pdfExporter
zoomToShapes;
noFixedShapes;
fileName: (self folder / 'tweets-histogram.pdf')fullName;
export.
^ {self. 'self tweets is empty'}
].
2022-04-16 17:08:30 +00:00
tweetsByTimeSpan := self collectMessages: [ self tweets] byTimeSpanSplits: aNumberOfBars.
subtotals := tweetsByTimeSpan values collect: [ :collection | collection size ].
tweetsHistogram := RSChart new.
tweetsHistogram extent: 800@200.
diagram := RSBarPlot new
x: (1 to: subtotals size)
y:subtotals.
diagram color: (Color r:(91/255) g:(131/255) b:(222/255)).
tweetsHistogram addPlot: diagram.
tweetsHistogram addDecoration: (RSHorizontalTick new
2022-04-16 17:08:30 +00:00
fromNames: tweetsByTimeSpan keys;
labelRotation: 0;
fontSize: 72 /aNumberOfBars;
yourself).
tweetsHistogram addDecoration: (RSVerticalTick new
integer;
fontSize: 72 /aNumberOfBars).
tweetsHistogram build.
tweetsHistogram canvas pngExporter
zoomToShapes;
noFixedShapes;
fileName: (self folder / 'tweets-histogram.png')fullName;
2022-04-19 00:19:49 +00:00
export.
tweetsHistogram canvas pdfExporter
zoomToShapes;
noFixedShapes;
fileName: (self folder / 'tweets-histogram.pdf')fullName;
export.
^ self folder / 'tweets-histogram.png'