A principal vantagem deste modelo de gráfico é que ele é extremamente intuitivo, basta uma olhada no gráfico para entender o que está acontecendo. Ele é lido da esquerda para a direita, em que uma ponta significa que a medida está mais “baixa” cor vermelha, e na outra mais “alta” cor verde. Por exemplo, esse gráfico pode ser usado para ilustrar o quanto uma empresa chegou perto de alcançar uma meta.
Exemplos:
library(dplyr)
library(googleVis)
dados
## Month Product Sales
## 1 January Item A 200
## 2 January Item B 300
## 3 February Item A 100
## 4 February Item B 500
## 5 March Item A 200
## 6 March Item B 150
## 7 April Item A 400
## 8 April Item B 300
dados_group_by_Month <- aggregate(Sales ~ Month,
data=dados,
FUN=sum)
dados_group_by_Month
## Month Sales
## 1 April 700
## 2 February 600
## 3 January 500
## 4 March 350
dados_Janeiro <- subset(dados_group_by_Month, Month =='January')
dados_Janeiro
## Month Sales
## 3 January 500
Gauge_Janeiro <- gvisGauge(dados_Janeiro,
options=list(min=0, max=1000,
greenFrom=500, greenTo=1000,
yellowFrom=200, yellowTo=500,
redFrom=0, redTo=200,
width=400, height=400,
minorTicks= 10))
Gauge_Janeiro$html$footer <- NULL
Gauge_Janeiro$html$jsFooter <- NULL
Gauge_Janeiro$html$caption <- NULL
plot(Gauge_Janeiro)
dados_group_by_Product <- aggregate(Sales ~ Product,
data=dados,
FUN=sum)
dados_group_by_Product
Gauge_Product <- gvisGauge(dados_group_by_Product,
options=list(
# Intervalo Total medidor. [min = início, max = final]
min=0, max=2000,
# Intervalo área verde do medidor. [greenFrom = início, greenTo = final]
greenFrom=1600, greenTo=2000,
# Intervalo área amarela do medidor. [yellowFrom = início, yellowTo = final]
yellowFrom=800, yellowTo=1600,
# Intervalo área vermelha do medidor. [redFrom = início, redTo = final]
redFrom=0, redTo=800,
# Largura e Altura do Medidor (No caso de mais de uma dimensão,
# a área será divida pelo número de dimesões).
width=600, height=600,
# Tamanho do subintervalo do medidor.
minorTicks= 10))
# Anulando plot rodapé.
Gauge_Product$html$footer <- NULL
Gauge_Product$html$jsFooter <- NULL
Gauge_Product$html$caption <- NULL
plot(Gauge_Product)
library(googleVis)
Gauge_Janeiro <- gvisGauge(sample_data_gauge,
options=list(min=0, max=1000,
greenFrom=500, greenTo=1000,
yellowFrom=200, yellowTo=500,
redFrom=0, redTo=200,
width=300, height=300,
minorTicks= 10))
Gauge_Janeiro$html$footer <- NULL
Gauge_Janeiro$html$jsFooter <- NULL
Gauge_Janeiro$html$caption <- NULL
plot(Gauge_Janeiro)