diff --git a/Socialmetrica.package/NitterUser.class/instance/exportTweetsHistogramWithBars..st b/Socialmetrica.package/NitterUser.class/instance/exportTweetsHistogramWithBars..st index 94afa61..cc59c6b 100644 --- a/Socialmetrica.package/NitterUser.class/instance/exportTweetsHistogramWithBars..st +++ b/Socialmetrica.package/NitterUser.class/instance/exportTweetsHistogramWithBars..st @@ -1,17 +1,10 @@ accessing exportTweetsHistogramWithBars: aNumberOfBars - | timeSpans labels tweetsByTimeSpan subtotals tweetsColor x tweetsHistogram diagram | - timeSpans := self tweets timeSpansOf: aNumberOfBars. - labels := (timeSpans collect: [ :timeSpan | - ((timeSpan start asDate asString removeSuffix: '2022'), '→ ', timeSpan end asDate asString removeSuffix: '2022') - ]) asArray. - tweetsByTimeSpan := OrderedCollection new. - 1 to: labels size do: [ :i | - tweetsByTimeSpan add: (self tweets messages select: [ :tweet | - (timeSpans at: i) includes: (tweet created asDateAndTime)]) - ]. - subtotals := tweetsByTimeSpan collect: [ :collection | collection size ]. + | tweetsByTimeSpan subtotals tweetsColor x 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. @@ -20,7 +13,7 @@ exportTweetsHistogramWithBars: aNumberOfBars diagram color: tweetsColor. tweetsHistogram addPlot: diagram. tweetsHistogram addDecoration: (RSHorizontalTick new - fromNames: labels; + fromNames: tweetsByTimeSpan keys; labelRotation: 0; fontSize: 80 /aNumberOfBars; yourself). diff --git a/Socialmetrica.package/TwitterUser.class/instance/collectMessages.byTimeSpanSplits..st b/Socialmetrica.package/TwitterUser.class/instance/collectMessages.byTimeSpanSplits..st new file mode 100644 index 0000000..ab8739e --- /dev/null +++ b/Socialmetrica.package/TwitterUser.class/instance/collectMessages.byTimeSpanSplits..st @@ -0,0 +1,15 @@ +accessing +collectMessages: aBlock byTimeSpanSplits: anInteger + | timespans spanLabels messagesByTimespan | + timespans := aBlock value timeSpansOf: anInteger. + spanLabels := (timespans collect: [ :timeSpan | + ((timeSpan start asDate greaseString removeSuffix: '2022'), '→ ', timeSpan end asDate greaseString removeSuffix: '2022') + ]) asArray. + messagesByTimespan := OrderedDictionary new. + spanLabels doWithIndex: [:label :i | + messagesByTimespan + at: label + put: (aBlock value messages select: [ :message | + (timespans at: i) includes: (message created asDateAndTime)]) + ]. + ^ messagesByTimespan \ No newline at end of file