Chart-1.2.2: A library for generating 2D Charts and Plots

Safe HaskellNone

Graphics.Rendering.Chart.Layout

Description

This module glues together axes and plots to actually create a renderable for a chart.

Note that Template haskell is used to derive accessor functions (see Lens) for each field of the following data types:

These accessors are not shown in this API documentation. They have the same name as the field, but with the leading underscore dropped. Hence for data field _f::F in type D, they have type

   f :: Lens' D F

Synopsis

Documentation

data Layout x y Source

A Layout value is a single plot area, with single x and y axis. The title is at the top and the legend at the bottom. It's parametrized by the types of values to be plotted on the x and y axes.

Constructors

Layout 

Fields

_layout_background :: FillStyle

How to fill the background of everything.

_layout_plot_background :: Maybe FillStyle

How to fill the background of the plot, if different from the overall background.

_layout_title :: String

Title to display above the chart.

_layout_title_style :: FontStyle

Font style to use for the title.

_layout_x_axis :: LayoutAxis x

Rules to generate the x axis.

_layout_top_axis_visibility :: AxisVisibility

Visibility options for the top axis.

_layout_bottom_axis_visibility :: AxisVisibility

Visibility options for the bottom axis.

_layout_y_axis :: LayoutAxis y

Rules to generate the y axis.

_layout_left_axis_visibility :: AxisVisibility

Visibility options for the left axis.

_layout_right_axis_visibility :: AxisVisibility

Visibility options for the right axis.

_layout_plots :: [Plot x y]

The data sets to plot in the chart. The are ploted over each other.

_layout_legend :: Maybe LegendStyle

How to style the legend.

_layout_margin :: Double

The margin distance to use.

_layout_grid_last :: Bool

If the grid shall be rendered beneath (False) or over (True) all plots.

Instances

(PlotValue x, PlotValue y) => Default (Layout x y)

Empty Layout without title and plots. The background is white and the grid is drawn beneath all plots. There will be a legend. The top and right axis will not be visible.

(Ord x, Ord y) => ToRenderable (Layout x y) 

data LayoutLR x y1 y2 Source

A LayoutLR value is a single plot area, with an x axis and independent left and right y axes, with a title at the top; legend at the bottom. It's parametrized by the types of values to be plotted on the x and two y axes.

Constructors

LayoutLR 

Fields

_layoutlr_background :: FillStyle

How to fill the background of everything.

_layoutlr_plot_background :: Maybe FillStyle

How to fill the background of the plot, if different from the overall background.

_layoutlr_title :: String

Title to display above the chart.

_layoutlr_title_style :: FontStyle

Font style to use for the title.

_layoutlr_x_axis :: LayoutAxis x

Rules to generate the x axis.

_layoutlr_top_axis_visibility :: AxisVisibility

Visibility options for the top axis.

_layoutlr_bottom_axis_visibility :: AxisVisibility

Visibility options for the bottom axis.

_layoutlr_left_axis :: LayoutAxis y1

Rules to generate the left y axis.

_layoutlr_left_axis_visibility :: AxisVisibility

Visibility options for the left axis.

_layoutlr_right_axis :: LayoutAxis y2

Rules to generate the right y axis.

_layoutlr_right_axis_visibility :: AxisVisibility

Visibility options for the right axis.

_layoutlr_plots :: [Either (Plot x y1) (Plot x y2)]

The data sets to plot in the chart. The are ploted over each other. The either type associates the plot with the left or right y axis.

_layoutlr_legend :: Maybe LegendStyle

How to style the legend.

_layoutlr_margin :: Double

The margin distance to use.

_layoutlr_grid_last :: Bool

If the grid shall be rendered beneath (False) or over (True) all plots.

Instances

(PlotValue x, PlotValue y1, PlotValue y2) => Default (LayoutLR x y1 y2)

Empty LayoutLR without title and plots. The background is white and the grid is drawn beneath all plots. There will be a legend. The top axis will not be visible.

(Ord x, Ord yl, Ord yr) => ToRenderable (LayoutLR x yl yr) 

data LayoutAxis x Source

Type of axis that is used in Layout and LayoutLR.

To generate the actual axis type (AxisData and AxisT) the _laxis_generate function is called and custom settings are applied with _laxis_override. Note that the AxisVisibility values in Layout and LayoutLR override visibility related settings of the axis.

Constructors

LayoutAxis 

Fields

_laxis_title_style :: FontStyle

Font style to use for the axis title.

_laxis_title :: String

Title displayed for the axis.

_laxis_style :: AxisStyle

Axis style applied.

_laxis_generate :: AxisFn x

Function that generates the axis data, based upon the points plotted. The default value is autoAxis.

_laxis_override :: AxisData x -> AxisData x

Function that can be used to override the generated axis data. The default value is id.

_laxis_reverse :: Bool

True if left to right (bottom to top) is to show descending values.

Instances

data LayoutPick x y1 y2 Source

Information on what is at a specifc location of a Layout or LayoutLR. This is delivered by the PickFn of a Renderable.

Constructors

LayoutPick_Legend String

A legend entry.

LayoutPick_Title String

The title.

LayoutPick_XTopAxisTitle String

The title of the top x axis.

LayoutPick_XBottomAxisTitle String

The title of the bottom x axis.

LayoutPick_YLeftAxisTitle String

The title of the left y axis.

LayoutPick_YRightAxisTitle String

The title of the right y axis.

LayoutPick_PlotArea x y1 y2

The plot area at the given plot coordinates.

LayoutPick_XTopAxis x

The top x axis at the given plot coordinate.

LayoutPick_XBottomAxis x

The bottom x axis at the given plot coordinate.

LayoutPick_YLeftAxis y1

The left y axis at the given plot coordinate.

LayoutPick_YRightAxis y2

The right y axis at the given plot coordinate.

Instances

(Show x, Show y1, Show y2) => Show (LayoutPick x y1 y2) 

data StackedLayouts x Source

A container for a set of vertically StackedLayouts. The x axis of the different layouts will be aligned.

Constructors

StackedLayouts 

Fields

_slayouts_layouts :: [StackedLayout x]

The stacked layouts from top (first element) to bottom (last element).

_slayouts_compress_legend :: Bool

If the different legends shall be combined in one legend at the bottom.

Instances

Default (StackedLayouts x)

A empty StackedLayout with compressions applied.

data StackedLayout x Source

A layout with its y type hidden, so that it can be stacked with other layouts with differing y axis, but the same x axis. See StackedLayouts.

Constructors

forall y . Ord y => StackedLayout (Layout x y)

A Layout to stack.

forall yl yr . (Ord yl, Ord yr) => StackedLayoutLR (LayoutLR x yl yr)

A LayoutLR to stack.

type MAxisFn t = [t] -> Maybe (AxisData t)Source

A MAxisFn is a function that generates an (optional) axis given the points plotted against that axis.

layoutToRenderable :: forall x y. (Ord x, Ord y) => Layout x y -> Renderable (LayoutPick x y y)Source

Render the given Layout.

layoutLRToRenderable :: forall x yl yr. (Ord x, Ord yl, Ord yr) => LayoutLR x yl yr -> Renderable (LayoutPick x yl yr)Source

Render the given LayoutLR.

setLayoutForeground :: AlphaColour Double -> Layout x y -> Layout x ySource

Helper to set the forground color uniformly on a Layout.

updateAllAxesStyles :: (AxisStyle -> AxisStyle) -> Layout x y -> Layout x ySource

Helper to update all axis styles on a Layout1 simultaneously.

setLayoutLRForeground :: AlphaColour Double -> LayoutLR x yl yr -> LayoutLR x yl yrSource

Helper to set the forground color uniformly on a LayoutLR.

updateAllAxesStylesLR :: (AxisStyle -> AxisStyle) -> LayoutLR x yl yr -> LayoutLR x yl yrSource

Helper to update all axis styles on a LayoutLR simultaneously.

defaultLayoutAxis :: PlotValue t => LayoutAxis tSource

Deprecated: Use the according Data.Default instance!

layout_title :: forall x y. Lens' (Layout x y) StringSource

layout_x_axis :: forall x y. Lens' (Layout x y) (LayoutAxis x)Source

layout_y_axis :: forall x y. Lens' (Layout x y) (LayoutAxis y)Source

layout_margin :: forall x y. Lens' (Layout x y) DoubleSource

layout_plots :: forall x y. Lens' (Layout x y) [Plot x y]Source

layoutlr_background :: forall x y1 y2. Lens' (LayoutLR x y1 y2) FillStyleSource

layoutlr_title :: forall x y1 y2. Lens' (LayoutLR x y1 y2) StringSource

layoutlr_title_style :: forall x y1 y2. Lens' (LayoutLR x y1 y2) FontStyleSource

layoutlr_x_axis :: forall x y1 y2. Lens' (LayoutLR x y1 y2) (LayoutAxis x)Source

layoutlr_left_axis :: forall x y1 y2. Lens' (LayoutLR x y1 y2) (LayoutAxis y1)Source

layoutlr_right_axis :: forall x y1 y2. Lens' (LayoutLR x y1 y2) (LayoutAxis y2)Source

layoutlr_plots :: forall x y1 y2. Lens' (LayoutLR x y1 y2) [Either (Plot x y1) (Plot x y2)]Source

layoutlr_legend :: forall x y1 y2. Lens' (LayoutLR x y1 y2) (Maybe LegendStyle)Source

layoutlr_margin :: forall x y1 y2. Lens' (LayoutLR x y1 y2) DoubleSource

layoutlr_grid_last :: forall x y1 y2. Lens' (LayoutLR x y1 y2) BoolSource

defaultStackedLayouts :: StackedLayouts xSource

Deprecated: Use the according Data.Default instance!

renderStackedLayouts :: forall x. Ord x => StackedLayouts x -> Renderable ()Source

Render several layouts with the same x-axis type and range, vertically stacked so that their origins and x-values are aligned.

The legends from all the charts may be optionally combined, and shown once on the bottom chart. See StackedLayouts for further information.