1 Star 1 Fork 0

yiliuyan / echartspy

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

chartspy

English documents 中文文档

帮助用户在python环境使用echarts g2plot 绘图

不同于pyecharts,不对echarts 概念和属性进行python映射和二次抽象,保证库不依赖于特定echarts版本

  • 实现了 python配置<=>JavaScript配置的双向互转

  • 同时借鉴plotly.express 封装了简单图表类型可视化函数

使用说明

简单模式

import chartspy.express as ex

ex.scatter_echarts(df, x='数量', y='价格', size='数量', group='水果', size_max=50, height='250px', title='scatter')

ex.pie_echarts(df, name='水果', value='数量', rose_type='area', title="pie2", height='350px')

ex.candlestick_echarts(df, left='5%', mas=[5, 10, 30], title='平安银行')

!!! note "" scatter

!!! note "" line

!!! note "" kline

高级模式

同js写法

手工书写,参考 echarts配置手册

from chartspy import Echarts, Tools

options = {
    'xAxis': {},
    'yAxis': {},
    'series': [{
        'symbolSize': 20,
        'data': [
            [10.0, 8.04],
            [8.07, 6.95],
            [13.0, 7.58],
            [9.05, 8.81],
            [11.0, 8.33]
        ],
        'type': 'scatter'
    }]
}
Echarts(options, height='600px', title='散点图测试').render_notebook()
from chartspy import G2PLOT, Tools

# G2PLOT
df= ...
# Echarts
options = {
    'xField':'time',
    'yField':'close'
}
G2PLOT(df,plot_type='Line',options=options).render_notebook()

半自动JavaScript配置->Python配置

半自动,从echarts示例 拷贝js配置,自动生成对应的python配置

convert_js_to_dict(js_str,print_dict=True) 会在控制台打印python 配置, 粘贴进行二次加工

from chartspy import Echarts, Tools, Js

js_str = """
{
    xAxis: {
        type: 'category',
        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    },
    yAxis: {
        type: 'value'
    },
    series: [{
        data: [820, 932, 901, 934, 1290, 1330, 1320],
        type: 'line',
        smooth: true
    }]
}
"""
options = Tools.convert_js_to_dict(js_str, print_dict=False)
Echarts(options, height='300px', width='300px').render_notebook()

安装&升级

安装

pip install chartspy

升级 echartspy

pip uninstall chartspy -y  && pip install chartspy

修改echarts版本

默认指向最新版,可以修改成指定版本

from  chartspy import  echarts
from chartspy import g2plot

echarts.ECHARTS_JS_URL = "https://unpkg.com/echarts@latest/dist/echarts.min.js"
g2plot.G2PLOT_JS_URL = "..."

其他说明参见chartspy文档

感谢Jetbrain

JetBrains 徽标(主要) logo

MIT License Copyright (c) 2017-2021 chenjiajia Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

帮助用户在python环境使用echarts 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Python
1
https://gitee.com/yiliuyan161/echartspy.git
git@gitee.com:yiliuyan161/echartspy.git
yiliuyan161
echartspy
echartspy
master

搜索帮助