wxChartDir  2.0.1
wxChartViewer Class Reference

Class representing a ChartDirector chart viewer control. More...

#include <wxchartviewer.h>

Inheritance diagram for wxChartViewer:

Public Member Functions

 wxChartViewer (wxWindow *parent=0, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name=wxPanelNameStr)
 Constructor for a chart viewer control. More...
 
 ~wxChartViewer ()
 Destructor for a chart viewer control.
 
virtual void setDPI (int dpi)
 Sets the DPI (scale factor) of the chart on the screen. More...
 
virtual int getDPI ()
 Gets the DPI (scale factor) of the chart on the screen. More...
 
virtual void setChart (BaseChart *chart)
 Sets a BaseChart object for display. More...
 
virtual BaseChart * getChart ()
 Gets the BaseChart pointer provided by the previous wxChartViewer::setChart method call. More...
 
virtual void setImageMap (const char *imageMap)
 Sets the image map that defines the hot spots on the chart image. More...
 
virtual ImageMapHandler * getImageMapHandler ()
 Gets the ImageMapHandler object for the current image map. More...
 
virtual void setDefaultToolTip (const wxString &text)
 Sets the default tool tip to use when the mouse is over the wxChartViewer but not over any hot spot. More...
 
virtual void setCDMLToolTipPrefix (const wxString &prefix)
 Sets the CDML tooltip prefix. More...
 
virtual void setViewPortControl (wxViewPortControl *vpc)
 Sets the viewport control to be associated with this chart viewer control. More...
 
virtual wxViewPortControlgetViewPortControl ()
 Get the viewport control associated with this chart viewer control. More...
 
virtual void setSelectionBorderWidth (int width)
 Sets the border width of the zoom selection box. More...
 
virtual int getSelectionBorderWidth ()
 Gets the border width of the zoom selection box. More...
 
virtual void setSelectionBorderColor (const wxColour &color)
 Sets the border color of the zoom selection box as a wxColour value. More...
 
virtual wxColour getSelectionBorderColor ()
 Gets the border color of the zoom selection box. More...
 
virtual void setSelectionBorderStyle (wxPenStyle style)
 Sets the border style of the zoom selection box. More...
 
virtual wxPenStyle getSelectionBorderStyle ()
 Gets the border style of the zoom selection box. More...
 
virtual void setMouseUsage (int mouseUsage)
 Sets the mouse usage mode. More...
 
virtual int getMouseUsage ()
 Gets the mouse usage mode. More...
 
virtual void setZoomDirection (int direction)
 Sets the zoom direction for mouse zoom in/out actions. More...
 
virtual int getZoomDirection ()
 Gets the zoom direction for mouse zoom in/out actions. More...
 
virtual void setScrollDirection (int direction)
 Sets the scroll direction for mouse scroll actions. More...
 
virtual int getScrollDirection ()
 Gets the scroll direction for mouse scroll actions. More...
 
virtual void setZoomInRatio (double ratio)
 Sets the magnification ratio for each zoom in click of the mouse. More...
 
virtual double getZoomInRatio ()
 Gets the magnification ratio for each zoom in click of the mouse. More...
 
virtual void setZoomOutRatio (double ratio)
 Sets the magnification ratio for each zoom out click of the mouse. More...
 
virtual double getZoomOutRatio ()
 Gets the magnification ratio for each zoom out click of the mouse. More...
 
virtual void setMouseWheelZoomRatio (double ratio)
 Sets the magnification ratio for each mouse wheel event. More...
 
virtual double getMouseWheelZoomRatio ()
 Gets the magnification ratio for each mouse wheel event. More...
 
virtual void setMinimumDrag (int offset)
 Sets the minimum mouse drag distance before it is considered as an intentional drag. More...
 
virtual int getMinimumDrag ()
 Gets the minimum mouse drag distance before it is considered as an intentional drag. More...
 
virtual void setUpdateInterval (int interval)
 Sets the minimum gap interval between two viewPortChanged signals in milliseconds. More...
 
virtual int getUpdateInterval ()
 Gets the minimum gap interval between two wxEVT_CHARTVIEWER_VIEWPORT_CHANGED events in milliseconds. More...
 
virtual bool needUpdateChart ()
 Determines if the current wxEVT_CHARTVIEWER_VIEWPORT_CHANGED event requires chart update. More...
 
virtual bool needUpdateImageMap ()
 Determines if the current viewPortChanged signal requires image map update. More...
 
virtual bool isMouseOnPlotArea ()
 Checks if the mouse cursor is on the extended plot area. More...
 
virtual bool isInMouseMoveEvent ()
 Checks if the current code is executing in a wxEVT_CHARTVIEWER_MOUSEMOVE_CHART or wxEVT_CHARTVIEWER_MOUSEMOVE_PLOTAREA event. More...
 
virtual bool isInViewPortChangedEvent ()
 Checks if the current code is executing in a ViewPortChanged event. More...
 
virtual bool isMouseDragging ()
 Checks if the mouse is dragging on the plot area. More...
 
virtual void updateViewPort (bool needUpdateChart, bool needUpdateImageMap)
 Triggers the wxEVT_CHARTVIEWER_VIEWPORT_CHANGED event. More...
 
virtual void updateDisplay ()
 Updates the display. More...
 
virtual bool onMouseWheelZoom (int x, int y, int zDelta)
 Handles mouse wheel zooming. More...
 
virtual void removeDynamicLayer (const wxString &msg)
 Set the message used to remove the dynamic layer. More...
 
virtual int getChartMouseX ()
 Gets the mouse x-coordinate in the chart pixel coordinate system. More...
 
virtual int getChartMouseY ()
 Gets the mouse y-coordinate in the chart pixel coordinate system. More...
 
virtual int getPlotAreaMouseX ()
 Gets the mouse x-coordinate on the plot area in the chart pixel coordinate system. More...
 
virtual int getPlotAreaMouseY ()
 Gets the mouse y-coordinate on the plot area in the chart pixel coordinate system. More...
 
virtual double getViewPortRight ()
 Gets the position of the right side of the viewport. More...
 
virtual double getViewPortBottom ()
 Gets the position of the bottom side of the viewport. More...
 

Static Public Member Functions

static double ConvertDateTimeToChartTime (wxDateTime dt)
 Convert from wxDateTime to chartTime. More...
 
static wxDateTime ConvertChartTimeToDateTime (double ct)
 Convert from chartTime to wxDateTime. More...
 

Protected Member Functions

void OnMouseMove (wxMouseEvent &evt)
 Handles mouse move events. More...
 
void OnPaint (wxPaintEvent &evt)
 Handles the OnPaint event. More...
 
void PaintNow (BaseChart *chart)
 Paints a chart immediately on screen. More...
 
void Render (wxDC &dc, BaseChart *chart)
 Renders a chart to a device context. More...
 
virtual void OnDelayedMouseMove ()
 Handles a delayed mouse move event.
 
virtual void OnMouseCaptureLost (wxMouseCaptureLostEvent &evt)
 Handles a mouse capture lost event. More...
 
virtual void OnMousePressEvent (wxMouseEvent &evt)
 Handles a left mouse button down event. More...
 
virtual void OnMouseReleaseEvent (wxMouseEvent &evt)
 Handles a left mouse button up event. More...
 
virtual void OnLeaveEvent (wxMouseEvent &evt)
 Handles a control leave event. More...
 
virtual void OnWheelEvent (wxMouseEvent &evt)
 Handles a mouse wheel event. More...
 
virtual void OnHoldTimerEvent (wxTimerEvent &evt)
 Handles a hold timer event. More...
 
virtual void OnDelayTimerEvent (wxTimerEvent &evt)
 Handles a delay timer event. More...
 
virtual void OnSetCursor ()
 Handles a set cursor event.
 

Detailed Description

Class representing a ChartDirector chart viewer control.

wxChartViewer is a wxWidgets control that inherits from wxPanel and from ViewPortManager. It is used in wxWidgets applications for displaying chart images and to handle mouse interactions.

Constructor & Destructor Documentation

◆ wxChartViewer()

wxChartViewer::wxChartViewer ( wxWindow *  parent = 0,
wxWindowID  id = wxID_ANY,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
long  style = wxTAB_TRAVERSAL,
const wxString &  name = wxPanelNameStr 
)

Constructor for a chart viewer control.

Parameters
parentThe parent window.
idAn identifier for the panel. wxID_ANY is taken to mean a default.
posThe panel position. The value wxDefaultPosition indicates a default position, chosen by either the windowing system or wxWidgets, depending on platform.
sizeThe panel size. The value wxDefaultSize indicates a default size, chosen by either the windowing system or wxWidgets, depending on platform.
styleThe window style.
nameWindow name.

Member Function Documentation

◆ ConvertChartTimeToDateTime()

wxDateTime wxChartViewer::ConvertChartTimeToDateTime ( double  ct)
static

Convert from chartTime to wxDateTime.

Many functions in the ChartDirector API accept dates/times as parameters, in which the dates/times are represented as the seconds elapsed since 1-1-0001 00:00:00.

This function allows to convert a chartTime value to the corresponding wxDateTime value.

Parameters
ctchartTime value to be converted to a wxDateTime value
Returns
wxDateTime value corresponding to chartTime ct

◆ ConvertDateTimeToChartTime()

double wxChartViewer::ConvertDateTimeToChartTime ( wxDateTime  dt)
static

Convert from wxDateTime to chartTime.

Many functions in the ChartDirector API accept dates/times as parameters, in which the dates/times are represented as the seconds elapsed since 1-1-0001 00:00:00.

This function allows to convert a wxDateTime value to the corresponding chartTime value.

Parameters
dtwxDateTime value to be converted to ChartDirector's chartTime
Returns
ChartDirector's chartTime value corresponding to wxDateTime dt

◆ getChart()

BaseChart * wxChartViewer::getChart ( )
virtual

Gets the BaseChart pointer provided by the previous wxChartViewer::setChart method call.

Gets the BaseChart pointer provided by the previous wxChartViewer::setChart method call.

Returns
The BaseChart pointer.

◆ getChartMouseX()

int wxChartViewer::getChartMouseX ( )
virtual

Gets the mouse x-coordinate in the chart pixel coordinate system.

This method is only valid when called inside the chart or plot area mouse events.

Returns
The mouse x-coordinate in the chart pixel coordinate system.

◆ getChartMouseY()

int wxChartViewer::getChartMouseY ( )
virtual

Gets the mouse y-coordinate in the chart pixel coordinate system.

This method is only valid when called inside the chart or plot area mouse events.

Returns
The mouse x-coordinate in the chart pixel coordinate system.

◆ getDPI()

int wxChartViewer::getDPI ( )
virtual

Gets the DPI (scale factor) of the chart on the screen.

Returns
The DPI of the chart on the screen.

◆ getImageMapHandler()

ImageMapHandler * wxChartViewer::getImageMapHandler ( )
virtual

Gets the ImageMapHandler object for the current image map.

Returns
The ImageMapHandler object that represents the image map of the chart.

◆ getMinimumDrag()

int wxChartViewer::getMinimumDrag ( )
virtual

Gets the minimum mouse drag distance before it is considered as an intentional drag.

Returns
The minimum mouse drag distance in pixels before it is considered as an intentional drag. See wxChartViewer::setMinimumDrag for the meaning of this value.

◆ getMouseUsage()

int wxChartViewer::getMouseUsage ( )
virtual

Gets the mouse usage mode.

Returns
An integer representing the mouse usage mode. See wxChartViewer::setMouseUsage for the meaning of this value.

◆ getMouseWheelZoomRatio()

double wxChartViewer::getMouseWheelZoomRatio ( )
virtual

Gets the magnification ratio for each mouse wheel event.

Please refer to wxChartViewer::setMouseWheelZoomRatio for the usage of this ratio.

Returns
The magnification ratio.

◆ getPlotAreaMouseX()

int wxChartViewer::getPlotAreaMouseX ( )
virtual

Gets the mouse x-coordinate on the plot area in the chart pixel coordinate system.

If the mouse cursor is not on the plot area, but is on the extended plot area (see wxChartViewer::setPlotAreaMouseMargin), this method will behave as if the mouse cursor is on the nearest plot area edge.

If the mouse cursor is not even on the extended plot area mouse region, this method will return the last coordinate when the mouse cursor was still on the extended plot area.

This method is only valid when called inside the chart or plot area mouse events.

Returns
The mouse x-coordinate in the chart pixel coordinate system.

◆ getPlotAreaMouseY()

int wxChartViewer::getPlotAreaMouseY ( )
virtual

Gets the mouse y-coordinate on the plot area in the chart pixel coordinate system.

If the mouse cursor is not on the plot area, but is on the extended plot area (see wxChartViewer::setPlotAreaMouseMargin), this method will behave as if the mouse cursor is on the nearest plot area edge.

If the mouse cursor is not even on the extended plot area mouse region, this method will return the last coordinate when the mouse cursor was still on the extended plot area.

This method is only valid when called inside the chart or plot area mouse events.

Returns
The mouse y-coordinate in the chart pixel coordinate system.

◆ getScrollDirection()

int wxChartViewer::getScrollDirection ( )
virtual

Gets the scroll direction for mouse scroll actions.

Please refer to wxChartViewer::setZoomDirection for the supported directions.

Returns
An integer representing the scroll direction.

◆ getSelectionBorderColor()

wxColour wxChartViewer::getSelectionBorderColor ( )
virtual

Gets the border color of the zoom selection box.

Returns
The border color of the zoom selection box as a wxColour value.

◆ getSelectionBorderStyle()

wxPenStyle wxChartViewer::getSelectionBorderStyle ( )
virtual

Gets the border style of the zoom selection box.

Returns
The border style of the zoom selection box.

◆ getSelectionBorderWidth()

int wxChartViewer::getSelectionBorderWidth ( )
virtual

Gets the border width of the zoom selection box.

Returns
The border width of the zoom selection box in pixels.

◆ getUpdateInterval()

int wxChartViewer::getUpdateInterval ( )
virtual

Gets the minimum gap interval between two wxEVT_CHARTVIEWER_VIEWPORT_CHANGED events in milliseconds.

Returns
The minimum gap interval between two viewPortChanged signals in milliseconds. See wxChartViewer::setUpdateInterval for the meaning of this value.

◆ getViewPortBottom()

virtual double wxChartViewer::getViewPortBottom ( )
inlinevirtual

Gets the position of the bottom side of the viewport.

The position of the viewport bottom side is its distance from the bottom side of the underlying surface, as a fraction of the height of the underlying surface. It should be between 0 and 1.

Returns
The position of the bottom side of the viewport.

◆ getViewPortControl()

wxViewPortControl * wxChartViewer::getViewPortControl ( )
virtual

Get the viewport control associated with this chart viewer control.

Returns
A pointer to the viewport control associated with this chart viewer.

◆ getViewPortRight()

virtual double wxChartViewer::getViewPortRight ( )
inlinevirtual

Gets the position of the right side of the viewport.

The position of the viewport right side is its distance from the right side of the underlying surface, as a fraction of the width of the underlying surface. It should be between 0 and 1.

Returns
The position of the right side of the viewport.

◆ getZoomDirection()

int wxChartViewer::getZoomDirection ( )
virtual

Gets the zoom direction for mouse zoom in/out actions.

Please refer to wxChartViewer::setZoomDirection for the supported directions.

Returns
An integer representing the zoom direction.

◆ getZoomInRatio()

double wxChartViewer::getZoomInRatio ( )
virtual

Gets the magnification ratio for each zoom in click of the mouse.

For zoom in, the ratio should be greater than 1. The default is 2.

Returns
The magnification ratio.

◆ getZoomOutRatio()

double wxChartViewer::getZoomOutRatio ( )
virtual

Gets the magnification ratio for each zoom out click of the mouse.

For zoom out, the ratio should be less than 1. The default is 0.5.

Returns
The magnification ratio.

◆ isInMouseMoveEvent()

bool wxChartViewer::isInMouseMoveEvent ( )
virtual

Checks if the current code is executing in a wxEVT_CHARTVIEWER_MOUSEMOVE_CHART or wxEVT_CHARTVIEWER_MOUSEMOVE_PLOTAREA event.

Returns
True if the current code is executing in a wxEVT_CHARTVIEWER_MOUSEMOVE_CHART message or wxEVT_CHARTVIEWER_MOUSEMOVE_PLOTAREA message, otherwise false.

◆ isInViewPortChangedEvent()

bool wxChartViewer::isInViewPortChangedEvent ( )
virtual

Checks if the current code is executing in a ViewPortChanged event.

This is to help preventing "event looping" in complicated GUI designs in which multiple controls can update the viewport and indirectly update each others.

For example, suppose in a scrollable chart design, the x-axis can be scrolled by both a scroll bar control and a date/time picker control. That means both scroll bar and date/time picker events may update the viewport.

The following sequence of events may happen:

  • User changes the start date on the x-axis using the date/time picker control.
  • The viewport is updated, so QChartViewer.updateViewPort is called, triggering a CVN_ViewPortChanged message.
  • In the ViewPortChanged event handler, the scroll bar position needs to be updated to reflect that the viewport has moved.
  • As the scroll bar has changed, a scroll bar event occurs. The scroll bar event handler may update the viewport and call QChartViewer.updateViewPort again.

The above is potentially an infinite loop as the ViewPortChanged event will keep firing again and again. To avoid this, wxChartViewer::updateViewPort will perform no action if it is called within wxEVT_CHARTVIEWER_VIEWPORT_CHANGED event. So the last step above cannot actually trigger another wxEVT_CHARTVIEWER_VIEWPORT_CHANGED event. This avoids the infinite loop.

Internally, wxChartViewer::updateViewPort uses this method to check if it is called within a wxEVT_CHARTVIEWER_VIEWPORT_CHANGED event, and ignores the request if it is already in the event. This method allows external code to also change behaviour in a wxEVT_CHARTVIEWER_VIEWPORT_CHANGED event.

Returns
True if the current code is executing in a wxEVT_CHARTVIEWER_VIEWPORT_CHANGED message, otherwise false.

◆ isMouseDragging()

bool wxChartViewer::isMouseDragging ( )
virtual

Checks if the mouse is dragging on the plot area.

A mouse is considered to be dragging on the plot area if the mouse is on the plot area when the mouse button is down, and the mouse button still has not been released.

Returns
True if the mouse is dragging on the plot area, otherwise false.

◆ isMouseOnPlotArea()

bool wxChartViewer::isMouseOnPlotArea ( )
virtual

Checks if the mouse cursor is on the extended plot area.

See wxChartViewer::setPlotAreaMouseMargin on what is the extended plot area.

Returns
True if the mouse is on the extended plot area, otherwise false.

◆ needUpdateChart()

bool wxChartViewer::needUpdateChart ( )
virtual

Determines if the current wxEVT_CHARTVIEWER_VIEWPORT_CHANGED event requires chart update.

The event handler for a wxEVT_CHARTVIEWER_VIEWPORT_CHANGED event can use this method to determine if chart update is necessary.

This method is only valid during handling of the wxEVT_CHARTVIEWER_VIEWPORT_CHANGED event. Its behaviour is undefined at other times.

Returns
A boolean value that indicates if the wxEVT_CHARTVIEWER_VIEWPORT_CHANGED event requires chart update.

◆ needUpdateImageMap()

bool wxChartViewer::needUpdateImageMap ( )
virtual

Determines if the current viewPortChanged signal requires image map update.

The event handler for a wxEVT_CHARTVIEWER_VIEWPORT_CHANGED signal can use this method to determine if image map update is necessary.

This method is only valid during handling of the wxEVT_CHARTVIEWER_VIEWPORT_CHANGED event. Its behaviour is undefined at other times.

Returns
A boolean value that indicates if the viewPortChanged signal requires image map update.

◆ OnDelayTimerEvent()

void wxChartViewer::OnDelayTimerEvent ( wxTimerEvent &  evt)
protectedvirtual

Handles a delay timer event.

Parameters
evtTimer event

◆ OnHoldTimerEvent()

void wxChartViewer::OnHoldTimerEvent ( wxTimerEvent &  evt)
protectedvirtual

Handles a hold timer event.

Parameters
evtTimer event

◆ OnLeaveEvent()

void wxChartViewer::OnLeaveEvent ( wxMouseEvent &  evt)
protectedvirtual

Handles a control leave event.

Parameters
evtMouse event

◆ OnMouseCaptureLost()

void wxChartViewer::OnMouseCaptureLost ( wxMouseCaptureLostEvent &  evt)
protectedvirtual

Handles a mouse capture lost event.

Parameters
evtMouse capture lost event

◆ OnMouseMove()

void wxChartViewer::OnMouseMove ( wxMouseEvent &  evt)
protected

Handles mouse move events.

Parameters
evtMouse event

◆ OnMousePressEvent()

void wxChartViewer::OnMousePressEvent ( wxMouseEvent &  evt)
protectedvirtual

Handles a left mouse button down event.

Parameters
evtMouse event

◆ OnMouseReleaseEvent()

void wxChartViewer::OnMouseReleaseEvent ( wxMouseEvent &  evt)
protectedvirtual

Handles a left mouse button up event.

Parameters
evtMouse event

◆ onMouseWheelZoom()

bool wxChartViewer::onMouseWheelZoom ( int  x,
int  y,
int  zDelta 
)
virtual

Handles mouse wheel zooming.

Parameters
xx-coordinate of the mouse cursor position
yy-coordinate of the mouse cursor position
zDeltaThe sign of zDelta determines the zoom direction (i.e. zoom in or zoom out)
Returns

◆ OnPaint()

void wxChartViewer::OnPaint ( wxPaintEvent &  evt)
protected

Handles the OnPaint event.

Parameters
evtPaint event

◆ OnWheelEvent()

void wxChartViewer::OnWheelEvent ( wxMouseEvent &  evt)
protectedvirtual

Handles a mouse wheel event.

Parameters
evtMouse event

◆ PaintNow()

void wxChartViewer::PaintNow ( BaseChart *  chart)
protected

Paints a chart immediately on screen.

Parameters
chartchart object to be painted on screen

◆ removeDynamicLayer()

void wxChartViewer::removeDynamicLayer ( const wxString &  msg)
virtual

Set the message used to remove the dynamic layer.

The dynamic layer (see BaseChart.initDynamicLayer) is commonly used for drawing track cursors. For these type of usages, it is often necessary to clear the dynamic layer when the mouse cursor leaves the plot area. The removeDynamicLayer method can be used in the dynamic layer drawing code to automatically clear the dynamic layer when the specified event occurs. This avoids the need to set up a separate event handler to call BaseChart.removeDynamicLayer.

In the current version of ChartDirector, this method only supports the eventId "MouseLeaveChart" and "MouseLeavePlotArea".

This method only applies to the first occurrence of the specified event after calling this method. If this method is called multiple times before the event occurs, only the last call has effect. To cancel this method, use an empty string as the eventId.

Parameters
msgThe event that causes BaseChart.removeDynamicLayer to be called.

◆ Render()

void wxChartViewer::Render ( wxDC &  dc,
BaseChart *  chart 
)
protected

Renders a chart to a device context.

Parameters
dcscreen device context
chartchart object to be rendered on screen

◆ setCDMLToolTipPrefix()

void wxChartViewer::setCDMLToolTipPrefix ( const wxString &  prefix)
virtual

Sets the CDML tooltip prefix.

wxChartViewer supports both standard tooltips and CDML tooltips. If the tooltip content starts with a CDML tag, it will be processed as a CDML tooltip, otherwise it will be processed as a standard tooltip. Standard tooltips are drawn by the GUI framework, so their style will be the same as in other GUI controls. CDML tooltips are drawn by ChartDirector, and can use multiple fonts and colors, contain tables and icons, and be semi-transparent.

For CDML tooltips, if the tooltip content starts with "<*cdml*>", wxChartViewer will substitute it with the following CDML. It configures a white rounded rectangle with grey border as the tooltip container and sets the tooltip font color to black. The setCDMLToolTipPrefix method can be use to change CDML that substitute the "<*cdml*>" tag.

Parameters
prefixThe text used to substitute the leading <cdml> tag.

◆ setChart()

void wxChartViewer::setChart ( BaseChart *  chart)
virtual

Sets a BaseChart object for display.

wxChartViewer stores the BaseChart pointer internally so it can later be retrieved with wxChartViewer::getChart. However, wxChartViewer does not use the stored pointer itself. So it is perfectly safe to immediately delete the BaseChart after calling wxChartViewer::setChart, or to use a BaseChart that is allocated on the stack for this method.

Parameters
chartThe BaseChart object to be displayed.

◆ setDefaultToolTip()

void wxChartViewer::setDefaultToolTip ( const wxString &  text)
virtual

Sets the default tool tip to use when the mouse is over the wxChartViewer but not over any hot spot.

Parameters
textThe default tool tip text to use.

◆ setDPI()

void wxChartViewer::setDPI ( int  dpi)
virtual

Sets the DPI (scale factor) of the chart on the screen.

Due to historical reasons, in programming, the display is assumed to be 96dpi (dot per inch). Modern operating systems also allows using higher DPI. For example, on Windows 10, in "Settings / System / Display", it is possible set a display scale factor such as 150%, which corresponds to 144dpi.

If the application is configured as "not DPI aware", the OS will assume the application GUI is 96dpi. The operating system will then resize the application output before displaying it on the screen.

If the application is configured as "DPI aware", the OS will assume the application will resize its GUI to match the display DPI, and the OS will not resize the application output again.

wxChartViewer will automatically detect if the application is "DPI aware" or not, and will automatically resize the chart to match the display DPI.

The setDPI method can be used to configure an alternative scale factor. For example, if the user code has already resized the chart, it is not necessary for the wxChartViewer to resize the chart again. In this case, setDPI can be used to set the DPI to 96 to disable the wxChartViewer from resizing the chart.

Parameters
dpiThe DPI to display the chart on the screen. A value of 0 means the DPI will be automatically determined.

◆ setImageMap()

void wxChartViewer::setImageMap ( const char *  imageMap)
virtual

Sets the image map that defines the hot spots on the chart image.

By using an image map, a wxChartViewer object can be configured to display tool tips specific to the hot spots when the mouse is over the hot spots. The mouse cursor can also change to a "hand" shape to provide visual feedback for clickable hot spots. A clickable hot spot is defined as a hot spot with a non-empty path attribute.

BaseChart.getHTMLImageMap can be used to generated image maps for charts automatically.

The ImageMapHandler object, accessible via wxChartViewer::getImageMapHandler, can be used to determine if the mouse cursor is over a hot spot and to retrieve the hot spot parameters.

Parameters
imageMapThe image map that defines the hot spots.

◆ setMinimumDrag()

void wxChartViewer::setMinimumDrag ( int  offset)
virtual

Sets the minimum mouse drag distance before it is considered as an intentional drag.

A mouse drag occurs if the mouse button is down while the mouse moves. However, sometimes a user may want to click on a point, but due to mouse vibrations, the mouse moves by a small amount while the button is still down. This may then be interpreted as a mouse drag.

This method determines the minimum drag distance in pixels before it is considered as an intentional drag. The default is 5 pixels. Non-intentional drags will be handled as mouse clicks instead of drags.

Parameters
offsetThe minimum mouse drag distance in pixels before it is considered as an intentional drag.

◆ setMouseUsage()

void wxChartViewer::setMouseUsage ( int  mouseUsage)
virtual

Sets the mouse usage mode.

The following table describes the supported mouse usage modes and the mouse behaviour in each mode.

ConstantValueDescription
MouseUsageDefault 0 This represents the default mouse behaviour, which is to support tool tips and hot spot events as defined by the image map.

See wxChartViewer::setImageMap on how to define an image map for a chart.
MouseUsageScroll 1The mouse is used for drag scrolling the chart.

When the mouse drags on the plot area, the mouse cursor will change to a scroll cursor, the viewport coordinates will shift to reflect the amount dragged, and viewPortChanged signals will be emitted.

If the mouse is not dragging inside the plot area, its behaviour is the same as the default mouse behaviour.
MouseUsageZoomIn 3 The mouse is used for zoom in actions.

When the mouse is inside the plot area, the following behaviour will apply:
  • The mouse cursor will change to a zoom in cursor (a magnifying glass cursor with a '+' sign inside).
  • When the mouse drags on the plot area, a selection rectangle will be visible. When the mouse button is subsequently released, the viewport coordinates will be updated to reflect the selection rectangle, and a viewPortChanged signal will be emitted.
  • When the mouse clicks on the plot area without dragging, the viewport will be updated to reflect zooming into the clicked point by a ratio specified in wxChartViewer::setZoomInRatio, and a viewPortChanged signal will be emitted.
If the mouse is not inside the plot area, its behaviour is the same as the default mouse behaviour.
MouseUsageZoomOut 4 The mouse is used for zoom out actions.

When the mouse is inside the plot area, the following behaviour will apply:
  • The mouse cursor will change to a zoom out cursor (a magnifying glass cursor with a '-' sign inside).
  • When the mouse clicks on the plot area , the viewport will be updated to reflect zooming out from the clicked point by a ratio specified in wxChartViewer::setZoomOutRatio, and a viewPortChanged signal will be emitted.
If the mouse is not inside the plot area, its behaviour is the same as the default mouse behaviour.
Parameters
mouseUsageThe mouse usage mode of the control, which must be one of the predefined constants as shown in the table above.

◆ setMouseWheelZoomRatio()

void wxChartViewer::setMouseWheelZoomRatio ( double  ratio)
virtual

Sets the magnification ratio for each mouse wheel event.

The magnification ratio is applied when the mouse wheel rolls towards the screen. The reciprocal of the ratio is applied when the mouse wheel rolls away from the screen. A ratio larger than 1 means to zoom in when the mouse wheel rolls towards the screen, and to zoom out when the mouse wheel rolls away from the screen. A ratio less than 1 means the opposite behaviour. A ratio equal to 1 disables mouse wheel zooming.

The mouse wheel causes zooming to occur, it will trigger the wxEVT_CHARTVIEWER_VIEWPORT_CHANGED message.

Parameters
ratioThe magnification ratio.

◆ setScrollDirection()

void wxChartViewer::setScrollDirection ( int  direction)
virtual

Sets the scroll direction for mouse scroll actions.

Please refer to wxChartViewer::setZoomDirection for the supported directions.

Parameters
directionThe scroll direction for mouse scroll actions.

◆ setSelectionBorderColor()

void wxChartViewer::setSelectionBorderColor ( const wxColour &  color)
virtual

Sets the border color of the zoom selection box as a wxColour value.

Parameters
colorThe border color as a wxColour value.

◆ setSelectionBorderStyle()

void wxChartViewer::setSelectionBorderStyle ( wxPenStyle  style)
virtual

Sets the border style of the zoom selection box.

Parameters
styleThe border style of the zoom selection box.

◆ setSelectionBorderWidth()

void wxChartViewer::setSelectionBorderWidth ( int  width)
virtual

Sets the border width of the zoom selection box.

Parameters
widthThe border width in pixels.

◆ setUpdateInterval()

void wxChartViewer::setUpdateInterval ( int  interval)
virtual

Sets the minimum gap interval between two viewPortChanged signals in milliseconds.

Some GUI designs may be capable of generate a lot of viewPortChanged events rapidly. For example, an external scroll bar may update the viewport and call wxChartViewer::updateViewPort rapidly and repeatedly when it is scrolling. As the chart is usually updated in the main GUI thread, updating too rapidly without a gap interval in between may cause other GUI elements to become sluggish.

This method specifies the minimum gap interval between two viewPortChanged signals. The default is 20ms.

If a viewPortChanged event needs to be emitted during the gap interval, the signal will be delayed and emitted after the gap interval.

If multiple viewPortChanged events needs to be emitted during the gap interval, they will be merged into one event, and be emitted after the gap interval.

Parameters
intervalThe minimum gap interval between two viewPortChanged signals in milliseconds.

◆ setViewPortControl()

void wxChartViewer::setViewPortControl ( wxViewPortControl vpc)
virtual

Sets the viewport control to be associated with this chart viewer control.

Parameters
vpcThe viewport control to be associated with this chart viewer.

◆ setZoomDirection()

void wxChartViewer::setZoomDirection ( int  direction)
virtual

Sets the zoom direction for mouse zoom in/out actions.

In zoom operations for charts, it is common to restrict zooming to one direction only. For example, in a chart plotting temperature against time, zooming in from a yearly chart to a daily chart may mean the time axis (x-axis) is zoomed in by 36500%, while the temperature axis (y-axis) may be auto-scaled and not zoomed in at all. The user may be surprise if you also zoom in the y-axis by 36500%, in which case the chart may become hardly readable.

This method allows you to determine the zoom direction for mouse zoom actions (see wxChartViewer::setMouseUsage), specified using the following predefined constants:

ConstantValueDescription
DirectionHorizontal 0 Zoom actions apply to horizontal direction only.
DirectionVertical 1 Zoom actions apply to vertical direction only.
DirectionHorizontalVertical 2Zoom actions apply to both horizontal and vertical directions.
Parameters
directionThe zoom direction for mouse zoom actions.

◆ setZoomInRatio()

void wxChartViewer::setZoomInRatio ( double  ratio)
virtual

Sets the magnification ratio for each zoom in click of the mouse.

For zoom in, the ratio should be greater than 1. The default is 2.

Parameters
ratioThe zoom in ratio.

◆ setZoomOutRatio()

void wxChartViewer::setZoomOutRatio ( double  ratio)
virtual

Sets the magnification ratio for each zoom out click of the mouse.

For zoom out, the ratio should be less than 1. The default is 0.5.

Parameters
ratioThe zoom out ratio.

◆ updateDisplay()

void wxChartViewer::updateDisplay ( )
virtual

Updates the display.

If a chart is assigned to a wxChartViewer for display, the wxChartViewer will automatically display it. If the chart is subsequently modified (eg. by drawing additional things in its dynamic layer - see BaseChart.initDynamicLayer), this method can be used to notify the wxChartViewer that the modification has been completed so that it can update the display.

◆ updateViewPort()

void wxChartViewer::updateViewPort ( bool  needUpdateChart,
bool  needUpdateImageMap 
)
virtual

Triggers the wxEVT_CHARTVIEWER_VIEWPORT_CHANGED event.

wxChartViewer may emit wxEVT_CHARTVIEWER_VIEWPORT_CHANGED events when the mouse clicks or drags on the plot area (see wxChartViewer::setMouseUsage). wxChartViewer also allows external objects (such as scroll bars, navigation buttons, timers, etc) to modify the viewport. This method allows external objects to request wxChartViewer to emit wxEVT_CHARTVIEWER_VIEWPORT_CHANGED events.

Many controls are able to update the viewport continuously as they are used. For example, a scroll bar may update the viewport continuously as the mouse drags on it. For these cases, the chart display may be updated continuously as the viewport changes. However, the image map does not need to update until the scrolling is completed (when the mouse button is released on the scroll bar and the mouse moves over the chart surface).

The needUpdateChart argument and needUpdateImageMap argument allows one to specify if the event requires a chart update, and/or an image map update.

For charts with a lot of hot spots and tool tips, the CPU power needed to handle the image map may not be negligible. Removing unnecessary image map updates may increase the update rate when the chart is being updated continuously.

Parameters
needUpdateChartA boolean value to indicate if the chart needs to be updated.
needUpdateImageMapA boolean value to indicate if the image map needs to be updated.