---
title: "Sales Target Dashboard"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: scroll
theme: yeti #"default", "bootstrap", "cerulean", "cosmo", "darkly", "flatly", "journal", "lumen", "paper", "readable", "sandstone", "simplex", "spacelab", "united", "yeti"
source_code: embed
self_contained: true
social: menu
---
```{r setup, include=FALSE}
library(flexdashboard)
library(ggplot2)
library(dplyr)
library(tidyverse)
library(plotly)
```
# Car Sales {data-icon="fa-car"}
## About cars
```{r}
head(mtcars)
```
### 🎯 Sales Target
```{r}
data(mtcars)
sales <- mtcars$mpg
target <- 30
actual <- mean(sales)
```
```{r}
gauge(actual, min = 0, max = target,
sectors = gaugeSectors(
success = c(target*0.8, target),
warning = c(target*0.5, target*0.8),
danger = c(0, target*0.5)
),
label = "Sales Achievement")
```
### 📈 Monthly Sales vs Target
```{r}
df <- data.frame(
Month = 1:12,
Sales = sales[1:12]
)
ggplot(df, aes(Month, Sales)) +
geom_line(size=1, color="blue") +
geom_point(size=2) +
geom_hline(yintercept = target, color="red", linetype="dashed") +
labs(title="Monthly Sales vs Target",
y="Sales", x="Month")
```
## Column2
### Customers
```{r}
valueBox(1200,
caption = "Total Customers",
icon="fa-users",
color="lavender")
```
### Car Showroom

# Motor Trends {data-icon="fa-tachometer"}
## Histogram {.tabset}
### MPG Distribution
```{r}
ggplot(mtcars, aes(x=mpg)) +
geom_histogram(binwidth=2, fill="steelblue", color="white") +
labs(title="Distribution of Miles Per Gallon", x="MPG", y="Count") +
theme_minimal()
```
### Horsepower Distribution
```{r}
ggplot(mtcars, aes(x=hp)) +
geom_histogram(binwidth=20, fill="darkgreen", color="white") +
labs(title="Distribution of Horsepower", x="HP", y="Count") +
theme_minimal()
```
## Pie Chart {.tabset}
### Cars by Cylinder
```{r}
cyl_table <- table(mtcars$cyl)
colors <- c("#66c2a5", "#fc8d62", "#8da0cb")
pie(
cyl_table,
labels = paste0(names(cyl_table), " cyl (", cyl_table, ")"),
col = colors,
main = "Proportion of Cars by Cylinders",
border = "white",
clockwise = TRUE,
radius = 1
)
```