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

29 lines
1.0 KiB
Smalltalk
Raw Normal View History

accessing
exportRepliesHistogramWithBars: aNumberOfBars
| tweetsByTimeSpan subtotals repliesColor x tweetsHistogram diagram |
tweetsByTimeSpan := self collectMessages: [ self replies ] byTimeSpanSplits: aNumberOfBars.
subtotals := tweetsByTimeSpan values collect: [ :collection | collection size ].
repliesColor := (Color r:(246/255) g:(185/255) b:(46/255)).
x := 1 to: subtotals size.
tweetsHistogram := RSChart new.
tweetsHistogram extent: 800@200.
diagram := RSBarPlot new x: x y:subtotals.
diagram color: repliesColor.
tweetsHistogram addPlot: diagram.
tweetsHistogram addDecoration: (RSHorizontalTick new
fromNames: tweetsByTimeSpan keys;
labelRotation: 0;
fontSize: 80 /aNumberOfBars;
yourself).
tweetsHistogram addDecoration: (RSVerticalTick new
integer;
fontSize: 80 /aNumberOfBars).
tweetsHistogram build.
tweetsHistogram canvas pngExporter
zoomToShapes;
noFixedShapes;
fileName: (self folder / 'replies-histogram.png')fullName;
export.
^ self folder / 'replies-histogram.png'