Giter Club home page Giter Club logo

django-echarts's Introduction

django-echarts

django-echarts version PyPI - Python Version PyPI - Django Version unittest codecov

A visual site scaffold based on pyecharts and django.

django-echarts 是一个基于pyechartsDjango 整合的可视化网站脚手架。

概述(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 django python 备注
0.5.x 1.9+ 2.0+ 3.7+ 开发维护中

可以使用 pip 命令安装。

pip install django-echarts

3分钟上手(Quickstart in 3 Minutes)

1. 创建Django项目。

django-admin startproject MyDemo

项目目录结构如下:

MyDemo
  |-- MyDemo
        |-- __init__.py
        |-- asgi.py
        |-- settings.py
        |-- urls.py
        |-- site_views.py
        |-- wsgi.py
  |-- manage.py

2. 添加 django_echarts包和对应的主题包到项目配置模块的 INSTALL_APPS列表。

INSTALL_APPS = (
    # Your apps
    'django_echarts',
    'django_echarts.contrib.bootstrap5'
    # Your apps
)

3. 创建新文件 site_views.py ,输入下列代码。

# ...
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 添加挂载点。

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. 启动开发服务器,打开浏览器预览结果。

python manage.py runserver 0.0.0.0:8900

运行效果(下图已添加其他组件)

fujian-forest-coverage

文档(Document)

在线文档

Build on Material for MkDocs

示例项目(Demo Project)

在线示例 https://zinc.pythonanywhere.com

参见项目 kinegratii/zinc

截图(Screen Shots)

Home with ValuesPanel (bootstrap5)

home_with_values_panel

Chart Detail Page (bootstrap3.paper)

chart_fj-map-gdp

开源协议(License)

MIT License

django-echarts's People

Contributors

kinegratii avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.