Skip to content

Commit

Permalink
Merge pull request #65 from kinegratii/release/060
Browse files Browse the repository at this point in the history
Release 0.6.0
  • Loading branch information
kinegratii authored Mar 17, 2023
2 parents 82c6832 + 50c0e06 commit 12de6cf
Show file tree
Hide file tree
Showing 73 changed files with 2,250 additions and 418 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/unittest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9' ]
python-version: [ '3.8', '3.9' ]
django-version: [ '2.2', '3.2' ]
pyecharts-version: ['1.9.1', '2.0.2']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -25,9 +26,9 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install django~=${{ matrix.django-version }}
pip install borax>=3.5
pip install pyecharts~=1.9
pip install typing_extensions~=4.0
pip install borax~=4.0
pip install pyecharts~=${{ matrix.pyecharts-version }}
pip install typing_extensions~=4.5
pip install htmlgenerator~=1.2
pip install flake8~=3.9
pip install nose2~=0.10
Expand All @@ -43,5 +44,5 @@ jobs:
file: ./coverage.xml
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: true
fail_ci_if_error: false
verbose: true
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,26 @@ django-echarts 主要提供了以下的内容:

## 安装(Install)

django-echarts包运行环境要求如下
django-echarts的运行环境要求如下

| django-echarts版本系列 | pyecharts | django | python | 备注 |
| ------ | ------ | ------ | ----- | ----- |
| 0.5.x | 1.9+ | 2.0+ | 3.7+ | 开发维护中 |
| django-echarts版本系列 | pyecharts & echarts | django | python |
| ------ | ------ | ----- | ----- |
| 0.6.x | 1.9 / 4.8.0 | 2.0 - 4.1 | 3.7+ |
| | 2.0 / 5.4.1 | 2.0 - 4.1 | 3.7+ |
| 0.5.x | 1.9 | 2.0 - 4.0 | 3.7+ |

可以使用 pip 命令安装。

```shell
pip install django-echarts
```

*requirements.txt* 引用 django-charts时,推荐使用 **固定次版本号** 的方式。

```
django-echarts~=0.6
```

## 3分钟上手(Quickstart in 3 Minutes)

**1.** 创建Django项目。
Expand Down
2 changes: 1 addition & 1 deletion django_echarts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
A django app for Echarts integration with pyecharts as chart builder.
"""

__version__ = '0.5.2'
__version__ = '0.6.0'
__author__ = 'kinegratii'
9 changes: 9 additions & 0 deletions django_echarts/class_typing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from typing import List, Union, TypedDict

from typing_extensions import NotRequired


class TNavConfig(TypedDict):
nav_left: NotRequired[List[Union[str, dict]]]
nav_right: NotRequired[List[Union[str, dict]]]
nav_footer: NotRequired[List[Union[str, dict]]]
26 changes: 21 additions & 5 deletions django_echarts/contrib/bootstrap3/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
{% for menu2 in nav.menus %}
{% for menu2 in nav.left_menus %}
{% if menu2.children %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
Expand All @@ -71,10 +71,26 @@
{% endfor %}
</ul>
<ul class="nav navbar-nav navbar-right">
{% for item in nav.links %}
<li>
{% dw_widget item %}
</li>
{% for menu2 in nav.right_menus %}
{% if menu2.children %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
aria-haspopup="true"
aria-expanded="false">{{ menu2.text }} <span class="caret"></span></a>
<ul class="dropdown-menu">
{% for item in menu2.children %}
{% if item.after_separator %}
<li role="separator" class="divider"></li>
{% endif %}
<li> {% dw_widget item %}</li>
{% endfor %}
</ul>
</li>
{% else %}
<li>
{% dw_widget menu2 %}
</li>
{% endif %}
{% endfor %}
</ul>
</div><!-- /.navbar-collapse -->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends 'base.html' %}
{% load echarts %}

{% block main_content %}
{{ chart_info.title }}

{% dw_widget link_group %}
{% endblock %}
3 changes: 2 additions & 1 deletion django_echarts/contrib/bootstrap3/templates/items_grid.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{% load echarts %}
<div class="row">
{% for chart_info in chart_info_list %}
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<a href="{% url 'dje_chart_single' chart_info.name %}">{{ chart_info.title }}</a>
<a href="{% url_single_chart chart_info.uri %}">{{ chart_info.title }}</a>
{% if chart_info.tags %}
<span class="pull-right">
{% for tag in chart_info.tags %}
Expand Down
3 changes: 2 additions & 1 deletion django_echarts/contrib/bootstrap3/templates/items_list.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% load echarts %}
<div class="list-group">
{% for chart_info in chart_info_list %}
<a href="{% url 'dje_chart_single' chart_info.name %}" class="list-group-item">
<a href="{% url_single_chart chart_info.uri %}" class="list-group-item">
<h4 class="list-group-item-heading">{{ chart_info.title }}</h4>
<p class="list-group-item-text">{{ chart_info.description|default:"暂无描述" }}</p>
</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="list-group">
{% for link in widget %}
<a href="{{ link.url }}" class="list-group-item">{{ link.text }}</a>
{% endfor %}
</div>
25 changes: 22 additions & 3 deletions django_echarts/contrib/bootstrap5/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
{% for menu2 in nav.menus %}
{% for menu2 in nav.left_menus %}
{% if menu2.children %}
<li class="nav-item dropdown">
<a id="{{ menu2.slug }}" href="#" class="nav-link dropdown-toggle"
Expand All @@ -62,8 +62,27 @@
{% endfor %}
</ul>
<ul class="navbar-nav ms-auto">
{% for item in nav.links %}
<li class="nav-item">{% dw_widget item class_="nav-link" %}</li>
{% for menu2 in nav.right_menus %}
{% if menu2.children %}
<li class="nav-item dropdown">
<a id="{{ menu2.slug }}" href="#" class="nav-link dropdown-toggle"
role="button" data-bs-toggle="dropdown">{{ menu2.text }} </a>
<ul class="dropdown-menu" aria-labelledby="{{ menu2.slug }}">
{% for item in menu2.children %}
{% if item.after_separator %}
<li>
<hr class="dropdown-divider">
</li>
{% endif %}
<li>{% dw_widget item class_="dropdown-item" %}</li>
{% endfor %}
</ul>
</li>
{% else %}
<li class="nav-item">
{% dw_widget menu2 class_="nav-link" %}
</li>
{% endif %}
{% endfor %}
</ul>
</div><!-- /.navbar-collapse -->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends 'base.html' %}
{% load echarts %}

{% block main_content %}
{{ chart_info.title }}

{% dw_widget link_group %}
{% endblock %}
3 changes: 2 additions & 1 deletion django_echarts/contrib/bootstrap5/templates/items_grid.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% load echarts %}
<div class="row">
{% for chart_info in chart_info_list %}
<div class="col-md-4">
Expand All @@ -13,7 +14,7 @@
</div>
<div class="card-body">
<p class="card-text">{{ chart_info.description|default:"暂无描述" }}</p>
<a href="{% url 'dje_chart_single' chart_info.name %}" role="button"
<a href="{% url_single_chart chart_info.uri %}" role="button"
class="btn btn-secondary btn-sm">详情</a>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion django_echarts/contrib/bootstrap5/templates/items_list.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% load echarts %}
<div class="list-group">
{% for chart_info in chart_info_list %}
<a href="{% url 'dje_chart_single' chart_info.name %}" class="list-group-item">
<a href="{% url_single_chart chart_info.uri %}" class="list-group-item">
<h4 class="list-group-item-heading">{{ chart_info.title }}</h4>
<p class="list-group-item-text text-first-indent">{{ chart_info.description|default:"暂无描述" }}</p>
</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="list-group">
{% for link in widget %}
<a href="{{ link.url }}" class="list-group-item list-group-item-action">{{ link.text }}</a>
{% endfor %}
</div>
21 changes: 14 additions & 7 deletions django_echarts/contrib/material/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<nav class="light-blue lighten-1" role="navigation">
<div class="nav-wrapper container"><a id="logo-container" href="{% url 'dje_home' %}"
class="brand-logo center">{{ site_title }}</a>
{% for menu2 in nav.menus %}
{% for menu2 in nav.left_menus %}
{% if menu2.children %}
<ul id="{{ menu2.slug }}" class="dropdown-content">
{% for item in menu2.children %}
Expand All @@ -29,7 +29,7 @@
{% endif %}
{% endfor %}
<ul class="left hide-on-med-and-down">
{% for menu2 in nav.menus %}
{% for menu2 in nav.left_menus %}
{% if menu2.children %}
<li><a class="dropdown-trigger" href="javascript:"
data-target="{{ menu2.slug }}">{{ menu2.text }}<i
Expand All @@ -43,11 +43,18 @@
</ul>

<ul id="nav-mobile" class="right hide-on-med-and-down">
{% for item in nav.links %}
<li>
{% dw_widget item %}
</li>
{% endfor %}
{% for menu2 in nav.right_menus %}
{% if menu2.children %}
<ul id="{{ menu2.slug }}" class="dropdown-content">
{% for item in menu2.children %}
{% if item.after_separator %}
<li class="divider"></li>
{% endif %}
<li>{% dw_widget item %}</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
</ul>
</div>
</nav>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends 'base.html' %}
{% load echarts %}

{% block main_content %}
{{ chart_info.title }}

{% dw_widget link_group %}
{% endblock %}
3 changes: 2 additions & 1 deletion django_echarts/contrib/material/templates/items_grid.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% load echarts %}
<div class="row">
{% for chart_info in chart_info_list %}
<div class="col s12 m4">
Expand All @@ -12,7 +13,7 @@
{% endif %}
</div>
<div class="card-action">
<a href="{% url 'dje_chart_single' chart_info.name %}">详情</a>
<a href="{% url_single_chart chart_info.uri %}">详情</a>
</div>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion django_echarts/contrib/material/templates/items_list.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% load echarts %}
<div class="row">
{% for chart_info in chart_info_list %}
<div class="col s12 m12">
Expand All @@ -15,7 +16,7 @@

</div>
<div class="card-action">
<a href="{% url 'dje_chart_single' chart_info.name %}">详情</a>
<a href="{% url_single_chart chart_info.uri %}">详情</a>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="collection">
{% for link in widget %}
<a href="{{ link.url }}" class="collection-item">{{ link.text }}</a>
{% endfor %}
</div>
34 changes: 30 additions & 4 deletions django_echarts/core/dms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Tuple, List

from pyecharts.datasets import FILENAMES, EXTRA
from pyecharts._version import __version__ as pyecharts_version
from django_echarts.utils.burl import BUrl
from .localfiles import LocalFilesMixin, DownloaderResource

Expand All @@ -13,8 +14,26 @@
# The repo contains all dependencies
_BUILTIN_REPOS_ = {
'pyecharts': 'https://assets.pyecharts.org/assets/',
'pycharts-v5': 'https://assets.pyecharts.org/assets/v5',
'local': '/static/assets/'
}


class PyechartsDMS:
VERSION2REPO = {
'1.9': {'dms_repo': 'pyecharts', 'echarts_version': '4.8.0'},
'2.0': {'dms_repo': 'pycharts-v5', 'echarts_version': '5.4.1'}
}

@staticmethod
def get_pyecharts__primary_version():
return pyecharts_version[:3]

@staticmethod
def get_pycharts_repo(version_pre: str):
return PyechartsDMS.VERSION2REPO.get(version_pre)


# Use #REPO in custom d2u
_OTHER_REPOS_ = {
'cdnjs': 'https://cdnjs.cloudflare.com/ajax/libs/echarts/{echarts_version}',
Expand All @@ -25,9 +44,9 @@
'united-kingdom': 'https://echarts-maps.github.io/echarts-united-kingdom-js'
}

_CUSTOM_D2U_MAP = {
'echarts': 'https://cdnjs.cloudflare.com/ajax/libs/echarts/4.8.0/echarts.min.js',
'echarts-gl': 'https://assets.pyecharts.org/assets/echarts-gl.min.js'
_PYECHARTS_VERSIONS_ = {
'1.9': {'dms_repo': 'pyecharts', 'echarts_version': '4.8.0'},
'2.0': {'dms_repo': 'pycharts-v5', 'echarts_version': '5.4.1'}
}


Expand All @@ -50,7 +69,14 @@ def add_repo(self, repo_name: str, repo_url: str):
self._repo_dic[repo_name] = repo_url

def load_from_dep2url_dict(self, d2u_dic: dict):
self._custom_dep2url.update(d2u_dic)
"""Parse user custom dep_url dict
Update 0.6.0: support #repo key-value."""
for k, v in d2u_dic.items():
if k.startswith('#') and isinstance(v, (list, tuple)):
for _v in v:
self._custom_dep2url[_v] = k
else:
self._custom_dep2url[k] = v

def _resolve_dep(self, dep_name: str, repo_name: str = None) -> Tuple:
if dep_name in self._custom_dep2url:
Expand Down
Loading

0 comments on commit 12de6cf

Please sign in to comment.