# django-echarts
   [](https://github.com/kinegratii/django-echarts/actions/workflows/unittest.yaml) [](https://codecov.io/gh/kinegratii/django-echarts)
> A visual site scaffold based on pyecharts and django.
django-echarts 是一个基于[pyecharts](https://github.com/pyecharts/pyecharts) 和 [Django](https://www.djangoproject.com) 整合的可视化网站脚手架。
## 概述(Summary)
django-echarts 主要提供了以下的内容:
- 支持 90%+的pyecharts图表类型
- 页面:主页 / 列表 / 详情 / 关于 / 设置
- 组件:导航栏 / 网站底部栏 / 热门板块 / 列表 / 合辑 / 关于面板
- UI主题:Bootstrap3 / Bootstrap5 / Material ,支持更换颜色模式
- 可灵活扩展: 支持整合 Django用户认证 / 数据库 / Session
- 基于Django Template Engine 的后端渲染
- js/css静态文件托管,支持在线/本地切换
- 生产力工具:代码生成器 / 静态文件下载器
- 90%+ Python Typing Hints覆盖
- 单元测试和85%+代码覆盖率
## 安装(Install)
django-echarts的运行环境要求如下:
| 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项目。
```shell
django-admin startproject MyDemo
```
项目目录结构如下:
```text
MyDemo
|-- MyDemo
|-- __init__.py
|-- asgi.py
|-- settings.py
|-- urls.py
|-- site_views.py
|-- wsgi.py
|-- manage.py
```
**2.** 添加 django_echarts包和对应的主题包到项目配置模块的 `INSTALL_APPS`列表。
```python
INSTALL_APPS = (
# Your apps
'django_echarts',
'django_echarts.contrib.bootstrap5'
# Your apps
)
```
**3.** 创建新文件 *site_views.py* ,输入下列代码。
```python
# ...
from django_echarts.starter.sites import DJESite
from django_echarts.entities import Copyright
from pyecharts import options as opts
from pyecharts.charts import Bar
site_obj = DJESite(site_title='福建统计')
site_obj.add_widgets(copyright_=Copyright(start_year=2022, powered_by='Zinc'))
chart_description = '截止2020年底,福建省土地面积1240.29万公顷,占我国国土总面积1.3%。全省森林面积811.58万公顷,森林覆盖率为66.8%,连续42年位居全国首位。
@site_obj.register_chart(title='森林覆盖率', description = chart_description, catalog='基本信息')
def fujian_forest_coverage():
bar = Bar().add_xaxis(
['福州', '厦门', '莆田', '三明', '漳州', '泉州', '南平', '龙岩', '宁德']
).add_yaxis(
'森林覆盖率', [54.7, 45, 58.1, 76.8, 63.4, 61, 75.3, 78, 75]
).set_global_opts(
title_opts=opts.TitleOpts(title="福建省各地市森林覆盖率", subtitle="单位:%"),
visualmap_opts=opts.VisualMapOpts(is_show=True, max_=100, min_=0)).set_series_opts(
markline_opts=opts.MarkLineOpts(
data=[
opts.MarkLineItem(y=66.8, name="全省"),
]
)
)
return bar
```
在函数`fujian_forest_coverage` 中编写pycharts代码,返回对应的图表对象。
根据需要修改文字显示,添加组件等。
**4.** 在项目的路由模块 *urls.py* 添加挂载点。
```python
from django.conf.urls import url, include
from django.urls import path
from .site_views import site_obj
urlpatterns = [
# Your urls
path('', include(site_obj.urls))
]
```
**5.** 启动开发服务器,打开浏览器预览结果。
```text
python manage.py runserver 0.0.0.0:8900
```
运行效果(下图已添加其他组件)

## 文档(Document)
[在线文档](https://django-echarts.readthedocs.io/)
Build on [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/)
## 示例项目(Demo Project)
在线示例 [https://zinc.pythonanywhere.com](https://zinc.pythonanywhere.com)
参见项目 [kinegratii/zinc](https://github.com/kinegratii/zinc) 。
## 截图(Screen Shots)
**Home with ValuesPanel (bootstrap5)**

**Chart Detail Page (bootstrap3.paper)**

## 开源协议(License)
MIT License
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论






















收起资源包目录





































































































共 199 条
- 1
- 2
资源评论


嵌入式大圣
- 粉丝: 7294
- 资源: 798
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 更新!2004-2023年全国31个省份婚姻(结婚率、离婚率、再婚率)面板数据
- 更新!2023年全国区县级平均房价数据(shp与Excel)
- 最新更新!2018-2024年国家、省教学成果奖
- 2002-2023年中国城市建设统计面板数据,城市人口密度、绿地面积、债券、供水等数据,
- 更新-“双高计划”专业群完整申报书与建设方案/中期评估报告
- 更新!1985-2024年城市统计【Excel版本】
- 最新更新!!2007-2024年全国各地级市减碳重视程度词频数据
- 2024年最新更新!!!中国367个城市空气质量年度指数+优良天数数据
- shiyannnn_Design1.ms14
- 小米路由器青春版固件刷机资源包
- 图解AUTOSAR-CP-EthernetDriver 逻辑图
- 基于opencv和dlib的人脸识别
- 目前全网最完整高清清华大学DeepSeek第一弹至第五弹(全).zip
- OFD阅读器3.0,用于打开OFD文件
- 基于OpenCV、OpenGL和Open3D的混合现实和增强现实项目
- 工具变量-上市公司企业高管机会主义减持数据-市场个股回报率收益率董监高持股变动薪酬(2006-2023年).txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
