Fixing and creating retweets histogram exporters.

This commit is contained in:
ruidajo 2022-04-20 16:27:54 -05:00
parent cde55509bf
commit 66298fc248
2 changed files with 46 additions and 6 deletions

View File

@ -6,19 +6,20 @@ exportRetweetsHistogram
retweetsOccurrences := self retweetsSortedByOccurrences. retweetsOccurrences := self retweetsSortedByOccurrences.
retweetColor := (Color r:(217/255) g:(56/255) b: (124/255)). retweetColor := (Color r:(217/255) g:(56/255) b: (124/255)).
x := 1 to: retweetsOccurrences size. x := 1 to: retweetsOccurrences size.
labels := retweetsOccurrences keys.
retweetsHistogram := RSChart new. retweetsHistogram := RSChart new.
retweetsHistogram extent: 800@200. retweetsHistogram extent: 800@200.
diagram := RSBarPlot new x: x y: retweetsOccurrences values. diagram := RSBarPlot new x: x y: retweetsOccurrences values.
diagram color: retweetColor. diagram color: retweetColor.
retweetsHistogram addPlot: diagram. retweetsHistogram addPlot: diagram.
retweetsHistogram addDecoration: (RSHorizontalTick new retweetsHistogram addDecoration: (RSHorizontalTick new
fromNames: labels; fromNames: labels;
labelRotation: 0; labelRotation: 0;
fontSize: 80 /retweetsOccurrences size; fontSize: 80 /retweetsOccurrences size;
yourself ). yourself).
retweetsHistogram addDecoration: (RSVerticalTick new retweetsHistogram addDecoration: (RSVerticalTick new
integer; integer;
fontSize: 80 /retweetsOccurrences size). fontSize: 80 /retweetsOccurrences size).
retweetsHistogram build. retweetsHistogram build.
retweetsHistogram canvas pdfExporter retweetsHistogram canvas pdfExporter

View File

@ -0,0 +1,39 @@
accessing
exportRetweetsHistogramWithBars: aNumberOfBars
| keysToRemove retweets x labels retweetsHistogram diagram |
retweets := self retweetsSortedByOccurrences.
(aNumberOfBars > retweets size) ifTrue: [ ^ self exportRetweetsHistogram ].
keysToRemove := OrderedCollection new.
1 to: retweets size - aNumberOfBars do:
[ :i | keysToRemove add: (retweets keys at: i + aNumberOfBars) ].
retweets removeKeys: keysToRemove.
x := 1 to: retweets size.
labels := retweets keys.
retweetsHistogram := RSChart new.
retweetsHistogram extent: 800@200.
diagram := RSBarPlot new x: x y: retweets values.
diagram color: (Color r:(217/255) g:(56/255) b: (124/255)).
retweetsHistogram addPlot: diagram.
retweetsHistogram addDecoration: (RSHorizontalTick new
fromNames: labels;
labelRotation: 0;
fontSize: 80 /retweets size;
yourself).
retweetsHistogram addDecoration: (RSVerticalTick new
integer;
fontSize: 80 /retweets size).
retweetsHistogram build.
retweetsHistogram canvas pdfExporter
zoomToShapes;
noFixedShapes;
fileName: (self folder / 'retweets-histogram.pdf')fullName;
export.
retweetsHistogram canvas pngExporter
zoomToShapes;
noFixedShapes;
fileName: (self folder / 'retweets-histogram.png')fullName;
export.
^ self folder / 'retweets-histogram.png'