Refactoring: minor changes in histogram exporters.

This commit is contained in:
ruidajo 2022-04-20 16:59:57 -05:00
parent 57adfca53a
commit f66d93e2ca
6 changed files with 26 additions and 22 deletions

View File

@ -1,14 +1,15 @@
accessing
exportQuotesHistogram
| quotesOccurrences labels diagram x quotesHistogram |
| quotesOccurrences labels diagram quotesHistogram |
quotesOccurrences := self quotesSortedByOccurrences.
x := 1 to: quotesOccurrences size.
labels := quotesOccurrences keys.
quotesHistogram := RSChart new.
quotesHistogram extent: 800@200.
diagram := RSBarPlot new x: x y: quotesOccurrences values.
diagram := RSBarPlot new
x: (1 to: quotesOccurrences size)
y: quotesOccurrences values.
diagram color: (Color r:(89/255) g:(217/255) b:(95/255)).
quotesHistogram addPlot: diagram.
quotesHistogram addDecoration: (RSHorizontalTick new

View File

@ -1,7 +1,7 @@
accessing
exportQuotesHistogramWithBars: aNumberOfBars
| keysToRemove quotes x labels quotesHistogram diagram |
| keysToRemove quotes labels quotesHistogram diagram |
quotes := self quotesSortedByOccurrences.
(aNumberOfBars > quotes size) ifTrue: [ ^ self exportQuotesHistogram ].
keysToRemove := OrderedCollection new.
@ -9,11 +9,12 @@ exportQuotesHistogramWithBars: aNumberOfBars
[ :i | keysToRemove add: (quotes keys at: i + aNumberOfBars) ].
quotes removeKeys: keysToRemove.
x := 1 to: quotes size.
labels := quotes keys.
quotesHistogram := RSChart new.
quotesHistogram extent: 800@200.
diagram := RSBarPlot new x: x y: quotes values.
diagram := RSBarPlot new
x: (1 to: quotes size)
y: quotes values.
diagram color: (Color r:(89/255) g:(217/255) b:(95/255)).
quotesHistogram addPlot: diagram.
quotesHistogram addDecoration: (RSHorizontalTick new

View File

@ -1,16 +1,16 @@
accessing
exportRepliesHistogramWithBars: aNumberOfBars
| tweetsByTimeSpan subtotals repliesColor x tweetsHistogram diagram |
| tweetsByTimeSpan subtotals 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.
diagram := RSBarPlot new
x: (1 to: subtotals size)
y:subtotals.
diagram color: (Color r:(246/255) g:(185/255) b:(46/255)).
tweetsHistogram addPlot: diagram.
tweetsHistogram addDecoration: (RSHorizontalTick new
fromNames: tweetsByTimeSpan keys;

View File

@ -1,15 +1,16 @@
accessing
exportRetweetsHistogram
| retweetsOccurrences labels retweetColor diagram x retweetsHistogram |
| retweetsOccurrences labels retweetColor diagram retweetsHistogram |
retweetsOccurrences := self retweetsSortedByOccurrences.
retweetColor := (Color r:(217/255) g:(56/255) b: (124/255)).
x := 1 to: retweetsOccurrences size.
labels := retweetsOccurrences keys.
retweetsHistogram := RSChart new.
retweetsHistogram extent: 800@200.
diagram := RSBarPlot new x: x y: retweetsOccurrences values.
diagram := RSBarPlot new
x: (1 to: retweetsOccurrences size)
y: retweetsOccurrences values.
diagram color: retweetColor.
retweetsHistogram addPlot: diagram.
retweetsHistogram addDecoration: (RSHorizontalTick new

View File

@ -1,7 +1,7 @@
accessing
exportRetweetsHistogramWithBars: aNumberOfBars
| keysToRemove retweets x labels retweetsHistogram diagram |
| keysToRemove retweets labels retweetsHistogram diagram |
retweets := self retweetsSortedByOccurrences.
(aNumberOfBars > retweets size) ifTrue: [ ^ self exportRetweetsHistogram ].
keysToRemove := OrderedCollection new.
@ -9,11 +9,12 @@ exportRetweetsHistogramWithBars: aNumberOfBars
[ :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 := RSBarPlot new
x: (1 to: retweets size)
y: retweets values.
diagram color: (Color r:(217/255) g:(56/255) b: (124/255)).
retweetsHistogram addPlot: diagram.
retweetsHistogram addDecoration: (RSHorizontalTick new

View File

@ -1,16 +1,16 @@
accessing
exportTweetsHistogramWithBars: aNumberOfBars
| tweetsByTimeSpan subtotals tweetsColor x tweetsHistogram diagram |
| tweetsByTimeSpan subtotals tweetsHistogram diagram |
tweetsByTimeSpan := self collectMessages: [ self tweets] byTimeSpanSplits: aNumberOfBars.
subtotals := tweetsByTimeSpan values collect: [ :collection | collection size ].
tweetsColor := (Color r:(91/255) g:(131/255) b:(222/255)).
x := 1 to: subtotals size.
tweetsHistogram := RSChart new.
tweetsHistogram extent: 800@200.
diagram := RSBarPlot new x: x y:subtotals.
diagram color: tweetsColor.
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
fromNames: tweetsByTimeSpan keys;