---
title: "销售分析"
author: "Lisa"
output:
flexdashboard::flex_dashboard:
orientation: columns
social: menu
source_code: embed
---
```{r setup, include=FALSE}
library(readxl)
library(highcharter)
library(dplyr);library(tidyr)
library(viridisLite)
library(forecast)
library(treemap)
library(flexdashboard)
library(rbokeh)
library(RgoogleMaps)
require(maps)
require(ggmap)
library(dplyr)
library(htmltools)
library(htmlwidgets)
library(metricsgraphics)
library(RColorBrewer)
library(leaflet)
library(googleVis)
library(shiny)
library(DT)
options(digits=2) # only show 2 digit numbers
```
```{r global, include=FALSE}
# load data in 'global' chunk so it can be shared by all users of the dashboard
ind=read_excel("销售.xlsx")
ind$时间=as.character(ind$时间)
place=read_excel("人员.xlsx")
#add lat and lon by "getGeoCode"
DF= cbind.data.frame(name=place$省份, lat = NA,lon = NA)
place_com =data.frame(place, t(sapply(DF$name, getGeoCode)))
#set up color
col=c("#7ca82b","#f7518e","#cbed97","#f9528d","#ff0202","#a01c01")
```
Amanda
=======================================================================
Column {data-width=500}
-----------------------------------------------------------------------
### 通过率
```{r}
#select 销售=乔健
sale=ind %>% filter(ind$姓名=="乔健")
pass_rate=sale %>% mutate(坏账率 = sale$坏账量/sale$通过量, 通过率 = sale$通过量/sale$总量) %>% mutate(未通过量 = sale$总量-sale$通过量) %>% select(分类,时间,通过量,未通过量,通过率)
#通过率
highchart() %>%
#hc_title(text = "坏账率") %>%
hc_legend(enabled = FALSE) %>%
hc_xAxis(categories = pass_rate$时间) %>%
hc_yAxis_multiples(
list(
title = list(text = "通过率"),
align = "left",
showFirstLabel = FALSE,
showLastLabel = FALSE,
labels = list(format = "{value}", useHTML = TRUE)
),
list(
title = list(text = "通过量"),
align = "right",
showFirstLabel = FALSE,
showLastLabel = FALSE,
labels = list(format = "{value} 单"),
opposite = TRUE
)
) %>%
hc_plotOptions(column = list(stacking = "normal")) %>%
hc_add_series(name = "销售未通过量",
type = "column",
data = filter(pass_rate,分类=="销售")$未通过量,
yAxis = 1,
stack = "M",
color=col[2]) %>%
hc_add_series(name = "销售通过量",
type = "column",
data = filter(pass_rate,分类=="销售")$通过量,
yAxis = 1,
stack = "M",
color=col[1]) %>%
hc_add_series(name = "门店未通过量",
type = "column",
data = filter(pass_rate,分类=="门店")$未通过量,
yAxis = 1,
stack = "F",
color=col[4]) %>%
hc_add_series(name = "门店通过量",
type = "column",
data = filter(pass_rate,分类=="门店")$通过量,
yAxis = 1,
stack = "F",
color=col[3]) %>% #stack by group
hc_add_series(name = "销售通过率", data = filter(pass_rate,分类=="门店")$通过率) %>%
hc_add_series(name = "门店通过率", data = filter(pass_rate,分类=="销售")$通过率) %>%
hc_tooltip(crosshairs = TRUE, #backgroundColor = "gray",
#headerFormat = "This is a custom header
",
shared = F, borderWidth = 5,
valueDecimals = 2,
pointFormat = "{series.name} : {point.y}
总量: {point.stackTotal}")
#%>%hc_add_theme(hc_theme_economist())
```
### 坏账率
```{r}
bad_debt=sale %>%
mutate(坏账率 = sale$坏账量/sale$通过量, 通过率 = sale$通过量/sale$总量) %>% mutate(非坏账量 = sale$通过量-sale$坏账量) %>% select(分类,时间,坏账量,非坏账量,坏账率)
#坏账率
highchart() %>%
#hc_title(text = "坏账率") %>%
hc_legend(enabled = FALSE) %>%
hc_xAxis(categories = bad_debt$时间) %>%
hc_yAxis_multiples(
list(
title = list(text = "坏账率"),
align = "left",
showFirstLabel = FALSE,
showLastLabel = FALSE,
labels = list(format = "{value}", useHTML = TRUE)
),
list(
title = list(text = "坏账量"),
align = "right",
showFirstLabel = FALSE,
showLastLabel = FALSE,
labels = list(format = "{value} 单"),
opposite = TRUE
)
) %>%
hc_plotOptions(column = list(stacking = "normal")) %>%
hc_add_series(name = "销售非坏账量",
type = "column",
data = filter(bad_debt,分类=="销售")$非坏账量,
yAxis = 1,
stack = "M",
color=col[1]) %>%
hc_add_series(name = "销售坏账量",
type = "column",
data = filter(bad_debt,分类=="销售")$坏账量,
yAxis = 1,
stack = "M",
color=col[2]) %>%
hc_add_series(name = "门店非坏账量",
type = "column",
data = filter(bad_debt,分类=="门店")$非坏账量,
yAxis = 1,
stack = "F",
color=col[3]) %>%
hc_add_series(name = "门店坏账量",
type = "column",
data = filter(bad_debt,分类=="门店")$坏账量,
yAxis = 1,
stack = "F",
color=col[4]) %>% #stack by group
hc_add_series(name = "门店坏账率", data = filter(bad_debt,分类=="门店")$坏账率, color=col[6]) %>%
hc_add_series(name = "销售坏账率", data = filter(bad_debt,分类=="销售")$坏账率, color=col[5]) %>%
hc_tooltip(crosshairs = TRUE, #backgroundColor = "gray",
#headerFormat = "This is a custom header
",
shared = F, borderWidth = 5,
valueDecimals = 2,
pointFormat = "{series.name} : {point.y}
总量: {point.stackTotal}")
```
Column {data-width=500}
-----------------------------------------------------------------------
### 数据
```{r}
#sale$ID[1:5]="销售"
#datatable(sale)# %>% formatPercentage(c('坏账率',"通过率"), 2)
#%>% formatDate("时间",'toLocaleDateString')
knitr::kable(sale[,-1])
```
### 销售区域1
```{r}
#use leaflet to plot
m=place_com %>% filter(place_com$姓名=="乔健")
content <- paste0("姓名: Amanda",
"
省份: ",
m$省份,
"
快捷到岗日期: ",
m$快捷到岗日期,
"
销售编号: ",
m$销售编号)
m %>%
leaflet() %>%
addTiles() %>%
setView(lng=104.19540, lat=35.86166, zoom = 4) %>%
addMarkers(lat = ~ lat, lng = ~ lon, popup =content )
```
```{r, results='asis', echo=FALSE,eval=FALSE}
#use givsGeoChart to plot
Geo <- gvisGeoChart(place[1,], locationvar="code", hovervar="姓名",
options=list(region="CN",
displayMode="regions", #show to show data value
resolution="provinces",
colorAxis="{colors:['#71196E', '#71196E']}",
#backgroundColor="#FCFFA4",
width=600, height=400))
#plot(Geo)
Tbl <- gvisTable(place[1,])
G=gvisMerge(Geo, Tbl)
print(G,"chart")
```
Angela
=======================================================================
Column {data-width=500}
-----------------------------------------------------------------------
### 通过率
```{r}
#select 销售=张鹤立
sale=ind %>% filter(ind$姓名=="张鹤立")
pass_rate=sale %>% mutate(坏账率 = sale$坏账量/sale$通过量, 通过率 = sale$通过量/sale$总量) %>% mutate(未通过量 = sale$总量-sale$通过量) %>% select(分类,时间,通过量,未通过量,通过率)
#通过率
highchart() %>%
#hc_title(text = "坏账率") %>%
hc_legend(enabled = FALSE) %>%
hc_xAxis(categories = pass_rate$时间) %>%
hc_yAxis_multiples(
list(
title = list(text = "通过率"),
align = "left",
showFirstLabel = FALSE,
showLastLabel = FALSE,
labels = list(format = "{value}", useHTML = TRUE)
),
list(
title = list(text = "通过量"),
align = "right",
showFirstLabel = FALSE,
showLastLabel = FALSE,
labels = list(format = "{value} 单"),
opposite = TRUE
)
) %>%
hc_plotOptions(column = list(stacking = "normal")) %>%
hc_add_series(name = "销售未通过量",
type = "column",
data = filter(pass_rate,分类=="销售")$未通过量,
yAxis = 1,
stack = "M",
color=col[2]) %>%
hc_add_series(name = "销售通过量",
type = "column",
data = filter(pass_rate,分类=="销售")$通过量,
yAxis = 1,
stack = "M",
color=col[1]) %>%
hc_add_series(name = "门店未通过量",
type = "column",
data = filter(pass_rate,分类=="门店")$未通过量,
yAxis = 1,
stack = "F",
color=col[4]) %>%
hc_add_series(name = "门店通过量",
type = "column",
data = filter(pass_rate,分类=="门店")$通过量,
yAxis = 1,
stack = "F",
color=col[3]) %>% #stack by group
hc_add_series(name = "销售通过率", data = filter(pass_rate,分类=="门店")$通过率) %>%
hc_add_series(name = "门店通过率", data = filter(pass_rate,分类=="销售")$通过率) %>%
hc_tooltip(crosshairs = TRUE, #backgroundColor = "gray",
#headerFormat = "This is a custom header
",
shared = F, borderWidth = 5,
valueDecimals = 2,
pointFormat = "{series.name} : {point.y}
总量: {point.stackTotal}")
#%>%hc_add_theme(hc_theme_economist())
```
### 坏账率
```{r}
bad_debt=sale %>%
mutate(坏账率 = sale$坏账量/sale$通过量, 通过率 = sale$通过量/sale$总量) %>% mutate(非坏账量 = sale$通过量-sale$坏账量) %>% select(分类,时间,坏账量,非坏账量,坏账率)
#坏账率
highchart() %>%
#hc_title(text = "坏账率") %>%
hc_legend(enabled = FALSE) %>%
hc_xAxis(categories = bad_debt$时间) %>%
hc_yAxis_multiples(
list(
title = list(text = "坏账率"),
align = "left",
showFirstLabel = FALSE,
showLastLabel = FALSE,
labels = list(format = "{value}", useHTML = TRUE)
),
list(
title = list(text = "坏账量"),
align = "right",
showFirstLabel = FALSE,
showLastLabel = FALSE,
labels = list(format = "{value} 单"),
opposite = TRUE
)
) %>%
hc_plotOptions(column = list(stacking = "normal")) %>%
hc_add_series(name = "销售非坏账量",
type = "column",
data = filter(bad_debt,分类=="销售")$非坏账量,
yAxis = 1,
stack = "M",
color=col[1]) %>%
hc_add_series(name = "销售坏账量",
type = "column",
data = filter(bad_debt,分类=="销售")$坏账量,
yAxis = 1,
stack = "M",
color=col[2]) %>%
hc_add_series(name = "门店非坏账量",
type = "column",
data = filter(bad_debt,分类=="门店")$非坏账量,
yAxis = 1,
stack = "F",
color=col[3]) %>%
hc_add_series(name = "门店坏账量",
type = "column",
data = filter(bad_debt,分类=="门店")$坏账量,
yAxis = 1,
stack = "F",
color=col[4]) %>% #stack by group
hc_add_series(name = "门店坏账率", data = filter(bad_debt,分类=="门店")$坏账率, color=col[6]) %>%
hc_add_series(name = "销售坏账率", data = filter(bad_debt,分类=="销售")$坏账率, color=col[5]) %>%
hc_tooltip(crosshairs = TRUE, #backgroundColor = "gray",
#headerFormat = "This is a custom header
",
shared = F, borderWidth = 5,
valueDecimals = 2,
pointFormat = "{series.name} : {point.y}
总量: {point.stackTotal}")
```
Column {data-width=500}
-----------------------------------------------------------------------
### 数据
```{r}
knitr::kable(sale[,-1])
```
### 销售区域2
```{r}
#地图地点
m=place_com %>% filter(place_com$姓名=="张鹤立")
content <- paste0("姓名: Angela",
"
省份: ",
m$省份,
"
快捷到岗日期: ",
m$快捷到岗日期,
"
销售编号: ",
m$销售编号)
m %>%
leaflet() %>%
addTiles() %>%
setView(lng=104.19540, lat=35.86166, zoom = 4) %>%
addMarkers(lat = ~ lat, lng = ~ lon, popup =content )
```
Justin
=======================================================================
Column {data-width=500}
-----------------------------------------------------------------------
### 通过率
```{r}
#select 销售=张德康
sale=ind %>% filter(ind$姓名=="张德康")
pass_rate=sale %>% mutate(坏账率 = sale$坏账量/sale$通过量, 通过率 = sale$通过量/sale$总量) %>% mutate(未通过量 = sale$总量-sale$通过量) %>% select(分类,时间,通过量,未通过量,通过率)
#通过率
highchart() %>%
#hc_title(text = "坏账率") %>%
hc_legend(enabled = FALSE) %>%
hc_xAxis(categories = pass_rate$时间) %>%
hc_yAxis_multiples(
list(
title = list(text = "通过率"),
align = "left",
showFirstLabel = FALSE,
showLastLabel = FALSE,
labels = list(format = "{value}", useHTML = TRUE)
),
list(
title = list(text = "通过量"),
align = "right",
showFirstLabel = FALSE,
showLastLabel = FALSE,
labels = list(format = "{value} 单"),
opposite = TRUE
)
) %>%
hc_plotOptions(column = list(stacking = "normal")) %>%
hc_add_series(name = "销售未通过量",
type = "column",
data = filter(pass_rate,分类=="销售")$未通过量,
yAxis = 1,
stack = "M",
color=col[2]) %>%
hc_add_series(name = "销售通过量",
type = "column",
data = filter(pass_rate,分类=="销售")$通过量,
yAxis = 1,
stack = "M",
color=col[1]) %>%
hc_add_series(name = "门店未通过量",
type = "column",
data = filter(pass_rate,分类=="门店")$未通过量,
yAxis = 1,
stack = "F",
color=col[4]) %>%
hc_add_series(name = "门店通过量",
type = "column",
data = filter(pass_rate,分类=="门店")$通过量,
yAxis = 1,
stack = "F",
color=col[3]) %>% #stack by group
hc_add_series(name = "销售通过率", data = filter(pass_rate,分类=="门店")$通过率) %>%
hc_add_series(name = "门店通过率", data = filter(pass_rate,分类=="销售")$通过率) %>%
hc_tooltip(crosshairs = TRUE, #backgroundColor = "gray",
#headerFormat = "This is a custom header
",
shared = F, borderWidth = 5,
valueDecimals = 2,
pointFormat = "{series.name} : {point.y}
总量: {point.stackTotal}")
#%>%hc_add_theme(hc_theme_economist())
```
### 坏账率
```{r}
bad_debt=sale %>%
mutate(坏账率 = sale$坏账量/sale$通过量, 通过率 = sale$通过量/sale$总量) %>% mutate(非坏账量 = sale$通过量-sale$坏账量) %>% select(分类,时间,坏账量,非坏账量,坏账率)
#坏账率
highchart() %>%
#hc_title(text = "坏账率") %>%
hc_legend(enabled = FALSE) %>%
hc_xAxis(categories = bad_debt$时间) %>%
hc_yAxis_multiples(
list(
title = list(text = "坏账率"),
align = "left",
showFirstLabel = FALSE,
showLastLabel = FALSE,
labels = list(format = "{value}", useHTML = TRUE)
),
list(
title = list(text = "坏账量"),
align = "right",
showFirstLabel = FALSE,
showLastLabel = FALSE,
labels = list(format = "{value} 单"),
opposite = TRUE
)
) %>%
hc_plotOptions(column = list(stacking = "normal")) %>%
hc_add_series(name = "销售非坏账量",
type = "column",
data = filter(bad_debt,分类=="销售")$非坏账量,
yAxis = 1,
stack = "M",
color=col[1]) %>%
hc_add_series(name = "销售坏账量",
type = "column",
data = filter(bad_debt,分类=="销售")$坏账量,
yAxis = 1,
stack = "M",
color=col[2]) %>%
hc_add_series(name = "门店非坏账量",
type = "column",
data = filter(bad_debt,分类=="门店")$非坏账量,
yAxis = 1,
stack = "F",
color=col[3]) %>%
hc_add_series(name = "门店坏账量",
type = "column",
data = filter(bad_debt,分类=="门店")$坏账量,
yAxis = 1,
stack = "F",
color=col[4]) %>% #stack by group
hc_add_series(name = "门店坏账率", data = filter(bad_debt,分类=="门店")$坏账率, color=col[6]) %>%
hc_add_series(name = "销售坏账率", data = filter(bad_debt,分类=="销售")$坏账率, color=col[5]) %>%
hc_tooltip(crosshairs = TRUE, #backgroundColor = "gray",
#headerFormat = "This is a custom header
",
shared = F, borderWidth = 5,
valueDecimals = 2,
pointFormat = "{series.name} : {point.y}
总量: {point.stackTotal}")
```
Column {data-width=500}
-----------------------------------------------------------------------
### 数据
```{r}
knitr::kable(sale[,-1])
```
### 销售区域3
```{r}
#地图地点
m=place_com %>% filter(place_com$姓名=="张德康")
content <- paste0("姓名: Justin",
"
省份: ",
m$省份,
"
快捷到岗日期: ",
m$快捷到岗日期,
"
销售编号: ",
m$销售编号)
m %>%
leaflet() %>%
addTiles() %>%
setView(lng=104.19540, lat=35.86166, zoom = 4) %>%
addMarkers(lat = ~ lat, lng = ~ lon, popup =content )
```
Taylor
=======================================================================
Column {data-width=500}
-----------------------------------------------------------------------
### 通过率
```{r}
#select 销售=义鑫
sale=ind %>% filter(ind$姓名=="义鑫")
pass_rate=sale %>% mutate(坏账率 = sale$坏账量/sale$通过量, 通过率 = sale$通过量/sale$总量) %>% mutate(未通过量 = sale$总量-sale$通过量) %>% select(分类,时间,通过量,未通过量,通过率)
#通过率
highchart() %>%
#hc_title(text = "坏账率") %>%
hc_legend(enabled = FALSE) %>%
hc_xAxis(categories = pass_rate$时间) %>%
hc_yAxis_multiples(
list(
title = list(text = "通过率"),
align = "left",
showFirstLabel = FALSE,
showLastLabel = FALSE,
labels = list(format = "{value}", useHTML = TRUE)
),
list(
title = list(text = "通过量"),
align = "right",
showFirstLabel = FALSE,
showLastLabel = FALSE,
labels = list(format = "{value} 单"),
opposite = TRUE
)
) %>%
hc_plotOptions(column = list(stacking = "normal")) %>%
hc_add_series(name = "销售未通过量",
type = "column",
data = filter(pass_rate,分类=="销售")$未通过量,
yAxis = 1,
stack = "M",
color=col[2]) %>%
hc_add_series(name = "销售通过量",
type = "column",
data = filter(pass_rate,分类=="销售")$通过量,
yAxis = 1,
stack = "M",
color=col[1]) %>%
hc_add_series(name = "门店未通过量",
type = "column",
data = filter(pass_rate,分类=="门店")$未通过量,
yAxis = 1,
stack = "F",
color=col[4]) %>%
hc_add_series(name = "门店通过量",
type = "column",
data = filter(pass_rate,分类=="门店")$通过量,
yAxis = 1,
stack = "F",
color=col[3]) %>% #stack by group
hc_add_series(name = "销售通过率", data = filter(pass_rate,分类=="门店")$通过率) %>%
hc_add_series(name = "门店通过率", data = filter(pass_rate,分类=="销售")$通过率) %>%
hc_tooltip(crosshairs = TRUE, #backgroundColor = "gray",
#headerFormat = "This is a custom header
",
shared = F, borderWidth = 5,
valueDecimals = 2,
pointFormat = "{series.name} : {point.y}
总量: {point.stackTotal}")
#%>%hc_add_theme(hc_theme_economist())
```
### 坏账率
```{r}
bad_debt=sale %>%
mutate(坏账率 = sale$坏账量/sale$通过量, 通过率 = sale$通过量/sale$总量) %>% mutate(非坏账量 = sale$通过量-sale$坏账量) %>% select(分类,时间,坏账量,非坏账量,坏账率)
#坏账率
highchart() %>%
#hc_title(text = "坏账率") %>%
hc_legend(enabled = FALSE) %>%
hc_xAxis(categories = bad_debt$时间) %>%
hc_yAxis_multiples(
list(
title = list(text = "坏账率"),
align = "left",
showFirstLabel = FALSE,
showLastLabel = FALSE,
labels = list(format = "{value}", useHTML = TRUE)
),
list(
title = list(text = "坏账量"),
align = "right",
showFirstLabel = FALSE,
showLastLabel = FALSE,
labels = list(format = "{value} 单"),
opposite = TRUE
)
) %>%
hc_plotOptions(column = list(stacking = "normal")) %>%
hc_add_series(name = "销售非坏账量",
type = "column",
data = filter(bad_debt,分类=="销售")$非坏账量,
yAxis = 1,
stack = "M",
color=col[1]) %>%
hc_add_series(name = "销售坏账量",
type = "column",
data = filter(bad_debt,分类=="销售")$坏账量,
yAxis = 1,
stack = "M",
color=col[2]) %>%
hc_add_series(name = "门店非坏账量",
type = "column",
data = filter(bad_debt,分类=="门店")$非坏账量,
yAxis = 1,
stack = "F",
color=col[3]) %>%
hc_add_series(name = "门店坏账量",
type = "column",
data = filter(bad_debt,分类=="门店")$坏账量,
yAxis = 1,
stack = "F",
color=col[4]) %>% #stack by group
hc_add_series(name = "门店坏账率", data = filter(bad_debt,分类=="门店")$坏账率, color=col[6]) %>%
hc_add_series(name = "销售坏账率", data = filter(bad_debt,分类=="销售")$坏账率, color=col[5]) %>%
hc_tooltip(crosshairs = TRUE, #backgroundColor = "gray",
#headerFormat = "This is a custom header
",
shared = F, borderWidth = 5,
valueDecimals = 2,
pointFormat = "{series.name} : {point.y}
总量: {point.stackTotal}")
```
Column {data-width=500}
-----------------------------------------------------------------------
### 数据
```{r}
knitr::kable(sale[,-1])
```
### 销售区域4
```{r}
#地图地点
m=place_com %>% filter(place_com$姓名=="义鑫")
content <- paste0("姓名: Taylor",
"
省份: ",
m$省份,
"
快捷到岗日期: ",
m$快捷到岗日期,
"
销售编号: ",
m$销售编号)
m %>%
leaflet() %>%
addTiles() %>%
setView(lng=104.19540, lat=35.86166, zoom = 4) %>%
addMarkers(lat = ~ lat, lng = ~ lon, popup =content )
```
Megan
=======================================================================
Column {data-width=500}
-----------------------------------------------------------------------
### 通过率
```{r}
#select 销售=肖卓
sale=ind %>% filter(ind$姓名=="肖卓")
pass_rate=sale %>% mutate(坏账率 = sale$坏账量/sale$通过量, 通过率 = sale$通过量/sale$总量) %>% mutate(未通过量 = sale$总量-sale$通过量) %>% select(分类,时间,通过量,未通过量,通过率)
#通过率
highchart() %>%
#hc_title(text = "坏账率") %>%
hc_legend(enabled = FALSE) %>%
hc_xAxis(categories = pass_rate$时间) %>%
hc_yAxis_multiples(
list(
title = list(text = "通过率"),
align = "left",
showFirstLabel = FALSE,
showLastLabel = FALSE,
labels = list(format = "{value}", useHTML = TRUE)
),
list(
title = list(text = "通过量"),
align = "right",
showFirstLabel = FALSE,
showLastLabel = FALSE,
labels = list(format = "{value} 单"),
opposite = TRUE
)
) %>%
hc_plotOptions(column = list(stacking = "normal")) %>%
hc_add_series(name = "销售未通过量",
type = "column",
data = filter(pass_rate,分类=="销售")$未通过量,
yAxis = 1,
stack = "M",
color=col[2]) %>%
hc_add_series(name = "销售通过量",
type = "column",
data = filter(pass_rate,分类=="销售")$通过量,
yAxis = 1,
stack = "M",
color=col[1]) %>%
hc_add_series(name = "门店未通过量",
type = "column",
data = filter(pass_rate,分类=="门店")$未通过量,
yAxis = 1,
stack = "F",
color=col[4]) %>%
hc_add_series(name = "门店通过量",
type = "column",
data = filter(pass_rate,分类=="门店")$通过量,
yAxis = 1,
stack = "F",
color=col[3]) %>% #stack by group
hc_add_series(name = "销售通过率", data = filter(pass_rate,分类=="门店")$通过率) %>%
hc_add_series(name = "门店通过率", data = filter(pass_rate,分类=="销售")$通过率) %>%
hc_tooltip(crosshairs = TRUE, #backgroundColor = "gray",
#headerFormat = "This is a custom header
",
shared = F, borderWidth = 5,
valueDecimals = 2,
pointFormat = "{series.name} : {point.y}
总量: {point.stackTotal}")
#%>%hc_add_theme(hc_theme_economist())
```
### 坏账率
```{r}
bad_debt=sale %>%
mutate(坏账率 = sale$坏账量/sale$通过量, 通过率 = sale$通过量/sale$总量) %>% mutate(非坏账量 = sale$通过量-sale$坏账量) %>% select(分类,时间,坏账量,非坏账量,坏账率)
#坏账率
highchart() %>%
#hc_title(text = "坏账率") %>%
hc_legend(enabled = FALSE) %>%
hc_xAxis(categories = bad_debt$时间) %>%
hc_yAxis_multiples(
list(
title = list(text = "坏账率"),
align = "left",
showFirstLabel = FALSE,
showLastLabel = FALSE,
labels = list(format = "{value}", useHTML = TRUE)
),
list(
title = list(text = "坏账量"),
align = "right",
showFirstLabel = FALSE,
showLastLabel = FALSE,
labels = list(format = "{value} 单"),
opposite = TRUE
)
) %>%
hc_plotOptions(column = list(stacking = "normal")) %>%
hc_add_series(name = "销售非坏账量",
type = "column",
data = filter(bad_debt,分类=="销售")$非坏账量,
yAxis = 1,
stack = "M",
color=col[1]) %>%
hc_add_series(name = "销售坏账量",
type = "column",
data = filter(bad_debt,分类=="销售")$坏账量,
yAxis = 1,
stack = "M",
color=col[2]) %>%
hc_add_series(name = "门店非坏账量",
type = "column",
data = filter(bad_debt,分类=="门店")$非坏账量,
yAxis = 1,
stack = "F",
color=col[3]) %>%
hc_add_series(name = "门店坏账量",
type = "column",
data = filter(bad_debt,分类=="门店")$坏账量,
yAxis = 1,
stack = "F",
color=col[4]) %>% #stack by group
hc_add_series(name = "门店坏账率", data = filter(bad_debt,分类=="门店")$坏账率, color=col[6]) %>%
hc_add_series(name = "销售坏账率", data = filter(bad_debt,分类=="销售")$坏账率, color=col[5]) %>%
hc_tooltip(crosshairs = TRUE, #backgroundColor = "gray",
#headerFormat = "This is a custom header
",
shared = F, borderWidth = 5,
valueDecimals = 2,
pointFormat = "{series.name} : {point.y}
总量: {point.stackTotal}")
```
Column {data-width=500}
-----------------------------------------------------------------------
### 数据
```{r}
knitr::kable(sale[,-1])
```
### 销售区域5
```{r}
#地图地点
m=place_com %>% filter(place_com$姓名=="肖卓")
content <- paste0("姓名: Megan",
"
省份: ",
m$省份,
"
快捷到岗日期: ",
m$快捷到岗日期,
"
销售编号: ",
m$销售编号)
m %>%
leaflet() %>%
addTiles() %>%
setView(lng=104.19540, lat=35.86166, zoom = 4) %>%
addMarkers(lat = ~ lat, lng = ~ lon, popup =content )
```