Signalsmith's Basic C++ Plots  1.1.0
A minimal C++ plotting library
Loading...
Searching...
No Matches
signalsmith::plot::Line2D Class Reference

#include <plot.h>

Detailed Description

A line on a 2D plot, with fill and/or stroke.

Inherits signalsmith::plot::SvgDrawable.

Nested Classes

class  LineLabel
 

Methods

 Line2D (Axis &axisX, Axis &axisY, PlotStyle::Counter styleIndex)
 
Line2Dadd (double x, double y)
 
template<class X, class Y>
Line2DaddArray (X &&x, Y &&y, size_t size)
 
template<class X, class Y>
Line2DaddArray (X &&x, Y &&y)
 
Line2Dcut ()
 
Point2D prev () const
 
Line2Dmarker (double x, double y, int shape=-1)
 
Line2Ddot (double x, double y, double screenR)
 Adds a scatter-plot style circle.
 
Line2Ddot (double x, double y, double screenR, double unitColour)
 Adds a scatter-plot style circle, with colour value in the 0-1 range.
 
Line2Dlabel (double valueX, double valueY, std::string name)
 
Line2Dlabel (double valueX, double valueY, std::string name, double degrees, double distance=0)
 Label with direction (degrees clockwise) and distance.
 
Line2Dlabel (std::string name, double degrees=0, double distance=0)
 Adds a label using the latest point/marker/dot position.
 
Line2Dlabel (double xIsh, std::string name, double degrees=0, double distance=0)
 Adds a label using the closest (line) point to the given x-axis position.
 
Draw config
Line2DdrawLine (bool draw=true)
 
Line2DdrawFill (bool draw=true)
 
Line2DfillToY (double y)
 Start/end the fill at a given Y value.
 
Line2DfillToX (double x)
 Start/end the fill at a given X value.
 
Line2DfillTo (Line2D &other)
 
Overridden from SvgDrawable
void toFrame (double time, bool clear=true) override
 Creates a frame from the current stat, and optionally clears the state ready for the next frame.
 
void loopFrame (double endTime) override
 Sets loop time (or < 0 to disable) for this element and all children.
 
void clearFrames () override
 Removes all animation frames. Mostly useful if re-using the diagram for multiple animations.
 
void writeLabel (SvgWriter &svg, const PlotStyle &style) override
 
void writeData (SvgWriter &svg, const PlotStyle &style) override
 
- Methods inherited from signalsmith::plot::SvgDrawable
 SvgDrawable (const SvgDrawable &other)=delete
 
SvgDrawableoperator= (const SvgDrawable &other)=delete
 
Bounds layoutIfNeeded (const PlotStyle &style)
 
void addChild (SvgDrawable *child, bool front=false)
 Takes ownership of the child.
 

Attributes

PlotStyle::Counter styleIndex
 
bool smoothFrame = false
 Flag to attempt interpolation of the path between frames.
 

Additional Inherited Members

- Protected Member Functions inherited from signalsmith::plot::SvgDrawable
void invalidateLayout ()
 
virtual void layout (const PlotStyle &style)
 
void addLayoutChild (SvgDrawable *child)
 These children are removed when the layout is invalidated.
 
- Protected Attributes inherited from signalsmith::plot::SvgDrawable
Bounds bounds
 

Method Details

◆ clearFrames()

void signalsmith::plot::Line2D::clearFrames ( )
inlineoverridevirtual

Removes all animation frames. Mostly useful if re-using the diagram for multiple animations.

Reimplemented from signalsmith::plot::SvgDrawable.

◆ dot() [1/2]

Line2D & signalsmith::plot::Line2D::dot ( double x,
double y,
double screenR )
inline

Adds a scatter-plot style circle.

◆ dot() [2/2]

Line2D & signalsmith::plot::Line2D::dot ( double x,
double y,
double screenR,
double unitColour )
inline

Adds a scatter-plot style circle, with colour value in the 0-1 range.

◆ fillToX()

Line2D & signalsmith::plot::Line2D::fillToX ( double x)
inline

Start/end the fill at a given X value.

◆ fillToY()

Line2D & signalsmith::plot::Line2D::fillToY ( double y)
inline

Start/end the fill at a given Y value.

◆ label() [1/3]

Line2D & signalsmith::plot::Line2D::label ( double valueX,
double valueY,
std::string name,
double degrees,
double distance = 0 )
inline

Label with direction (degrees clockwise) and distance.

◆ label() [2/3]

Line2D & signalsmith::plot::Line2D::label ( double xIsh,
std::string name,
double degrees = 0,
double distance = 0 )
inline

Adds a label using the closest (line) point to the given x-axis position.

◆ label() [3/3]

Line2D & signalsmith::plot::Line2D::label ( std::string name,
double degrees = 0,
double distance = 0 )
inline

Adds a label using the latest point/marker/dot position.

◆ loopFrame()

void signalsmith::plot::Line2D::loopFrame ( double loopTime)
inlineoverridevirtual

Sets loop time (or < 0 to disable) for this element and all children.

Elements may have different loop time

Reimplemented from signalsmith::plot::SvgDrawable.

◆ toFrame()

void signalsmith::plot::Line2D::toFrame ( double time,
bool clear = true )
inlineoverridevirtual

Creates a frame from the current stat, and optionally clears the state ready for the next frame.

The time is the start-time of the frame being created.

Two lines with a different number of frames

Reimplemented from signalsmith::plot::SvgDrawable.

◆ writeData()

void signalsmith::plot::Line2D::writeData ( SvgWriter & svg,
const PlotStyle & style )
inlineoverridevirtual

Reimplemented from signalsmith::plot::SvgDrawable.

◆ writeLabel()

void signalsmith::plot::Line2D::writeLabel ( SvgWriter & svg,
const PlotStyle & style )
inlineoverridevirtual

Reimplemented from signalsmith::plot::SvgDrawable.

Member Data Documentation

◆ smoothFrame

bool signalsmith::plot::Line2D::smoothFrame = false

Flag to attempt interpolation of the path between frames.