Wt  3.3.3
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
Public Member Functions | Protected Member Functions | List of all members
Wt::Chart::WCartesianChart Class Reference

A cartesian chart. More...

#include <Wt/Chart/WCartesianChart>

Inheritance diagram for Wt::Chart::WCartesianChart:
Inheritance graph
[legend]

Public Member Functions

 WCartesianChart (WContainerWidget *parent=0)
 Creates a new cartesian chart. More...
 
 WCartesianChart (ChartType type, WContainerWidget *parent=0)
 Creates a new cartesian chart. More...
 
void setType (ChartType type)
 Sets the chart type. More...
 
ChartType type () const
 Returns the chart type. More...
 
void setOrientation (Orientation orientation)
 Sets the chart orientation. More...
 
Orientation orientation () const
 Returns the chart orientation. More...
 
void setXSeriesColumn (int modelColumn)
 Sets the the model column for the X series. More...
 
int XSeriesColumn () const
 Returns the model column for the X series. More...
 
void addSeries (const WDataSeries &series)
 Adds a data series. More...
 
void removeSeries (int modelColumn)
 Removes a data series. More...
 
void setSeries (const std::vector< WDataSeries > &series)
 Sets all data series. More...
 
WDataSeriesseries (int modelColumn)
 Returns a data series corresponding to a data column. More...
 
const WDataSeriesseries (int modelColumn) const
 Returns a data series corresponding to a data column. More...
 
const std::vector< WDataSeries > & series () const
 Returns a list with the current data series. More...
 
WAxisaxis (Axis axis)
 Returns a chart axis. More...
 
const WAxisaxis (Axis axis) const
 Accesses a chart axis. More...
 
void setBarMargin (double margin)
 Sets the margin between bars of different series. More...
 
double barMargin () const
 Returns the margin between bars of different series. More...
 
void setLegendEnabled (bool enabled)
 Enables the legend. More...
 
bool isLegendEnabled () const
 Returns whether the legend is enabled. More...
 
void setLegendLocation (LegendLocation location, Side side, AlignmentFlag alignment)
 Configures the legend location. More...
 
void setLegendStyle (const WFont &font, const WPen &border, const WBrush &background)
 Configures the legend decoration. More...
 
LegendLocation legendLocation () const
 Returns the legend location. More...
 
Side legendSide () const
 Returns the legend side. More...
 
AlignmentFlag legendAlignment () const
 Returns the legend alignment. More...
 
int legendColumns () const
 Returns the legend columns. More...
 
WLength legendColumnWidth () const
 Returns the legend column width. More...
 
WFont legendFont () const
 Returns the legend font. More...
 
WPen legendBorder () const
 Returns the legend border pen. More...
 
WBrush legendBackground () const
 Returns the legend background brush. More...
 
void setLegendColumns (int columns, const WLength &width)
 Configures multiple legend columns. More...
 
virtual void paint (WPainter &painter, const WRectF &rectangle=WRectF()) const
 Paint the chart in a rectangle of the given painter. More...
 
virtual void drawMarker (const WDataSeries &series, WPainterPath &result) const
 Draws the marker for a given data series. More...
 
virtual void renderLegendIcon (WPainter &painter, const WPointF &pos, const WDataSeries &series) const
 Renders the legend icon for a given data series. More...
 
virtual void renderLegendItem (WPainter &painter, const WPointF &pos, const WDataSeries &series) const
 Renders the legend item for a given data series. More...
 
WPointF mapFromDevice (const WPointF &point, Axis ordinateAxis=OrdinateAxis) const
 Maps from device coordinates to model coordinates. More...
 
WPointF mapToDevice (const boost::any &xValue, const boost::any &yValue, Axis axis=OrdinateAxis, int xSegment=0, int ySegment=0) const
 Maps model values onto chart coordinates. More...
 
bool initLayout (const WRectF &rectangle=WRectF()) const
 Initializes the chart layout. More...
 
WWidgetcreateLegendItemWidget (int index)
 Creates a widget which renders the a legend item. More...
 
virtual void addDataPointArea (const WDataSeries &series, const WModelIndex &xIndex, WAbstractArea *area)
 Adds a data point area (used for displaying e.g. tooltips). More...
 
void setAxisPadding (int axisPadding)
 Sets the padding between the chart area and the axes. More...
 
int axisPadding () const
 Returns the padding between the chart area and the axes. More...
 
- Public Member Functions inherited from Wt::Chart::WAbstractChart
virtual ~WAbstractChart ()
 Destructor.
 
void setModel (WAbstractItemModel *model)
 Set the model. More...
 
WAbstractItemModelmodel () const
 Returns the model. More...
 
void setBackground (const WBrush &background)
 Sets a background for the chart. More...
 
const WBrushbackground () const
 Returns the background of the chart. More...
 
void setPalette (WChartPalette *palette)
 Set a palette for the chart. More...
 
WChartPalettepalette () const
 Returns the palette for the chart. More...
 
void setPlotAreaPadding (int padding, WFlags< Side > sides=All)
 Set an internal margin for the main plot area. More...
 
int plotAreaPadding (Side side) const
 Returns the internal margin for the main plot area. More...
 
void setTitle (const WString &title)
 Set a chart title. More...
 
const WStringtitle () const
 Return the chart title. More...
 
void setTitleFont (const WFont &titleFont)
 Set the font for the chart title. More...
 
const WFonttitleFont () const
 Returns the font for the chart title. More...
 
- Public Member Functions inherited from Wt::WPaintedWidget
 WPaintedWidget (WContainerWidget *parent=0)
 Create a new painted widget.
 
 ~WPaintedWidget ()
 Destructor.
 
void setPreferredMethod (Method method)
 Sets the preferred rendering method. More...
 
Method preferredMethod () const
 Returns the preferred rendering method. More...
 
void update (WFlags< PaintFlag > flags=0)
 Lets the widget repaint itself. More...
 
virtual void resize (const WLength &width, const WLength &height)
 Resizes the widget. More...
 
void addArea (WAbstractArea *area)
 Adds an interactive area. More...
 
void insertArea (int index, WAbstractArea *area)
 Inserts an interactive area. More...
 
void removeArea (WAbstractArea *area)
 Removes an interactive area. More...
 
WAbstractAreaarea (int index) const
 Returns the interactive area at the given index. More...
 
const std::vector
< WAbstractArea * > 
areas () const
 Returns the interactive areas set for this widget. More...
 
- Public Member Functions inherited from Wt::WInteractWidget
 WInteractWidget (WContainerWidget *parent=0)
 Create an InteractWidget with optional parent.
 
EventSignal< WKeyEvent > & keyWentDown ()
 Event signal emitted when a keyboard key is pushed down. More...
 
EventSignal< WKeyEvent > & keyPressed ()
 Event signal emitted when a "character" was entered. More...
 
EventSignal< WKeyEvent > & keyWentUp ()
 Event signal emitted when a keyboard key is released. More...
 
EventSignalenterPressed ()
 Event signal emitted when enter was pressed. More...
 
EventSignalescapePressed ()
 Event signal emitted when escape was pressed. More...
 
EventSignal< WMouseEvent > & clicked ()
 Event signal emitted when a mouse key was clicked on this widget. More...
 
EventSignal< WMouseEvent > & doubleClicked ()
 Event signal emitted when a mouse key was double clicked on this widget. More...
 
EventSignal< WMouseEvent > & mouseWentDown ()
 Event signal emitted when a mouse key was pushed down on this widget. More...
 
EventSignal< WMouseEvent > & mouseWentUp ()
 Event signal emitted when a mouse key was released on this widget. More...
 
EventSignal< WMouseEvent > & mouseWentOut ()
 Event signal emitted when the mouse went out of this widget. More...
 
EventSignal< WMouseEvent > & mouseWentOver ()
 Event signal emitted when the mouse entered this widget. More...
 
EventSignal< WMouseEvent > & mouseMoved ()
 Event signal emitted when the mouse moved over this widget. More...
 
EventSignal< WMouseEvent > & mouseDragged ()
 Event signal emitted when the mouse is dragged over this widget. More...
 
EventSignal< WMouseEvent > & mouseWheel ()
 Event signal emitted when the mouse scroll wheel was used. More...
 
EventSignal< WTouchEvent > & touchStarted ()
 Event signal emitted when a finger is placed on the screen. More...
 
EventSignal< WTouchEvent > & touchEnded ()
 Event signal emitted when a finger is removed from the screen. More...
 
EventSignal< WTouchEvent > & touchMoved ()
 Event signal emitted when a finger, which is already placed on the screen, is moved across the screen. More...
 
EventSignal< WGestureEvent > & gestureStarted ()
 Event signal emitted when a gesture is started. More...
 
EventSignal< WGestureEvent > & gestureChanged ()
 Event signal emitted when a gesture is changed. More...
 
EventSignal< WGestureEvent > & gestureEnded ()
 Event signal emitted when a gesture is ended. More...
 
void setDraggable (const std::string &mimeType, WWidget *dragWidget=0, bool isDragWidgetOnly=false, WObject *sourceWidget=0)
 Configure dragging for drag and drop. More...
 
void setMouseOverDelay (int delay)
 Sets a delay for the mouse over event. More...
 
int mouseOverDelay () const
 Returns the mouse over signal delay. More...
 
virtual void setPopup (bool popup)
 Lets the widget overlay over other sibling widgets. More...
 
virtual void load ()
 Loads content just before the widget is used. More...
 
virtual bool isEnabled () const
 Returns whether the widget is enabled. More...
 
- Public Member Functions inherited from Wt::WWebWidget
 WWebWidget (WContainerWidget *parent=0)
 Construct a WebWidget with a given parent. More...
 
virtual void setPositionScheme (PositionScheme scheme)
 Sets the CSS position scheme. More...
 
virtual PositionScheme positionScheme () const
 Returns the CSS position scheme. More...
 
virtual void setOffsets (const WLength &offset, WFlags< Side > sides=All)
 Sets CSS offsets for a non-statically positioned widget. More...
 
virtual WLength offset (Side s) const
 Returns a CSS offset. More...
 
virtual WLength width () const
 Returns the width. More...
 
virtual WLength height () const
 Returns the height. More...
 
virtual void setMinimumSize (const WLength &width, const WLength &height)
 Sets a minimum size. More...
 
virtual WLength minimumWidth () const
 Returns the minimum width. More...
 
virtual WLength minimumHeight () const
 Returns the minimum height. More...
 
virtual void setMaximumSize (const WLength &width, const WLength &height)
 Sets a maximum size. More...
 
virtual WLength maximumWidth () const
 Returns the maximum width. More...
 
virtual WLength maximumHeight () const
 Returns the maximum height. More...
 
virtual void setLineHeight (const WLength &height)
 Sets the CSS line height for contained text.
 
virtual WLength lineHeight () const
 Returns the CSS line height for contained text. More...
 
virtual void setFloatSide (Side s)
 Specifies a CSS float side. More...
 
virtual Side floatSide () const
 Returns the CSS float side. More...
 
virtual void setClearSides (WFlags< Side > sides)
 Sets the sides that should be cleared of floats. More...
 
virtual WFlags< SideclearSides () const
 Returns the sides that should remain empty. More...
 
virtual void setMargin (const WLength &margin, WFlags< Side > sides=All)
 Sets CSS margins around the widget. More...
 
virtual WLength margin (Side side) const
 Returns a CSS margin set. More...
 
virtual void setHiddenKeepsGeometry (bool enabled)
 Sets whether the widget keeps its geometry when hidden. More...
 
virtual bool hiddenKeepsGeometry () const
 Returns whether the widget keeps its geometry when hidden. More...
 
virtual void setHidden (bool hidden, const WAnimation &animation=WAnimation())
 Hides or shows the widget. More...
 
virtual bool isHidden () const
 Returns whether the widget is set hidden. More...
 
virtual bool isVisible () const
 Returns whether the widget is visible. More...
 
virtual void setDisabled (bool disabled)
 Sets whether the widget is disabled. More...
 
virtual bool isDisabled () const
 Returns whether the widget is set disabled. More...
 
virtual bool isPopup () const
 Returns whether the widget is overlayed. More...
 
virtual void setInline (bool isInline)
 Sets whether the widget is displayed inline or as a block. More...
 
virtual bool isInline () const
 Returns whether the widget is displayed inline or as block. More...
 
virtual void setDecorationStyle (const WCssDecorationStyle &style)
 Sets a CSS decoration style. More...
 
virtual WCssDecorationStyledecorationStyle ()
 Returns the decoration style of this widget. More...
 
virtual void setStyleClass (const WString &styleClass)
 Sets (one or more) CSS style classes. More...
 
virtual WString styleClass () const
 Returns the CSS style class. More...
 
virtual void addStyleClass (const WString &styleClass, bool force=false)
 Adds a CSS style class. More...
 
virtual void removeStyleClass (const WString &styleClass, bool force=false)
 Removes a CSS style class. More...
 
virtual bool hasStyleClass (const WString &styleClass) const
 Returns whether the widget has a style class.
 
virtual void setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength())
 Sets the vertical alignment. More...
 
virtual AlignmentFlag verticalAlignment () const
 Returns the vertical alignment. More...
 
virtual WLength verticalAlignmentLength () const
 Returns the fixed vertical alignment that was set. More...
 
virtual void setToolTip (const WString &text, TextFormat textFormat=PlainText)
 Sets a tooltip. More...
 
virtual void setDeferredToolTip (bool enable, TextFormat textFormat=PlainText)
 Enable deferred tooltip. More...
 
virtual WString toolTip () const
 Returns the tooltip.
 
virtual void refresh ()
 Refresh the widget. More...
 
virtual void setAttributeValue (const std::string &name, const WString &value)
 Sets an attribute value. More...
 
virtual WString attributeValue (const std::string &name) const
 Returns an attribute value. More...
 
virtual void setJavaScriptMember (const std::string &name, const std::string &value)
 Sets a JavaScript member. More...
 
virtual std::string javaScriptMember (const std::string &name) const
 Returns the value of a JavaScript member. More...
 
virtual void callJavaScriptMember (const std::string &name, const std::string &args)
 Calls a JavaScript member. More...
 
virtual bool loaded () const
 Returns whether this widget has been loaded. More...
 
virtual void setTabIndex (int index)
 Sets the tab index. More...
 
virtual int tabIndex () const
 Returns the tab index. More...
 
virtual void setId (const std::string &id)
 Sets the CSS Id. More...
 
virtual WWidgetfind (const std::string &name)
 Finds a descendent widget by name. More...
 
virtual void setSelectable (bool selectable)
 Sets as selectable. More...
 
virtual void doJavaScript (const std::string &javascript)
 Executes the given JavaScript statements when the widget is rendered or updated. More...
 
virtual const std::string id () const
 Returns the (unique) identifier for this object. More...
 
void setLoadLaterWhenInvisible (bool)
 Change the way the widget is loaded when invisible. More...
 
const std::vector< WWidget * > & children () const
 Returns contained widgets. More...
 
SignalchildrenChanged ()
 Signal emitted when children have been added or removed. More...
 
virtual bool setFirstFocus ()
 Set focus on the widget's first descendant. More...
 
- Public Member Functions inherited from Wt::WWidget
virtual ~WWidget ()
 Destructor. More...
 
WWidgetparent () const
 Returns the parent widget. More...
 
virtual void removeChild (WObject *child)
 Removes a child object. More...
 
void setWidth (const WLength &width)
 Sets the width. More...
 
void setHeight (const WLength &height)
 Sets the height. More...
 
virtual void positionAt (const WWidget *widget, Orientation orientation=Vertical)
 Positions a widget next to another widget. More...
 
virtual void toggleStyleClass (const WString &styleClass, bool add, bool force=false)
 Toggles a CSS style class.
 
std::string jsRef () const
 Returns a JavaScript expression to the corresponding DOM node. More...
 
virtual void acceptDrops (const std::string &mimeType, const WString &hoverStyleClass=WString())
 Sets a mime type to be accepted for dropping. More...
 
virtual void stopAcceptDrops (const std::string &mimeType)
 Indicates that a mime type is no longer accepted for dropping. More...
 
virtual void htmlText (std::ostream &out)
 Streams the (X)HTML representation. More...
 
bool isRendered () const
 Returns whether the widget is rendered. More...
 
void hide ()
 Hides the widget. More...
 
void animateHide (const WAnimation &animation)
 Hides the widget using an animation. More...
 
void show ()
 Shows the widget. More...
 
void animateShow (const WAnimation &animation)
 Shows the widget using an animation. More...
 
void enable ()
 Enables the widget. More...
 
void disable ()
 Disable thes widget. More...
 
bool layoutSizeAware () const
 Returns whether the widget is layout size aware. More...
 
- Public Member Functions inherited from Wt::WObject
 WObject (WObject *parent=0)
 Create a WObject with a given parent object. More...
 
virtual ~WObject ()
 Destructor. More...
 
virtual void setObjectName (const std::string &name)
 Sets an object name. More...
 
virtual std::string objectName () const
 Returns the object name. More...
 
void resetLearnedSlots ()
 Resets learned stateless slot implementations. More...
 
template<class T >
void resetLearnedSlot (void(T::*method)())
 Resets a learned stateless slot implementation. More...
 
template<class T >
WStatelessSlot * implementStateless (void(T::*method)())
 Declares a slot to be stateless and learn client-side behaviour on first invocation. More...
 
template<class T >
WStatelessSlot * implementStateless (void(T::*method)(), void(T::*undoMethod)())
 Declares a slot to be stateless and learn client-side behaviour in advance. More...
 
template<class T >
WStatelessSlot * implementJavaScript (void(T::*method)(), const std::string &jsCode)
 Provides a JavaScript implementation for a method. More...
 
void addChild (WObject *child)
 Adds a child object. More...
 
const std::vector< WObject * > & children () const
 Returns the children.
 
WObjectparent () const
 Returns the parent object.
 

Protected Member Functions

virtual void modelColumnsInserted (const WModelIndex &parent, int start, int end)
 Method called when colums have been inserted in the model. More...
 
virtual void modelColumnsRemoved (const WModelIndex &parent, int start, int end)
 Method called when colums have been removed from the model. More...
 
virtual void modelRowsInserted (const WModelIndex &parent, int start, int end)
 Method called when rows have been inserted from the model. More...
 
virtual void modelRowsRemoved (const WModelIndex &parent, int start, int end)
 Method called when rows have been removed from the model. More...
 
virtual void modelDataChanged (const WModelIndex &topLeft, const WModelIndex &bottomRight)
 Method called when data has been changed in the model. More...
 
virtual void modelHeaderDataChanged (Orientation orientation, int start, int end)
 Method called when header data has been changed in the model. More...
 
virtual void modelChanged ()
 Method called whenever the entire model was changed. More...
 
virtual void modelReset ()
 Method called whenever the entire model was reset. More...
 

Rendering logic

int calcNumBarGroups () const
 Paints the widget. More...
 
int seriesIndexOf (int modelColumn) const
 Paints the widget. More...
 
WPointF hv (double x, double y, double width) const
 Paints the widget. More...
 
WPointF inverseHv (double x, double y, double width) const
 Paints the widget. More...
 
void paintEvent (WPaintDevice *paintDevice)
 Paints the widget. More...
 
virtual void render (WPainter &painter, const WRectF &rectangle) const
 Renders the chart. More...
 
virtual WPointF map (double xValue, double yValue, Axis yAxis=OrdinateAxis, int currentXSegment=0, int currentYSegment=0) const
 Map (x, y) value pair to chart coordinates coordinates. More...
 
virtual void renderLabel (WPainter &painter, const WString &text, const WPointF &pos, const WColor &color, WFlags< AlignmentFlag > flags, double angle, int margin) const
 Utility function for rendering text. More...
 
WPointF hv (double x, double y) const
 Conversion between chart and painter coordinates. More...
 
WPointF hv (const WPointF &f) const
 Conversion between chart and painter coordinates. More...
 
WRectF hv (const WRectF &f) const
 Conversion between chart and painter coordinates. More...
 
WRectF chartSegmentArea (WAxis yAxis, int xSegment, int ySegment) const
 Returns the segment area for a combination of X and Y segments. More...
 
virtual void calcChartArea () const
 Calculates the chart area. More...
 
virtual bool prepareAxes () const
 Prepares the axes for rendering. More...
 
virtual void renderBackground (WPainter &painter) const
 Renders the background. More...
 
virtual void renderAxes (WPainter &painter, WFlags< AxisProperty > properties) const
 Renders one or more properties of the axes. More...
 
virtual void renderSeries (WPainter &painter) const
 Renders all series data, including value labels. More...
 
virtual void renderLegend (WPainter &painter) const
 Renders the (default) legend and chart titles. More...
 
virtual void renderAxis (WPainter &painter, const WAxis &axis, WFlags< AxisProperty > properties) const
 Renders properties of one axis. More...
 
virtual void renderGrid (WPainter &painter, const WAxis &axis) const
 Renders grid lines along the ticks of the given axis. More...
 
int calcNumBarGroups ()
 Calculates the total number of bar groups.
 

Additional Inherited Members

- Public Types inherited from Wt::WPaintedWidget
enum  Method { InlineSvgVml, HtmlCanvas, PngImage }
 Enumeration that indicates a rendering method. More...
 
- Static Public Member Functions inherited from Wt::WWebWidget
static WString escapeText (const WString &text, bool newlinesToo=false)
 Escape HTML control characters in the text, to display literally (deprecated). More...
 
static std::string & escapeText (std::string &text, bool newlinestoo=false)
 Escape HTML control characters in the text, to display literally (deprecated). More...
 
static bool removeScript (WString &text)
 Remove tags/attributes from text that are not passive (deprecated). More...
 
static std::string jsStringLiteral (const std::string &v, char delimiter= '\'')
 Turn a UTF8 encoded string into a JavaScript string literal. More...
 
- Static Protected Member Functions inherited from Wt::WObject
static WObjectsender ()
 Returns the sender of the current slot call. More...
 

Detailed Description

A cartesian chart.

A cartesian chart is a chart that uses X and Y axes. It can display one or multiple data series, which each may be rendered using bars, lines, areas, or points.

To use a cartesian chart, the minimum you need to do is set a model using setModel(), set the model column that holds the X data using setXSeriesColumn(int modelColumn), and add one or more series using addSeries(const WDataSeries&). Each series corresponds to one data column that holds Y data.

A cartesian chart is either a CategoryChart or a ScatterPlot.

In a CategoryChart, the X series represent different categories, which are listed consecutively in model row order. The X axis scale is set to CategoryScale.

ChartWCartesianChart-1.png
A category chart with bar series

Each series may be rendered differently, and this is configured in the data series (see WDataSeries for more information).

In a ScatterPlot, the X series data are interpreted as numbers on a numerical scale. The scale for the X axis defaults to a LinearScale, but this may be changed to a DateScale when the X series contains dates (of type WDate) to create a time series chart, or to a LogScale. A ScatterPlot supports the same types of data series as a CategoryChart, but does not support stacking. In a scatter plot, the X series do not need to be ordered in increasing values, and may be set differently for each dataseries using WDataSeries::setXSeriesColumn(int modelColumn).

ChartWCartesianChart-2.png
A time series scatter plot with line series

Missing data in a model series Y values is interpreted as a break. For curve-like series, this breaks the curve (or line).

The cartesian chart has support for dual Y axes. Each data series may be bound to one of the two Y axes. By default, only the first Y axis is displayed. To show the second Y axis you will need to call:

chart->axis(Y2Axis).setVisible(true);

By default a chart has a horizontal X axis and a vertical Y axis, which corresponds to a Vertical orientation. The orientation may be changed to Horizontal using setOrientation().

The styling of the series data are dictated by a palette which may be set using setPalette(WChartPalette *), but may be overridden by settings in each data series.

CSS

Styling through CSS is not applicable.

See Also
WDataSeries, WAxis
WPieChart

Constructor & Destructor Documentation

Wt::Chart::WCartesianChart::WCartesianChart ( WContainerWidget parent = 0)

Creates a new cartesian chart.

Creates a cartesian chart of type CategoryChart.

Wt::Chart::WCartesianChart::WCartesianChart ( ChartType  type,
WContainerWidget parent = 0 
)

Creates a new cartesian chart.

Creates a cartesian chart of the indicated type.

Member Function Documentation

void Wt::Chart::WCartesianChart::addDataPointArea ( const WDataSeries series,
const WModelIndex xIndex,
WAbstractArea area 
)
virtual

Adds a data point area (used for displaying e.g. tooltips).

You may want to specialize this is if you wish to modify (or delete) the area.

Note
Currently, an area is only created if the Wt::ToolTipRole data at the data point is not empty.
void Wt::Chart::WCartesianChart::addSeries ( const WDataSeries series)

Adds a data series.

A single chart may display one or more data series. Each data series displays data from a single model column in the chart. Series are plotted in the order that they have been added to the chart.

The series column is reset to -1 when the model is set (or changed). Thus you need to set a model before configuring the series.

See Also
removeSeries(), setSeries()
WAxis & Wt::Chart::WCartesianChart::axis ( Axis  axis)

Returns a chart axis.

Returns a reference to the specified axis.

const WAxis & Wt::Chart::WCartesianChart::axis ( Axis  axis) const

Accesses a chart axis.

Returns a const reference to the specified axis.

int Wt::Chart::WCartesianChart::axisPadding ( ) const

Returns the padding between the chart area and the axes.

See Also
setAxisPadding()
double Wt::Chart::WCartesianChart::barMargin ( ) const

Returns the margin between bars of different series.

See Also
setBarMargin(double)
void Wt::Chart::WCartesianChart::calcChartArea ( ) const
protectedvirtual

Calculates the chart area.

This calculates the chartArea(), which is the rectangle (in chart coordinates) that bounds the actual chart (thus excluding axes, labels, titles, legend, etc...).

See Also
plotAreaPadding()
int Wt::Chart::WCartesianChart::calcNumBarGroups ( ) const
private

Paints the widget.

This calls render() to paint on the paint device.

WRectF Wt::Chart::WCartesianChart::chartSegmentArea ( WAxis  yAxis,
int  xSegment,
int  ySegment 
) const
protected

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.

WWidget * Wt::Chart::WCartesianChart::createLegendItemWidget ( int  index)

Creates a widget which renders the a legend item.

The legend item widget will contain a text and a WPaintedWidget which draws the series' symbol.

void Wt::Chart::WCartesianChart::drawMarker ( const WDataSeries series,
WPainterPath result 
) const
virtual

Draws the marker for a given data series.

Draws the marker for the indicated series in the result. This method is called while painting the chart, and you may want to reimplement this method if you wish to provide a custom marker for a particular data series.

See Also
setLegendEnabled()
WPointF Wt::Chart::WCartesianChart::hv ( double  x,
double  y 
) const
protected

Conversion between chart and painter coordinates.

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

WPointF Wt::Chart::WCartesianChart::hv ( const WPointF f) const
protected

Conversion between chart and painter coordinates.

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

WRectF Wt::Chart::WCartesianChart::hv ( const WRectF f) const
protected

Conversion between chart and painter coordinates.

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

WPointF Wt::Chart::WCartesianChart::hv ( double  x,
double  y,
double  width 
) const
private

Paints the widget.

This calls render() to paint on the paint device.

bool Wt::Chart::WCartesianChart::initLayout ( const WRectF rectangle = WRectF()) const

Initializes the chart layout.

The mapping between model and device coordinates is only established after a rendering phase, or after calling initLayout manually.

You need a layout in order to use the mapFromDevice() and mapToDevice() methods.

Unless a specific chart rectangle is specified, the entire widget area is assumed.

WPointF Wt::Chart::WCartesianChart::inverseHv ( double  x,
double  y,
double  width 
) const
private

Paints the widget.

This calls render() to paint on the paint device.

bool Wt::Chart::WCartesianChart::isLegendEnabled ( ) const

Returns whether the legend is enabled.

See Also
setLegendEnabled()
AlignmentFlag Wt::Chart::WCartesianChart::legendAlignment ( ) const

Returns the legend alignment.

See Also
setLegendLocation()
WBrush Wt::Chart::WCartesianChart::legendBackground ( ) const

Returns the legend background brush.

See Also
setLegendStyle()
WPen Wt::Chart::WCartesianChart::legendBorder ( ) const

Returns the legend border pen.

See Also
setLegendStyle()
int Wt::Chart::WCartesianChart::legendColumns ( ) const

Returns the legend columns.

See Also
setLegendColumns()
WLength Wt::Chart::WCartesianChart::legendColumnWidth ( ) const

Returns the legend column width.

See Also
setLegendColumns()
WFont Wt::Chart::WCartesianChart::legendFont ( ) const

Returns the legend font.

See Also
setLegendStyle()
LegendLocation Wt::Chart::WCartesianChart::legendLocation ( ) const

Returns the legend location.

See Also
setLegendLocation()
Side Wt::Chart::WCartesianChart::legendSide ( ) const

Returns the legend side.

See Also
setLegendLocation()
WPointF Wt::Chart::WCartesianChart::map ( double  xValue,
double  yValue,
Axis  yAxis = OrdinateAxis,
int  currentXSegment = 0,
int  currentYSegment = 0 
) const
protectedvirtual

Map (x, y) value pair to chart coordinates coordinates.

The result needs further transformation using hv() to painter coordinates.

WPointF Wt::Chart::WCartesianChart::mapFromDevice ( const WPointF point,
Axis  ordinateAxis = OrdinateAxis 
) const

Maps from device coordinates to model coordinates.

Maps a position in the chart back to model coordinates.

This uses the axis dimensions that are based on the latest chart rendering. If you have not yet rendered the chart, or wish to already the mapping reflect model changes since the last rendering, you should call initLayout() first.

See Also
mapToDevice()
WPointF Wt::Chart::WCartesianChart::mapToDevice ( const boost::any &  xValue,
const boost::any &  yValue,
Axis  axis = OrdinateAxis,
int  xSegment = 0,
int  ySegment = 0 
) const

Maps model values onto chart coordinates.

This returns the chart device coordinates for a (x,y) pair of model values.

This uses the axis dimensions that are based on the latest chart rendering. If you have not yet rendered the chart, or wish to already the mapping reflect model changes since the last rendering, you should call initLayout() first.

The xSegment and ySegment arguments are relevant only when the corresponding axis is broken using WAxis::setBreak(). Then, its possible values may be 0 (below the break) or 1 (above the break).

See Also
mapFromDevice()
void Wt::Chart::WCartesianChart::modelChanged ( )
protectedvirtual

Method called whenever the entire model was changed.

See Also
setModel(WAbstractItemModel *)

Reimplemented from Wt::Chart::WAbstractChart.

void Wt::Chart::WCartesianChart::modelColumnsInserted ( const WModelIndex parent,
int  start,
int  end 
)
protectedvirtual

Method called when colums have been inserted in the model.

See Also
WAbstractItemModel::columnsInserted

Implements Wt::Chart::WAbstractChart.

void Wt::Chart::WCartesianChart::modelColumnsRemoved ( const WModelIndex parent,
int  start,
int  end 
)
protectedvirtual

Method called when colums have been removed from the model.

See Also
WAbstractItemModel::columnsRemoved

Implements Wt::Chart::WAbstractChart.

void Wt::Chart::WCartesianChart::modelDataChanged ( const WModelIndex topLeft,
const WModelIndex bottomRight 
)
protectedvirtual

Method called when data has been changed in the model.

See Also
WAbstractItemModel::dataChanged

Implements Wt::Chart::WAbstractChart.

void Wt::Chart::WCartesianChart::modelHeaderDataChanged ( Orientation  orientation,
int  start,
int  end 
)
protectedvirtual

Method called when header data has been changed in the model.

See Also
WAbstractItemModel::headerDataChanged

Implements Wt::Chart::WAbstractChart.

void Wt::Chart::WCartesianChart::modelReset ( )
protectedvirtual

Method called whenever the entire model was reset.

Bound to the WAbstractItemModel::modelReset() and WAbstractItemModel::layoutChanged() signals.

Reimplemented from Wt::Chart::WAbstractChart.

void Wt::Chart::WCartesianChart::modelRowsInserted ( const WModelIndex parent,
int  start,
int  end 
)
protectedvirtual

Method called when rows have been inserted from the model.

See Also
WAbstractItemModel::rowsInserted

Implements Wt::Chart::WAbstractChart.

void Wt::Chart::WCartesianChart::modelRowsRemoved ( const WModelIndex parent,
int  start,
int  end 
)
protectedvirtual

Method called when rows have been removed from the model.

See Also
WAbstractItemModel::rowsRemoved

Implements Wt::Chart::WAbstractChart.

Orientation Wt::Chart::WCartesianChart::orientation ( ) const

Returns the chart orientation.

See Also
setOrientation()
void Wt::Chart::WCartesianChart::paint ( WPainter painter,
const WRectF rectangle = WRectF() 
) const
virtual

Paint the chart in a rectangle of the given painter.

Paints the chart inside the painter, in the area indicated by rectangle. When rectangle is a null rectangle, the entire painter window is used.

Implements Wt::Chart::WAbstractChart.

void Wt::Chart::WCartesianChart::paintEvent ( WPaintDevice paintDevice)
protectedvirtual

Paints the widget.

This calls render() to paint on the paint device.

Implements Wt::WPaintedWidget.

bool Wt::Chart::WCartesianChart::prepareAxes ( ) const
protectedvirtual

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.

See Also
initLayout()
void Wt::Chart::WCartesianChart::removeSeries ( int  modelColumn)

Removes a data series.

This removes the first data series which plots the given modelColumn.

See Also
addSeries(), setSeries()
void Wt::Chart::WCartesianChart::render ( WPainter painter,
const WRectF rectangle 
) const
protectedvirtual

Renders the chart.

Renders the chart within the given rectangle. To accomodate both rendering of horizontal and vertically oriented charts, all rendering logic assumes horizontal. This "chart coordinates" space is transformed to painter coordinates using hv().

The default implementation looks like:

painter.save();
painter.translate(rectangle.topLeft());
if (initLayout(rectangle)) {
renderBackground(painter);
renderGrid(painter, axis(XAxis));
renderGrid(painter, axis(Y1Axis));
renderGrid(painter, axis(Y2Axis));
renderSeries(painter);
renderAxes(painter, Line | Labels);
renderLegend(painter);
}
painter.restore();
void Wt::Chart::WCartesianChart::renderAxes ( WPainter painter,
WFlags< AxisProperty properties 
) const
protectedvirtual

Renders one or more properties of the axes.

This calls renderAxis() for each axis.

See Also
render()
void Wt::Chart::WCartesianChart::renderAxis ( WPainter painter,
const WAxis axis,
WFlags< AxisProperty properties 
) const
protectedvirtual

Renders properties of one axis.

See Also
renderAxes()
void Wt::Chart::WCartesianChart::renderBackground ( WPainter painter) const
protectedvirtual

Renders the background.

See Also
render()
void Wt::Chart::WCartesianChart::renderGrid ( WPainter painter,
const WAxis axis 
) const
protectedvirtual

Renders grid lines along the ticks of the given axis.

See Also
render()
void Wt::Chart::WCartesianChart::renderLabel ( WPainter painter,
const WString text,
const WPointF pos,
const WColor color,
WFlags< AlignmentFlag flags,
double  angle,
int  margin 
) const
protectedvirtual

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.

void Wt::Chart::WCartesianChart::renderLegend ( WPainter painter) const
protectedvirtual

Renders the (default) legend and chart titles.

See Also
render()
void Wt::Chart::WCartesianChart::renderLegendIcon ( WPainter painter,
const WPointF pos,
const WDataSeries series 
) const
virtual

Renders the legend icon for a given data series.

Renders the legend icon for the indicated series in the painter at position pos.

This method is called while rendering a legend item, and you may want to reimplement this method if you wish to provide a custom legend icon for a particular data series.

See Also
renderLegendItem()
void Wt::Chart::WCartesianChart::renderLegendItem ( WPainter painter,
const WPointF pos,
const WDataSeries series 
) const
virtual

Renders the legend item for a given data series.

Renders the legend item for the indicated series in the painter at position pos. The default implementation draws the marker, and the series description to the right. The series description is taken from the model's header data for that series' data column.

This method is called while painting the chart, and you may want to reimplement this method if you wish to provide a custom marker for a particular data series.

See Also
setLegendEnabled()
void Wt::Chart::WCartesianChart::renderSeries ( WPainter painter) const
protectedvirtual

Renders all series data, including value labels.

See Also
render()
WDataSeries & Wt::Chart::WCartesianChart::series ( int  modelColumn)

Returns a data series corresponding to a data column.

Returns a reference to the first data series that plots data from modelColumn.

const WDataSeries & Wt::Chart::WCartesianChart::series ( int  modelColumn) const

Returns a data series corresponding to a data column.

Returns a const reference to the first data series that plots data from modelColumn.

const std::vector<WDataSeries>& Wt::Chart::WCartesianChart::series ( ) const

Returns a list with the current data series.

Returns the complete list of current data series.

See Also
setSeries(const std::vector<WDataSeries>&)
int Wt::Chart::WCartesianChart::seriesIndexOf ( int  modelColumn) const
private

Paints the widget.

This calls render() to paint on the paint device.

void Wt::Chart::WCartesianChart::setAxisPadding ( int  axisPadding)

Sets the padding between the chart area and the axes.

See Also
axisPadding()
void Wt::Chart::WCartesianChart::setBarMargin ( double  margin)

Sets the margin between bars of different series.

Use this method to change the margin that is set between bars of different series. The margin is specified as a fraction of the width. For example, a value of 0.1 adds a 10% margin between bars of each series. Negative values are also allowed. For example, use a margin of -1 to plot the bars of different series on top of each other.

The default value is 0.

void Wt::Chart::WCartesianChart::setLegendColumns ( int  columns,
const WLength width 
)

Configures multiple legend columns.

Multiple columns are typically useful when placing the legend at the top or at the bottom of the chart.

The default value is a single column, 100 pixels wide.

void Wt::Chart::WCartesianChart::setLegendEnabled ( bool  enabled)

Enables the legend.

The location of the legend can be configured using setLegendLocation(). Only series for which the legend is enabled are included in this legend.

The default value is false.

See Also
see WDataSeries::isLegendEnabled(), setLegendLocation()
void Wt::Chart::WCartesianChart::setLegendLocation ( LegendLocation  location,
Side  side,
AlignmentFlag  alignment 
)

Configures the legend location.

The legend can be renderd either inside or outside of the chart area. When location is Chart::LegendInside, the legend will be rendered inside the chart. When location is Chart::Legendoutside, the legend is rendered outside the chart, in the chart padding area.

The provided side can either be Wt::Left, Wt::Right, Wt::Top, Wt::Bottom and configures the side of the chart at which the legend is displayed.

The alignment specifies how the legend is aligned. This can be a horizontal alignment flag (Wt::AlignLeft, Wt::AlignCenter, or Wt::AlignRight), when the side is Bottom or Top, or a vertical alignment flag (Wt::AlignTop, Wt::AlignMiddle, or Wt::AlignBottom) when the side is Left or Right.

The default location is Chart::LegendOutside, Wt::Right and Wt::AlignMiddle.

To have more control over the legend, you could reimplement the renderLegendItem() method to customize how one item in the legend is rendered, or, alternatively you can disable the legend generated by the chart itself, and reimplement the paint() method in which you use the renderLegendItem() method repeatedly to render a customized legend.

See Also
WDataSeries::setLegendEnabled()
void Wt::Chart::WCartesianChart::setLegendStyle ( const WFont font,
const WPen border,
const WBrush background 
)

Configures the legend decoration.

This configures the font, border and background for the legend.

The default font is a 10pt sans serif font (the same as the default axis label font), the default border is NoPen and the default background is NoBrush.

See Also
setLegendEnabled()
void Wt::Chart::WCartesianChart::setOrientation ( Orientation  orientation)

Sets the chart orientation.

Sets the chart orientation, which corresponds to the orientation of the Y axis: a Wt::Vertical orientation corresponds to the conventional way of a horizontal X axis and vertical Y axis. A Wt::Horizontal orientation is the other way around.

The default orientation is Wt::Vertical.

See Also
orientation()
void Wt::Chart::WCartesianChart::setSeries ( const std::vector< WDataSeries > &  series)

Sets all data series.

Replaces the current list of series with the new list.

See Also
series(), addSeries(), removeSeries()
void Wt::Chart::WCartesianChart::setType ( ChartType  type)

Sets the chart type.

The chart type determines how (x,y) data are interpreted. In a CategoryChart, the X values are categories, and these are plotted consecutively, evenly spaced, and in row order. In a ScatterPlot, the X values are interpreted numerically (as for Y values).

The default chart type is a CategoryChart.

See Also
type()
WAxis::setScale(), axis(Axis)
void Wt::Chart::WCartesianChart::setXSeriesColumn ( int  modelColumn)

Sets the the model column for the X series.

Use this method to specify the default data for the X series. For a ScatterPlot this is mandatory if an X series is not specified for every WDataSeries. For a CategoryChart, if not specified, an increasing series of integer numbers will be used (1, 2, ...).

Scatterplot dataseries may each individually be given its own X series data using WDataSeries::setXSeriesColumn(int modelColumn)

The default value is -1 (not specified).

The series column is reset to -1 when the model is set (or changed). Thus you need to set a model before configuring the series.

See Also
XSeriesColumn()
ChartType Wt::Chart::WCartesianChart::type ( ) const

Returns the chart type.

See Also
setType()
int Wt::Chart::WCartesianChart::XSeriesColumn ( ) const

Returns the model column for the X series.

See Also
setXSeriesColumn()

Generated on Tue May 27 2014 for the C++ Web Toolkit (Wt) by doxygen 1.8.4