跳转到主要内容

此小部件允许使用Bokeh库显示图表。

项目描述

Production/Stable License: LGPL-3 OCA/web Translate me on Weblate Try me on Runboat

此模块添加了将Bokeh图表插入Odoo标准视图的可能性。

Bokeh Chart inserted into an Odoo view

Bokeh是一个针对现代网络浏览器进行演示的Python交互式可视化库。它的目标是提供优雅、简洁的基本探索性和高级自定义图形构建,类似于D3.js,同时也通过高性能交互性在非常大的或流式数据集上提供此功能。Bokeh可以帮助任何想快速轻松创建交互式图形、仪表板和数据应用的人。

如果您想查看Bokeh功能的示例,请点击以下链接

目录

安装

您需要安装python bokeh库

pip3 install bokeh==3.1.1

用法

要将Bokeh图表插入视图,请按以下步骤操作

使用Char字段

  1. 声明一个文本计算字段如下

    bokeh_chart = fields.Text(
        string='Bokeh Chart',
        compute='_compute_bokeh_chart',
    )
  2. 在模块顶部添加以下导入

    from bokeh.plotting import figure
    from bokeh.embed import components
    import json
  3. 在其计算方法中做

    def _compute_bokeh_chart(self):
        for rec in self:
            # Design your bokeh figure:
            p = figure()
            line = p.line([0, 2], [1, 8], line_width=5)
            # (...)
            # fill the record field with both markup and the script of a chart.
            script, div = components(p, wrap_script=False)
            rec.bokeh_chart = json.dumps({"div": div, "script": script})
  4. 在视图中,在您想要显示Bokeh图表的任何地方添加以下内容

    <div>
        <field name="bokeh_chart" widget="bokeh_chart" nolabel="1"/>
    </div>

使用Json字段

  1. 声明一个json计算字段如下

    bokeh_chart = fields.Json(
        string='Bokeh Chart',
        compute='_compute_bokeh_chart',
    )
  2. 在模块顶部添加以下导入

    from bokeh.plotting import figure
    from bokeh.embed import components
  3. 在其计算方法中做

    def _compute_bokeh_chart(self):
        for rec in self:
            # Design your bokeh figure:
            p = figure()
            line = p.line([0, 2], [1, 8], line_width=5)
            # (...)
            # fill the record field with both markup and the script of a chart.
            script, div = components(p, wrap_script=False)
            rec.bokeh_chart = {"div": div, "script": script}
  4. 在视图中,在您想要显示Bokeh图表的任何地方添加以下内容

    <div>
        <field name="bokeh_chart" widget="bokeh_chart_json

已知问题/路线图

  1. 在17版本中,我们可以移除char字段,只使用Json字段

错误追踪器

错误在 GitHub Issues 上跟踪。如有问题,请检查是否已报告您的问题。如果您是第一个发现它的,请提供详细的欢迎反馈,帮助我们解决问题。

请不要直接联系贡献者以获取支持或技术问题的帮助。

致谢

作者

  • ForgeFlow

  • Creu Blanca

贡献者

其他致谢

  • 本模块使用Bokeh库,该库受开源BSD 3-clause “New”或“Revised”许可证的约束。版权所有(c)2012,Anaconda,Inc。

  • Odoo社区协会(OCA)

维护者

本模块由OCA维护。

Odoo Community Association

OCA或Odoo社区协会是一个非营利组织,其使命是支持Odoo功能的协作开发并推广其广泛应用。

当前维护者

LoisRForgeFlow ChrisOForgeFlow

本模块是GitHub上OCA/web项目的一部分。

欢迎您贡献力量。有关如何贡献的更多信息,请访问https://odoo-community.org/page/Contribute

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分发

本发布没有提供源分发文件。请参阅生成分发存档的教程。

构建分发

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面