G2 是一种可视化语法,用于仪表盘构建、数据探索和故事讲述。
创建该项目是为了在 streamlit 中渲染 G2 图表。Live Demo
Installation
pip install streamlit-g2
Usage
import streamlit as st from streamlit_g2 import g2 options = { "type": "interval", "data": [ { "genre": 'Sports', "sold": 275 }, { "genre": 'Strategy', "sold": 115 }, { "genre": 'Action', "sold": 120 }, { "genre": 'Shooter', "sold": 350 }, { "genre": 'Other', "sold": 150 }, ], "encode": { "x": "genre", "y": "sold", "color": "genre", } } g2(options=options, style=None, key="streamlit_g2")
API
streamlit-g2 目前只有一个名为 g2 的 API,参见 G2 Spec API 中的选项。
Property | Description | Type | Default |
---|---|---|---|
options | the options for the visualization, say chart.options(options) |
G2options | null |
- |
style | the style of the container | CSSProperties |
- |
评论