beta support for 331 second-in-line cities. and a dozen more to come.

This commit is contained in:
chfw 2017-08-28 00:32:52 +01:00
parent b1ee9c4e0b
commit 215a623af6
8 changed files with 37 additions and 67 deletions

View File

@ -2,3 +2,4 @@ include README.md
include changelog.md
include pyecharts/templates/*.html
include pyecharts/templates/js/echarts/*.js
include pyecharts/templates/js/echarts/registry.json

View File

@ -8,7 +8,8 @@
## 版本信息
* ### version 0.2.2 (Dev)
* Todo
#### Added
* 增加331个二线城市地图: 六盘水,安顺,毕节,贵阳,遵义,铜仁,黔东南苗族侗族自治州,黔南布依族苗族自治州,黔西南布依族苗族自治州,三门峡,信阳,南阳,周口,商丘,安阳,平顶山,开封,新乡,洛阳,漯河,濮阳,焦作,许昌,郑州,驻马店,鹤壁,东营,临沂,威海,德州,日照,枣庄,泰安,济南,济宁,淄博,滨州,潍坊,烟台,聊城,莱芜,菏泽,青岛,乐山,内江,凉山彝族自治州,南充,宜宾,巴中,广元,广安,德阳,成都,攀枝花,泸州,甘孜藏族自治州,眉山,绵阳,自贡,资阳,达州,遂宁,阿坝藏族羌族自治州,雅安,南京,南通,宿迁,常州,徐州,扬州,无锡,泰州,淮安,盐城,苏州,连云港,镇江,果洛藏族自治州,海东,海北藏族自治州,海南藏族自治州,海西蒙古族藏族自治州,玉树藏族自治州,西宁,黄南藏族自治州,三明,南平,厦门,宁德,泉州,漳州,福州,莆田,龙岩,丽水,台州,嘉兴,宁波,杭州,温州,湖州,绍兴,舟山,衢州,金华,十堰,咸宁,孝感,宜昌,恩施土家族苗族自治州,武汉,荆州,荆门,襄阳,鄂州,随州,黄冈,黄石,上饶,九江,南昌,吉安,宜春,抚州,新余,景德镇,萍乡,赣州,鹰潭,山南,拉萨,日喀则,昌都,林芝,那曲地区,阿里地区,七台河,伊春,佳木斯,双鸭山,哈尔滨,大兴安岭地区,大庆,牡丹江,绥化,鸡西,鹤岗,黑河,齐齐哈尔,云浮,佛山,广州,惠州,揭阳,梅州,汕头,汕尾,江门,河源,深圳,清远,湛江,潮州,珠海,肇庆,茂名,阳江,韶关,临沧,丽江,保山,大理白族自治州,德宏傣族景颇族自治州,怒江傈僳族自治州,文山壮族苗族自治州,昆明,昭通,普洱,曲靖,楚雄彝族自治州,玉溪,红河哈尼族彝族自治州,西双版纳傣族自治州,迪庆藏族自治州,北海,南宁,崇左,来宾,柳州,桂林,梧州,河池,玉林,百色,贵港,贺州,钦州,防城港,咸阳,商洛,安康,宝鸡,延安,榆林,汉中,渭南,西安,铜川,临夏回族自治州,兰州,天水,定西,平凉,庆阳,张掖,武威,甘南藏族自治州,白银,酒泉,金昌,陇南,保定,唐山,廊坊,张家口,承德,石家庄,秦皇岛,衡水,邢台,邯郸,中卫,吴忠,固原,石嘴山,银川,吉林,四平,延边朝鲜族自治州,松原,白城,白山,辽源,通化,长春,娄底,岳阳,常德,张家界,怀化,株洲,永州,湘潭,湘西土家族苗族自治州,益阳,衡阳,邵阳,郴州,长沙,亳州,六安,合肥,安庆,宣城,宿州,池州,淮北,淮南,滁州,芜湖,蚌埠,铜陵,阜阳,马鞍山,黄山,乌兰察布,乌海,兴安盟,包头,呼伦贝尔,呼和浩特,巴彦淖尔,赤峰,通辽,鄂尔多斯,锡林郭勒盟,阿拉善盟,临汾,吕梁,大同,太原,忻州,晋中,晋城,朔州,运城,长治,阳泉,万宁,三亚,三沙,东方,临高县,乐东黎族自治县,五指山,保亭黎族苗族自治县,儋州,定安县,屯昌县,文昌,昌江黎族自治县,海口,澄迈县,琼中黎族苗族自治县,琼海,白沙黎族自治县,陵水黎族自治县,丹东,大连,抚顺,朝阳,本溪,沈阳,盘锦,营口,葫芦岛,辽阳,铁岭,锦州,阜新,鞍山
* ### version 0.2.1 - 2017.8.25Current

View File

@ -1,2 +1,2 @@
__version__ = '0.2.1'
__version__ = '0.2.2'
__author__ = 'chenjiandongx'

View File

@ -1,18 +1,21 @@
#!/usr/bin/env python
# coding=utf-8
import sys
from pyecharts.base import Base
from pyecharts.option import get_all_options
from pyecharts.constants import CITY_NAME_PINYIN_MAP
from pyecharts.template import CITY_NAME_PINYIN_MAP
PY2 = sys.version_info[0] == 2
class Map(Base):
"""
<<< Map chart >>>
Map is maily used in the visulization of geographic area data,which can be used
with visualMap component to visualize the datas such as population
distribution density in diffrent areas.
Map is maily used in the visulization of geographic area data,which
can be used with visualMap component to visualize the datas such as
population distribution density in diffrent areas.
"""
def __init__(self, title="", subtitle="", **kwargs):
super(Map, self).__init__(title, subtitle, **kwargs)
@ -58,6 +61,8 @@ class Map(Base):
"data": _data,
"roam": is_roam
})
if PY2:
maptype = maptype.decode('utf-8')
name_in_pinyin = CITY_NAME_PINYIN_MAP.get(maptype, maptype)
self._js_dependencies.add(name_in_pinyin)
self._legend_visualmap_colorlst(**kwargs)

View File

@ -2,58 +2,12 @@
# coding=utf-8
from __future__ import unicode_literals
DEFAULT_HOST = 'https://chfw.github.io/jupyter-echarts/echarts'
CONFIGURATION = dict(
HOST='/nbextensions/echarts'
)
DEFAULT_JS_LIBRARIES = dict(
echarts='echarts.min',
echartsgl='echarts-gl.min',
liquidfill='echarts-liquidfill.min',
world='world',
china='china',
wordcloud='echarts-wordcloud.min'
)
CITY_NAME_PINYIN_MAP = {
"广东": "guangdong",
"安徽": "anhui",
"澳门": "aomen",
"北京": "beijing",
"重庆": "chongqing",
"福建": "fujian",
"甘肃": "gansu",
"广西": "guangxi",
"贵州": "guizhou",
"海南": "hainan",
"河北": "hebei",
"黑龙江": "heilongjiang",
"河南": "henan",
"湖北": "hubei",
"湖南": "hunan",
"江苏": "jiangsu",
"江西": "jiangxi",
"吉林": "jilin",
"辽宁": "liaoning",
"内蒙古": "neimenggu",
"宁夏": "ningxia",
"青海": "qinghai",
"山东": "shandong",
"上海": "shanghai",
"山西": "shanxi",
"四川": "sichuan",
"台湾": "taiwan",
"天津": "tianjin",
"香港": "xianggang",
"新疆": "xinjiang",
"西藏": "xizang",
"云南": "yunnan",
"浙江": "zhejiang"
}
CITY_GEO_COORDS = {
'阿城': [126.58, 45.32],
'阿克苏': [80.19, 41.09],

View File

@ -8,8 +8,29 @@ import sys
import codecs
from jinja2 import Environment, FileSystemLoader
import pyecharts.constants as constants
import json
def get_resource_dir(folder):
"""
:param folder:
:return:
"""
current_path = os.path.dirname(__file__)
resource_path = os.path.join(current_path, folder)
return resource_path
#with codecs.open(os.path.join(get_resource_dir('templates'), 'js', 'echarts', 'registry.json'), 'r', 'utf-8') as f:
with open(os.path.join(get_resource_dir('templates'), 'js', 'echarts', 'registry.json'), 'rb') as f:
content = f.read().decode('utf-8')
CONFIG = json.loads(content)
DEFAULT_JS_LIBRARIES = CONFIG['FILE_MAP']
CITY_NAME_PINYIN_MAP = CONFIG['PINYIN_MAP']
PY2 = sys.version_info[0] == 2
JS_PATTERN = re.compile(r'<!-- build -->(.*)<!-- endbuild -->',
@ -50,17 +71,6 @@ def freeze_js(html_content):
return html_content
def get_resource_dir(folder):
"""
:param folder:
:return:
"""
current_path = os.path.dirname(__file__)
resource_path = os.path.join(current_path, folder)
return resource_path
# Single Singleton Instance for jinja2
JINJA2_ENV = Environment(
loader=FileSystemLoader(get_resource_dir('templates')),
@ -114,7 +124,7 @@ def produce_html_script_list(dependencies):
"""
_d = ensure_echarts_is_in_the_front(dependencies)
script_list = [
'%s' % constants.DEFAULT_JS_LIBRARIES.get(key, key)
'%s' % DEFAULT_JS_LIBRARIES.get(key, key)
for key in _d]
return script_list
@ -141,4 +151,3 @@ def ensure_echarts_is_in_the_front(dependencies):
def online(host=constants.DEFAULT_HOST):
constants.CONFIGURATION['HOST'] = host

@ -1 +1 @@
Subproject commit bb5c33e2f22227dfec6f9378262230e95fdc2767
Subproject commit 08d38a2406f337fa61e3ade8f35257ce6fc8ad16

View File

@ -16,7 +16,7 @@ except:
__title__ = 'pyecharts'
__description__ = 'Python echarts, make charting easier'
__url__ = 'https://github.com/chenjiandongx/pyecharts'
__version__ = '0.2.1'
__version__ = '0.2.2'
__author__ = 'chenjiandongx'
__author_email__ = 'chenjiandongx@qq.com'
__license__ = 'MIT'