BI Statement Items.EchartsThematic analysis statements
Project Background:
The Company holds special meetings from time to time to analyze and discuss the operating indicators of the Company's key businesses in order to identify problems and formulate solutions in a timely manner.
Data sources:
Sales data submitted by the relevant sales departments for each directly-managed store and authorized specialty store, cleaned and deposited into theMySQLDatabase. Intercepted order records from 2015-2018.
Click on the image below to display the original high-resolution image:
1. Sales comparison by quarter
Use horizontal bar charts to display sales by year, stacked by quarter to clearly show sales comparisons by quarter of each year, and select any quarter for easy quarter-by-quarter comparisons.
Click on the image below to display the original high-resolution image:
2、Sales and profit analysis by city
Use Geo charts to visualize sales by city, with larger dots indicating higher sales, and add a visual mapping of profits to show the amount of profit brought in by each city. Add ripple effects for cities with sales and margins above a threshold, highlighting the cities that are the core of the current business.
Click on the image below to display the original high-resolution image:
3、Comparison of sales by category
Show sales data for 3 product categories on a monthly basis, using bar charts and adding a timeline to make it easier to switch between years. You can also select or hide each category and analyze them one by one.
Click on the image below to display the original high-resolution image:
4. Regional sales trends
Daily sales trends since 2015, with stacked area charts (Line,stack,area) by region to visualize sales trends by region. You can easily select a time period by using the area zoom control (DataZoom), and you can also select or hide a region by using the legend control.
Click on the image below to display the original high-resolution image:
5. Annual regional sales share
Intuitive display of sales share by region for each year, with the ability to select or hide a region for comparison on a case-by-case basis.
Click on the image below to display the original high-resolution image:
Attachment: Echarts code
Introducing modules:
import numpy as np
import pandas as pd
import pymysql
import pyecharts
from pyecharts.charts import Bar,BMap,Line,Pie,Timeline,Map,Geo,Graph
from pyecharts import options as opts
from pyecharts.globals import ThemeType,GeoType
- 1
- 2
- 3
- 4
- 5
- 6
- 7
1. Sales comparison by quarter
Horizontally stacked bar charts:
bar_smt2 = Bar(init_opts=opts.InitOpts(width="800px",height="260px",theme=ThemeType.DARK))
bar_smt2.add_xaxis(x_year)
bar_smt2.add_yaxis("1st quarter",y_Q1,stack=True)
bar_smt2.add_yaxis("2nd quarter",y_Q2,stack=True)
bar_smt2.add_yaxis("3rd quarter",y_Q2,stack=True)
bar_smt2.add_yaxis("4th quarter",y_Q4,stack=True)
bar_smt2.reversal_axis()
bar_smt2.set_global_opts(legend_opts=opts.LegendOpts(pos_top="10px"),
title_opts=opts.TitleOpts(title="Quarterly Sales Comparison",pos_top="10px",pos_left="30px"))
bar_smt2.set_series_opts(label_opts=opts.LabelOpts(position="inside"))
bar_smt2.render_notebook()
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
2、Sales and profit analysis by city
Geographic Coordinate System:
geo1 = Geo(init_opts=opts.InitOpts(width="800px",height="500px",theme=ThemeType.DARK))
geo1.add_schema(maptype="china",is_roam=False)
for i in range(len(l_cs)):
if l_cp_p[i][1]>10 and l_cs[i][1]>200000: # Ripple Scatter used in areas with margins over 10% and sales over $200K
geo1.add("",[l_cp[i]],type_="effectScatter",symbol_size=l_cs_size[i],color="red")
else:
geo1.add("",[l_cp[i]],type_="scatter",symbol_size=l_cs_size[i],color="red")
geo1.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
geo1.set_global_opts(visualmap_opts=opts.VisualMapOpts(min_=-1000,max_=45000,orient="horizontal",pos_bottom="80px",pos_left="80px"),
title_opts=opts.TitleOpts(title="Sales and profit analysis by city.",subtitle="Size indicates sales, color indicates profit.",pos_left="280px",pos_top="35px"))
geo1.render_notebook()
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
3、Comparison of sales by category
Bar charts, timelines:
tl = Timeline(init_opts=opts.InitOpts(width="900px",height="450px",theme=ThemeType.DARK))
tl.add_schema(is_auto_play=True)
x = ["January","February.","March.","April.","May.","June.","July.","August.","September.","October.","November.","December."]
for i in range(2015,2019):
data_i = data2[data2["Year."]==str(i)]
bar_2 = (
Bar()
.add_xaxis(x)
.add_yaxis("Furniture products",data_i[data_i["Product category"]=="Furniture products"]["Sales"].tolist())
.add_yaxis("Technical products",data_i[data_i["Product category"]=="Technical products"]["Sales"].tolist())
.add_yaxis("Office supplies",data_i[data_i["Product category"]=="Office supplies"]["Sales"].tolist())
)
bar_2.set_global_opts(title_opts=opts.TitleOpts(title="Comparison of sales by category",pos_top="10px",pos_left="100px"),
legend_opts=opts.LegendOpts(pos_top="13px"))
tl.add(bar_2,"{}year".format(i))
tl.render_notebook()
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
4. Regional sales trends
Stacked area maps, data scaling controls:
line4 = Line(init_opts=opts.InitOpts(width="800px",height="500px",theme=ThemeType.DARK))
line4.add_xaxis(x4_date)
line4.add_yaxis("South China",y4_hn,stack=True,areastyle_opts=opts.AreaStyleOpts(opacity=0.9),is_smooth=True)
line4.add_yaxis("North China",y4_hb,stack=True,areastyle_opts=opts.AreaStyleOpts(opacity=0.9),is_smooth=True)
line4.add_yaxis("East China",y4_hd,stack=True,areastyle_opts=opts.AreaStyleOpts(opacity=0.9),is_smooth=True)
line4.add_yaxis("Northeast.",y4_db,stack=True,areastyle_opts=opts.AreaStyleOpts(opacity=0.9),is_smooth=True)
line4.add_yaxis("Northwest.",y4_xb,stack=True,areastyle_opts=opts.AreaStyleOpts(opacity=0.9),is_smooth=True)
line4.add_yaxis("Southwest.",y4_xn,stack=True,areastyle_opts=opts.AreaStyleOpts(opacity=0.9),is_smooth=True)
line4.set_global_opts(datazoom_opts=opts.DataZoomOpts(is_show=True,type_="slider",range_start=80,range_end=80.8),
title_opts=opts.TitleOpts(title="Regional Sales Trends",pos_left="130px",pos_top="5px"),
legend_opts=opts.LegendOpts(pos_top="13px",pos_left="350px"))
line4.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
line4.render_notebook()
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
5. Annual regional sales share
Pie Charts, Ring Nightingale Charts,:
pie5 = Pie(init_opts=opts.InitOpts(width="800px",height="800px",theme=ThemeType.DARK))
pie5.add("2015",l5_2015,rosetype="radius",radius=["12%","30%"],center=["25%","300px"])
pie5.add("2016",l5_2016,rosetype="radius",radius=["12%","30%"],center=["75%","300px"])
pie5.add("2017",l5_2017,rosetype="radius",radius=["12%","30%"],center=["25%","590px"])
pie5.add("2018",l5_2018,rosetype="radius",radius=["12%","30%"],center=["75%","590px"])
pie5.set_global_opts(legend_opts=opts.LegendOpts(pos_top="90px"),
title_opts=opts.TitleOpts(title=" Annual regional sales share ",subtitle="2015/2016/2017/2018",pos_top="20px",pos_left="300px"))
pie5.set_series_opts(label_opts=opts.LabelOpts(color="write",formatter="{d}%",position="top"))
pie5.add("",[["",1]],radius=["0%","0%"],center=["25%","300px"],label_opts=opts.LabelOpts(position="inside",formatter="2015",font_size=20),
tooltip_opts=opts.TooltipOpts(is_show=False,trigger="none"))
pie5.add("",[["",1]],radius=["0%","0%"],center=["75%","300px"],label_opts=opts.LabelOpts(position="inside",formatter="2016",font_size=20),
tooltip_opts=opts.TooltipOpts(is_show=False,trigger="none"))
pie5.add("",[["",1]],radius=["0%","0%"],center=["25%","590px"],label_opts=opts.LabelOpts(position="inside",formatter="2017",font_size=20),
tooltip_opts=opts.TooltipOpts(is_show=False,trigger="none"))
pie5.add("",[["",1]],radius=["0%","0%"],center=["75%","590px"],label_opts=opts.LabelOpts(position="inside",formatter="2018",font_size=20),
tooltip_opts=opts.TooltipOpts(is_show=False,trigger="none"))
pie5.render_notebook()
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17