How to make PPT as cool as PyeCharts?

Author | Zhou Zhipeng

Editor-in-Chief | Guo Rui

In the past few days, some small partners in the group have been trapped by a strange demand:

"Pyecharts drawing is both cool and interactive. However, this cool effect often only exists in the analyst's own editor. At best, it generates an html file to hi hi. Is there any way to embed PPT ? "

"Why do you want to embed PPT?" I was a little puzzled.

"For analysts, PPT is the main battlefield to communicate with the business. Of course, it is also the main battlefield with X. Sometimes, a cool picture can make everyone in the conference room call a cow X! "

"Yes! Screenshots are put in there ~" Witty like me.

"Pyecharts without interactive functions have no soul!"

.....

So I searched around and found that the content on how to achieve this requirement is either unclear, extremely troublesome, or completely outdated.

Finally, I found a relatively easy way to share with everyone.

This sentence has a strong subtext: This is to throw a brick and attract jade, friends, there is a way, do not forget each other!

The logic of this method is actually very simple, it can be said to be a primary school application problem:

It is known that the graphics drawn by pyecharts can be saved in html format, open through the web page, and can also view the html source code

It is also known that there is a ppt plug-in that can edit html text codes and finally generate corresponding visual effects

Seeking: How to make pyecharts graph appear in ppt?

Answer: First use pyecharts to draw and generate html files, then view the source code, copy the relevant source code to the PPT plug-in, and click Run.

Let's practice the whole operation with an example.

Note: The author is Win10 system, 2016 version of Office.

Pyecharts generates html files and obtains source code

Here pyecharts drawing directly uses the sample code of the official document:

from pyecharts import options as opts
from pyecharts.charts import PictorialBar
from pyecharts.globals import SymbolType


location = ["山西", "四川", "西藏", "北京", "上海", "内蒙古", "云南", "黑龙江", "广东", "福建"]
values = [13, 42, 67, 81, 86, 94, 166, 220, 249, 262]


c = (
    PictorialBar()
    .add_xaxis(location)
    .add_yaxis(
        "",
        values,
        label_opts=opts.LabelOpts(is_show=False),
        symbol_size=18,
        symbol_repeat="fixed",
        symbol_offset=[0, 0],
        is_symbol_clip=True,
        symbol=SymbolType.ROUND_RECT,
    )
    .reversal_axis()
    .set_global_opts(
        title_opts=opts.TitleOpts(title="PictorialBar-各省份人口数量(虚假数据)"),
        xaxis_opts=opts.AxisOpts(is_show=False),
        yaxis_opts=opts.AxisOpts(
            axistick_opts=opts.AxisTickOpts(is_show=False),
            axisline_opts=opts.AxisLineOpts(
                linestyle_opts=opts.LineStyleOpts(opacity=0)
            ),
        ),
    )
    .render("pictorialbar_base.html")
)

Next, open the generated html file:

Right click or Ctrl + U to view the source code:

We got a long visualization source code, no need to worry about how to write it, just copy it all.

Load the plugin in PPT

Open the PPT, "insert" module to find "get add-on", the old version is "app store".

Then enter "html" in the add-in search box and add the first result "Office Apps Fiddle for PowerPoint":

The network speed is different, this plugin may load for a while, we can wait patiently for a while.

Put the drawing source code into the plugin and run

After loading, we click the "HTML" module above, copy the code, and then click the button in the upper right corner that looks a little like the play button:

Not surprisingly, an ugly error will be reported:

Don't panic, after giving it off, click the gear in the upper right corner:

Then it will automatically return to the interface just before running:

Following the instructions above, we click again on the place in the upper right corner that looks like a play button.

Duang!

The graphic with interactive function that was drawn at the beginning, finally jumped above the PPT:

Put the mouse up, there will be expected data feedback.

We can adjust its size and position in the PPT to maintain the overall aesthetics of the layout.

"I'm going! Such a cool PPT!" Little A, who doesn't understand the data next door, peeped at my computer screen and couldn't help but be surprised.

I took pictures of cats and tigers, and inserted a Sankey diagram in the PPT according to the same process:

"WOC! Cow X!"

Hearing the pleasing praise, I laughed out of the pig ...

Although this is one of the most usable implementation methods I have found at present, the whole process still experienced difficulties and obstacles, and finally a summary of minefield review:

The error will always be reported when running for the first time, ignore the error and run again.

In the end, we generated an interactive graph. The only thing that was missing was that the pillars and gears next to them did not find a hidden method. Fortunately, they were not conspicuous and did not affect the overall situation.

After saving the PPT, open it again and send the file to others to open it. The related interaction diagram will most likely need to be reloaded (ignore the error and run again), so this method of inserting the PPT is suitable for few and precise renderings to achieve It is both simple and stunning.

Because of my poverty, I always run on Windows, Mac has never tried it, and the file is sent to the friends of Mac. It is always displayed as a picture and there is no interactive function. I hope Mac students will also test if there is a solution.

Everyone is welcome to add and explore better methods ...

Author: Zhou Zhipeng, 3-year data analysis, deeply felt fun and the learning process of data analysis in the case of a lack of frustration, then newly opened public number "data is not bragging", regularly updated data analysis techniques relevant and interesting cases (including actual data Set), everyone is welcome to pay attention to exchanges.

Disclaimer: This article is submitted by the author and the copyright belongs to him.

【END】

More exciting recommendations

With Bitcoin as the ransom, WannaRen ransomware strikes twice!

☞Depth | An article to understand the application development of "emotional computing" in retail

☞Three major operators will launch 5G news; Apple and Google team up to track 3 billion users; jQuery 3.5.0 released | Geek Headlines

☞The 360 tycoon who was blocked by Zhou Hongyi from the entire net: grassroots work to 36-year-old counterattack!

☞Your company's virtual machine is still idle? Learn about continuous integration testing practices based on Jenkins and Kubernetes!

☞From Web 1.0 to Web 3.0: detailed analysis of the development and future direction of the Internet in these years

☞One article to understand the application development of "emotional computing" in retail

Every "watching" you order, I take it seriously

Released 1953 original articles · won praise 40000 + · Views 18,170,000 +

Guess you like

Origin blog.csdn.net/csdnnews/article/details/105525461