# # json--带有特定格式的字符串
#
# import json
# # 准备列表,列表中元素是字典,将其转换成json
# data = [{"name": "张三", "age": 19}, {"name": "1234", "age": 15}, {"name": "1239", "age": 14}]
# # json数据转换
# json_str = json.dumps(data, ensure_ascii=False) # 后面的是中文转换,dumps函数使用转化
# print(type(json_str), json_str)
# # 准备字典将字典转换为json
# dict11 = {"name": "王", "age": 25}
# json_str = json.dumps(dict11, ensure_ascii=False)
# print(type(json_str), json_str)
#
#
# # 将json字符串转换成python数据类型
# data = '[{"name": "张三", "age": 19}, {"name": "1234", "age": 15}, {"name": "1239", "age": 14}]'
# l = json.loads(data)
# print(type(l))
# print(data)
# # 将json字符串转换成python数据类型
# dict11 = '{"name": "王", "age": 25}'
# d = json.loads(dict11)
# print(type(d))
# print(d)
# ECharts模块
# from pyecharts import options as opts
# from pyecharts.charts import Geo
# from pyecharts.datasets import register_url
#
# # try:
# # register_url("https://assets.pyecharts.org/assets/maps/")
# # except Exception:
# # import ssl
# #
# # ssl._create_default_https_context = ssl._create_unverified_context
# # register_url("https://assets.pyecharts.org/assets/maps/")
#
# geo = (
# Geo()
# .add_schema(maptype="瑞士")
# .set_global_opts(title_opts=opts.TitleOpts(title="瑞士"))
# .render("geo_chart_countries_js.html")
# )
# 导包,导入Line功能构建折线图
from pyecharts.charts import Line
from pyecharts.options import TitleOpts, LegendOpts, ToolboxOpts, VisualMapOpts
# 得到折线图对象
line = Line()
# 绘制x,y轴
line.add_xaxis(["china", "USA", "UK"])
line.add_yaxis("GDP", [30, 20, 10])
line.set_global_opts(
title_opts=TitleOpts("GDP", pos_left="center", pos_bottom="1%"),
legend_opts=LegendOpts(is_show=True),
toolbox_opts=ToolboxOpts(is_show=True),
visualmap_opts=VisualMapOpts(is_piecewise=True, is_calculable=True)
)
# 生成图表
line.render()