Wt: Wt::Chart::WChart2DRenderer Class Reference

Wt 3.3.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
Wt::Chart::WChart2DRenderer Class Reference
Charts (Wt::Chart)

Helper class for rendering a cartesian chart. More...

`#include <Wt/Chart/WChart2DRenderer>`

List of all members.

## Public Types
enum | AxisProperty { , Grid = 0x2, Line = 0x4 }
| Enumeration that specifies a property of the axes. More...
## Public Member Functions
| WChart2DRenderer (WCartesianChart *chart, WPainter &painter, const WRectF &rectangle)
| Creates a renderer.
virtual | ~WChart2DRenderer ()
| Destructor.
WCartesianChart * | chart ()
| Returns the corresponding chart.
WPainter & | painter ()
| Returns a reference to the painter.
WRectF | chartArea ()
| Returns the main plotting area rectangle.
virtual void | calcChartArea ()
| Calculates the main plotting area rectangle.
bool | initLayout ()
| Initializes the layout.
virtual void | render ()
| Renders the chart.
virtual WPointF | map (double xValue, double yValue, Axis axis=OrdinateAxis, int currentXSegment=0, int currentYSegment=0) const
| Maps a (X, Y) point to chart coordinates.
void | renderLabel (const WString &text, const WPointF &pos, const WColor &color, WFlags< AlignmentFlag > flags, double angle, int margin)
| Utility function for rendering text.
WPointF | hv (double x, double y) const
| Conversion between chart and painter coordinates.
WPointF | hv (const WPointF &f) const
| Conversion between chart and painter coordinates.
WRectF | hv (const WRectF &f) const
| Conversion between chart and painter coordinates.
WRectF | chartSegmentArea (WAxis yAxis, int xSegment, int ySegment) const
| Returns the segment area for a combination of X and Y segments.
## Protected Member Functions
virtual bool | prepareAxes ()
| Prepares the axes for rendering.
virtual void | renderBackground ()
| Renders the background.
virtual void | renderAxes (WFlags< AxisProperty > properties)
| Renders one or more properties of the axes.
virtual void | renderSeries ()
| Renders all series data, including value labels.
virtual void | renderLegend ()
| Renders the (default) legend and chart titles.
int | width () const
| Returns the width along the X axis (as if orientation is Vertical)
int | height () const
| Returns the height along the Y axis (as if orientation is Vertical)
int | segmentMargin () const
| Returns the segment margin.
void | renderAxis (const WAxis &axis, WFlags< AxisProperty > properties)
| Renders properties of one axis.
int | calcNumBarGroups ()
| Calculates the total number of bar groups.
void | iterateSeries (SeriesIterator *iterator, bool reverseStacked=false)
| Iterates over the series using an iterator.
## Protected Attributes
AxisValue | location_ [3]
| The computed axis locations.

## Detailed Description

Helper class for rendering a cartesian chart.

This class is used by WCartesianChart during rendering, and normally, you will not need to use this class directly. You may want to specialize this class if you want to override particular aspects of how the chart is renderered. In that case, you will want to instantiate the specialized class in WCartesianChart::createRenderer().

To simplify the simulatenous handling of Horizontal and Vertical charts, the renderer makes abstraction of the orientation of the chart: regardless of the chart orientation, the width() corresponds to the length along the X axis, and height() corresponds to the length along the Y axis. Similarly, calcChartArea() and chartArea() return a rectangle where the bottom side corresponds to the lowest displayed Y values, and the left side corresponds to the lowest displayed X values. To map these "chart coordinates" to painter coordinates, use one of the hv() methods.

Note, this class is part of the internal charting API, and may be subject of changes and refactorings.

## Member Enumeration Documentation

enum Wt::Chart::WChart2DRenderer::AxisProperty

Enumeration that specifies a property of the axes.

Enumerator:

  Grid | Labels property.
  Line | Grid property.

## Constructor & Destructor Documentation

Wt::Chart::WChart2DRenderer::WChart2DRenderer | ( | WCartesianChart * | chart,
|  | WPainter & | painter,
|  | const WRectF & | rectangle
| ) |  |

Creates a renderer.

Creates a renderer for the cartesian chart chart, for rendering in the specified rectangle of the painter.

## Member Function Documentation

void Wt::Chart::WChart2DRenderer::calcChartArea | ( |  | ) | `[virtual]`

Calculates the main plotting area rectangle.

This method calculates the main plotting area, and stores it in the member chartArea_. The default implementation simply removes the plot area padding from the entire painting rectangle.

See also:
  WCartesianChart::plotAreaPadding().

WRectF Wt::Chart::WChart2DRenderer::chartArea | ( |  | ) |

Returns the main plotting area rectangle.

This area is calculated and cached by calcChartArea().

WRectF Wt::Chart::WChart2DRenderer::chartSegmentArea | ( | WAxis | yAxis,
|  | int | xSegment,
|  | int | ySegment
| ) |  | const

Returns the segment area for a combination of X and Y segments.

This segment area is used for clipping when rendering in a particular segment.

WPointF Wt::Chart::WChart2DRenderer::hv | ( | double | x,
|  | double | y
| ) |  | const

Conversion between chart and painter coordinates.

Converts from chart coordinates to painter coordinates, taking into account the chart orientation.

WPointF Wt::Chart::WChart2DRenderer::hv | ( | const WPointF & | f | ) | const

Conversion between chart and painter coordinates.

Converts from chart coordinates to painter coordinates, taking into account the chart orientation.

WRectF Wt::Chart::WChart2DRenderer::hv | ( | const WRectF & | f | ) | const

Conversion between chart and painter coordinates.

Converts from chart coordinates to painter coordinates, taking into account the chart orientation.

bool Wt::Chart::WChart2DRenderer::initLayout | ( |  | ) |

Initializes the layout.

This computes the chart plotting area dimensions, and intializes the axes so that they provide a suitable mapping from logical coordinates to device coordinates.

WPointF Wt::Chart::WChart2DRenderer::map | ( | double | xValue,
|  | double | yValue,
|  | Axis | axis = `OrdinateAxis`,
|  | int | currentXSegment = `0`,
|  | int | currentYSegment = `0`
| ) |  | const`[virtual]`

Maps a (X, Y) point to chart coordinates.

This method maps the point with given (xValue, yValue) to chart coordinates. The y value is mapped by one of the Y axes indicated by axis.

Note that chart coordinates may not be the same as painter coordinates, because of the chart orientation. To map from chart coordinates to painter coordinates, use hv().

The currentXSegment and currentYSegment specify the axis segments in which you wish to map the point.

bool Wt::Chart::WChart2DRenderer::prepareAxes | ( |  | ) | `[protected, virtual]`

Prepares the axes for rendering.

Computes axis properties such as the range (if not manually specified), label interval (if not manually specified) and axis locations. These properties are stored within the axes (we may want to change that later to allow for reentrant rendering by multiple renderers ?).

void Wt::Chart::WChart2DRenderer::render | ( |  | ) | `[virtual]`

Renders the chart.

This method renders the chart. The default implementation does the following:

     calcChartArea();           // sets chartArea_
     prepareAxes();             // provides logical dimensions to the axes

     renderBackground();        // render the background
     renderAxes(Grid);          // render the grid
     renderSeries();            // render the data series
     renderAxes(Line | Labels); // render the axes (lines & labels)
     renderLegend();            // render legend and titles

You may want to reimplement this method to change the sequence of steps for rendering the chart.

void Wt::Chart::WChart2DRenderer::renderAxis | ( | const WAxis & | axis,
|  | WFlags< AxisProperty > | properties
| ) |  | `[protected]`

Renders properties of one axis.

See also:
  renderAxes()

void Wt::Chart::WChart2DRenderer::renderLabel | ( | const WString & | text,
|  | const WPointF & | pos,
|  | const WColor & | color,
|  | WFlags< AlignmentFlag > | flags,
|  | double | angle,
|  | int | margin
| ) |  |

Utility function for rendering text.

This method renders text on the chart position pos, with a particular alignment flags. These are both specified in chart coordinates. The position is converted to painter coordinates using hv(), and the alignment flags are changed accordingly. The rotation, indicated by angle is specified in painter coordinates and thus an angle of 0 always indicates horizontal text, regardless of the chart orientation.

int Wt::Chart::WChart2DRenderer::segmentMargin | ( |  | ) | const`[protected]`

Returns the segment margin.

This is the separation between segments, and defaults to 40 pixels.

## Member Data Documentation

AxisValue Wt::Chart::WChart2DRenderer::location_[3]`[protected]`

The computed axis locations.

See also:
  prepareAxes()

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator