---
title: "Avance de Obra"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
library(ggplot2)
library(plotly)
library(plyr)
# these computing functions are only toy examples
fortalezas = function(...) return(45)
debilidades = function(...) return(126)
amenazas = function(...) return(15)
oportunidades = function(...) return(6)
computeSpam = function(...) return(19)
```


General
===

Column {data-width=350}
-----------------------------------------------------------------------


### Curva de Avance

```{r}
rate <- 86
gauge(rate, min = 0, max = 100, symbol = '%', gaugeSectors(
  success = c(80, 100), warning = c(40, 79), danger = c(0, 39)
))
```

### Hs Hombre Trabajadas vs Disponibles  (hs)

```{r}
rating <- 1720
gauge(rating, min = 0, max = 2499, gaugeSectors(
  success = c(1800, 2499), warning = c(1500, 1799), danger = c(0, 1499)
))
```

### Actividades Improductivas (porcentaje)

```{r}
cancellations <- 7
gauge(cancellations, min = 0, max = 10, gaugeSectors(
  success = c(0, 2), warning = c(3, 6), danger = c(7, 10)
))
```

<hr>



### Puntualidad en la entrega proveedores

```{r}
plot(density(cars$speed))
```



Row 
-----------------------------------------------------------------------
### Localización Retroexcavadora


```{r}
library(leaflet)

m <- leaflet() %>%
  addTiles() %>%  # Add default OpenStreetMap map tiles
  addMarkers(lng=-68.756636, lat=-32.9036298, popup="Centro de Distribución de Cargas Activo")
m  # Print the map
```



Column {data-width=350}
-----------------------------------------------------------------------

### Consumo y eficiencia de combustibles

```{r}
library(ggplot2)
library(plotly)
library(plyr)
set.seed(955)
dat <- data.frame(cond = rep(c("A", "B"), each=10),
                  xvar = 1:20 + rnorm(20,sd=3),
                  yvar = 1:20 + rnorm(20,sd=3))

p <- ggplot(dat, aes(x=xvar+10, y=yvar )) + 
  xlab("Kg_Diesel/Hora") +
  ylab("Distancia en Km") +
            geom_point(shape=1) +     # Use hollow circles
            geom_smooth()            

ggplotly(p)
```

### Zig Bee de operarios

```{r}
df <- data.frame(x <- rchisq(1000, 10, 10),
                 y <- rnorm(1000))

p <- ggplot(df, aes(x, y)) + 
     geom_point(alpha = 0.5) + 
     geom_density_2d() + 
     theme(panel.background = element_rect(fill = '#ffffff'))

ggplotly(p)
```


Dimensiones Estratégicas
===



```{r}

```

Column {data-width=350}
-----------------------------------------------------------------------

### Perspectiva del proceso interno

```{r}

```

### Perspectiva financiera

```{r}

```


Column {data-width=350}
-----------------------------------------------------------------------

### Perspectiva del Cliente

```{r}

```

### Perspectiva del aprendizaje y crecimiento

```{r}

```



KPI
===


Column {data-width=650}
-----------------------------------------------------------------------



### Fortalezas

```{r}

fortalezas = fortalezas()
valueBox(fortalezas, icon = "fa-pencil")



```

### Debilidades
```{r}
spam = computeSpam()
valueBox(
  spam, icon = "fa-trash",
  color = ifelse(spam > 10, "warning", "primary")
)
```


Column {data-width=650}
-----------------------------------------------------------------------


### Amenazas

```{r}

amenazas = amenazas()
valueBox(amenazas, icon = "fa-table", color = "danger")



```

### Oportunidades

```{r}

oportunidades = oportunidades()
valueBox(oportunidades, icon = "fa-anchor")



```


