Skip to content

Commit

Permalink
:lipstrick: make readme more useful
Browse files Browse the repository at this point in the history
  • Loading branch information
chfw committed Aug 29, 2017
1 parent 0836122 commit 23c410d
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 48 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ language: python
notifications:
email: false
python:
- 3.6
- 2.7
before_install:
- pip install -r tests/requirements.txt
- pip install -r test/requirements.txt
script:
- nosetests
96 changes: 64 additions & 32 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!Doctype html>
<html>
<head>
<title>Jupyter-Echarts Map Demo</title>
<title>363 Chinese provincial cities Map Demo</title>
<meta charset="utf-8" />
<style>
.citymap{
Expand Down
14 changes: 8 additions & 6 deletions makedemo.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,20 @@ def list_a_directory(src_folder):
print("%s-> %s, %s -> %s" % (cname, pname, src_file, _dest_file))
shutil.copy(src_file, _dest_file)
rendering_dict[cfolder].append((cname, pname))
# statistics
count = 0
for cprovince in rendering_dict.keys():
count += len(rendering_dict[cprovince])
provinces, cities = len(rendering_dict.keys()), count

jinja2_env = Environment(
loader=FileSystemLoader('./templates'),
keep_trailing_newline=True,
trim_blocks=True,
lstrip_blocks=True)
template = jinja2_env.get_template('index.html')
html = template.render(names=name_dict, registry=rendering_dict)
html = template.render(names=name_dict, registry=rendering_dict,
num_cities=cities)
with codecs.open('index.html', 'wb', 'utf-8') as f:
f.write(html)

Expand All @@ -56,11 +63,6 @@ def list_a_directory(src_folder):
with codecs.open(os.path.join('dist', 'config.json'), 'wb', 'utf-8') as f:
f.write(config_json)

count = 0
for cprovince in rendering_dict.keys():
count += len(rendering_dict[cprovince])
provinces, cities = len(rendering_dict.keys()), count

readme = jinja2_env.get_template('README.md')
readme_txt = readme.render(
names=name_dict, registry=rendering_dict,
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pinyin
mafan
44 changes: 38 additions & 6 deletions templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,68 @@ It collects all geo-jsons in javascript of all {{num_cities}} provincial cities
in {{num_provinces}} and acts as a static asset to jupyter-echarts or your
echarts collection.

# Feature
## Use with echarts

```
<html>
<head>
<meta charset="utf-8" />
<style>
.citymap{
width: 100%;
height: 100%;
}
</style>
<script src="https://chfw.github.io/echarts-china-cities-js/echarts.min.js"></script>
<script src="https://chfw.github.io/echarts-china-cities-js/dist/jiang1_xi1/nan2_chang1.js"></script>
</head>
<body>
<div id='nan2_chang1' class='citymap'></div>
<script src='https://chfw.github.io/echarts-china-cities-js/demo.js'></script>
<script>
make_city('南昌', 'nan2_chang1');
</script>
</body>
</html>
```

![Usage with echarts](https://chfw.github.io/echarts-china-cities-js/nanchang.png)

## Use with pyecharts

![Usage with pyecharts](https://user-images.githubusercontent.com/4280312/29755070-9bc9ae70-8b89-11e7-9bf2-bec09cb5f1a1.png)

## Featuring Cities(or for Single Download)

Cities:
{% for cprovince in registry.keys() %}
{{loop.index}}. **{{cprovince}}**:
{% for city in registry[cprovince] %}
{{city[0]}}{% if not loop.last %}, {% endif %}{% endfor %}
[{{city[0]}}]("https://chfw.github.io/echarts-china-cities-js/dist/{{names[cprovince]}}/{{city[1]}}.js"){% if not loop.last %}, {% endif %}{% endfor %}

{% endfor %}


# Development
## Development

Please use python

```shell
$ python makedemo.py
```

# Test
## Test

```shell
$ pip install test/requirements.txt
$ npm test
```

# License
## License

This bundling code is MIT license. The geojson libraries are downloaded from
AMap.com(高德地图) via echarts-map-tool, hence are subjected to AMap's license. Similiar
AMap.com(高德地图) via [echarts-map-tool](http://ecomfe.github.io/echarts-map-tool/),
hence are subjected to AMap's license. Similiar
to google's map dadta, it is free as long as the public's access to your files
are free. And you shall not start making commercial applications using the
files in this package without engaging AMap.com.
2 changes: 1 addition & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!Doctype html>
<html>
<head>
<title>Jupyter-Echarts Map Demo</title>
<title>{{num_cities}} Chinese provincial cities Map Demo</title>
<meta charset="utf-8" />
<style>
.citymap{
Expand Down

0 comments on commit 23c410d

Please sign in to comment.