10

I just graduated from university and am currently engaged in product operation in an Internet company. The first quarter has just passed, and the company needs me to submit a product operation data report. Due to the large amount of product user data, order data and other data, I hope to find a Bi product , which supports me to make a beautiful visual report, and also allows me to view the original data document directly in the report content. I will gradually realize my needs from the following two points:

1. Data visualization: I found some Bi tools on the Internet, and they all need to be charged without exception. Finally, I decided to try pyecharts to realize it. Fortunately, I have the basis of self-learning Python, so it is not difficult to implement;
2. Online preview of data documents: After selecting pyecharts, since the final display is a web view, it is necessary to view the original excel document directly on the web page. This implementation is relatively difficult. With the Yongzhongyun preview plug-in version, if you get the treasure, the most important thing is that you only need 2 lines of code to achieve it, and it is completely free!

Here is a screenshot of my data visualization report:
image.png
image.png

Here's a brief description of how to do it:
1. Data visualization report

 import pandas as pd
from pyecharts import options as opts
from pyecharts.charts import Geo, Page, Grid
from pyecharts.globals import ChartType, SymbolType
from pyecharts.charts import Liquid
from pyecharts.charts import Funnel
from pyecharts.globals import ThemeType
from pyecharts.charts import Bar,Bar3D
from pyecharts.charts import Pie
from pyecharts.charts import Line, EffectScatter
from pyecharts import charts

Python library:
Pandas: mainly to read excel source data;
Pyecharts: Bar bar chart, Pie pie chart, Geo map, Liquid droplet chart, Funnel funnel chart, Line line chart Of course, there are other icons that are not used. If you need it, you can go to the official website to check related documents: https://pyecharts.org /#/en-us/intro

Take one of the data view product channel promotion and channel activation as an example, I need to make a pie chart to show

 pie_moblie = (
    Pie()
        .add(
        "推广费",
        [list(z) for z in zip(qudao_mobile, cost_mobile)],
        radius=["20%", "45%"],
        center=["22%", "50%"],
        rosetype="radius",
        label_opts=opts.LabelOpts(is_show=True,formatter='{b}:{d}%' ),
    )
        .add(
        "激活量",
        [list(z) for z in zip(qudao_mobile, jihuo_mobile)],
        radius=["20%", "45%"],
        center=["70%", "50%"],
        rosetype="area",
        label_opts=opts.LabelOpts(is_show=True,formatter='{b}:{d}%'),
    )
        .set_global_opts(title_opts=opts.TitleOpts(title="2022年一季度各渠道消耗&激活"),
                         legend_opts=opts.LegendOpts(is_show=True,)
                         )
)

The effect is as follows:
image.png

After making each view

 page.add(bar3,c3,pie_mobile)
page.render('test.html')

Put the previously made view on a page through page.add(), and finally generate an html page through page.render(), and then make appropriate style adjustments to the generated html to get the final effect shown above.

2. Online preview of the document:
Download the free plugin first

image.png
Put the downloaded plug-in in the same directory as html, and then add the corresponding code to the just generated html according to the sample code

         <div id="click" style="text-align: center; font-size: 10px;font-weight: bold;margin-top:40px;margin-bottom: 70px;">点击查看源数据</div>
    <script>
 
        const url = 'https:/xxxx.com/1.docx'; // url为预览文件地址
 
        document.getElementById('click').onclick = function() {
 
            getFileUrl(url) // 调用getFileUrl方法,预览文件
 
        }

Fill in the url address of the file in the URL, so that "click to view the source data" will appear on the page. After clicking, you can directly preview the office file online without starting the local Office software, and both word excel ppt pdf are supported.

Preview effect:
image.png
image.png

The above is the result of my own work in the past few days. The entire data view does not require any software and is easy to share. Whether it is the data view or the source file preview, there are no device and browser barriers.


徐骏
16 声望3 粉丝