65 lines
2.1 KiB
Smalltalk
65 lines
2.1 KiB
Smalltalk
"
|
|
I'm used to help in the citizen oversight of public spending.
|
|
I load scrapped information of public Government sites (starting with
|
|
Colombian ones) and help in its understanding by providing visualizations and other techniques.
|
|
"
|
|
Class {
|
|
#name : #OpenSpending,
|
|
#superclass : #Object,
|
|
#instVars : [
|
|
'contractsData'
|
|
],
|
|
#category : #'Dataviz-OpenSpending'
|
|
}
|
|
|
|
{ #category : #accessing }
|
|
OpenSpending >> contractsData [
|
|
^ contractsData
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
OpenSpending >> contractsData: anObject [
|
|
contractsData := anObject
|
|
]
|
|
|
|
{ #category : #'data import' }
|
|
OpenSpending >> listSectors [
|
|
"I import data from aFile storaged in Comma Separated Values (CSV) format.
|
|
Is supposed that they're taken from a query that contains ths contracting sectors
|
|
according to https://en.wikipedia.org/wiki/UNSPSC"
|
|
| queryResults dbSectorsClassifier |
|
|
dbSectorsClassifier := FileLocator documents / 'DataWeek' / 'clasificador.csv'.
|
|
queryResults := (RTTabTable new input: dbSectorsClassifier contents usingDelimiter: $,) values.
|
|
"table removeFirstRow.
|
|
self contractsData: table."
|
|
^ queryResults
|
|
]
|
|
|
|
{ #category : #'data import' }
|
|
OpenSpending >> loadDataFromCSV: aFile usingDelimiter: aCharacter [
|
|
"I import data from aFile storaged in Comma Separated Values (CSV) format.
|
|
Is supposed that they're taken from a query that sums the sectors of the economy"
|
|
| table |
|
|
table := RTTabTable new input: aFile contents usingDelimiter: aCharacter.
|
|
table removeFirstRow.
|
|
self contractsData: table.
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
OpenSpending >> showTreeMap [
|
|
"I show a treemap visualization of my contract data"
|
|
|
|
| builder popup sectors subtotals |
|
|
popup := RTPopup new.
|
|
sectors := self contractsData valuesOfColumn: 1.
|
|
subtotals := self contractsData valuesOfColumn: 2.
|
|
popup text: [:index | (sectors at: index), String cr, (subtotals at: index) ].
|
|
builder := RTTreeMapBuilder new.
|
|
builder shape color: [:n | Color random].
|
|
builder from: (1 to: (self contractsData numberOfRows)) using: [#()].
|
|
builder weight: [:n | (self contractsData valuesOfColumn: 2) at: n ].
|
|
builder build.
|
|
builder view elements @ popup.
|
|
^ builder view.
|
|
]
|