Todas as traduções são feitas com o google tradutor
Vou falar em portuñolglish
highcharter
creator/developerQual gráfico funciona bem com: A região sul mostrou o maior aumento
region | Q1 | Q2 | Q3 | Q4 |
---|---|---|---|---|
sur | 100 | 150 | 225 | 290 |
norte | 150 | 160 | 180 | 300 |
este | 180 | 200 | 200 | 240 |
oeste | 250 | 250 | 300 | 170 |
Opção #1
Opção #2
Opção #3
hchart
hchart
hchart
é uma função genérica (semelhante a plot
)## Observations: 53,940
## Variables: 10
## $ carat <dbl> 0.23, 0.21, 0.23, 0.29, 0.31, 0.24, 0.24, 0.26, 0.22, ...
## $ cut <ord> Ideal, Premium, Good, Premium, Good, Very Good, Very G...
## $ color <ord> E, E, E, I, J, J, I, H, E, H, J, J, F, J, E, E, I, J, ...
## $ clarity <ord> SI2, SI1, VS1, VS2, SI2, VVS2, VVS1, SI1, VS2, VS1, SI...
## $ depth <dbl> 61.5, 59.8, 56.9, 62.4, 63.3, 62.8, 62.3, 61.9, 65.1, ...
## $ table <dbl> 55, 61, 65, 58, 58, 57, 57, 55, 61, 61, 55, 56, 61, 54...
## $ price <int> 326, 326, 327, 334, 335, 336, 336, 337, 337, 338, 339,...
## $ x <dbl> 3.95, 3.89, 4.05, 4.20, 4.34, 3.94, 3.95, 4.07, 3.87, ...
## $ y <dbl> 3.98, 3.84, 4.07, 4.23, 4.35, 3.96, 3.98, 4.11, 3.78, ...
## $ z <dbl> 2.43, 2.31, 2.31, 2.63, 2.75, 2.48, 2.47, 2.53, 2.49, ...
Variáveis numéricas
Fatores
Séries temporais
E muito mais:
igraph
, survival
, quantmod
data(citytemp)
citytemp_long <- citytemp %>%
gather(city, temp, -month) %>%
mutate(month = factor(month, month.abb))
glimpse(citytemp_long)
## Observations: 48
## Variables: 3
## $ month <fct> Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, D...
## $ city <chr> "tokyo", "tokyo", "tokyo", "tokyo", "tokyo", "tokyo", "t...
## $ temp <dbl> 7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3,...
hc <- hchart(citytemp_long, "line", hcaes(month, temp, group = city))
hc2 <- hc %>%
hc_xAxis(
title = list(text = "Month in x Axis"),
plotLines = list(list(
label = list(text = "This is a plotLine"),
color = "#FF0000", width = 2, value = 5.5
))
) %>%
hc_yAxis(
title = list(text = "Temperature in y Axis"),
opposite = TRUE,
plotBands = list(list(
from = 25, to = 80, color = "rgba(100, 0, 0, 0.1)",
label = list(text = "This is a plotBand")
))
) %>%
hc_annotations(
list(
labels = list(
list(point = list(x = 7, y = 26.5, xAxis = 0, yAxis = 0), text = "Muito Calor"))
)) %>%
hc_legend(
align = "left", verticalAlign = "top", layout = "vertical"
) %>%
hc_exporting(enabled = TRUE) # "exporting option" :) muito bom recurso
Highcharts (e portante highcharter) have a lot of type of charts implemented. Os clássicos (pie, column, point), mais:
## Observations: 86
## Variables: 3
## $ x <dbl> 0.00000e+00, 3.15569e+10, 6.31138e+10, 9.46707e+10, 1.2622...
## $ y <int> 30, 14, 27, 31, 27, 20, 26, 16, 23, 32, 13, 7, 4, 13, 8, 8...
## $ key <chr> ">700 Tonnes", ">700 Tonnes", ">700 Tonnes", ">700 Tonnes"...
hcspills2 <- hcspills %>%
hc_colors(c("#000000", "#222222")) %>%
hc_title(align = "left", style = list(color = "black")) %>%
hc_plotOptions(series = list(marker = list(enabled = FALSE))) %>%
hc_tooltip(sort = TRUE, table = TRUE) %>%
hc_legend(align = "right",
verticalAlign = "top",
layout = "horizontal") %>%
hc_credits(enabled = TRUE,
text = "Data from ITOPF.com",
href = "http://www.itopf.com/knowledge-resources/data-statistics/statistics/") %>%
hc_chart(divBackgroundImage = "https://images-na.ssl-images-amazon.com/images/I/71EUEG8orVL._SL1500_.jpg",
backgroundColor = hex_to_rgba("white", 0.50)) %>%
hc_xAxis(
opposite = TRUE,
gridLineWidth = 0,
title = list(text = "Time", style = list(color = "black")),
lineColor = "black",
tickColor = "black",
labels = list(style = list(color = "black"))
) %>%
hc_yAxis(
reversed = TRUE,
gridLineWidth = 0,
lineWidth = 1,
lineColor = "black",
tickWidth = 1,
tickLength = 10,
tickColor = "black",
title = list(text = "Oil Spills", style = list(color = "black")),
labels = list(style = list(color = "black"))
) %>%
hc_add_theme(hc_theme_elementary())
Expressar-se com seu próprio estilo
no início, todas as aplicações são semelhantes
O site foi
O site é agora
dabr <- read_excel("data/BasesEstados.xlsx") %>%
select(Sigla, Perc_pobres, Expectativa_anos_de_estudo, Populacao,
PIB, Gini, Agua, Estado, CodigoReg)
glimpse(dabr)
## Observations: 27
## Variables: 9
## $ Sigla <chr> "AC", "AL", "AM", "AP", "BA", "CE",...
## $ Perc_pobres <dbl> 29.46, 34.29, 30.78, 24.07, 28.72, ...
## $ Expectativa_anos_de_estudo <dbl> 8.69, 9.07, 8.54, 9.44, 8.63, 9.82,...
## $ Populacao <dbl> 733559, 3120494, 3483985, 669526, 1...
## $ PIB <dbl> 9629239, 29544708, 64119836, 104195...
## $ Gini <dbl> 0.63, 0.63, 0.65, 0.60, 0.62, 0.61,...
## $ Agua <dbl> 86.51, 77.56, 77.32, 91.44, 85.66, ...
## $ Estado <chr> "Acre", "Alagoas", "Amazonas", "Ama...
## $ CodigoReg <chr> "N", "NE", "N", "N", "NE", "NE", "M...
tooltip_table
permite: “tooltip” as “table” ;)
dabt_temporal <- read_excel("data/BasesEstadosSerie.xlsx") %>%
select(Sigla, x = ANO, y = PIB_Estadual) %>%
nest(-Sigla) %>%
rename(ttdata = data) %>%
mutate(ttdata = map(ttdata, list_parse))
dabt_temporal
## # A tibble: 27 x 2
## Sigla ttdata
## <chr> <list>
## 1 AC <list [26]>
## 2 AL <list [26]>
## 3 AM <list [26]>
## 4 AP <list [26]>
## 5 BA <list [26]>
## 6 CE <list [26]>
## 7 DF <list [26]>
## 8 ES <list [26]>
## 9 GO <list [26]>
## 10 MA <list [26]>
## # ... with 17 more rows
tooltip_chart
permite…
dabr <- left_join(dabr, dabt_temporal, by = "Sigla")
ttchart <- tooltip_chart("ttdata", hc_opts = list(title = list(text = "point.name")),
width = 350, height = 250)
hcbr3 <- hchart(dabr, "point", hcaes(Perc_pobres, Expectativa_anos_de_estudo, z = Populacao, group = CodigoReg, name = Estado)) %>%
hc_tooltip(pointFormatter = ttchart, useHTML = TRUE, headerFormat = "") %>%
hc_plotOptions(series = list(maxSize = 30))
tooltip_chart -> pointFormatter
tooltip_table -> pointFormat
hcbr4 <- hchart(dabr, "pie", hcaes(name = Estado, y = PIB), innerSize = 400) %>%
hc_tooltip(
useHTML = TRUE,
headerFormat = "<b>{point.key}</b>",
pointFormatter = tooltip_chart(
accesor = "ttdata",
hc_opts = list(
credits = list(enabled = FALSE),
plotOptions = list(scatter = list(marker = list(radius = 2)))
),
height = 225
),
positioner = JS(
"function () {
/* one of the most important parts! */
xp = this.chart.chartWidth/2 - this.label.width/2
yp = this.chart.chartHeight/2 - this.label.height/2
return { x: xp, y: yp };
}"),
shadow = FALSE,
borderWidth = 0,
backgroundColor = "transparent",
hideDelay = 1000
)
Eu quase esqueci de mostrar mapas