Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site













SourceForge.net Logo

ScatterDraw

 

class ScatterDraw

 

 

Versatile 2D scatter graph control. It does not require GUI so it works in command line programs.

 

In case of GUI it can be used ScatterCtrl that is based on ScatterDraw.

 

ScatterDraw data is included in DataSource.

 

In ScatterCtrl_demo there is an overview of control possibilities.

 

 

Constructor Detail


 

ScatterDraw()

Initializes the class.

 

 

Public Member List


 

Callback3<String&, int, doublecbModifFormatX

If set this callback will give the String to be painted beside every X axis grid line and in the pop window. The input values are the X axis value set as int and double.

 


 

Callback3<String&, int, doublecbModifFormatDeltaX

If set this callback will give the String to be painted in the pop window representing the delta between two X axis points. The input values are the X axis value set as int and double.

 


 

Callback3<String&, int, doublecbModifFormatY

If set this callback will give the String to be painted beside every main Y axis grid line and in the pop window. The input values are the Y axis value set as int and double.

 


 

Callback3<String&, int, doublecbModifFormatDeltaY

If set this callback will give the String to be painted in the pop window representing the delta between two Y axis points. The input values are the Y axis value set as int and double.

 


 

Callback3<String&, int, doublecbModifFormatY2

If set this callback will give the String to be painted beside every secondary and in the pop window Y axis grid line. The input values are the Y axis value set as int and double.

 


 

Callback3<String&, int, doublecbModifFormatDeltaY2

If set this callback will give the String to be painted in the pop window representing the secondary delta between two Y axis points. The input values are the Y axis value set as int and double.

 


 

Callback WhenZoomScroll

Callback called when the user does a zoom or a scroll.

 


 

Callback WhenSetRange

Callback called when some of the control ranges is changed.

 


 

Callback WhenSetXYMin

Callback called when scatter plot origin is changed.

 


 

ScatterDraw& SetSize(Size sz)

Sets the control size with sz. Functions like GetImage() will return a bitmap of sz size.

 


 

virtual Size GetSize() const

Returns the control size. Functions like GetImage() will return a bitmap of sz size.

 


 

ScatterDraw& SetColor(const Color& color)

Sets color .as graph background color.

 


 

ScatterDraw& SetTitle(const String& title)

Sets title as graph title.

 


 

const String& GetTitle()

Returns graph title.

 


 

ScatterDraw& SetTitleFont(const Font& fontTitle)

Sets fontTitle as title font.

 


 

ScatterDraw& SetTitleColor(const Color& colorTitle)

Sets colorTitle as title text color.

 


 

Font& GetTitleFont()

Returns the title font.

 


 

void SetLabels(const String& xLabel, const String& yLabel, const String& yLabel2 = "")

Sets the labels of the horizontal axis (xLabel), vertical axis (yLabel) and secondary vertical axis (yLabel2).

 


 

ScatterDraw& SetLabelX(const String& xLabel)

Sets xLabel as the label of the horizontal axis.

 


 

const String &GetLabelX()

Returns the label of the horizontal axis.

 


 

ScatterDraw& SetLabelY(const String& yLabel)

Sets yLabel as the label of the vertical axis.

 


 

const String &GetLabelY()

Returns the label of the vertical axis.

 


 

ScatterDraw& SetLabelY2(const String& yLabel)

Sets yLabel as the label of the secondary vertical axis.

 


 

const String &GetLabelY2()

Returns the label of the secondary vertical axis.

 


 

ScatterDraw& SetLabelsFont(const Font& fontLabels)

Sets fontLabels as the labels font.

 


 

Font GetLabelsFont()

Returns the font of the labels.

 


 

ScatterDraw& SetLabelsColor(const Color& colorLabels)

Sets colorLabels as the color of the labels.

 


 

ScatterDraw& SetPlotAreaMargin(int hLeft, int hRight, int vTop, int vBottom)

Sets the left(hLeft), right (hRight), top(vTop) and bottom (vBottom) margins of the scatter plots inside ScatterDraw control.

 


 

ScatterDraw& SetPlotAreaLeftMargin(int margin)

Sets the left margin of scatter plot inside ScatterDraw control.

 


 

int GetPlotAreaLeftMargin()

Returns the plot area left margin.

 


 

ScatterDraw& SetPlotAreaRightMargin(int margin)

Sets the right margin of scatter plot inside ScatterDraw control.

 


 

int GetPlotAreaRightMargin()

Returns the plot area right margin.

 


 

ScatterDraw& SetPlotAreaTopMargin(int margin)

Sets the top margin of scatter plot inside ScatterDraw control.

 


 

int GetPlotAreaTopMargin()

Returns the plot area top margin.

 


 

ScatterDraw& SetPlotAreaBottomMargin(int margin)

Sets the bottom margin of scatter plot inside ScatterDraw control.

 


 

int GetPlotAreaBottomMargin()

Returns the plot area bottom margin.

 


 

ScatterDraw& SetPlotAreaColor(const Color& p_a_color)

Sets p_a_color as the plot area background color.

 


 

Color& GetPlotAreaColor()

Returns the plot area background color.

 


 

ScatterDraw& SetAxisColor(const Color& axis_color)

Sets axis_color as the color of the axis.

    

 


 

ScatterDraw& SetAxisWidth(int axis_width)

Sets axis_width as the width of the axis in pixels.

 


 

ScatterDraw& SetGridColor(const Color& grid_color)

Sets grid_color as the color of the grid.

    

 


 

ScatterDraw& SetGridWidth(int grid_width)

Sets grid_width as the width of the grid in pixels.

 


 

ScatterDraw& ShowVGrid(bool show)

If show is true the vertical grid is shown

 


 

ScatterDraw& ShowHGrid(bool show)

If show is true the horizontal grid is shown

 


 

ScatterDraw& ShowLegend(bool show = true)

If show is true graphs name, color and style will be shown.

Here there are described legend details.

    

 


 

bool GetShowLegend()

Returns true if legend is shown.

Here there are described legend details.

 


 

ScatterDraw& SetLegendPos(const Point &pos)

Sets the coordinates (pos) of the legend table corner relative to the plot corner.

Here there are described legend details.

    

 


 

ScatterDraw& SetLegendPosX(int x)

Sets the x coordinate.of the legend table corner relative to the plot corner.

 


 

ScatterDraw& SetLegendPosY(int y)

Sets the y coordinate.of the legend table corner relative to the plot corner.

 


 

Point& GetLegendPos()

Returns the pos of the legend corner relative to the plot corner.

 


 

ScatterDraw& SetLegendNumCols(int num)

Sets the number num of legend columns.

3 columns

        

2 columns

        

 


 

int GetLegendNumCols()

Returns the number of legend columns.

 


 

ScatterDraw& SetLegendRowSpacing(int num)

Sets the height (num) between legend rows.

num = 0

        

num = 5

        

 


 

int GetLegendRowSpacing()

Returns the height between legend rows.

 


 

enum LEGEND_POS LEGEND_TOP

 


 

enum LEGEND_POS LEGEND_ANCHOR_LEFT_TOP

 


 

enum LEGEND_POS LEGEND_ANCHOR_RIGHT_TOP

 


 

enum LEGEND_POS LEGEND_ANCHOR_LEFT_BOTTOM

 


 

enum LEGEND_POS LEGEND_ANCHOR_RIGHT_BOTTOM

 


 

ScatterDraw& SetLegendAnchor(int anchor)

Sets with anchor the legend table position:

LEGEND_TOP,

LEGEND_ANCHOR_LEFT_TOP,

LEGEND_ANCHOR_RIGHT_TOP,

LEGEND_ANCHOR_LEFT_BOTTOM,

LEGEND_ANCHOR_RIGHT_BOTTOM

 

 


 

int GetLegendAnchor()

Returns the legend table position.

 


 

ScatterDraw& SetLegendFillColor(const Color &color)

Sets with color the legend background color.

 


 

ScatterDraw& SetLegendBorderColor(const Color &color)

Sets with color the legend border color.

 


 

Color& GetLegendFillColor()

Returns the legend background color

 


 

Color& GetLegendBorderColor()

Returns the legend border color.

 


 

ScatterDraw& SetMode(int _mode = MD_ANTIALIASED)

Sets the drawing mode. Values are:

Drawn with Draw

MD_DRAW

Drawn with PAINTER

MD_ANTIALIASED    = MODE_ANTIALIASED,

MD_NOAA            = MODE_NOAA,

MD_SUBPIXEL    = MODE_SUBPIXEL

 


 

int GetMode()

Returns the drawing mode as documented in SetMode().

 


 

void Zoom(double scale, bool hor = true, bool ver = true)

Zooms plots by scale factor horizontally if hor is true and vertically if ver is true.

 


 

void Scroll(double factorX, double factorY)

Scrolls plots horizontally by factorX and vertically by factor factorY.

 


 

ScatterDraw& LinkedWith(ScatterDraw& ctrl)

Links zoom and scroll events with ctrl.

All zoom and scroll in either of both controls will affect the other control.

 

 


 

ScatterDraw &SetZoomStyleX(ZoomStyle style = TO_CENTER)

Sets the X zoom style. Valid values are:

TO_CENTER: Zoom is centered to the control center.

FROM_BASE: Zoom is centered to the X origin.

 


 

ScatterDraw &SetZoomStyleY(ZoomStyle style = TO_CENTER)

Sets the Y zoom style. Valid values are:

TO_CENTER: Zoom is centered to the control center.

FROM_BASE: Zoom is centered to the Y origin.

 


 

ScatterDraw& SetRange(double rx, double ry, double ry2 = 100)

Sets the horizontal (rx), vertical (ry) and secondary vertical (ry2) axis ranges.

Range is the visible with of the plot in series units (not in pixels).

 


 

double GetXRange()const

Returns the x axis range.

 


 

double GetYRange()const

Returns the y axis range.

 


 

double GetY2Range()const

Returns the secondary y axis range.

 


 

ScatterDraw &SetMajorUnits(double ux, double uy)

Sets the horizontal (ux) and vertical (uy) distance between grid lines.

 


 

ScatterDraw &SetMajorUnitsNum(int nx, int ny)

Sets the horizontal (nx) and vertical (ny) number of grid lines.

 


 

ScatterDraw &SetMaxMajorUnits(int maxX, int maxY)

Sets the maximum number of horizontal (maxX) and vertical (maxY) grid lines.

 


 

double GetMajorUnitsX()

Returns the maximum number of horizontal grid lines.

 


 

double GetMajorUnitsY()

Returns the maximum number of vertical grid lines.

 


 

ScatterDraw& SetMinUnits(double ux, double uy)

Sets with ux and uy the first X and Y axis grid lines location.

 


 

double GetXMinUnit () const

Returns the first X axis grid line location.

 


 

double GetYMinUnit () const

Returns the first Y axis grid line location.

 


 

double GetYMinUnit2 () const

Returns the first secondary Y axis grid line location.

 


 

ScatterDraw& SetXYMin(double xmin,double ymin,double ymin2 = 0)

Sets with xmin, ymin and ymin2 the X, Y and secondary Y axis origin.

 


 

void ZoomToFit(bool horizontal = true, bool vertical = false, double factor = 0)

Rescales the x axis if horizontal is true and y axis if vertical is true to show all graphs data.on the control. factor indicates the fit factor (0 fills the control).

 


 

double GetXMin () const

Returns the X axis origin.

 


 

double GetYMin () const

Returns the Y axis origin.

 


 

double GetYMin2 () const

Returns the secondary Y axis origin.

 


 

double GetY2Min () const

Returns the secondary Y axis origin.

 


 

ScatterDraw &SetPolar(bool polar = true)

If polar is true, ScatterDraw is converted into a Polar plot..

 


 

ScatterDraw &AddSeries(double *yData, int numData, double x0 = 0, double deltaX = 1)

Adds a new series stored in yData C array with numData where the yData[0] X value is x0 and the horizontal distance between yData values is deltaX.

yData has to be stored in a permanent location during ScatterDraw life to avoid memory problems.

 


 

ScatterDraw &AddSeries(double *xData, double *yData, int numData)

Adds a new series stored in xData and yData C arrays with numData.

xData and yData has to be stored in a permanent location during ScatterDraw life to avoid memory problems.

 


 

ScatterDraw &AddSeries(Vector<double> &xData, Vector<double> &yData)

Adds a new series stored in xData and yData Vector<double>.

xData and yData has to be stored in a permanent location during ScatterDraw life to avoid memory problems.

 


 

ScatterDraw &AddSeries(Array<double> &xData, Array<double> &yData)

Adds a new series stored in xData and yData Array<double>.

xData and yData has to be stored in a permanent location during ScatterDraw life to avoid memory problems.

 


 

ScatterDraw &AddSeries(Vector<Pointf> &points)

Adds a new series stored in points Vector<Pointf>.

points has to be stored in a permanent location during ScatterDraw life to avoid memory problems.

 


 

ScatterDraw &AddSeries(Array<Pointf> &points)

Adds a new series stored in points Array<Pointf>.

points has to be stored in a permanent location during ScatterDraw life to avoid memory problems.

 


 

ScatterDraw &AddSeries(Vector<Vector <double> > &data)

Adds a new series stored in data .

 


 

ScatterDraw &Opacity(double opacity = 1)

Sets the series opacity .from 1 (opaque) to 0 (transparent/invisible).

 


 

ScatterDraw &Legend(const String legend)

Sets the series legend.

 


 

ScatterDraw& Legend(int index, const String legend)

Sets the legend for index series.

 


 

const String& GetLegend(int index)

Returns the legend for index series.

 


 

ScatterDraw &Units(const String unitsY, const String unitsX = "")

Sets the series units for Y axis (unitsY) and X axis (unitsX).

 


 

ScatterDraw &Units(int index, const String unitsY, const String unitsX = "")

Sets the index series units for Y axis (unitsY) and X axis (unitsX).

 


 

const String GetUnitsX(int index)

Returns the X axis units for index series.

 


 

const String GetUnitsY(int index)

Returns the Y axis units for index series.

 


 

ScatterDraw& SetDrawXReticle(bool set = true)

If set is true the small lines and texts beside every X grid line are shown.

 


 

ScatterDraw& SetDrawYReticle(bool set = true)

If set is true the small lines and texts to the left of  every Y grid line are shown.

 


 

ScatterDraw& SetDrawY2Reticle(bool set = true)

If set is true the small lines and texts to the right of  every Y grid line are shown.

 


 

void SetDataPrimaryY(int index, bool primary = true)

If primary is true, index series is considered to be a primary series so it uses the left vertical axis. If false it uses right vertical axis.

 


 

ScatterDraw &SetDataPrimaryY(bool primary)

If primary is true, last added series is considered to be a primary series so it uses the left vertical axis. If false it uses right vertical axis..

 


 

bool IsDataPrimaryY(int indexconst throw (Exc)

Returns true if index series is primary.

 


 

void SetSequentialX(int index, bool sequential = true)

If sequential is true, index series is considered to be sequential so all data points are ordered following the X axis.

 


 

ScatterDraw &SetSequentialX(bool sequential = true)

If sequential is true the last added series is considered to be sequential so all data points are ordered following the X axis.

 


 

ScatterDraw &SetSequentialXAll(bool sequential = true)

If sequential is true all series are considered to be sequential so all data points are ordered following the X axis.

 


 

void Show(int index, bool show = true)

If show is true it sets the opacity of index data series to 1. If false, the opacity will be set to 0.

 


 

bool IsVisible(int index)

Returns true if index data series opacity is greater than 0.

 


 

ScatterDraw &ShowAll(bool show = true)

If show is true it sets the opacity of all series to 1. If false, the opacity will be set to 0.

 


 

void RemoveSeries(int index)

Remove index data series from control. It does not delete the series data.

 


 

void RemoveAllSeries()

Remove all data series from control. It does not delete the series data.

 


 

ScatterDraw& Id(int id)

Sets the id of the last added data series.

 


 

ScatterDraw& Id(int index, int id)

Sets the id if index data series.

 


 

int GetId(int index)

Returns the id of index data series.

 


 

Drawing GetDrawing()

Returns the control Drawing.

 


 

Image GetImage(int scale = 1)

Returns the control Image scaled at scale.

 


 

double GetXByPoint(double x)

Returns the X axis value of pixel x in data set units.

 


 

double GetYByPoint(double y)

Returns theY axis value of pixel y in data set units.

 


 

double GetY2ByPoint(double y)

Returns the secondary Y axis value of pixel y in data set units.

 


 

double GetXPointByValue(double x)

Returns the X axis pixel value of x in data set units.

 


 

double GetYPointByValue(double y)

Returns the Y axis pixel value of y in data set units.

 


 

void SaveAsMetafile(const char* fileconst

Windows

Saves the control as a windows metafile in file.

 


 

ScatterDraw& SetMinZoom(double x, double y = -1)

Sets x and y as the minimum visible range. If y is -1, only x zoom is considered.

Equal to SetMinRange().

 


 

ScatterDraw& SetMaxZoom(double x, double y = -1)

Sets x and y as the maximum visible range. If y is -1, only x zoom is considered.

Equal to SetMaxRange().

 


 

ScatterDraw& SetMinRange(double x, double y = -1)

Sets x and y as the minimum visible range. If y is -1, only x zoom is considered.

 


 

ScatterDraw& SetMaxRange(double x, double y = -1)

Sets x and y as the maximum visible range. If y is -1, only x zoom is considered.

 


 

ScatterDraw& SetFastViewX(bool set = true)

If set is true, only one point per screen pixel will be drawn. The Y value of this point will be the average of all data points between two pixels.

In case of big datasets and zoom in with big detail, this option can accelerate strongly the control refresh.

 


 

int GetCount()

Returns the number of series loaded.

 


 

bool IsEmpty()

Returns true if there are no series.

 

Do you want to contribute?