Framework Reference
WEALTHLAB FRAMEWORK / CLASS REFERENCE

PlotBase

API documentation, members, signatures, and C# examples.

Search the framework

Find classes, members, and documentation.

NamespaceWealthLab.ChartWPF
Parent
Configurable
Descendants

PlotBase is the base class for objects that can be plotted on a WL9 chart. It provides access to the chart, pane, historical data, chart preferences, coordinate conversion, rendering passes, configuration, and a number of helper methods for rendering lines, rectangles, and text.

Chart Related

19

Bars

public BarHistory Bars

Returns the BarHistory instance currently associated with this plot object. If BarsOverride is not null, Bars returns that instance instead of the BarHistory being charted.

BarsOverride

public BarHistory BarsOverride

Allows a PlotBase instance to use a BarHistory other than the one currently displayed by the chart. When this property is not null, the Bars property returns BarsOverride instead of Chart.Bars.

Chart

public CoreChart Chart

Returns the CoreChart associated with this plot object's Pane, or null if the plot object is not associated with a pane.

ChartPreferences

public ChartPreferences ChartPreferences

Returns the ChartPreferences that should be used when rendering this plot object. If ChartPreferencesOverride is not null, that instance is returned. Otherwise, the ChartPreferences of the associated Chart is returned.

Color

public WLColor Color

Specifies the primary color used when rendering this plot object. If the Parameters collection contains a Parameter named "Color", the property uses that Parameter's value. Otherwise, it uses the plot object's internal color value.

ConfigurableType

public override ConfigurableType ConfigurableType

Returns ConfigurableType.ParameterList, indicating that PlotBase instances use a ParameterList for their configuration.

DefaultBrush

public Brush DefaultBrush

Returns a WPF Brush using the plot object's current Color. The Brush is obtained through PenBrushFactory.

DefaultPen

public Pen DefaultPen

Returns the default WPF Pen for rendering this plot object. The Pen uses the plot object's current Color. Its default thickness is 2. If the Parameters collection contains a Parameter named "Thickness", that Parameter's integer value is used instead.

GetBarColor

public virtual WLColor GetBarColor(int idx)

Returns the color that should be used to render the bar at the specified idx. The default implementation returns the plot object's Color. Override this method when a plot object can render different bars using different colors.

GetMaxValue

public virtual double GetMaxValue(int start, int end)

Returns the highest y-axis value required by the plot object within the specified start and end bar index range. Derived classes should override this method when their values affect the chart pane's vertical scaling. The default implementation returns Double.MinValue.

GetMinValue

public virtual double GetMinValue(int start, int end)

Returns the lowest y-axis value required by the plot object within the specified start and end bar index range. Derived classes should override this method when their values affect the chart pane's vertical scaling. The default implementation returns Double.MaxValue.

GetValueMarker

public virtual ValueMarker GetValueMarker()

Returns a ValueMarker associated with this plot object. Derived classes can override this method to provide a value marker for display on the chart's value axis. The default implementation returns null.

IsMouseOver

public virtual bool IsMouseOver(Point pt)

Returns true if the chart coordinate specified by pt is considered to be over this plot object. Derived classes can override this method to provide hit testing. The default implementation returns false.

Name

public override string Name

Returns the runtime type name of the PlotBase instance.

Opacity

public byte Opacity

Gets or sets the opacity used when rendering this plot object. The property works with a Parameter named Opacity (0-100) when that Parameter is present in the Parameters collection. When read, the Parameter's 0-to-100 value is converted to a byte in the range 0 to 255. If no opacity Parameter exists, the property returns 255. When assigned, the supplied byte value is converted from the 0-to-255 range to the Parameter's 0-to-100 range.

OPACITY_LABEL

public const string OPACITY_LABEL = "Opacity (0-100)"

Contains the standard Parameter name used by PlotBase for an opacity Parameter.

Pane

public ChartPane Pane

Gets or sets the ChartPane associated with this plot object. The Chart property derives its value from this Pane.

PaneTag

public string PaneTag

Gets or sets the pane tag associated with this plot object. Plot objects such as indicators can use PaneTag to specify the chart pane in which they should be rendered.

Configuration

9

ConfigKey

public virtual string ConfigKey

Inherited from Configurable. Contains the key used when WL9 saves this item's configuration to the user's local file system. By default, ConfigKey is composed from Name plus "_Configuration". Derived classes can override it when multiple Configurable objects should share the same configuration.

Configuration

public string Configuration

Inherited from Configurable. Contains the item's configuration represented as a single string. For ParameterList-based objects such as PlotBase, the configuration is based on the Parameter instances contained in Parameters.

Description

public virtual string Description

Inherited from Configurable. Returns a short description of the configurable item. If the user edits the object's Parameters, this text can be displayed in the parameter editor dialog.

EditConfig

public virtual string EditConfig()

Inherited from Configurable. The default implementation displays a Parameter editor that allows the user to modify the object's Parameters. Derived classes can override this method to provide a custom configuration interface.

IsConfigurable

public virtual bool IsConfigurable

Inherited from Configurable. Indicates whether the object exposes configuration that can be edited.

Parameters

public ParameterList Parameters

Inherited from Configurable. Contains the Parameter instances that comprise the configuration for this plot object. See the ParameterList QuickRef entry for more information.

Parse

public virtual void Parse(string s)

Restores PlotBase-specific state from the string specified in s. The method restores PaneTag, parses the persisted ParameterList, and assigns the saved Parameter values to the existing Parameters collection.

Persist

public virtual string Persist()

Returns a string containing the state that PlotBase persists for the chart. The persisted data contains the plot object's pane tag followed by its serialized Parameters. If the object is currently associated with a Pane, the Pane's PaneTag is persisted. Otherwise, the object's PaneTag property is used.

ProcessConfig

public virtual void ProcessConfig()

Inherited from Configurable. Processes the current Configuration after it has changed. Derived classes can override this method to perform additional processing after configuration changes.

Coordinate Conversion

6

ConvertDateTimeToX

public double ConvertDateTimeToX(DateTime dt)

Converts the specified DateTime dt to an x-axis pixel coordinate on the chart. Returns 0 if the plot object is not associated with a Chart.

ConvertIndexToX

public double ConvertIndexToX(int idx)

Converts the specified BarHistory index idx to an x-axis pixel coordinate. Returns 0 if the plot object is not associated with a Chart.

ConvertValueToY

public double ConvertValueToY(double value)

Converts the specified data value to a y-axis pixel coordinate using the associated Pane.

ConvertXToDateTime

public DateTime ConvertXToDateTime(double x)

Converts the x-axis pixel coordinate x to the corresponding DateTime on the chart. Returns DateTime.MinValue if the plot object is not associated with a Chart.

ConvertXToIndex

public virtual int ConvertXToIndex(double x)

Converts the x-axis pixel coordinate x to an index in the BarHistory being charted. Returns 0 if the plot object is not associated with a Chart. Derived classes can override this behavior if they use a different x-axis mapping.

ConvertYToValue

public double ConvertYToValue(double y)

Converts the y-axis pixel coordinate y to a data value using the associated Pane.

Rendering

7

HasMouseOverState

public virtual bool HasMouseOverState

Returns true if the plot object has a special rendering state when the mouse is positioned over it. The default implementation returns false. Derived classes can override this property to support effects such as highlighting drawing objects or indicators during mouse interaction.

PostRender

public virtual void PostRender(DrawingContext dc)

WL9 calls this method after the main rendering phase for the plot object. The default implementation does nothing.

PreRender

public virtual void PreRender(DrawingContext dc)

WL9 calls this method before the main rendering phase for the plot object. The default implementation does nothing.

Render

public abstract void Render(DrawingContext dc)

WL9 calls this method when the plot object should render itself to the specified WPF DrawingContext dc. Derived PlotBase classes must implement this method.

RenderEachPass

public virtual bool RenderEachPass

Determines whether the plot object should render on every applicable chart rendering pass. The default implementation returns false.

RenderHighlight

public virtual void RenderHighlight(DrawingContext dc)

WL9 calls this method when the plot object's mouse-over or highlight state should be rendered to the specified DrawingContext. The default implementation does nothing.

RenderPasses

public virtual int RenderPasses

Specifies the chart rendering passes in which the plot object participates. WL9 uses render passes 1, 2, and 4. A derived class can return one pass or combine multiple passes using a bitwise OR. Objects rendered in pass 1 appear beneath those in pass 2, while objects rendered in pass 4 appear above passes 1 and 2. The default implementation returns 4. During rendering, a derived class that participates in multiple passes can inspect the chart's current render pass to determine which pass is being processed.

Rendering Helpers

3

RenderLine

public void RenderLine(
DrawingContext dc,
int idx1,
double value1,
int idx2,
double value2,
WLColor color,
int width = 1,
LineStyle lineStyle = LineStyle.Solid)

Renders a line between two bar index/value coordinates. The method converts idx1, value1, idx2, and value2 to chart pixel coordinates and obtains an appropriate Pen from PenBrushFactory.

RenderRectangle

public void RenderRectangle(
DrawingContext dc,
int idx1,
double value1,
int idx2,
double value2,
WLColor color,
int width = 1,
LineStyle lineStyle = LineStyle.Solid)

Renders an unfilled rectangle whose opposite corners are defined by the two supplied bar index/value coordinates. The rectangle outline uses the specified color, width, and lineStyle.

RenderText

public void RenderText(
DrawingContext dc,
string txt,
int idx,
double value,
bool aboveBar,
WLColor color,
double xOffset = 0.0,
double yOffset = 0.0,
bool center = true)
public void RenderText(
DrawingContext dc,
string txt,
double x,
double y,
bool aboveBar,
WLColor color,
double xOffset = 0.0,
double yOffset = 0.0,
bool center = true)
public void RenderText(
DrawingContext dc,
string txt,
double x,
double y,
bool aboveBar,
WLColor color,
WLColor colorBkg,
double xOffset = 0.0,
double yOffset = 0.0,
bool center = true,
int fontSize = 10)

Renders text to the specified DrawingContext. The first overload accepts a bar index and data value and converts them to chart pixel coordinates. The second overload accepts x and y pixel coordinates directly. The third overload also renders a background rectangle behind the text using colorBkg and allows the font size to be specified. When center is true, the text is horizontally centered on the supplied x coordinate. When aboveBar is true, the text is shifted upward by its rendered height. The optional xOffset and yOffset values provide additional pixel positioning adjustments.

Need help with this API?

Ask the community or explore custom development services.