PocPlot

PocPlot — PocPlot canvas widget

Functions

Properties

gfloat border Read / Write / Construct
gboolean enable-plot-fill Read / Write / Construct
GdkRGBA * plot-fill Read / Write
gchar * title Read / Write / Construct
PocAxis * x-axis Read / Write
PocAxis * y-axis Read / Write

Types and Values

#define POC_TYPE_PLOT
  PocPlot

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── GtkWidget
            ╰── GtkDrawingArea
                ╰── PocPlot

Implemented Interfaces

PocPlot implements AtkImplementorIface and GtkBuildable.

Includes

#include <poc.h>

Description

PocPlot is a 2D graph plotting canvas. To create a plot, add PocAxis and PocDataset gadgets to this widget, see poc_plot_add_dataset() and poc_plot_add_axis().

PocPlot as GtkBuildable

The PocPlot implementation supports a custom <plot> element which supports any number of <dataset> and <axis> elements.

An example of a UI definition fragment for a PocPlot.

1
2
3
4
5
6
7
8
9
10
11
12
<object class="PocPlot">
  <plot>
    <dataset source="blue"/>
    <axis source="red" orientation="vertical" hidden="false"/>
  </plot>
</object>
<object class="PocDataset" id="blue">
  ...
</object>
<object class="PocAxis" id="red">
  ...
</object>

The <dataset> element supports the following attributes:

  • source: Xml id of a PocDataset element.

  • x-pack: an optional GtkPackType, how to pack the dataset's X axis.

  • y-pack: an optional GtkPackType, how to pack the dataset's Y axis.

The <axis> elements support the following attribute:

  • source: Xml id of a PocAxis element.

  • pack: an optional GtkPackType, how to pack the axis.

  • orientation: a GtkOrientation, set the Axis orientation

  • hidden: an optional gboolean, whether the axis should be displayed or hidden.

Functions

poc_plot_new ()

PocPlot *
poc_plot_new (void);

Create a new PocPlot

Returns

New PocPlot.

[transfer full]


poc_plot_set_enable_plot_fill ()

void
poc_plot_set_enable_plot_fill (PocPlot *self,
                               gboolean value);

Set whether to fill the plot area plot.

Parameters

self

A PocPlot

 

value

TRUE to enable plot fill.

 

poc_plot_get_enable_plot_fill ()

gboolean
poc_plot_get_enable_plot_fill (PocPlot *self);

Get whether to fill the plot area plot.

Parameters

self

A PocPlot

 

Returns

TRUE if plot fill is enabled.


poc_plot_get_plot_fill ()

void
poc_plot_get_plot_fill (PocPlot *self,
                        GdkRGBA *rgba);

Set the plot area background colour.

Parameters

self

A PocPlot

 

rgba

A GdkRGBA with the plot background colour.

 

poc_plot_set_plot_fill ()

void
poc_plot_set_plot_fill (PocPlot *self,
                        const GdkRGBA *rgba);

Get the plot area plot colour.

Parameters

self

A PocPlot

 

rgba

A GdkRGBA to receive the plot background colour.

 

poc_plot_get_border ()

gfloat
poc_plot_get_border (PocPlot *self);

Get the internal border width.

Parameters

self

A PocPlot

 

Returns

border width


poc_plot_set_border ()

void
poc_plot_set_border (PocPlot *self,
                     gfloat size);

Set the internal border width.

Parameters

self

A PocPlot

 

size

border width

 

poc_plot_set_title ()

void
poc_plot_set_title (PocPlot *self,
                    const gchar *title);

Set the plot title. The title is not used directly by the PocPlot widget, however it may be used by other gadgets added to the plot.

Parameters

self

A PocPlot

 

title

Title for the plot.

 

poc_plot_get_title ()

const gchar *
poc_plot_get_title (PocPlot *self);

Set the plot title.

Parameters

self

A PocPlot

 

Returns

Plot title.

[transfer none]


poc_plot_set_x_axis ()

void
poc_plot_set_x_axis (PocPlot *self,
                     PocAxis *x_axis);

Set the current X axis. This is used to draw the X axis grid lines in the plot area.

Parameters

self

A PocPlot

 

x_axis

PocAxis to set the current plot grid

 

poc_plot_get_x_axis ()

PocAxis *
poc_plot_get_x_axis (PocPlot *self);

Get the current X axis.

Parameters

self

A PocPlot

 

Returns

current X-Axis.

[transfer none]


poc_plot_set_y_axis ()

void
poc_plot_set_y_axis (PocPlot *self,
                     PocAxis *y_axis);

Set the current Y axis. This is used to draw the Y axis grid lines in the plot area.

Parameters

self

A PocPlot

 

y_axis

PocAxis to set the current plot grid

 

poc_plot_get_y_axis ()

PocAxis *
poc_plot_get_y_axis (PocPlot *self);

Get the current Y axis.

Parameters

self

A PocPlot

 

Returns

current Y-Axis.

[transfer none]


poc_plot_set_axis ()

void
poc_plot_set_axis (PocPlot *self,
                   PocAxis *axis);

Set the current axis. The PocPlot determines whether axis refers to an X or Y axis.

Parameters

self

A PocPlot

 

axis

PocAxis to set the current plot grid

 

poc_plot_add_dataset ()

void
poc_plot_add_dataset (PocPlot *self,
                      PocDataset *dataset,
                      GtkPackType x_pack,
                      GtkPackType y_pack);

Add a PocDataset gadget to the plot. x_pack and y_pack determine which edge of the plot should show the axes.

Parameters

self

A PocPlot

 

dataset

PocDataset to add.

 

x_pack

How to pack the X axis.

 

y_pack

How to pack the Y axis (start = bottom, end = top).

 

poc_plot_remove_dataset ()

void
poc_plot_remove_dataset (PocPlot *self,
                         PocDataset *dataset);

Remove a dataset from the plot. The dataset must already belong to the plot. Axes that are no longer referenced by another PocDataset are also removed.

Parameters

self

A PocPlot

 

dataset

PocDataset to remove

 

poc_plot_clear_dataset ()

void
poc_plot_clear_dataset (PocPlot *self);

Remove all datasets from the plot.

Parameters

self

A PocPlot

 

poc_plot_find_dataset ()

PocDataset *
poc_plot_find_dataset (PocPlot *self,
                       const gchar *nickname);

Find a dataset belonging to the plot with the requested nickname.

Parameters

self

A PocPlot

 

nickname

Nickname for a PocDataset

 

Returns

a PocDataset or NULL if not found.

[transfer none]


poc_plot_solo_dataset ()

void
poc_plot_solo_dataset (PocPlot *self,
                       PocDataset *dataset,
                       gboolean solo);

Show only the grid lines and plot data for the specified dataset . If multiple datasets have solo enabled only they are displayed, if no datasets are solo then all datasets are displayed.

Parameters

self

A PocPlot.

 

dataset

A PocDataset belonging to the plot.

 

solo

TRUE to show only this dataset .

 

poc_plot_axis_at_point ()

PocAxis *
poc_plot_axis_at_point (PocPlot *self,
                        gdouble x,
                        gdouble y);

Find the PocAxis under the specifiec x , y coordinate.

Parameters

self

A PocPlot

 

x

x-coordinate in pixels

 

y

y-coordinate in pixels

 

Returns

the PocAxis.

[transfer none]


poc_plot_add_axis ()

void
poc_plot_add_axis (PocPlot *self,
                   PocAxis *axis,
                   gboolean hidden,
                   GtkPackType pack,
                   GtkOrientation orientation);

Add an axis to the plot. pack and orientation specify how the axis should be displayed. Normally this is not required as axes belonging to datasets are added automatically.

Parameters

self

A PocPlot

 

axis

PocAxis to add.

 

hidden

Do not draw axis if TRUE

 

pack

How to pack the axis.

 

orientation

Orientation for the axis.

 

poc_plot_remove_axis ()

void
poc_plot_remove_axis (PocPlot *self,
                      PocAxis *axis);

Remove the axis from the plot.

Parameters

self

A PocPlot

 

axis

PocAxis to remove.

 

poc_plot_clear_axes ()

void
poc_plot_clear_axes (PocPlot *self);

Remove all axes from the plot.

Parameters

self

A PocPlot

 

poc_plot_notify_update ()

void
poc_plot_notify_update (PocPlot *self);

Notify PocPlot of updates in a dataset or axis.

Parameters

self

A PocPlot

 

PocPlotDatasetForEachFunc ()

gboolean
(*PocPlotDatasetForEachFunc) (PocPlot *self,
                              PocDataset *dataset,
                              gpointer user_data);

poc_plot_dataset_foreach ()

PocDataset *
poc_plot_dataset_foreach (PocPlot *self,
                          PocPlotDatasetForEachFunc predicate,
                          gpointer user_data);

Call predicate for each dataset in the plot. If predicate returns TRUE return the dataset. If iteration completes NULL is returned.

Parameters

self

A PocPlot

 

predicate

iterator predicate function.

[scope call]

user_data

user data passed to predicate .

 

Returns

the PocDataset or NULL.

[transfer none]


PocPlotAxisForEachFunc ()

gboolean
(*PocPlotAxisForEachFunc) (PocPlot *self,
                           PocAxis *axis,
                           gpointer user_data);

poc_plot_axis_foreach ()

PocAxis *
poc_plot_axis_foreach (PocPlot *self,
                       PocPlotAxisForEachFunc predicate,
                       gpointer user_data);

Call predicate for each axis in the plot. If predicate returns TRUE return the axis. If iteration completes NULL is returned.

Parameters

self

A PocPlot

 

predicate

iterator predicate function.

[scope call]

user_data

user data passed to predicate .

 

Returns

the PocAxis or NULL.

[transfer none]

Types and Values

POC_TYPE_PLOT

#define POC_TYPE_PLOT			poc_plot_get_type ()

PocPlot

typedef struct _PocPlot PocPlot;

Property Details

The “border” property

  “border”                   gfloat

Internal border width between plot items.

Owner: PocPlot

Flags: Read / Write / Construct

Allowed values: [0,100]

Default value: 6


The “enable-plot-fill” property

  “enable-plot-fill”         gboolean

Enable plot fill colour.

Owner: PocPlot

Flags: Read / Write / Construct

Default value: FALSE


The “plot-fill” property

  “plot-fill”                GdkRGBA *

Plot fill colour for graph area.

Owner: PocPlot

Flags: Read / Write


The “title” property

  “title”                    gchar *

Plot title.

Owner: PocPlot

Flags: Read / Write / Construct

Default value: NULL


The “x-axis” property

  “x-axis”                   PocAxis *

Current X axis - draw X coordinate grid for this axis.

Owner: PocPlot

Flags: Read / Write


The “y-axis” property

  “y-axis”                   PocAxis *

Current X axis - draw Y coordinate grid for this axis.

Owner: PocPlot

Flags: Read / Write

See Also

PocAxis PocDataset PocLegend PocSample