From 66298fc2487530bd1c2bd2b0338d5b0f55e3eee4 Mon Sep 17 00:00:00 2001 From: ruidajo Date: Wed, 20 Apr 2022 16:27:54 -0500 Subject: [PATCH] Fixing and creating retweets histogram exporters. --- .../instance/exportRetweetsHistogram.st | 13 ++++--- .../exportRetweetsHistogramWithBars..st | 39 +++++++++++++++++++ 2 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 Socialmetrica.package/NitterUser.class/instance/exportRetweetsHistogramWithBars..st diff --git a/Socialmetrica.package/NitterUser.class/instance/exportRetweetsHistogram.st b/Socialmetrica.package/NitterUser.class/instance/exportRetweetsHistogram.st index cf756f4..c53b94a 100644 --- a/Socialmetrica.package/NitterUser.class/instance/exportRetweetsHistogram.st +++ b/Socialmetrica.package/NitterUser.class/instance/exportRetweetsHistogram.st @@ -6,19 +6,20 @@ exportRetweetsHistogram 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 color: retweetColor. retweetsHistogram addPlot: diagram. retweetsHistogram addDecoration: (RSHorizontalTick new - fromNames: labels; - labelRotation: 0; - fontSize: 80 /retweetsOccurrences size; - yourself ). + fromNames: labels; + labelRotation: 0; + fontSize: 80 /retweetsOccurrences size; + yourself). retweetsHistogram addDecoration: (RSVerticalTick new - integer; - fontSize: 80 /retweetsOccurrences size). + integer; + fontSize: 80 /retweetsOccurrences size). retweetsHistogram build. retweetsHistogram canvas pdfExporter diff --git a/Socialmetrica.package/NitterUser.class/instance/exportRetweetsHistogramWithBars..st b/Socialmetrica.package/NitterUser.class/instance/exportRetweetsHistogramWithBars..st new file mode 100644 index 0000000..b63a634 --- /dev/null +++ b/Socialmetrica.package/NitterUser.class/instance/exportRetweetsHistogramWithBars..st @@ -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' \ No newline at end of file