ChartForm

class compas_rhino.forms.ChartForm(*args, **kwargs)[source]

Bases: BaseForm

A form for displaying charts.

Parameters
  • series (list[dict]) – A list of dictionaries with each dictionary defining the attributes of a series. The following attributes are supported:

    • name: The name of the series.

    • data: A dictionary with x-y pairs.

    • color (optional): A hex color or an RGB(255) color specification.

    • linewidth (optional): The width of the series graph line.

    • linetype (optional): The visual style of the graph line. Should be one of {'solid', 'dotted', 'dashed'}.

  • xlimits (tuple[float, float]) – Minimum and maximum values on the X-axis.

  • xstep (int) – Size of the steps along the X-axis.

  • ylimits (tuple[float, float], optional) – Minimum and maximum values on the Y-axis. Default is None, in which case the limits will be computed from the min/max values of the data in the series.

  • ystep (int, optional) – Size of the steps along the Y-axis. Default is int((ymax - ymin) / 10.)`.

  • chartsize (tuple[int, int], optional) – The size of the form in pixels.

  • padding (tuple[int, int, int, int], optional) – Padding of the area inside the form.

  • bgcolor (tuple[int, int, int], optional) – The background color of the chart area.

  • title (str, optional) – Title of the form.

Examples

import random

from compas.utilities import fibonacci
from compas_rhino.forms import ChartForm

series = [
    {
        'name'      : 'series1',
        'color'     : (255, 0, 0),
        'linewidth' : 1,
        'linestyle' : 'dashed',
        'data'      : dict((str(i), random.randint(30, 70)) for i in range(10)),
    },
    {
        'name'      : 'series2',
        'color'     : (0, 255, 0),
        'linewidth' : 1,
        'linestyle' : 'solid',
        'data'      : dict((str(i), i ** 2) for i in range(10)),
    },
    {
        'name'      : 'series3',
        'color'     : (0, 0, 255),
        'linewidth' : 1,
        'linestyle' : 'dotted',
        'data'      : dict((str(i), fibonacci(i)) for i in range(10)),
    },
]

form = ChartForm(series, (0, 10), 1)
form.show()

Methods

init

Initialize the form.

Inherited Methods

on_form_closed

Callback for the closing event of the form.

show

Show the form as a modal dialog.