Wt
4.11.0
|
A cartesian chart. More...
#include <Wt/Chart/WCartesianChart.h>
Public Member Functions | |
WCartesianChart () | |
Creates a new cartesian chart. | |
WCartesianChart (ChartType type) | |
Creates a new cartesian chart. | |
void | setType (ChartType type) |
Sets the chart type. | |
ChartType | type () const |
Returns the chart type. | |
void | setOrientation (Orientation orientation) |
Sets the chart orientation. | |
Orientation | orientation () const |
Returns the chart orientation. | |
void | setXSeriesColumn (int modelColumn) |
Sets the the model column for the X series. | |
void | setTextPen (const WPen &pen) |
set the pen used to render the labels | |
int | XSeriesColumn () const |
Returns the model column for the X series. | |
void | addSeries (std::unique_ptr< WDataSeries > series) |
Adds a data series. | |
std::unique_ptr< WDataSeries > | removeSeries (WDataSeries *series) |
Removes a data series. | |
void | setSeries (std::vector< std::unique_ptr< WDataSeries > > series) |
Sets all data series. | |
WDataSeries & | series (int modelColumn) |
Returns a data series corresponding to a data column. | |
const WDataSeries & | series (int modelColumn) const |
Returns a data series corresponding to a data column. | |
const std::vector< std::unique_ptr< WDataSeries > > & | series () const |
Returns a list with the current data series. | |
WAxis & | axis (Axis axis) |
Returns a chart axis. | |
const WAxis & | axis (Axis axis) const |
Accesses a chart axis. | |
void | setAxis (std::unique_ptr< WAxis > waxis, Axis axis) |
Sets an axis. | |
std::vector< WAxis * > | xAxes () |
Returns a vector of all X axes associated with this chart. | |
std::vector< const WAxis * > | xAxes () const |
Returns a vector of all X axes associated with this chart. | |
std::vector< WAxis * > | yAxes () |
Returns a vector of all Y axes associated with this chart. | |
std::vector< const WAxis * > | yAxes () const |
Returns a vector of all Y axes associated with this chart. | |
int | xAxisCount () const |
Returns the number of X axes associated with this chart. | |
int | yAxisCount () const |
Returns the number of Y axes associated with this chart. | |
WAxis & | xAxis (int i) |
Retrieves the X axis at index i. | |
const WAxis & | xAxis (int i) const |
Retrieves the X axis at index i. | |
WAxis & | yAxis (int i) |
Retrieves the Y axis at index i. | |
const WAxis & | yAxis (int i) const |
Retrieves the Y axis at index i. | |
int | addXAxis (std::unique_ptr< WAxis > waxis) |
Adds a X axis to this chart. | |
int | addYAxis (std::unique_ptr< WAxis > waxis) |
Adds a Y axis to this chart. | |
std::unique_ptr< WAxis > | removeXAxis (int xAxisId) |
Removes the X axis with the given id. | |
std::unique_ptr< WAxis > | removeYAxis (int yAxisId) |
Removes the Y axis with the given id. | |
void | clearXAxes () |
Clears all X axes. | |
void | clearYAxes () |
Clears all Y axes. | |
void | setBarMargin (double margin) |
Sets the margin between bars of different series. | |
double | barMargin () const |
Returns the margin between bars of different series. | |
void | setLegendEnabled (bool enabled) |
Enables the legend. | |
bool | isLegendEnabled () const |
Returns whether the legend is enabled. | |
void | setLegendLocation (LegendLocation location, Side side, AlignmentFlag alignment) |
Configures the legend location. | |
void | setLegendStyle (const WFont &font, const WPen &border, const WBrush &background) |
Configures the legend decoration. | |
LegendLocation | legendLocation () const |
Returns the legend location. | |
Side | legendSide () const |
Returns the legend side. | |
AlignmentFlag | legendAlignment () const |
Returns the legend alignment. | |
int | legendColumns () const |
Returns the legend columns. | |
WLength | legendColumnWidth () const |
Returns the legend column width. | |
WFont | legendFont () const |
Returns the legend font. | |
WPen | legendBorder () const |
Returns the legend border pen. | |
WBrush | legendBackground () const |
Returns the legend background brush. | |
void | setLegendColumns (int columns, const WLength &width) |
Configures multiple legend columns. | |
virtual void | paint (WPainter &painter, const WRectF &rectangle=WRectF()) const override |
Paint the chart in a rectangle of the given painter. | |
virtual void | drawMarker (const WDataSeries &series, WPainterPath &result) const |
Draws the marker for a given data series. | |
virtual void | renderLegendIcon (WPainter &painter, const WPointF &pos, const WDataSeries &series) const |
Renders the legend icon for a given data series. | |
virtual void | renderLegendItem (WPainter &painter, const WPointF &pos, const WDataSeries &series) const |
Renders the legend item for a given data series. | |
WPointF | mapFromDevice (const WPointF &point, Axis ordinateAxis=Axis::Ordinate) const |
Maps from device coordinates to model coordinates. | |
WPointF | mapFromDevice (const WPointF &point, int ordinateAxis) const |
Maps from device coordinates to model coordinates. | |
WPointF | mapFromDeviceWithoutTransform (const WPointF &point, Axis ordinateAxis=Axis::Ordinate) const |
Maps from device coordinates to model coordinates, ignoring the current zoom range. | |
WPointF | mapFromDevice (const WPointF &point, const WAxis &xAxis, const WAxis &yAxis) const |
Maps from device coordinates to model coordinates. | |
WPointF | mapFromDeviceWithoutTransform (const WPointF &point, int ordinateAxis) const |
Maps from device coordinates to model coordinates, ignoring the current zoom range. | |
WPointF | mapFromDeviceWithoutTransform (const WPointF &point, const WAxis &xAxis, const WAxis &yAxis) const |
Maps from device coordinates to model coordinates, ignoring the current zoom range. | |
WPointF | mapToDevice (const cpp17::any &xValue, const cpp17::any &yValue, Axis axis=Axis::Ordinate, int xSegment=0, int ySegment=0) const |
Maps model values onto chart coordinates. | |
WPointF | mapToDevice (const cpp17::any &xValue, const cpp17::any &yValue, int yAxis, int xSegment=0, int ySegment=0) const |
Maps model values onto chart coordinates. | |
WPointF | mapToDevice (const cpp17::any &xValue, const cpp17::any &yValue, const WAxis &xAxis, const WAxis &yAxis, int xSegment=0, int ySegment=0) const |
Maps model values onto chart coordinates. | |
WPointF | mapToDeviceWithoutTransform (const cpp17::any &xValue, const cpp17::any &yValue, Axis axis=Axis::Ordinate, int xSegment=0, int ySegment=0) const |
Maps model values onto chart coordinates, ignoring the current zoom range. | |
WPointF | mapToDeviceWithoutTransform (const cpp17::any &xValue, const cpp17::any &yValue, int yAxis, int xSegment=0, int ySegment=0) const |
Maps model values onto chart coordinates, ignoring the current zoom range. | |
WPointF | mapToDeviceWithoutTransform (const cpp17::any &xValue, const cpp17::any &yValue, const WAxis &xAxis, const WAxis &yAxis, int xSegment=0, int ySegment=0) const |
Maps model values onto chart coordinates, ignoring the current zoom range. | |
bool | initLayout (const WRectF &rectangle=WRectF(), WPaintDevice *device=nullptr) const |
Initializes the chart layout. | |
std::unique_ptr< WWidget > | createLegendItemWidget (int index) |
Creates a widget which renders the a legend item. | |
virtual void | addDataPointArea (const WDataSeries &series, int xRow, int xColumn, std::unique_ptr< WAbstractArea > area) |
Adds a data point area (used for displaying e.g. tooltips). | |
void | setAxisPadding (int axisPadding) |
Sets the padding between the chart area and the axes. | |
int | axisPadding () const |
Returns the padding between the chart area and the axes. | |
void | setBorderPen (const WPen &pen) |
Sets the pen of the border to be drawn around the chart area. | |
const WPen & | borderPen () const |
Returns the pen used to draw the border around the chart area. | |
void | addCurveLabel (const CurveLabel &label) |
Add a curve label. | |
void | setCurveLabels (const std::vector< CurveLabel > &labels) |
Configure all curve labels at once. | |
void | clearCurveLabels () |
Clear all curve labels. | |
const std::vector< CurveLabel > & | curveLabels () const |
Get all of the registered curve labels. | |
Client side interaction | |
These methods allow to activate the client side interactive features of a WCartesianChart.
| |
bool | isInteractive () const |
Returns whether this chart is interactive. | |
void | setZoomEnabled (bool zoom=true) |
Enables zoom functionality. | |
bool | zoomEnabled () const |
Returns whether zoom is enabled. | |
void | setPanEnabled (bool pan=true) |
Enables pan functionality. | |
bool | panEnabled () const |
Returns whether pan is enabled. | |
void | setCrosshairEnabled (bool crosshair=true) |
Enables the crosshair functionality. | |
bool | crosshairEnabled () const |
Returns whether the crosshair is enabled. | |
void | setCrosshairColor (const WColor &color) |
Sets the crosshair color. | |
const WColor & | crosshairColor () const |
Returns the crosshair color. | |
void | setCrosshairXAxis (int xAxis) |
Sets the X axis to use for the crosshair. | |
int | crosshairXAxis () const |
Returns the X axis to use for the crosshair. | |
void | setCrosshairYAxis (int yAxis) |
Sets the Y axis to use for the crosshair. | |
int | crosshairYAxis () const |
Returns the Y axis to use for the crosshair. | |
void | setFollowCurve (int modelColumn) |
Enables the follow curve functionality for a data series. | |
void | setFollowCurve (const WDataSeries *series) |
Enabled the follow curve funtionality for a data series. | |
void | disableFollowCurve () |
Disable the follow curve functionality. | |
const WDataSeries * | followCurve () const |
Returns the curve that is to be followed. | |
void | setRubberBandEffectEnabled (bool rubberBand=true) |
Enables/disables the inertial scrolling and rubberband effect. | |
bool | rubberBandEffectEnabled () const |
Checks whether the rubberband effect is enabled. | |
void | setWheelActions (WheelActions wheelActions) |
Sets the mapping of mouse wheel actions for interactive charts. | |
WheelActions | wheelActions () const |
Returns the current mouse wheel actions for interactive charts. | |
void | setSoftLabelClipping (bool enabled) |
Enables or disables soft label clipping on all axes. | |
void | setSeriesSelectionEnabled (bool enabled=true) |
Sets whether series selection is enabled. | |
bool | seriesSelectionEnabled () const |
Returns whether series selection is enabled. | |
Signal< const WDataSeries *, WPointF > & | seriesSelected () |
A signal that notifies the selection of a new curve. | |
void | setSelectedSeries (const WDataSeries *series) |
Sets the series that is currently selected. | |
const WDataSeries * | selectedSeries () const |
Get the currently selected curve. | |
void | setCurveManipulationEnabled (bool enabled=true) |
Enable curve manipulation. | |
bool | curveManipulationEnabled () const |
Returns whether curve manipulation is enabled. | |
void | setOnDemandLoadingEnabled (bool enabled) |
Enable on-demand loading. | |
bool | onDemandLoadingEnabled () const |
Returns whether on-demand loading is enabled. | |
void | setLoadingBackground (const WBrush &brush) |
Set the background brush for the unloaded area. | |
const WBrush & | loadingBackground () const |
Returns the background brush for the unloaded area. | |
Public Member Functions inherited from Wt::Chart::WAbstractChart | |
virtual | ~WAbstractChart () |
Destructor. | |
void | setModel (const std::shared_ptr< WAbstractItemModel > &model) |
Sets the model. | |
void | setModel (const std::shared_ptr< WAbstractChartModel > &model) |
Sets the model. | |
std::shared_ptr< WAbstractChartModel > | model () const |
Returns the model. | |
std::shared_ptr< WAbstractItemModel > | itemModel () const |
Returns the model. | |
void | setBackground (const WBrush &background) |
Sets a background for the chart. | |
const WBrush & | background () const |
Returns the background of the chart. | |
void | setPalette (const std::shared_ptr< WChartPalette > &palette) |
Set a palette for the chart. | |
std::shared_ptr< WChartPalette > | palette () const |
Returns the palette for the chart. | |
void | setPlotAreaPadding (int padding, WFlags< Side > sides=AllSides) |
Set an internal margin for the main plot area. | |
int | plotAreaPadding (Side side) const |
Returns the internal margin for the main plot area. | |
void | setAutoLayoutEnabled (bool enabled=true) |
Configures the chart layout to be automatic. | |
bool | isAutoLayoutEnabled () const |
Returns whether chart layout is computed automatically. | |
void | setTitle (const WString &title) |
Set a chart title. | |
const WString & | title () const |
Return the chart title. | |
void | setTitleFont (const WFont &titleFont) |
Set the font for the chart title. | |
const WFont & | titleFont () const |
Returns the font for the chart title. | |
Public Member Functions inherited from Wt::WPaintedWidget | |
WPaintedWidget () | |
Create a new painted widget. | |
~WPaintedWidget () | |
Destructor. | |
void | setPreferredMethod (RenderMethod method) |
Sets the preferred rendering method. | |
RenderMethod | preferredMethod () const |
Returns the preferred rendering method. | |
void | update (WFlags< PaintFlag > flags=None) |
Lets the widget repaint itself. | |
virtual void | resize (const WLength &width, const WLength &height) override |
Resizes the widget. | |
void | addArea (std::unique_ptr< WAbstractArea > area) |
Adds an interactive area. | |
void | insertArea (int index, std::unique_ptr< WAbstractArea > area) |
Inserts an interactive area. | |
std::unique_ptr< WAbstractArea > | removeArea (WAbstractArea *area) |
Removes an interactive area. | |
WAbstractArea * | area (int index) const |
Returns the interactive area at the given index. | |
const std::vector< WAbstractArea * > | areas () const |
Returns the interactive areas set for this widget. | |
JSlot & | repaintSlot () |
A JavaScript slot that repaints the widget when triggered. | |
Public Member Functions inherited from Wt::WInteractWidget | |
WInteractWidget () | |
Create an InteractWidget. | |
EventSignal< WKeyEvent > & | keyWentDown () |
Event signal emitted when a keyboard key is pushed down. | |
EventSignal< WKeyEvent > & | keyPressed () |
Event signal emitted when a "character" was entered. | |
EventSignal< WKeyEvent > & | keyWentUp () |
Event signal emitted when a keyboard key is released. | |
EventSignal & | enterPressed () |
Event signal emitted when enter was pressed. | |
EventSignal & | escapePressed () |
Event signal emitted when escape was pressed. | |
EventSignal< WMouseEvent > & | clicked () |
Event signal emitted when the primary mouse button was clicked on this widget. | |
EventSignal< WMouseEvent > & | doubleClicked () |
Event signal emitted when the primary mouse button was double clicked on this widget. | |
EventSignal< WMouseEvent > & | mouseWentDown () |
Event signal emitted when a mouse button was pushed down on this widget. | |
EventSignal< WMouseEvent > & | mouseWentUp () |
Event signal emitted when a mouse button was released on this widget. | |
EventSignal< WMouseEvent > & | mouseWentOut () |
Event signal emitted when the mouse went out of this widget. | |
EventSignal< WMouseEvent > & | mouseWentOver () |
Event signal emitted when the mouse entered this widget. | |
EventSignal< WMouseEvent > & | mouseMoved () |
Event signal emitted when the mouse moved over this widget. | |
EventSignal< WMouseEvent > & | mouseDragged () |
Event signal emitted when the mouse is dragged over this widget. | |
EventSignal< WMouseEvent > & | mouseWheel () |
Event signal emitted when the mouse scroll wheel was used. | |
EventSignal< WTouchEvent > & | touchStarted () |
Event signal emitted when a finger is placed on the screen. | |
EventSignal< WTouchEvent > & | touchEnded () |
Event signal emitted when a finger is removed from the screen. | |
EventSignal< WTouchEvent > & | touchMoved () |
Event signal emitted when a finger, which is already placed on the screen, is moved across the screen. | |
EventSignal< WGestureEvent > & | gestureStarted () |
Event signal emitted when a gesture is started. | |
EventSignal< WGestureEvent > & | gestureChanged () |
Event signal emitted when a gesture is changed. | |
EventSignal< WGestureEvent > & | gestureEnded () |
Event signal emitted when a gesture is ended. | |
void | setDraggable (const std::string &mimeType, WWidget *dragWidget=nullptr, bool isDragWidgetOnly=false, WObject *sourceWidget=nullptr) |
Configure dragging for drag and drop. | |
void | unsetDraggable () |
Disable drag & drop for this widget. | |
void | setMouseOverDelay (int delay) |
Sets a delay for the mouse over event. | |
int | mouseOverDelay () const |
Returns the mouse over signal delay. | |
virtual void | setPopup (bool popup) override |
Lets the widget overlay over other sibling widgets. | |
virtual void | load () override |
Loads content just before the widget is used. | |
virtual bool | isEnabled () const override |
Returns whether the widget is enabled. | |
Public Member Functions inherited from Wt::WWebWidget | |
WWebWidget () | |
Construct a WebWidget. | |
virtual std::vector< WWidget * > | children () const override |
Returns child widgets. | |
Signal & | childrenChanged () |
Signal emitted when children have been added or removed. | |
virtual void | setPositionScheme (PositionScheme scheme) override |
Sets the CSS position scheme. | |
virtual PositionScheme | positionScheme () const override |
Returns the CSS position scheme. | |
virtual void | setOffsets (const WLength &offset, WFlags< Side > sides=AllSides) override |
Sets CSS offsets for a non-statically positioned widget. | |
virtual WLength | offset (Side s) const override |
Returns a CSS offset. | |
virtual WLength | width () const override |
Returns the width. | |
virtual WLength | height () const override |
Returns the height. | |
virtual void | setMinimumSize (const WLength &width, const WLength &height) override |
Sets a minimum size. | |
virtual WLength | minimumWidth () const override |
Returns the minimum width. | |
virtual WLength | minimumHeight () const override |
Returns the minimum height. | |
virtual void | setMaximumSize (const WLength &width, const WLength &height) override |
Sets a maximum size. | |
virtual WLength | maximumWidth () const override |
Returns the maximum width. | |
virtual WLength | maximumHeight () const override |
Returns the maximum height. | |
virtual void | setLineHeight (const WLength &height) override |
Sets the CSS line height for contained text. | |
virtual WLength | lineHeight () const override |
Returns the CSS line height for contained text. | |
virtual void | setFloatSide (Side s) override |
Specifies a CSS float side. | |
virtual Side | floatSide () const override |
Returns the CSS float side. | |
virtual void | setClearSides (WFlags< Side > sides) override |
Sets the sides that should be cleared of floats. | |
virtual WFlags< Side > | clearSides () const override |
Returns the sides that should remain empty. | |
virtual void | setMargin (const WLength &margin, WFlags< Side > sides=AllSides) override |
Sets CSS margins around the widget. | |
virtual WLength | margin (Side side) const override |
Returns a CSS margin set. | |
virtual void | setHiddenKeepsGeometry (bool enabled) override |
Sets whether the widget keeps its geometry when hidden. | |
virtual bool | hiddenKeepsGeometry () const override |
Returns whether the widget keeps its geometry when hidden. | |
virtual void | setHidden (bool hidden, const WAnimation &animation=WAnimation()) override |
Hides or shows the widget. | |
virtual bool | isHidden () const override |
Returns whether the widget is set hidden. | |
virtual bool | isVisible () const override |
Returns whether the widget is visible. | |
virtual void | setDisabled (bool disabled) override |
Sets whether the widget is disabled. | |
virtual bool | isDisabled () const override |
Returns whether the widget is set disabled. | |
virtual bool | isPopup () const override |
Returns whether the widget is overlayed. | |
virtual void | setInline (bool isInline) override |
Sets whether the widget is displayed inline or as a block. | |
virtual bool | isInline () const override |
Returns whether the widget is displayed inline or as block. | |
virtual void | setDecorationStyle (const WCssDecorationStyle &style) override |
Sets a CSS decoration style. | |
virtual WCssDecorationStyle & | decorationStyle () override |
Returns the decoration style of this widget. | |
virtual void | setStyleClass (const WString &styleClass) override |
Sets (one or more) CSS style classes. | |
virtual WString | styleClass () const override |
Returns the CSS style class. | |
virtual void | addStyleClass (const WString &styleClass, bool force=false) override |
Adds a CSS style class. | |
virtual void | removeStyleClass (const WString &styleClass, bool force=false) override |
Removes a CSS style class. | |
virtual bool | hasStyleClass (const WString &styleClass) const override |
Returns whether the widget has a style class. | |
virtual void | setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength()) override |
Sets the vertical alignment. | |
virtual AlignmentFlag | verticalAlignment () const override |
Returns the vertical alignment. | |
virtual WLength | verticalAlignmentLength () const override |
Returns the fixed vertical alignment that was set. | |
virtual void | setToolTip (const WString &text, TextFormat textFormat=TextFormat::Plain) override |
Sets a tooltip. | |
virtual void | setDeferredToolTip (bool enable, TextFormat textFormat=TextFormat::Plain) override |
Enable deferred tooltip. | |
virtual WString | toolTip () const override |
Returns the tooltip. | |
virtual void | refresh () override |
Refresh the widget. | |
virtual void | setAttributeValue (const std::string &name, const WString &value) override |
Sets an attribute value. | |
virtual WString | attributeValue (const std::string &name) const override |
Returns an attribute value. | |
virtual void | setJavaScriptMember (const std::string &name, const std::string &value) override |
Sets a JavaScript member. | |
virtual std::string | javaScriptMember (const std::string &name) const override |
Returns the value of a JavaScript member. | |
virtual void | callJavaScriptMember (const std::string &name, const std::string &args) override |
Calls a JavaScript member. | |
virtual bool | loaded () const override |
Returns whether this widget has been loaded. | |
virtual void | setId (const std::string &id) override |
Sets the CSS Id. | |
virtual WWidget * | find (const std::string &name) override |
Finds a descendent widget by name. | |
virtual WWidget * | findById (const std::string &id) override |
Finds a descendent widget by id. | |
virtual void | setSelectable (bool selectable) override |
Sets as selectable. | |
virtual void | doJavaScript (const std::string &javascript) override |
Executes the given JavaScript statements when the widget is rendered or updated. | |
virtual const std::string | id () const override |
Returns the (unique) identifier for this object. | |
void | setLoadLaterWhenInvisible (bool) |
Change the way the widget is loaded when invisible. | |
std::string | htmlTagName () const |
returns the current html tag name | |
void | setHtmlTagName (const std::string &tag) |
set the custom HTML tag name | |
virtual void | setCanReceiveFocus (bool enabled) override |
Sets whether the widget can receive focus. | |
virtual bool | canReceiveFocus () const override |
Returns whether the widget can receive focus. | |
virtual bool | setFirstFocus () override |
Set focus on the widget's first descendant. | |
virtual void | setFocus (bool focus) override |
Sets focus. | |
virtual bool | hasFocus () const override |
Returns whether the widget currently has the focus. | |
virtual void | setTabIndex (int index) override |
Sets the tab index. | |
virtual int | tabIndex () const override |
Returns the tab index. | |
EventSignal & | blurred () |
Signal emitted when the widget lost focus. | |
EventSignal & | focussed () |
Signal emitted when the widget recieved focus. | |
virtual bool | scrollVisibilityEnabled () const final override |
Returns whether scroll visibility detection is enabled for this widget. | |
virtual void | setScrollVisibilityEnabled (bool enabled) final override |
Sets whether scroll visibility detection is enabled for this widget. | |
virtual int | scrollVisibilityMargin () const final override |
Returns the margin around the viewport within which the widget is considered visible. | |
virtual void | setScrollVisibilityMargin (int margin) final override |
Sets the margin around the viewport within which the widget is considered visible. | |
virtual Signal< bool > & | scrollVisibilityChanged () final override |
Signal triggered when the scroll visibility of this widget changes. | |
virtual bool | isScrollVisible () const final override |
Returns whether this widget is currently considered scroll visible. | |
virtual void | setThemeStyleEnabled (bool enabled) final override |
Sets whether theme styling for a widget is enabled or disabled. | |
virtual bool | isThemeStyleEnabled () const final override |
Returns whether this widget is currently styled by the chosen theme. | |
virtual void | setObjectName (const std::string &name) override |
Sets an object name. | |
void | setFocus () |
Sets focus. | |
virtual void | setFocus (bool focus)=0 |
Sets focus. | |
Public Member Functions inherited from Wt::WWidget | |
virtual | ~WWidget () |
Destructor. | |
WWidget * | parent () const |
Returns the parent widget. | |
virtual std::unique_ptr< WWidget > | removeWidget (WWidget *widget) |
Removes a child widget. | |
template<typename Widget > | |
std::unique_ptr< Widget > | removeWidget (Widget *widget) |
Removes a child widget. | |
std::unique_ptr< WWidget > | removeFromParent () |
Removes the widget from its parent. | |
void | setWidth (const WLength &width) |
Sets the width. | |
void | setHeight (const WLength &height) |
Sets the height. | |
virtual void | positionAt (const WWidget *widget, Orientation orientation=Orientation::Vertical) |
Positions a widget next to another widget. | |
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. | |
void | setFocus () |
Sets focus. | |
virtual void | acceptDrops (const std::string &mimeType, const WString &hoverStyleClass=WString()) |
Sets a mime type to be accepted for dropping. | |
virtual void | stopAcceptDrops (const std::string &mimeType) |
Indicates that a mime type is no longer accepted for dropping. | |
virtual void | htmlText (std::ostream &out) |
Streams the (X)HTML representation. | |
bool | isRendered () const |
Returns whether the widget is rendered. | |
void | hide () |
Hides the widget. | |
void | animateHide (const WAnimation &animation) |
Hides the widget using an animation. | |
void | show () |
Shows the widget. | |
void | animateShow (const WAnimation &animation) |
Shows the widget using an animation. | |
void | enable () |
Enables the widget. | |
void | disable () |
Disable thes widget. | |
bool | layoutSizeAware () const |
Returns whether the widget is layout size aware. | |
Public Member Functions inherited from Wt::WObject | |
void | addChild (std::unique_ptr< WObject > child) |
Add a child WObject whose lifetime is determined by this WObject. | |
template<typename Child > | |
Child * | addChild (std::unique_ptr< Child > child) |
Add a child WObject, returning a raw pointer. | |
std::unique_ptr< WObject > | removeChild (WObject *child) |
Remove a child WObject, so its lifetime is no longer determined by this WObject. | |
template<typename Child > | |
std::unique_ptr< Child > | removeChild (Child *child) |
Remove a child WObject, so its lifetime is no longer determined by this WObject. | |
virtual std::string | objectName () const |
Returns the object name. | |
void | resetLearnedSlots () |
Resets learned stateless slot implementations. | |
template<class T > | |
void | resetLearnedSlot (void(T::*method)()) |
Resets a learned stateless slot implementation. | |
template<class T > | |
WStatelessSlot * | implementStateless (void(T::*method)()) |
Declares a slot to be stateless and learn client-side behaviour on first invocation. | |
template<class T > | |
WStatelessSlot * | implementStateless (void(T::*method)(), void(T::*undoMethod)()) |
Declares a slot to be stateless and learn client-side behaviour in advance. | |
void | isNotStateless () |
Marks the current function as not stateless. | |
template<class T > | |
WStatelessSlot * | implementJavaScript (void(T::*method)(), const std::string &jsCode) |
Provides a JavaScript implementation for a method. | |
Public Member Functions inherited from Wt::Core::observable | |
observable () noexcept | |
Default constructor. | |
virtual | ~observable () |
Destructor. | |
template<typename... Args, typename C > | |
auto | bindSafe (void(C::*method)(Args...)) noexcept |
Protects a method call against object destruction. | |
template<typename... Args, typename C > | |
auto | bindSafe (void(C::*method)(Args...) const) const noexcept |
Protects a const method call against object destruction. | |
template<typename Function > | |
auto | bindSafe (const Function &function) noexcept |
Protects a function against object destruction. | |
Protected Member Functions | |
virtual void | render (WFlags< RenderFlag > flags) override |
Renders the widget. | |
WTransform | zoomRangeTransform (int yAxis=0) const |
Returns the current zoom range transform. | |
WTransform | zoomRangeTransform (const WAxis &xAxis, const WAxis &yAxis) const |
Returns the current zoom range transform. | |
Rendering logic | |
virtual void | paintEvent (WPaintDevice *paintDevice) override |
Paints the widget. | |
virtual void | render (WPainter &painter, const WRectF &rectangle) const |
Renders the chart. | |
virtual WPointF | map (double xValue, double yValue, Axis yAxis=Axis::Ordinate, int currentXSegment=0, int currentYSegment=0) const |
Map (x, y) value pair to chart coordinates coordinates. | |
virtual WPointF | map (double xValue, double yValue, int yAxis, int currentXSegment=0, int currentYSegment=0) const |
Map (x, y) value pair to chart coordinates coordinates. | |
virtual WPointF | map (double xValue, double yValue, const WAxis &xAxis, const WAxis &yAxis, int currentXSegment=0, int currentYSegment=0) const |
Map (x, y) value pair to chart coordinates coordinates. | |
virtual void | renderLabel (WPainter &painter, const WString &text, const WPointF &pos, WFlags< AlignmentFlag > flags, double angle, int margin) const |
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 (const WAxis &yAxis, int xSegment, int ySegment) const |
Returns the segment area for a combination of X and Y segments. | |
WRectF | chartSegmentArea (const WAxis &xAxis, const WAxis &yAxis, int xSegment, int ySegment) const |
Returns the segment area for a combination of X and Y segments. | |
virtual void | calcChartArea () const |
Calculates the chart area. | |
virtual bool | prepareAxes (WPaintDevice *device) const |
Prepares the axes for rendering. | |
virtual void | renderBackground (WPainter &painter) const |
Renders the background. | |
virtual void | renderAxes (WPainter &painter, WFlags< AxisProperty > properties) const |
Renders one or more properties of the axes. | |
virtual void | renderBorder (WPainter &painter) const |
Renders the border of the chart area. | |
virtual void | renderCurveLabels (WPainter &painter) const |
Renders the curve labels. | |
virtual void | renderSeries (WPainter &painter) const |
Renders all series data, including value labels. | |
virtual void | renderLegend (WPainter &painter) const |
Renders the (default) legend and chart titles. | |
virtual void | renderAxis (WPainter &painter, const WAxis &axis, WFlags< AxisProperty > properties) const |
Renders properties of one axis. | |
virtual void | renderGrid (WPainter &painter, const WAxis &axis) const |
Renders grid lines along the ticks of the given axis. | |
virtual void | renderOther (WPainter &painter) const |
Renders other, user-defined things. | |
int | calcNumBarGroups () |
Calculates the total number of bar groups. | |
Protected Member Functions inherited from Wt::WPaintedWidget | |
WJavaScriptHandle< WTransform > | createJSTransform () |
Create a WTransform that is accessible from JavaScript, associated with this WPaintedWidget. | |
WJavaScriptHandle< WBrush > | createJSBrush () |
Create a WBrush that is accessible from JavaScript, associated with this WPaintedWidget. | |
WJavaScriptHandle< WPen > | createJSPen () |
Create a WPen that is accessible from JavaScript, associated with this WPaintedWidget. | |
WJavaScriptHandle< WPainterPath > | createJSPainterPath () |
Create a WPainterPath that is accessible from JavaScript, associated with this WPaintedWidget. | |
WJavaScriptHandle< WRectF > | createJSRect () |
Create a WRectF that is accessible from JavaScript, associated with this WPaintedWidget. | |
WJavaScriptHandle< WPointF > | createJSPoint () |
Create a WPointF that is accessible from JavaScript, associated with this WPaintedWidget. | |
virtual void | layoutSizeChanged (int width, int height) override |
Virtual method that indicates a size change. | |
virtual RenderMethod | getMethod () const |
Returns the actual method used for rendering. | |
virtual std::unique_ptr< WPaintDevice > | createPaintDevice () const |
Creates a paint device. | |
virtual void | enableAjax () override |
Progresses to an Ajax-enabled widget. | |
std::string | objJsRef () const |
Returns a JavaScript reference to the client side representation of the WPaintedWidget. | |
Protected Member Functions inherited from Wt::WInteractWidget | |
virtual void | propagateSetEnabled (bool enabled) override |
Propagates that a widget was enabled or disabled through children. | |
Protected Member Functions inherited from Wt::WWebWidget | |
virtual WStatelessSlot * | getStateless (Method method) override |
On-demand stateless slot implementation. | |
Protected Member Functions inherited from Wt::WWidget | |
void | setLayoutSizeAware (bool sizeAware) |
Sets the widget to be aware of its size set by a layout manager. | |
WWidget () | |
Creates a widget. | |
virtual void | dropEvent (WDropEvent dropEvent) |
Handles a drop event. | |
virtual int | boxPadding (Orientation orientation) const |
Returns the widget's built-in padding. | |
virtual int | boxBorder (Orientation orientation) const |
Returns the widget's built-in border width. | |
void | scheduleRender (WFlags< RepaintFlag > flags=None) |
Schedules rerendering of the widget. | |
Additional Inherited Members | |
Public Types inherited from Wt::WObject | |
typedef void(WObject::* | Method) () |
Typedef for a WObject method without arguments. | |
Static Public Member Functions inherited from Wt::WWebWidget | |
static std::string | jsStringLiteral (const std::string &v, char delimiter='\'') |
Turn a CharEncoding::UTF8 encoded string into a JavaScript string literal. | |
Static Public Member Functions inherited from Wt::WWidget | |
static WString | tr (const char *key) |
Short hand for WString::tr() | |
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(std::unique_ptr<WDataSeries>). Each series corresponds to one data column that holds Y data.
A cartesian chart is either a ChartType::Category or a ChartType::Scatter.
In a ChartType::Category, the X series represent different categories, which are listed consecutively in model row order. The X axis scale is set to AxisScale::Discrete.
Each series may be rendered differently, and this is configured in the data series (see WDataSeries for more information).
In a ChartType::Scatter, the X series data are interpreted as numbers on a numerical scale. The scale for the X axis defaults to a AxisScale::Linear, but this may be changed to a AxisScale::Date when the X series contains dates (of type WDate) to create a time series chart, or to a AxisScale::Log. A ChartType::Scatter supports the same types of data series as a ChartType::Category, 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).
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:
By default a chart has a horizontal X axis and a vertical Y axis, which corresponds to a Orientation::Vertical orientation. The orientation may be changed to Orientation::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.
Styling through CSS is not applicable.
Wt::Chart::WCartesianChart::WCartesianChart | ( | ) |
Creates a new cartesian chart.
Creates a cartesian chart of type ChartType::Category.
Wt::Chart::WCartesianChart::WCartesianChart | ( | ChartType | type | ) |
Creates a new cartesian chart.
Creates a cartesian chart of the indicated type
.
void Wt::Chart::WCartesianChart::addCurveLabel | ( | const CurveLabel & | label | ) |
Add a curve label.
|
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 ignore) the area.
void Wt::Chart::WCartesianChart::addSeries | ( | std::unique_ptr< 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.
Adds a X axis to this chart.
The first extra axis will have index 1, the next index 2,...
Returns the index of the added axis.
Adds a Y axis to this chart.
The first extra axis will have index 2, the next index 3,...
Returns the index of the added axis.
Returns a chart axis.
Returns a reference to the specified axis
.
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.
This number may not reflect the actual padding of the individual axes, if another padding has been applied on the individual axes.
double Wt::Chart::WCartesianChart::barMargin | ( | ) | const |
Returns the margin between bars of different series.
Returns the pen used to draw the border around the chart area.
Defaults to PenStyle::None.
|
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...).
|
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.
|
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.
void Wt::Chart::WCartesianChart::clearCurveLabels | ( | ) |
Clear all curve labels.
void Wt::Chart::WCartesianChart::clearXAxes | ( | ) |
Clears all X axes.
The effect is the same as repeatedly using removeYAxis() until are axes are removed, i.e. any WDataSeries will also be removed.
void Wt::Chart::WCartesianChart::clearYAxes | ( | ) |
Clears all Y axes.
The effect is the same as repeatedly using removeYAxis() until are axes are removed, i.e. any WDataSeries will also be removed.
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.
Returns the crosshair color.
bool Wt::Chart::WCartesianChart::crosshairEnabled | ( | ) | const |
Returns whether the crosshair is enabled.
const std::vector< CurveLabel > & Wt::Chart::WCartesianChart::curveLabels | ( | ) | const |
Get all of the registered curve labels.
bool Wt::Chart::WCartesianChart::curveManipulationEnabled | ( | ) | const |
Returns whether curve manipulation is enabled.
void Wt::Chart::WCartesianChart::disableFollowCurve | ( | ) |
Disable the follow curve functionality.
|
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.
const WDataSeries * Wt::Chart::WCartesianChart::followCurve | ( | ) | const |
Returns the curve that is to be followed.
If follow curve functionality is not enabled, returns -1.
Conversion between chart and painter coordinates.
Converts from chart coordinates to painter coordinates, taking into account the chart orientation.
Conversion between chart and painter coordinates.
Converts from chart coordinates to painter coordinates, taking into account the chart orientation.
Conversion between chart and painter coordinates.
Converts from chart coordinates to painter coordinates, taking into account the chart orientation.
bool Wt::Chart::WCartesianChart::initLayout | ( | const WRectF & | rectangle = WRectF() , |
WPaintDevice * | device = nullptr |
||
) | 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.
bool Wt::Chart::WCartesianChart::isInteractive | ( | ) | const |
Returns whether this chart is interactive.
Return true iff one of the interactive features is enabled, and the chart is being rendered on an HTML canvas.
bool Wt::Chart::WCartesianChart::isLegendEnabled | ( | ) | const |
Returns whether the legend is enabled.
AlignmentFlag Wt::Chart::WCartesianChart::legendAlignment | ( | ) | const |
Returns the legend alignment.
WBrush Wt::Chart::WCartesianChart::legendBackground | ( | ) | const |
Returns the legend background brush.
WPen Wt::Chart::WCartesianChart::legendBorder | ( | ) | const |
Returns the legend border pen.
int Wt::Chart::WCartesianChart::legendColumns | ( | ) | const |
Returns the legend columns.
WLength Wt::Chart::WCartesianChart::legendColumnWidth | ( | ) | const |
Returns the legend column width.
WFont Wt::Chart::WCartesianChart::legendFont | ( | ) | const |
Returns the legend font.
LegendLocation Wt::Chart::WCartesianChart::legendLocation | ( | ) | const |
Returns the legend location.
Side Wt::Chart::WCartesianChart::legendSide | ( | ) | const |
Returns the legend side.
Returns the background brush for the unloaded area.
|
protectedvirtual |
Map (x, y) value pair to chart coordinates coordinates.
The result needs further transformation using hv() to painter coordinates.
The default implementation is:
|
protectedvirtual |
Map (x, y) value pair to chart coordinates coordinates.
The result needs further transformation using hv() to painter coordinates.
|
protectedvirtual |
Map (x, y) value pair to chart coordinates coordinates.
The result needs further transformation using hv() to painter coordinates.
The default implementation is:
WPointF Wt::Chart::WCartesianChart::mapFromDevice | ( | const WPointF & | point, |
Axis | ordinateAxis = Axis::Ordinate |
||
) | 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 that the mapping already reflects model changes since the last rendering, you should call initLayout() first.
If the chart is interactive, mapFromDevice will correctly take the current zoom range into account.
WPointF Wt::Chart::WCartesianChart::mapFromDevice | ( | const WPointF & | point, |
const WAxis & | xAxis, | ||
const WAxis & | yAxis | ||
) | 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 that the mapping already reflects model changes since the last rendering, you should call initLayout() first.
If the chart is interactive, mapFromDevice will correctly take the current zoom range into account.
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 that the mapping already reflects model changes since the last rendering, you should call initLayout() first.
If the chart is interactive, mapFromDevice will correctly take the current zoom range into account.
WPointF Wt::Chart::WCartesianChart::mapFromDeviceWithoutTransform | ( | const WPointF & | point, |
Axis | ordinateAxis = Axis::Ordinate |
||
) | const |
Maps from device coordinates to model coordinates, ignoring the current zoom range.
Maps a position in the chart back to model coordinates, as if the chart was not zoomed in (nor panned).
This uses the axis dimensions that are based on the latest chart rendering. If you have not yet rendered the chart, or wish that the mapping already reflects model changes since the last rendering, you should call initLayout() first.
This function will not take the current zoom range into account. The mapping will be performed as if zoomRangeTransform() is the identity transform.
WPointF Wt::Chart::WCartesianChart::mapFromDeviceWithoutTransform | ( | const WPointF & | point, |
const WAxis & | xAxis, | ||
const WAxis & | yAxis | ||
) | const |
Maps from device coordinates to model coordinates, ignoring the current zoom range.
Maps a position in the chart back to model coordinates, as if the chart was not zoomed in (nor panned).
This uses the axis dimensions that are based on the latest chart rendering. If you have not yet rendered the chart, or wish that the mapping already reflects model changes since the last rendering, you should call initLayout() first.
This function will not take the current zoom range into account. The mapping will be performed as if zoomRangeTransform() is the identity transform.
WPointF Wt::Chart::WCartesianChart::mapFromDeviceWithoutTransform | ( | const WPointF & | point, |
int | ordinateAxis | ||
) | const |
Maps from device coordinates to model coordinates, ignoring the current zoom range.
Maps a position in the chart back to model coordinates, as if the chart was not zoomed in (nor panned).
This uses the axis dimensions that are based on the latest chart rendering. If you have not yet rendered the chart, or wish that the mapping already reflects model changes since the last rendering, you should call initLayout() first.
This function will not take the current zoom range into account. The mapping will be performed as if zoomRangeTransform() is the identity transform.
WPointF Wt::Chart::WCartesianChart::mapToDevice | ( | const cpp17::any & | xValue, |
const cpp17::any & | yValue, | ||
Axis | axis = Axis::Ordinate , |
||
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 that the mapping already reflects 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).
If the chart is interactive, mapToDevice will correctly take the current zoom range into account.
WPointF Wt::Chart::WCartesianChart::mapToDevice | ( | const cpp17::any & | xValue, |
const cpp17::any & | yValue, | ||
const WAxis & | xAxis, | ||
const WAxis & | yAxis, | ||
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 that the mapping already reflects 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).
If the chart is interactive, mapToDevice will correctly take the current zoom range into account.
WPointF Wt::Chart::WCartesianChart::mapToDevice | ( | const cpp17::any & | xValue, |
const cpp17::any & | yValue, | ||
int | yAxis, | ||
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 that the mapping already reflects 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).
If the chart is interactive, mapToDevice will correctly take the current zoom range into account.
WPointF Wt::Chart::WCartesianChart::mapToDeviceWithoutTransform | ( | const cpp17::any & | xValue, |
const cpp17::any & | yValue, | ||
Axis | axis = Axis::Ordinate , |
||
int | xSegment = 0 , |
||
int | ySegment = 0 |
||
) | const |
Maps model values onto chart coordinates, ignoring the current zoom range.
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 that the mapping already reflects 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).
This function will not take the current zoom range into account.The mapping will be performed as if zoomRangeTransform() is the identity transform.
WPointF Wt::Chart::WCartesianChart::mapToDeviceWithoutTransform | ( | const cpp17::any & | xValue, |
const cpp17::any & | yValue, | ||
const WAxis & | xAxis, | ||
const WAxis & | yAxis, | ||
int | xSegment = 0 , |
||
int | ySegment = 0 |
||
) | const |
Maps model values onto chart coordinates, ignoring the current zoom range.
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 that the mapping already reflects 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).
This function will not take the current zoom range into account.The mapping will be performed as if zoomRangeTransform() is the identity transform.
WPointF Wt::Chart::WCartesianChart::mapToDeviceWithoutTransform | ( | const cpp17::any & | xValue, |
const cpp17::any & | yValue, | ||
int | yAxis, | ||
int | xSegment = 0 , |
||
int | ySegment = 0 |
||
) | const |
Maps model values onto chart coordinates, ignoring the current zoom range.
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 that the mapping already reflects 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).
This function will not take the current zoom range into account.The mapping will be performed as if zoomRangeTransform() is the identity transform.
bool Wt::Chart::WCartesianChart::onDemandLoadingEnabled | ( | ) | const |
Returns whether on-demand loading is enabled.
Orientation Wt::Chart::WCartesianChart::orientation | ( | ) | const |
Returns the chart orientation.
|
overridevirtual |
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.
|
overrideprotectedvirtual |
bool Wt::Chart::WCartesianChart::panEnabled | ( | ) | const |
Returns whether pan is enabled.
|
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.
std::unique_ptr< WDataSeries > Wt::Chart::WCartesianChart::removeSeries | ( | WDataSeries * | series | ) |
Removes a data series.
This will disassociate the given series from any WAxisSliderWidgets.
Removes the X axis with the given id.
The indices of the axes with an id higher than xAxisId will be decremented.
Any WDataSeries associated with the removed axis are also removed.
Removes the Y axis with the given id.
The indices of the axes with an id higher than yAxisId will be decremented.
Any WDataSeries associated with the removed axis are also removed.
|
overrideprotectedvirtual |
Renders the widget.
This function renders the widget (or an update for the widget), after this has been scheduled using scheduleRender().
The default implementation will render the widget by serializing changes to JavaScript and HTML. You may want to reimplement this widget if you have been postponing some of the layout / rendering implementation until the latest moment possible. In that case you should make sure you call the base implementation however.
Reimplemented from Wt::WPaintedWidget.
|
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:
|
protectedvirtual |
|
protectedvirtual |
Renders properties of one axis.
Renders the background.
Renders the border of the chart area.
Renders the curve labels.
|
protectedvirtual |
Renders grid lines along the ticks of the given axis.
|
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.
Renders the (default) legend and chart titles.
|
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.
|
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.
Renders other, user-defined things.
The default implementation sets the painter's clip path to the chart area, but does not enable clipping.
This method can be overridden to draw extra content onto the chart.
Chart coordinates can be mapped to device coordinates with mapToDeviceWithoutTransform(). If these need to move and scale along with the zoom range, those points can be transformed with zoomRangeTransform().
This method is called last by default. If you want to render other things at some other moment, you can override render(WPainter&, const WRectF&).
Renders all series data, including value labels.
bool Wt::Chart::WCartesianChart::rubberBandEffectEnabled | ( | ) | const |
Checks whether the rubberband effect is enabled.
const WDataSeries * Wt::Chart::WCartesianChart::selectedSeries | ( | ) | const |
Get the currently selected curve.
-1 means that no curve is currently selected.
const std::vector< std::unique_ptr< WDataSeries > > & Wt::Chart::WCartesianChart::series | ( | ) | const |
Returns a list with the current data series.
Returns the complete list of current data series.
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
.
Signal< const WDataSeries *, WPointF > & Wt::Chart::WCartesianChart::seriesSelected | ( | ) |
A signal that notifies the selection of a new curve.
This signal is emitted if a series is selected using a mouse click or long press. The first argument is the selected series. The second argument is the point that was selected, in model coordinates.
bool Wt::Chart::WCartesianChart::seriesSelectionEnabled | ( | ) | const |
Returns whether series selection is enabled.
Sets an axis.
Sets the padding between the chart area and the axes.
This calls WAxes::setPadding() on all axes.
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.
Sets the pen of the border to be drawn around the chart area.
Enables the crosshair functionality.
When enabled, the crosshair will follow mouse movement, and show in the top right corner the coordinate (according to X axis and the first Y axis) corresponding to this position.
When using touch, the crosshair can be moved with a drag. If both panning and the crosshair are enabled, the crosshair will be moved when dragging close to the crosshair. Otherwise, the chart will pan.
Sets the X axis to use for the crosshair.
Defaults to 0 (first X axis)
Sets the Y axis to use for the crosshair.
Defaults to 0 (first Y axis)
void Wt::Chart::WCartesianChart::setCurveLabels | ( | const std::vector< CurveLabel > & | labels | ) |
Configure all curve labels at once.
Enable curve manipulation.
If curve manipulation is enabled, the scale and offset of the selected curve can be manipulated interactively using drag, scroll, and pinch.
void Wt::Chart::WCartesianChart::setFollowCurve | ( | const WDataSeries * | series | ) |
Enabled the follow curve funtionality for a data series.
This enables follow curve functionality for the data series corresponding to the given column.
If the data series is of type SeriesType::Line or SeriesType::Curve, the crosshair can only be moved in the x direction. The y position of the crosshair will be determined by the value of the data series. The crosshair will snap to the nearest point that is defined in the data series.
When using the mouse, the x position will change on mouseover. When using touch, the x position can be moved with a drag. The follow curve functionality has priority over the crosshair functionality.
Set to null to disable the follow curve feature.
Enables the follow curve functionality for a data series.
This enables follow curve functionality for the data series corresponding to the given column.
If the data series is of type SeriesType::Line or SeriesType::Curve, the crosshair can only be moved in the x direction. The y position of the crosshair will be determined by the value of the data series. The crosshair will snap to the nearest point that is defined in the data series.
When using the mouse, the x position will change on mouseover. When using touch, the x position can be moved with a drag. The follow curve functionality has priority over the crosshair functionality.
Use column index -1 or disableFollowCurve() to disable the follow curve feature.
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.
When automatic chart layout is enabled, then the legend column width is computed automatically, and this setting is ignored.
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
.
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::LegendLocation::Inside, the legend will be rendered inside the chart. When location
is Chart::LegendLocation::Outside, the legend is rendered outside the chart, in the chart padding area.
The provided side
can either be Wt::Side::Left, Wt::Side::Right, Wt::Side::Top, Wt::Side::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::AlignmentFlag::Left, Wt::AlignmentFlag::Center, or Wt::AlignmentFlag::Right), when the side
is Side::Bottom or Side::Top, or a vertical alignment flag (Wt::AlignmentFlag::Top, Wt::AlignmentFlag::Middle, or Wt::AlignmentFlag::Bottom) when the side
is Side::Left or Side::Right.
The default location is Chart::LegendLocation::Outside, Wt::Side::Right and Wt::AlignmentFlag::Middle.
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.
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 PenStyle::None and the default background
is BrushStyle::None.
Set the background brush for the unloaded area.
Enable on-demand loading.
By default, when on-demand loading is not enabled, the entire chart area is loaded, regardless of whether it is within the current zoom range of the X axis.
When on-demand loading is enabled only the currently visible area + some margin is loaded. As the visible area changes, different data is loaded. This improves performance for charts with a lot of data if not all of the data needs to be visible at the same time.
This feature is especially useful in combination with WAxis::setMaximumZoomRange() or WAxis::setMinZoom(), which makes it impossible for the user to view all of the data at the same time, because that would incur too much overhead.
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::Orientation::Vertical orientation corresponds to the conventional way of a horizontal X axis and vertical Y axis. A Wt::Orientation::Horizontal orientation is the other way around.
The default orientation is Wt::Orientation::Vertical.
Enables pan functionality.
When using the mouse, you can click and drag to pan the chart (if zoomed in), or use the scrollwheel.
When using touch, you can drag to pan the chart. If the rubberband effect is enabled, this is intertial (it will keep scrolling after you let go) and there is an overscroll and bounce back effect on the sides.
The default value is false
.
Enables/disables the inertial scrolling and rubberband effect.
void Wt::Chart::WCartesianChart::setSelectedSeries | ( | const WDataSeries * | series | ) |
Sets the series that is currently selected.
The series with the given model column will be selected. The other series will be shown in a lighter color. The series that is currently selected is the one that can be manipulated if curve manipulation is enabled, and it is a SeriesType::Line or SeriesType::Curve.
The selected series can be changed using a long touch or mouse click.
If the argument provided is null or series selection is not enabled, no series will be selected.
void Wt::Chart::WCartesianChart::setSeries | ( | std::vector< std::unique_ptr< WDataSeries > > | series | ) |
Sets all data series.
Replaces the current list of series with the new list.
Sets whether series selection is enabled.
If series selection is enabled, series can be selected with a mouse click or long press. If the selected series is a SeriesType::Line or SeriesType::Curve, it can be manipulated if curve manipulation is enabled. The series that are not selected, will be shown in a lighter color.
Enables or disables soft label clipping on all axes.
set the pen used to render the labels
This method overwrites the pen for all axes
Sets the chart type.
The chart type determines how (x,y) data are interpreted. In a ChartType::Category, the X values are categories, and these are plotted consecutively, evenly spaced, and in row order. In a ChartType::Scatter, the X values are interpreted numerically (as for Y values).
The default chart type is a ChartType::Category.
void Wt::Chart::WCartesianChart::setWheelActions | ( | WheelActions | wheelActions | ) |
Sets the mapping of mouse wheel actions for interactive charts.
Sets the the model column for the X series.
Use this method to specify the default data for the X series. For a ChartType::Scatter this is mandatory if an X series is not specified for every WDataSeries. For a ChartType::Category, 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.
Enables zoom functionality.
When using the mouse, press the ctrl key while scrolling to zoom in/out a specific point on the chart. If you press shift+ctrl, it will only zoom vertically. If you press alt+ctrl, it will only zoom horizontally. To change these default mappings, use setWheelActions().
When using touch, you can use a pinch gesture to zoom in/out. If the pinch gesture is vertical/horizontal, it will zoom only vertically/horizontally, otherwise it will zoom both axes equally.
The default value is false
.
WheelActions Wt::Chart::WCartesianChart::wheelActions | ( | ) | const |
Returns the current mouse wheel actions for interactive charts.
std::vector< WAxis * > Wt::Chart::WCartesianChart::xAxes | ( | ) |
Returns a vector of all X axes associated with this chart.
This defaults to a vector of one axis.
Returns a vector of all X axes associated with this chart.
This defaults to a vector of one axis.
Retrieves the X axis at index i.
The following expression is always true:
Retrieves the X axis at index i.
The following expression is always true:
int Wt::Chart::WCartesianChart::XSeriesColumn | ( | ) | const |
Returns the model column for the X series.
std::vector< WAxis * > Wt::Chart::WCartesianChart::yAxes | ( | ) |
Returns a vector of all Y axes associated with this chart.
This defaults to a vector of two axes: the Y1 and Y2 axes. Y1 will be at index 0, and Y2 will be at index 1.
Returns a vector of all Y axes associated with this chart.
This defaults to a vector of two axes: the Y1 and Y2 axes. Y1 will be at index 0, and Y2 will be at index 1.
Retrieves the Y axis at index i.
The following expressions are always true:
bool Wt::Chart::WCartesianChart::zoomEnabled | ( | ) | const |
Returns whether zoom is enabled.
|
protected |
Returns the current zoom range transform.
This transform maps device coordinates from the fully zoomed out position to the current zoom range.
This transform is a JavaScript bound transform if this chart is interactive. Otherwise, this transform is just the identity transform.
|
protected |
Returns the current zoom range transform.
This transform maps device coordinates from the fully zoomed out position to the current zoom range.
This transform is a JavaScript bound transform if this chart is interactive. Otherwise, this transform is just the identity transform.