CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-pyecharts

Python ❤️ ECharts = pyecharts - comprehensive data visualization toolkit built on Apache ECharts

Pending
Overview
Eval results
Files

composite-charts.mddocs/

Composite Charts

Multi-chart layouts and complex visualizations for creating dashboards, reports, and comprehensive data presentations. These components enable combining multiple charts, creating animations, and organizing content across pages and tabs.

Capabilities

Grid Layouts

Combine multiple charts in a single layout with precise positioning control.

class Grid:
    def __init__(self, init_opts=None, render_opts=None):
        """
        Initialize a grid layout.
        
        Args:
            init_opts (InitOpts, optional): Chart initialization options
            render_opts (RenderOpts, optional): Rendering options
        """

    def add(self, chart, grid_opts, grid_index=0):
        """
        Add a chart to the grid.
        
        Args:
            chart: Chart instance to add
            grid_opts (GridOpts): Grid positioning options
            grid_index (int): Grid index for multiple grids
            
        Returns:
            Grid: Self for method chaining
        """

Usage Example:

from pyecharts.charts import Bar, Line, Grid
from pyecharts import options as opts

# Create individual charts
bar = (
    Bar()
    .add_xaxis(["A", "B", "C"])
    .add_yaxis("Series", [1, 2, 3])
)

line = (
    Line()
    .add_xaxis(["A", "B", "C"])
    .add_yaxis("Series", [3, 2, 1])
)

# Combine in grid
grid = (
    Grid()
    .add(bar, grid_opts=opts.GridOpts(pos_left="55%"))
    .add(line, grid_opts=opts.GridOpts(pos_right="55%"))
)

Timeline Animations

Create animated charts that change over time with timeline controls.

class Timeline:
    def __init__(self, init_opts=None, render_opts=None):
        """
        Initialize a timeline animation.
        
        Args:
            init_opts (InitOpts, optional): Chart initialization options
            render_opts (RenderOpts, optional): Rendering options
        """

    def add(self, chart, time_point):
        """
        Add a chart frame to the timeline.
        
        Args:
            chart: Chart instance for this time point
            time_point (str): Time point label
            
        Returns:
            Timeline: Self for method chaining
        """

    def add_schema(self, **kwargs):
        """
        Configure timeline settings.
        
        Args:
            axis_type (str): Timeline axis type ("category", "time", "value")
            is_auto_play (bool): Enable auto-play
            is_loop_play (bool): Loop animation
            is_rewind_play (bool): Enable rewind
            play_interval (int): Play interval in milliseconds
            is_timeline_show (bool): Show timeline control
            symbol (str): Timeline symbol
            symbol_size (int): Timeline symbol size
            is_inverse (bool): Inverse timeline direction
            pos_left (str): Left position
            pos_right (str): Right position
            pos_top (str): Top position
            pos_bottom (str): Bottom position
            width (str): Timeline width
            height (str): Timeline height
            
        Returns:
            Timeline: Self for method chaining
        """

Multi-Page Documents

Create multi-page chart documents for comprehensive reports and dashboards.

class Page:
    def __init__(self, page_title="Awesome-pyecharts", layout_opts=None):
        """
        Initialize a multi-page document.
        
        Args:
            page_title (str): Document title
            layout_opts (PageLayoutOpts, optional): Page layout configuration
        """

    def add(self, *charts):
        """
        Add charts to the page.
        
        Args:
            *charts: Variable number of chart instances
            
        Returns:
            Page: Self for method chaining
        """

    def render(self, path="render.html"):
        """
        Render the multi-page document.
        
        Args:
            path (str): Output file path
            
        Returns:
            str: Generated HTML content
        """

    def save_resize_html(self, source_path, dest_path, cfg_file=None, cfg_dict=None):
        """
        Save resized HTML version.
        
        Args:
            source_path (str): Source HTML file path
            dest_path (str): Destination file path
            cfg_file (str, optional): Configuration file path
            cfg_dict (dict, optional): Configuration dictionary
        """

Tabbed Interfaces

Create tabbed chart interfaces for organized content presentation.

class Tab:
    def __init__(self, page_title="Awesome-pyecharts"):
        """
        Initialize a tabbed interface.
        
        Args:
            page_title (str): Document title
        """

    def add(self, chart, tab_name):
        """
        Add a chart as a tab.
        
        Args:
            chart: Chart instance
            tab_name (str): Tab label
            
        Returns:
            Tab: Self for method chaining
        """

    def render(self, path="render.html"):
        """
        Render the tabbed interface.
        
        Args:
            path (str): Output file path
            
        Returns:
            str: Generated HTML content
        """

Configuration Options

Grid Configuration

class GridOpts:
    def __init__(self, **kwargs):
        """
        Grid positioning and spacing options.
        
        Args:
            pos_left (str|int): Left position ("20%", 100)
            pos_right (str|int): Right position
            pos_top (str|int): Top position
            pos_bottom (str|int): Bottom position
            width (str|int): Grid width
            height (str|int): Grid height
            is_contain_label (bool): Include axis labels in grid area
            background_color (str): Grid background color
            border_color (str): Grid border color
            border_width (int): Grid border width
            shadow_blur (int): Shadow blur radius
            shadow_color (str): Shadow color
            shadow_offset_x (int): Shadow X offset
            shadow_offset_y (int): Shadow Y offset
            opacity (float): Grid opacity
            tooltip_opts (TooltipOpts): Grid-specific tooltip options
        """

Page Layout Configuration

class PageLayoutOpts:
    def __init__(self, **kwargs):
        """
        Multi-page layout configuration.
        
        Args:
            justify_content (str): Horizontal alignment ("center", "start", "end", "space-around", "space-between")
            align_items (str): Vertical alignment ("center", "start", "end")
            display (str): Display mode ("flex")
            flex_wrap (str): Flex wrap behavior ("wrap", "nowrap")
            margin (str): Page margins
            padding (str): Page padding
            background_color (str): Page background color
        """

Timeline Configuration

class TimelineCheckPointerStyle:
    def __init__(self, **kwargs):
        """
        Timeline checkpoint styling.
        
        Args:
            color (str): Checkpoint color
            border_color (str): Checkpoint border color
            border_width (int): Checkpoint border width
            symbol (str): Checkpoint symbol
            symbol_size (int): Checkpoint symbol size
            symbol_offset (list): Symbol offset [x, y]
            animation_duration (int): Animation duration
            animation_easing (str): Animation easing function
        """

class TimelineControlStyle:
    def __init__(self, **kwargs):
        """
        Timeline control button styling.
        
        Args:
            is_show (bool): Show control buttons
            show_play_button (bool): Show play button
            show_prev_button (bool): Show previous button
            show_next_button (bool): Show next button
            itemsize (int): Control button size
            itemgap (int): Gap between control buttons
            position (str): Control position ("left", "right", "top", "bottom")
            play_icon (str): Play button icon
            stop_icon (str): Stop button icon
            prev_icon (str): Previous button icon
            next_icon (str): Next button icon
            color (str): Control button color
            border_color (str): Control button border color
            border_width (int): Control button border width
        """

Tab Configuration

class TabChartGlobalOpts:
    def __init__(self, **kwargs):
        """
        Tab chart global options.
        
        Args:
            animation_opts (AnimationOpts): Animation configuration
            title_opts (TitleOpts): Title configuration
            legend_opts (LegendOpts): Legend configuration
            tooltip_opts (TooltipOpts): Tooltip configuration
            toolbox_opts (ToolboxOpts): Toolbox configuration
            brush_opts (BrushOpts): Brush configuration
            datazoom_opts (list): Data zoom controls
            visualmap_opts (VisualMapOpts): Visual mapping
            aria_opts (AriaOpts): Accessibility options
            dataset_opts (DatasetOpts): Dataset configuration
        """

Advanced Composite Patterns

Synchronized Charts

Create multiple charts that share interactions and data updates:

# Example: Synchronized bar and line charts
from pyecharts.charts import Bar, Line, Grid
from pyecharts import options as opts

# Shared data
categories = ["Jan", "Feb", "Mar", "Apr", "May"]
values1 = [120, 132, 101, 134, 90]
values2 = [220, 182, 191, 234, 290]

# Create charts with shared x-axis
bar = (
    Bar()
    .add_xaxis(categories)
    .add_yaxis("Product A", values1)
    .set_global_opts(
        title_opts=opts.TitleOpts(title="Sales Data"),
        legend_opts=opts.LegendOpts(pos_top="5%"),
        toolbox_opts=opts.ToolboxOpts(is_show=True),
        brush_opts=opts.BrushOpts()  # Enable data brushing
    )
)

line = (
    Line()
    .add_xaxis(categories)
    .add_yaxis("Product B", values2)
    .set_global_opts(
        legend_opts=opts.LegendOpts(pos_top="5%"),
        toolbox_opts=opts.ToolboxOpts(is_show=True),
        brush_opts=opts.BrushOpts()
    )
)

# Combine with synchronized interactions
grid = (
    Grid(init_opts=opts.InitOpts(width="1200px", height="600px"))
    .add(bar, grid_opts=opts.GridOpts(pos_bottom="60%"))
    .add(line, grid_opts=opts.GridOpts(pos_top="60%"))
)

Dashboard Layouts

Create comprehensive dashboards with multiple visualization types:

# Example: Multi-chart dashboard
from pyecharts.charts import Bar, Pie, Line, Scatter, Page
from pyecharts import options as opts

# Create individual charts
bar_chart = Bar().add_xaxis([...]).add_yaxis("Sales", [...])
pie_chart = Pie().add("Market Share", [...])
line_chart = Line().add_xaxis([...]).add_yaxis("Trend", [...])
scatter_chart = Scatter().add_xaxis([...]).add_yaxis("Correlation", [...])

# Organize in dashboard
dashboard = (
    Page(page_title="Business Dashboard")
    .add(bar_chart, pie_chart, line_chart, scatter_chart)
)

Interactive Animations

Create complex animated visualizations with timeline controls:

# Example: Animated bubble chart over time
from pyecharts.charts import Scatter, Timeline
from pyecharts import options as opts

timeline = Timeline()

for year in range(2010, 2021):
    # Create scatter chart for each year
    scatter = (
        Scatter()
        .add_xaxis([...])  # GDP data for year
        .add_yaxis(f"Year {year}", [...])  # Population data
        .set_global_opts(
            title_opts=opts.TitleOpts(title=f"GDP vs Population - {year}"),
            visualmap_opts=opts.VisualMapOpts(max_=100)
        )
    )
    timeline.add(scatter, str(year))

# Configure animation
timeline.add_schema(
    is_auto_play=True,
    play_interval=1000,
    is_timeline_show=True
)

Install with Tessl CLI

npx tessl i tessl/pypi-pyecharts

docs

3d-charts.md

basic-charts.md

composite-charts.md

geographic-charts.md

index.md

options.md

rendering.md

utilities.md

tile.json