当前位置: 首页>移动开发>正文

Python 获取北上广深历史天气数据并做数据可视化

鍡ㄥ柦锛屽ぇ瀹跺ソ鍛€~杩欓噷鏄埍鐪嬬編濂崇殑鑼滆寽鍛?/h3>
Python 获取北上广深历史天气数据并做数据可视化,第1张

鐭ヨ瘑鐐?

  1. 鍔ㄦ€佹暟鎹姄鍖?/p>

  2. requests鍙戦€佽姹?/p>

  3. 缁撴瀯鍖?闈炵粨鏋勫寲鏁版嵁瑙f瀽

寮€鍙戠幆澧?

  1. python 3.8 杩愯浠g爜

  2. pycharm 2022.3.2 杈呭姪鏁蹭唬鐮?涓撲笟鐗?/p>

  3. requests 鍙戦€佽姹?pip install requests

  4. parsel 瑙f瀽鏁版嵁 pip install parsel

鐖櫕妗堜緥瀹炵幇娴佺▼:

涓€. 鎶撳寘鍒嗘瀽 (鎵惧埌鏁版嵁鏉ユ簮)

https://tianqi.2345.com/Pc/GetHistoryareaInfo%5BareaId%5D=57687&areaInfo%5BareaType%5D=2&date%5Byear%5D=2023&date%5Bmonth%5D=3        

浜? 浠g爜瀹炵幇

  1. 鍙戦€佽姹?(璁块棶 鏁版嵁鏉ユ簮鐨剈rl)

  2. 鑾峰彇鏁版嵁

  3. 鎻愬彇鏁版嵁 (灏嗛渶瑕佺殑淇℃伅鎻愬彇鍑烘潵)

  4. 淇濆瓨鏁版嵁 (淇濆瓨涓篶sv琛ㄦ牸鏁版嵁)

鑾峰彇鏁版嵁

import requests
import parsel
import csv
import execjs

f = open('demo.js', mode='r', encoding='utf-8').read()
ctx = execjs.compile(f)
city_list = ctx.call("get_city")
areaInfoList = []
for city_li in city_list:
    if city_li:
        for city_info in city_li:
            info_list = city_info.split('|')
            for info in info_list:
                city = info.split(' ')[-1]
                city_name = city.split('-')[0]
                city_code = city.split('-')[1]
                areaInfoList.append([city_name, city_code])
# print(areaInfoList)
with open('tianqi.csv', mode='a', newline='', encoding='utf-8') as f:
    csv.writer(f).writerow(["鏃ユ湡", "鏈€楂樻俯", "鏈€浣庢俯", "澶╂皵", "椋庡姏椋庡悜", "绌烘皵璐ㄩ噺鎸囨暟", "鍩庡競"])

for areaInfo in areaInfoList:
    city_name = areaInfo[0]
    city_code = areaInfo[1]
    for year in range(2020, 2023):
        for month in range(1, 13):
            url = f'https://tianqi.2345.com/Pc/GetHistory?areaInfo%5BareaId%5D={city_code}&areaInfo%5BareaType%5D=2&date%5Byear%5D={year}&date%5Bmonth%5D={month}'
            # 1. 鍙戦€佽姹?(璁块棶 鏁版嵁鏉ユ簮鐨剈rl)
            response = requests.get(url)
            # 2. 鑾峰彇鏁版嵁
            json_data = response.json() # .json()鍙互灏嗘嬁鍒扮殑text鍐呭 杞负瀛楀吀鏁版嵁
            # 3. 鎻愬彇鏁版嵁 (灏嗛渶瑕佺殑淇℃伅鎻愬彇鍑烘潵)
            html_data = json_data.get('data')
            # tr
            select = parsel.Selector(html_data)
            trs = select.xpath('//tr')
            for tr in trs[1:]:
                tds = tr.xpath('./td//text()').getall()
                tds.append(city_name)
                print(tds)
                with open('tianqi.csv', mode='a', newline='', encoding='utf-8') as f:
                    csv.writer(f).writerow(tds)

Python 获取北上广深历史天气数据并做数据可视化,第2张

鏁版嵁鍙鍖?/h3>

瀵煎叆鍖?/p>

import pandas as pd
import datetime
from pyecharts import options as opts
from pyecharts.charts import *
from pyecharts.commons.utils import JsCode

璇诲叆鏁版嵁

data = pd.read_csv('澶╂皵.csv')
data

Python 获取北上广深历史天气数据并做数据可视化,第3张

鏁版嵁棰勮

data.sample(5)

data.info()

鍒嗗壊鏃ユ湡/鏄熸湡

data[['鏃ユ湡','鏄熸湡']] = data['鏃ユ湡'].str.split(' ',expand=True,n=1)

data

鍘婚櫎澶氫綑瀛楃

data[['鏈€楂樻俯搴?,'鏈€浣庢俯搴?]] = data[['鏈€楂樻俯搴?,'鏈€浣庢俯搴?]].apply(lambda x: x.str.replace('掳','').replace('', '0'))
data.head()

璁$畻涓嬮洩澶╂皵

data.loc[data['澶╂皵'].str.contains('闆?),'涓嬮洩鍚?]='鏄?
data.fillna('鍚?,inplace=True)

鍒嗗壊鏃ユ湡鏃堕棿

data['鏃ユ湡'] = pd.to_datetime(data['鏃ユ湡'])
data[['鏈€楂樻俯搴?,'鏈€浣庢俯搴?]] = data[['鏈€楂樻俯搴?,'鏈€浣庢俯搴?]].astype('int')

data['骞翠唤'] = data['鏃ユ湡'].dt.year
data['鏈堜唤'] = data['鏃ユ湡'].dt.month
data['鏃?] = data['鏃ユ湡'].dt.day
# 棰勮
data.sample(5)

鍚勫煄甯傚垵闆殑鏃堕棿

s_data = data[data['涓嬮洩鍚?]=='鏄?]
s_data[(s_data['鏈堜唤']>=9)].groupby('骞翠唤').first().reset_index()

Python 获取北上广深历史天气数据并做数据可视化,第4张

鍚勫煄甯備笅闆ぉ姘斿垎甯?/p>

s_data.groupby(['鍩庡競','骞翠唤'])['鏃ユ湡'].count().to_frame('涓嬮洩澶╂暟').reset_index()

鍋氶€忚琛?/h4>
data_bj = data[(data['骞翠唤'] == 2021) & (data['鍩庡競'] == '鍖椾含')]
data_bj = data_bj.groupby(['鏈堜唤','澶╂皵'], as_index=False)['鏃ユ湡'].count()

data_pivot =  pd.pivot(data_bj,
                values='鏃ユ湡',
                index='鏈堜唤',
                columns='澶╂皵')
data_pivot = data_pivot.astype('float')
# 鎸夌収 绱㈠紩骞存湀鍊掑簭鎺掑簭
data_pivot.sort_index(ascending=False,inplace=True)

data_pivot

鍖椾笂骞挎繁2021骞?0鏈堜唤澶╂皵鐑姏鍥惧垎甯?/h4>
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors
import seaborn as sns

#璁剧疆鍏ㄥ眬榛樿瀛椾綋 涓?闆呴粦
plt.rcParams['font.family'] = ['Microsoft YaHei'] 
# 璁剧疆鍏ㄥ眬杞存爣绛惧瓧鍏稿ぇ灏?
plt.rcParams["axes.labelsize"] = 14  
# 璁剧疆鑳屾櫙
sns.set_style("darkgrid",{"font.family":['Microsoft YaHei', 'SimHei']})  
# 璁剧疆鐢诲竷闀垮 鍜?dpi
plt.figure(figsize=(18,8),dpi=100)
# 鑷畾涔夎壊鍗?
cmap = mcolors.LinearSegmentedColormap.from_list("n",['#95B359','#D3CF63','#E0991D','#D96161','#A257D0','#7B1216']) 
# 缁樺埗鐑姏鍥?

ax = sns.heatmap(data_pivot, cmap=cmap, vmax=30, 
                 annot=True, # 鐑姏鍥句笂鏄剧ず鏁板€?
                 linewidths=0.5,
                ) 
# 灏唜杞村埢搴︽斁鍦ㄦ渶涓婇潰
ax.xaxis.set_ticks_position('top') 
plt.title('鍖椾含鏈€杩?0涓湀澶╂皵鍒嗗竷',fontsize=16) #鍥剧墖鏍囬鏂囨湰鍜屽瓧浣撳ぇ灏?
plt.show()
Python 获取北上广深历史天气数据并做数据可视化,第5张
data_gz= data[(data['骞翠唤'] == 2021) & (data['鍩庡競'] == '骞垮窞')]
data_gz = data_gz.groupby(['鏈堜唤','澶╂皵'], as_index=False)['鏃ユ湡'].count()
data_sz= data[(data['骞翠唤'] == 2021) & (data['鍩庡競'] == '娣卞湷')]
data_sz = data_sz.groupby(['鏈堜唤','澶╂皵'], as_index=False)['鏃ユ湡'].count()
data_sh= data[(data['骞翠唤'] == 2021) & (data['鍩庡競'] == '涓婃捣')]
data_sh = data_sh.groupby(['鏈堜唤','澶╂皵'], as_index=False)['鏃ユ湡'].count()

data_pivot_sz =  pd.pivot(data_sz,
                values='鏃ユ湡',
                index='鏈堜唤',
                columns='澶╂皵')
data_pivot_sz = data_pivot_sz.astype('float')
# 鎸夌収 绱㈠紩骞存湀鍊掑簭鎺掑簭
data_pivot_sz.sort_index(ascending=False,inplace=True)

#璁剧疆鍏ㄥ眬榛樿瀛椾綋 涓?闆呴粦
plt.rcParams['font.family'] = ['Microsoft YaHei'] 
# 璁剧疆鍏ㄥ眬杞存爣绛惧瓧鍏稿ぇ灏?
plt.rcParams["axes.labelsize"] = 14  
# 璁剧疆鑳屾櫙
sns.set_style("darkgrid",{"font.family":['Microsoft YaHei', 'SimHei']})  
# 璁剧疆鐢诲竷闀垮 鍜?dpi
plt.figure(figsize=(18,8),dpi=100)
# 鑷畾涔夎壊鍗?
cmap = mcolors.LinearSegmentedColormap.from_list("n",['#95B359','#D3CF63','#E0991D','#D96161','#A257D0','#7B1216']) 
# 缁樺埗鐑姏鍥?

ax_sz = sns.heatmap(data_pivot_sz, cmap=cmap, vmax=31, 
                 annot=True, # 鐑姏鍥句笂鏄剧ず鏁板€?
                 linewidths=0.5,
                ) 
# 灏唜杞村埢搴︽斁鍦ㄦ渶涓婇潰
ax_sz.xaxis.set_ticks_position('top') 
plt.title('娣卞湷鏈€杩?0涓湀澶╂皵鍒嗗竷',fontsize=16) #鍥剧墖鏍囬鏂囨湰鍜屽瓧浣撳ぇ灏?
plt.show()

Python 获取北上广深历史天气数据并做数据可视化,第6张
data_pivot_gz =  pd.pivot(data_gz,
                values='鏃ユ湡',
                index='鏈堜唤',
                columns='澶╂皵')
data_pivot_gz = data_pivot_gz.astype('float')
# 鎸夌収 绱㈠紩骞存湀鍊掑簭鎺掑簭
data_pivot_gz.sort_index(ascending=False,inplace=True)

#璁剧疆鍏ㄥ眬榛樿瀛椾綋 涓?闆呴粦
plt.rcParams['font.family'] = ['Microsoft YaHei'] 
# 璁剧疆鍏ㄥ眬杞存爣绛惧瓧鍏稿ぇ灏?
plt.rcParams["axes.labelsize"] = 14  
# 璁剧疆鑳屾櫙
sns.set_style("darkgrid",{"font.family":['Microsoft YaHei', 'SimHei']})  
# 璁剧疆鐢诲竷闀垮 鍜?dpi
plt.figure(figsize=(18,8),dpi=100)
# 鑷畾涔夎壊鍗?
cmap = mcolors.LinearSegmentedColormap.from_list("n",['#95B359','#D3CF63','#E0991D','#D96161','#A257D0','#7B1216']) 
# 缁樺埗鐑姏鍥?

ax_sz = sns.heatmap(data_pivot_gz, cmap=cmap, vmax=31, 
                 annot=True, # 鐑姏鍥句笂鏄剧ず鏁板€?
                 linewidths=0.5,
                ) 
# 灏唜杞村埢搴︽斁鍦ㄦ渶涓婇潰
ax_sz.xaxis.set_ticks_position('top') 
plt.title('骞垮窞鏈€杩?0涓湀澶╂皵鍒嗗竷',fontsize=16) #鍥剧墖鏍囬鏂囨湰鍜屽瓧浣撳ぇ灏?
plt.show()

Python 获取北上广深历史天气数据并做数据可视化,第7张
data_pivot_sh =  pd.pivot(data_sh,
                values='鏃ユ湡',
                index='鏈堜唤',
                columns='澶╂皵')
data_pivot_sh = data_pivot_sh.astype('float')
# 鎸夌収 绱㈠紩骞存湀鍊掑簭鎺掑簭
data_pivot_sh.sort_index(ascending=False,inplace=True)

#璁剧疆鍏ㄥ眬榛樿瀛椾綋 涓?闆呴粦
plt.rcParams['font.family'] = ['Microsoft YaHei'] 
# 璁剧疆鍏ㄥ眬杞存爣绛惧瓧鍏稿ぇ灏?
plt.rcParams["axes.labelsize"] = 14  
# 璁剧疆鑳屾櫙
sns.set_style("darkgrid",{"font.family":['Microsoft YaHei', 'SimHei']})  
# 璁剧疆鐢诲竷闀垮 鍜?dpi
plt.figure(figsize=(18,8),dpi=100)
# 鑷畾涔夎壊鍗?
cmap = mcolors.LinearSegmentedColormap.from_list("n",['#95B359','#D3CF63','#E0991D','#D96161','#A257D0','#7B1216']) 
# 缁樺埗鐑姏鍥?

ax_sz = sns.heatmap(data_pivot_sh, cmap=cmap, vmax=31, 
                 annot=True, # 鐑姏鍥句笂鏄剧ず鏁板€?
                 linewidths=0.5,
                ) 
# 灏唜杞村埢搴︽斁鍦ㄦ渶涓婇潰
ax_sz.xaxis.set_ticks_position('top') 
plt.title('涓婃捣鏈€杩?0涓湀澶╂皵鍒嗗竷',fontsize=16) #鍥剧墖鏍囬鏂囨湰鍜屽瓧浣撳ぇ灏?
plt.show()
Python 获取北上广深历史天气数据并做数据可视化,第8张
data_bj = data[(data['鍩庡競']=='鍖椾含') & (data['骞翠唤'] == 2021)]
data_bj['鏃ユ湡'] = pd.to_datetime(data_bj.鏃ユ湡,format="%Y骞?m鏈?d鏃?)
data_bj = data_bj.sort_values(by='鏃ユ湡',ascending=True)

鍖椾含2021骞存瘡鏃ユ渶楂樻渶浣庢俯搴﹀彉鍖?/h4>
'''
python璧勬枡鑾峰彇鐪嬭繖閲屽櫌锛侊紒 灏忕紪 V锛歅ytho8987锛堣寰楀ソ鍙嬮獙璇佸娉細6 鍚﹀垯鍙兘涓嶉€氳繃锛?
鍗冲彲鑾峰彇锛氭枃绔犳簮鐮?鏁欑▼/璧勬枡/瑙g瓟绛夌鍒╋紝杩樻湁涓嶉敊鐨勮棰戝涔犳暀绋嬪拰PDF鐢靛瓙涔︼紒
'''
color0 = ['#FF76A2','#24ACE6']
color_js0 = """new echarts.graphic.LinearGradient(0, 1, 0, 0,
    [{offset: 0, color: '#FFC0CB'}, {offset: 1, color: '#ed1941'}], false)"""
color_js1 = """new echarts.graphic.LinearGradient(0, 1, 0, 0,
    [{offset: 0, color: '#FFFFFF'}, {offset: 1, color: '#009ad6'}], false)"""

tl = Timeline()
for i in range(0,len(data_bj)):
    coordy_high = list(data_bj['鏈€楂樻俯搴?])[i]
    coordx = list(data_bj['鏃ユ湡'])[i]
    coordy_low = list(data_bj['鏈€浣庢俯搴?])[i]
    x_max = list(data_bj['鏃ユ湡'])[i]+datetime.timedelta(days=10)
    y_max = int(max(list(data_bj['鏈€楂樻俯搴?])[0:i+1]))+3
    y_min = int(min(list(data_bj['鏈€浣庢俯搴?])[0:i+1]))-3
    title_date = list(data_bj['鏃ユ湡'])[i].strftime('%Y-%m-%d')
    c = (
        Line(
            init_opts=opts.InitOpts(
            theme='dark',
            #璁剧疆鍔ㄧ敾
            animation_opts=opts.AnimationOpts(animation_delay_update=800),#(animation_delay=1000, animation_easing="elasticOut"),
            #璁剧疆瀹藉害銆侀珮搴?
            width='1500px',
            height='900px', )
        )
        .add_xaxis(list(data_bj['鏃ユ湡'])[0:i])
        .add_yaxis(
            series_name="",
            y_axis=list(data_bj['鏈€楂樻俯搴?])[0:i], is_smooth=True,is_symbol_show=False,
            linestyle_opts={
                   'normal': {
                       'width': 3,
                       'shadowColor': 'rgba(0, 0, 0, 0.5)',
                       'shadowBlur': 5,
                       'shadowOffsetY': 10,
                       'shadowOffsetX': 10,
                       'curve': 0.5,
                       'color': JsCode(color_js0)
                   }
               },
            itemstyle_opts={
            "normal": {
                "color": JsCode(
                    """new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                offset: 0,
                color: '#ed1941'
            }, {
                offset: 1,
                color: '#009ad6'
            }], false)"""
                ),
                "barBorderRadius": [45, 45, 45, 45],
                "shadowColor": "rgb(0, 160, 221)",
            }
        },

        )
        .add_yaxis(
            series_name="",
            y_axis=list(data_bj['鏈€浣庢俯搴?])[0:i], is_smooth=True,is_symbol_show=False,
#             linestyle_opts=opts.LineStyleOpts(color=color0[1],width=3),
            itemstyle_opts=opts.ItemStyleOpts(color=JsCode(color_js1)),
            linestyle_opts={
                   'normal': {
                       'width': 3,
                       'shadowColor': 'rgba(0, 0, 0, 0.5)',
                       'shadowBlur': 5,
                       'shadowOffsetY': 10,
                       'shadowOffsetX': 10,
                       'curve': 0.5,
                       'color': JsCode(color_js1)
                   }
               },
        )
        .set_global_opts(
            title_opts=opts.TitleOpts("鍖椾含2021骞存瘡鏃ユ渶楂樻渶浣庢俯搴﹀彉鍖朶n\n{}".format(title_date),pos_left=330,padding=[30,20]),
            xaxis_opts=opts.AxisOpts(type_="time",max_=x_max),#, interval=10,min_=i-5,split_number=20,axistick_opts=opts.AxisTickOpts(length=2500),axisline_opts=opts.AxisLineOpts(linestyle_opts=opts.LineStyleOpts(color="grey"))
            yaxis_opts=opts.AxisOpts(min_=y_min,max_=y_max),#鍧愭爣杞撮鑹?axisline_opts=opts.AxisLineOpts(linestyle_opts=opts.LineStyleOpts(color="grey"))
        )
    )
    tl.add(c, "{}".format(list(data_bj['鏃ユ湡'])[i]))
    tl.add_schema(
        axis_type='time',
        play_interval=100,  # 琛ㄧず鎾斁鐨勯€熷害
        pos_bottom="-29px",
        is_loop_play=False, # 鏄惁寰幆鎾斁
        width="780px",
        pos_left='30px',
        is_auto_play=True,  # 鏄惁鑷姩鎾斁銆?
        is_timeline_show=False)
tl.render('1.html')

Python 获取北上广深历史天气数据并做数据可视化,第9张
data_10 = data[(data['骞翠唤'] == 2022) & ( data['鏈堜唤'] == 10)]
data_10.head()

鍖椾笂骞挎繁10鏈堜唤姣忔棩鏈€楂樻皵娓╁彉鍖?/h4>
# 鑳屾櫙鑹?
background_color_js = (
    "new echarts.graphic.LinearGradient(0, 0, 0, 1, "
    "[{offset: 0, color: '#c86589'}, {offset: 1, color: '#06a7ff'}], false)"
)

# 绾挎潯鏍峰紡
linestyle_dic = { 'normal': {
                    'width': 4,  
                    'shadowColor': '#696969', 
                    'shadowBlur': 10,  
                    'shadowOffsetY': 10,  
                    'shadowOffsetX': 10,  
                    }
                }
timeline = Timeline(init_opts=opts.InitOpts(bg_color=JsCode(background_color_js),
                                            width='980px',height='600px'))

bj, gz, sh, sz= [], [], [], []
all_max = []
x_data = data_10[data_10['鍩庡競'] == '鍖椾含']['鏃?].tolist()
for d_time in range(len(x_data)):
    bj.append(data_10[(data_10['鏃?] == x_data[d_time]) & (data_10['鍩庡競']=='鍖椾含')]["鏈€楂樻俯搴?].values.tolist()[0])
    gz.append(data_10[(data_10['鏃?] == x_data[d_time]) & (data_10['鍩庡競']=='骞垮窞')]["鏈€楂樻俯搴?].values.tolist()[0])
    sh.append(data_10[(data_10['鏃?] == x_data[d_time]) & (data_10['鍩庡競']=='涓婃捣')]["鏈€楂樻俯搴?].values.tolist()[0])
    sz.append(data_10[(data_10['鏃?] == x_data[d_time]) & (data_10['鍩庡競']=='娣卞湷')]["鏈€楂樻俯搴?].values.tolist()[0])

    line = (
        Line(init_opts=opts.InitOpts(bg_color=JsCode(background_color_js),
                                     width='980px',height='600px'))
        .add_xaxis(
            x_data,
                  )

        .add_yaxis(
            '鍖椾含',
            bj,
            symbol_size=5,
            is_smooth=True,
            is_hover_animation=True,
            label_opts=opts.LabelOpts(is_show=False),
        )

        .add_yaxis(
            '骞垮窞',
            gz,
            symbol_size=5,
            is_smooth=True,
            is_hover_animation=True,
            label_opts=opts.LabelOpts(is_show=False),
        )

        .add_yaxis(
            '涓婃捣',
            sh,
            symbol_size=5,
            is_smooth=True,
            is_hover_animation=True,
            label_opts=opts.LabelOpts(is_show=False),

        )

        .add_yaxis(
            '娣卞湷',
            sz,
            symbol_size=5,
            is_smooth=True,
            is_hover_animation=True,
            label_opts=opts.LabelOpts(is_show=False),

        )

        .set_series_opts(linestyle_opts=linestyle_dic)
        .set_global_opts(
            title_opts=opts.TitleOpts(
                title='鍖椾笂骞挎繁10鏈堜唤鏈€楂樻皵娓╁彉鍖栬秼鍔?,
                pos_left='center',
                pos_top='2%',
                title_textstyle_opts=opts.TextStyleOpts(color='#DC143C', font_size=20)),

            tooltip_opts=opts.TooltipOpts(
                trigger="axis",
                axis_pointer_type="cross",
                background_color="rgba(245, 245, 245, 0.8)",
                border_width=1,
                border_color="#ccc",
                textstyle_opts=opts.TextStyleOpts(color="#000"),
        ),
            xaxis_opts=opts.AxisOpts(
#                 axislabel_opts=opts.LabelOpts(font_size=14, color='red'),
#                 axisline_opts=opts.AxisLineOpts(is_show=True,
#                 linestyle_opts=opts.LineStyleOpts(width=2, color='#DB7093'))
                is_show = False
            ),

            yaxis_opts=opts.AxisOpts(
                name='鏈€楂樻皵娓?,            
                is_scale=True,
#                 min_= int(min([gz[d_time],sh[d_time],sz[d_time],bj[d_time]])) - 10,
                max_= int(max([gz[d_time],sh[d_time],sz[d_time],bj[d_time]])) + 10,
                name_textstyle_opts=opts.TextStyleOpts(font_size=16,font_weight='bold',color='#5470c6'),
                axislabel_opts=opts.LabelOpts(font_size=13,color='#5470c6'),
                splitline_opts=opts.SplitLineOpts(is_show=True, 
                                                  linestyle_opts=opts.LineStyleOpts(type_='dashed')),
                axisline_opts=opts.AxisLineOpts(is_show=True,
                                        linestyle_opts=opts.LineStyleOpts(width=2, color='#5470c6'))
            ),
            legend_opts=opts.LegendOpts(is_show=True, pos_right='1%', pos_top='2%',
                                        legend_icon='roundRect',orient = 'vertical'),
        ))

    timeline.add(line, '{}'.format(x_data[d_time]))

timeline.add_schema(
    play_interval=1000,          # 杞挱閫熷害
    is_timeline_show=True,      # 鏄惁鏄剧ず timeline 缁勪欢
    is_auto_play=True,          # 鏄惁鑷姩鎾斁
    pos_left="0",
    pos_right="0"
)
timeline.render('2.html')

灏捐

鎰熻阿浣犺鐪嬫垜鐨勬枃绔犲憪~鏈鑸彮鍒拌繖閲屽氨缁撴潫鍟?馃洭

甯屾湜鏈瘒鏂囩珷鏈夊浣犲甫鏉ュ府鍔?馃帀锛屾湁瀛︿範鍒颁竴鐐圭煡璇唦

韬茶捣鏉ョ殑鏄熸槦馃崶涔熷湪鍔姏鍙戝厜锛屼綘涔熻鍔姏鍔犳补锛堣鎴戜滑涓€璧峰姫鍔涘彮锛夈€?/p>


https://www.xamrdz.com/mobile/43q1997399.html

相关文章: