Skip to main content

将 highchart 配置转换为图像文件的 Python 包

项目描述

highchartexport

使用 HighCharts 的导出服务器将 highchart 配置转换为图像文件,即http://export.highcharts.com/

安装

您可以使用 pip 命令

pip install highchartexport

例子

在终端

highchartexport --json "{\"chart\":{\"type\":\"area\"},\"series\":[{\"data\":[1,2,3,4,5,6],\"name\":\"areaplot\"}]}" --out area_chart.png
highchartexport --json "{\"chart\":{\"type\":\"area\"},\"series\":[{\"data\":[1,2,3,4,5,6],\"name\":\"areaplot\"}]}" --out area_chart.png --width 2000 --scale 2

通过 highchart json 文件

  • 对于 PNG 图像文件
highchartexport --in hc_config.json --out area_chart.png --width 2000 --scale 2 --type png
  • 对于 SVG 文件
highchartexport --in hc_config.json --out area_chart.svg --width 2000 --scale 2 --type svg
  • 对于带有 StockChart 的 SVG 文件
highchartexport --in hc_config.json --out area_chart.svg --chart StockChart --width 2000 --scale 2 --type svg
  • 对于带有地图的 PDF 文件
highchartexport --in hc_config.json --out area_chart.svg --chart Map --width 2000 --scale 2 --type pdf

在你的 Python 程序中导入

import highchartexport as hc_export

config = {
    "chart": {
        "type": 'bubble',
        "plotBorderWidth": 1,
        "zoomType": 'xy'
    },

    "title": {
        "text": 'Highcharts bubbles save in pdf file'
    },

    "series": [{
        "data": [
            [19, 81, 63],
            [98, 5, 89],
            [51, 50, 73],
        ],
        "marker": {
            "fillColor": {
                "radialGradient": { "cx": 0.4, "cy": 0.3, "r": 0.7 },
                "stops": [
                    [0, 'rgba(255,255,255,0.5)'],
                    [1, 'rgba(200, 200, 200, 0.8)']
                ]
            }
        }
    }]
}

# use default width and scale value
hc_export.save_as_pdf(config=config, filename="bubble.pdf")

# you can pass width and scale value
hc_export.save_as_pdf(config=config, filename="bubble.pdf", width=1000, scale=4)

项目详情


下载文件

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

源分布

highchartexport-0.0.5.tar.gz (25.2 kB 查看哈希

已上传 source

内置分布

highchartexport-0.0.5-py3-none-any.whl (17.4 kB 查看哈希

已上传 py3