covidgraphs

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2020 License: CC0-1.0 Imports: 15 Imported by: 0

README

covidgraphs

A library to retrieve and parse plots of the Italian daily pandemic data

This library allows to retrieve data about the pandemic from the daily report on pcm-dpc repository and to create plots using wcharzuk's go-chart library.

Documentation

Index

Constants

View Source
const ProvinceOffset = 149

Variables

This section is empty.

Functions

func AndamentoNazionaleCompleto

func AndamentoNazionaleCompleto(data *[]NationData, title, filename string) (error, string)

Returns a plot including total cases, healed and dead

func AttualmentePositiviNazione

func AttualmentePositiviNazione(data *[]NationData, placeAnnotations bool, title, filename string) (error, string)

Returns a plot including national current positive cases

func CalculateDelta

func CalculateDelta(first int, second int) (float64, string)

Calculates delta between two integer quantities

func DeleteAllPlots

func DeleteAllPlots(folder string)

Deletes plots folder and recreates it

func DeleteFile

func DeleteFile(filename string) error

Deletes the specified file

func FilenameCreator

func FilenameCreator(plotTitle string) (filename string)

Returns a well formatted filename

func FindFirstOccurrenceNation

func FindFirstOccurrenceNation(data *[]NationData, fieldName string, toFind interface{}) (int, error)

Finds the first occurence in the nation data array for the specified field

func FindFirstOccurrenceNote

func FindFirstOccurrenceNote(data *[]NoteData, fieldName string, toFind interface{}) (int, error)

Finds the first occurence in the notes data array for the specified field

func FindFirstOccurrenceProvince

func FindFirstOccurrenceProvince(data *[]ProvinceData, fieldName string, toFind interface{}) (int, error)

Finds the first occurence in the provinces data array for the specified field

func FindFirstOccurrenceRegion

func FindFirstOccurrenceRegion(data *[]RegionData, fieldName string, toFind interface{}) (int, error)

Finds the first occurence in the regions data array for the specified field

func FindLastOccurrenceProvince

func FindLastOccurrenceProvince(data *[]ProvinceData, fieldName string, toFind interface{}) (int, error)

Finds the last occurence in the provinces data array for the specified field

func FindLastOccurrenceRegion

func FindLastOccurrenceRegion(data *[]RegionData, fieldName string, toFind interface{}) (int, error)

Finds the last occurence in the regions data array for the specified field

func GetCentroRegionsNamesList

func GetCentroRegionsNamesList() []string

Returns central regions names list

func GetLastProvincesByRegionName

func GetLastProvincesByRegionName(data *[]ProvinceData, regionName string) *[]ProvinceData

Returns the last provinces data according to the given region name

func GetNation

func GetNation() (*[]NationData, error)

Retrieves and parses nation data from the pcm repo

func GetNordRegionsNamesList

func GetNordRegionsNamesList() []string

Returns northern regions names list

func GetNotes

func GetNotes() (*[]NoteData, error)

Retrieves and parses notes data from the pcm repo

func GetProvinces

func GetProvinces() (*[]ProvinceData, error)

Retrieves and parses provinces data from the pcm repo

func GetRegions

func GetRegions() (*[]RegionData, error)

Retrieves and parses regions data from the pcm repo

func GetRegionsNamesList

func GetRegionsNamesList(data *[]RegionData) []string

Returns regions names list

func GetSudRegionsNamesList

func GetSudRegionsNamesList() []string

Returns southern regions names list

func GetTopTenProvincesTotaleContagi

func GetTopTenProvincesTotaleContagi(data *[]ProvinceData) *[]ProvinceData

Returns top provinces according to field totale_casi

func GetTopTenRegionsTotaleContagi

func GetTopTenRegionsTotaleContagi(data *[]RegionData) *[]RegionData

Returns top regions according to field totale_contagi

func IsGraphExisting

func IsGraphExisting(filename string) bool

Checks if a given plot already exist by title

func NuoviPositiviNazione

func NuoviPositiviNazione(data *[]NationData, placeAnnotations bool, title, filename string) (error, string)

Returns a plot including national new cases

func NuoviPositiviProvincia

func NuoviPositiviProvincia(data *[]ProvinceData, provinceName string, placeAnnotations bool, title, filename string) (error, string)

Returns new cases for the given province

func TotaleDecedutiNazione

func TotaleDecedutiNazione(data *[]NationData, placeAnnotations bool, title, filename string) (error, string)

Returns a plot including national total deaths

func TotaleGuaritiNazione

func TotaleGuaritiNazione(data *[]NationData, placeAnnotations bool, title, filename string) (error, string)

Returns a plot including national total healed

func TotalePositiviNazione

func TotalePositiviNazione(data *[]NationData, placeAnnotations bool, title, filename string) (error, string)

Returns a plot including national total cases

func TotalePositiviProvincia

func TotalePositiviProvincia(data *[]ProvinceData, provinceIndex int, provinceCode int, title, filename string) (error, string)

Returns total cases for the given province

func VociNazione

func VociNazione(data *[]NationData, fieldName []string, nationIndex int, title, filename string) (error, string)

Returns a plot with the national data according to the specified fields

func VociProvince

func VociProvince(data *[]ProvinceData, fieldName []string, provinceIndex int, provinceCode int, title, filename string) (error, string)

Returns a plot with the data of a specified province according to the specified fields

func VociRegione

func VociRegione(data *[]RegionData, fieldName []string, regionIndex int, regionCode int, title, filename string) (error, string)

Returns a plot with the data of a specified region according to the specified fields

Types

type NationData

type NationData struct {
	Data                   string `json:"data"`
	Stato                  string `json:"stato"`
	Ricoverati_con_sintomi int    `json:"ricoverati_con_sintomi"`
	Terapia_intensiva      int    `json:"terapia_intensiva"`
	Totale_ospedalizzati   int    `json:"totale_ospedalizzati"`
	Isolamento_domiciliare int    `json:"isolamento_domiciliare"`
	Totale_positivi        int    `json:"totale_positivi"`
	Nuovi_positivi         int    `json:"nuovi_positivi"`
	Dimessi_guariti        int    `json:"dimessi_guariti"`
	Deceduti               int    `json:"deceduti"`
	Totale_casi            int    `json:"totale_casi"`
	Tamponi                int    `json:"tamponi"`
	Note_it                string `json:"note_it"`
}

National data struct containing fields from the parsed JSON

type NoteData

type NoteData struct {
	Codice           string `json:"codice"`
	Data             string `json:"Data"`
	Regione          string `json:"regione"`
	Provincia        string `json:"provincia"`
	Tipologia_avviso string `json:"tipologia_avviso"`
	Avviso           string `json:"avviso"`
	Note             string `json:"NoteData"`
}

Notes data struct containing fields from the parsed CSV

type ProvinceData

type ProvinceData struct {
	Data                    string  `json:"data"`
	Stato                   string  `json:"stato"`
	Codice_regione          int     `json:"codice_regione"`
	Denominazione_regione   string  `json:"denominazione_regione"`
	Codice_provincia        int     `json:"codice_provincia"`
	Denominazione_provincia string  `json:"denominazione_provincia"`
	Sigla_provincia         string  `json:"sigla_provincia"`
	Lat                     float64 `json:"lat"`
	Long                    float64 `json:"long"`
	Totale_casi             int     `json:"totale_casi"`
	Note_it                 string  `json:"note_it"`

	NuoviCasi int
}

Provincial data struct containing fields from the parsed JSON

type RegionData

type RegionData struct {
	Data                   string  `json:"data"`
	Stato                  string  `json:"stato"`
	Codice_regione         int     `json:"codice_regione"`
	Denominazione_regione  string  `json:"denominazione_regione"`
	Lat                    float64 `json:"lat"`
	Long                   float64 `json:"long"`
	Ricoverati_con_sintomi int     `json:"ricoverati_con_sintomi"`
	Terapia_intensiva      int     `json:"terapia_intensiva"`
	Totale_ospedalizzati   int     `json:"totale_ospedalizzati"`
	Isolamento_domiciliare int     `json:"isolamento_domiciliare"`
	Totale_positivi        int     `json:"totale_positivi"`
	Nuovi_positivi         int     `json:"nuovi_positivi"`
	Dimessi_guariti        int     `json:"dimessi_guariti"`
	Deceduti               int     `json:"deceduti"`
	Totale_casi            int     `json:"totale_casi"`
	Tamponi                int     `json:"tamponi"`
	Note_it                string  `json:"note_it"`
}

Regional data struct containing fields from the parsed JSON

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL