Platforms to show: All Mac Windows Linux Cross-Platform

Back to CDXYChartMBS class.

Previous items

CDXYChartMBS.getXValue(xCoor as Integer) as Double

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ChartDirector MBS ChartDirector Plugin 12.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Gets the x data value given the x pixel coordinate.

Note: This method should be used only after ChartDirector has output the chart image, or after XYChart.layoutAxes, BaseChart.layout or XYChart.packPlotArea has been called. ChartDirector needs to perform auto- scaling and layout the axis before it can convert between pixel coordinates and data values.

ArgumentDefaultDescription
xCoor(Mandatory)The x pixel coordinate.

Returns the x data value at the x pixel coordinate.

Some examples using this method:

CDXYChartMBS.getYCoor(value as Double, yAxis as CDAxisMBS=nil) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ChartDirector MBS ChartDirector Plugin 8.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Gets the y pixel coordinate of a point given the y data value.

Note: You must call BaseChart.layout first before calling this method. It is because ChartDirector needs to perform auto-scaling and determine the axis scale first before it can compute the coordinates.

For a 3D chart, this method will get the pixel coordinate of the data value on the top surface of the chart. Use Layer.getYCoor to obtain the pixel coordinate of the data value on a particular chart layer.

ParameterDefaultDescription
v(Mandatory)The y data value.
yAxisnilThe y-axis to use to determine the pixel coordinates of data values. The y-axis may be obtained using XYChart.yAxis, XYChart.yAxis2 or XYChart.addAxis. The default is to use the primary y-axis.

Return Value
The y coordinate of the y data value.

CDXYChartMBS.getYValue(yCoor as Integer, axis as CDAxisMBS = nil) as Double

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ChartDirector MBS ChartDirector Plugin 12.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Gets the y data value given the y pixel coordinate.

Note: This method should be used only after ChartDirector has output the chart image, or after XYChart.layoutAxes, BaseChart.layout or XYChart.packPlotArea has been called. ChartDirector needs to perform auto- scaling and layout the axis before it can convert between pixel coordinates and data values.

ArgumentDefaultDescription
yCoor(Mandatory)The y pixel coordinate.
yAxisnilThe y-axis to use to determine the pixel coordinates of data values. The y-axis may be obtained using XYChart.yAxis, XYChart.yAxis2 or XYChart.addAxis. The default is to use the primary y-axis.

Returns the y data value at the y pixel coordinate.

Some examples using this method:

CDXYChartMBS.layoutAxes

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ChartDirector MBS ChartDirector Plugin 9.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Performs axis auto-scaling and sets the axis positions and lengths.

ChartDirector automatically calls this method when creating the chart output (eg. using BaseChart.makeChart). There is usually no need to call this method explicitly.

However, if you would like to draw custom objects whose positions or contents depend on the axis scales, you may call this method to auto-scaling the axes before creating the chart output.

The axes will auto-scale based on the data at the time of calling this method. New data added afterwards will not affect the axis scale.

You should not modify the axis scale (eg. using Axis.setLinearScale, Axis.setLabels, etc) after calling this method.

Some examples using this method:

CDXYChartMBS.packPlotArea(leftX as Integer, topY as Integer, rightX as Integer, bottomY as Integer, minWidth as Integer = 0, minHeight as Integer = 0)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ChartDirector MBS ChartDirector Plugin 9.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Adjusts the plot area size and position to fit the plot area and the axis labels in a bounding box.

In some charts, the axis labels may vary widely and can be very short or very long. It may be difficult to determine to plot area position and size so as to reserve reasonable and sufficient space for the axis labels.
This method adjusts the size and position of the plot area, so that the plot area, together with the axis labels can fit within a given bounding box.
Note that this method only adjusts for the thickness of the primary and secondary axes, and assumes they are at the border of the plot area. For other axes, you may use Axis.getThickness to get their thickness and adjust the plot area size and position accordingly.
For this method to determine the thickness of the axes, it needs to auto-scale the axes to determine the axis labels. That means all the data should be entered to the chart before calling this method.
Furthermore, the labels generated by auto-scaling depend on the number of labels that can fit on the axis, which in turn depends on the plot area size. So even the final plot area size is determined by this method, the XYChart.setPlotArea must still be used to set a reasonable initial plot area size.
To adjust only the plot area width and horizontal position, and leave the height and vertical position unchanged, simply use a bounding box with zero height (eg. set both topY and bottomY to 0). Similarly, to adjust only the height and vertical position, use a bounding box with zero width.
In some extreme cases, the axis labels may be so long that the plot area needs to adjust to an unreasonably small size, or even zero in size. For example, the axis labels may be names entered by the user, and the user may enter a name thousands of characters long. These extreme cases should be avoided by checking and limiting the length of the labels before passing the labels to ChartDirector. This method also has a safeguard for these unreasonable labels by ensuring the plot area will not shrink below a given minimum size.

Arguments:
ArgumentDefaultDescription
leftX(Mandatory)The left x coordinate of the bounding box.
topY(Mandatory)The top y coordinate of the bounding box.
rightX(Mandatory)The right x coordinate of the bounding box.
bottomY(Mandatory)The bottom y coordinate of the bounding box.
minWidth0The minimum width the plot area can adjust to.
minHeight0The minimum height the plot area can adjust to.

Some examples using this method:

CDXYChartMBS.setAxisAtOrigin(originMode as Integer = 3, symmetryMode as Integer = 0)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ChartDirector MBS ChartDirector Plugin 8.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sets the chart into 4 quadrant mode. The axes may intersect at origin inside the plot area (as opposed to at the border of the plot area).

By default, ChartDirector puts the axes at the border of the plot area. This ensures the axes and the axes labels will not block the contents of the plot area.

However, in some cases, it may be desirable for the axes to intersect at the origin. The axes may need to move inside the plot area.

ChartDirector allows you to move the primary x-axis and/or y-axis to so that they intersect with the zero point of the other axis. The following constants represent different possibilities:

ConstantValueDescription
XAxisAtOrigin1Move the x-axis so that it will intersect with the zero point of the y-axis, if that point exists.
YAxisAtOrigin2Move the y-axis so that it will intersect with the zero point of the x-axis, if that point exists.
XYAxisAtOrigin3Move the x-axis so that it will intersect with the zero point of the y-axis, if that point exists. Move the y-axis so that it will intersect with the zero point of the x-axis, if that point exists.

In addition to ensure the axes intersects at the origin, ChartDirector allows you to control if the axes are symmetrical about the origin with the following flags. Multiple flags can be specified by "or" them together.

ConstantValueDescription
XAxisSymmetric1 Adjust the x-axis so that it becomes symmetrical about the zero point, that is, the positive and negative part of the x-axis will be of the same length.
XAxisSymmetricIfNeeded2 Adjust the x-axis will be symmetrical about the zero point if the axis scale needs both positive and negative values.
YAxisSymmetric4 Adjust the y-axis so that it becomes symmetrical about the zero point, that is, the positive and negative part of the y-axis will be of the same length.
YAxisSymmetricIfNeeded8 Adjust the y-axis will be symmetrical about the zero point if the axis scale needs both positive and negative values.
XYAxisSymmetric16Adjust the x-axes and y-axes so that they become symmetrical about the zero point. The positive and negative parts of the x-axes and the y-axes will all be of the same length.
XYAxisSymmetricIfNeeded32Adjust the x-axes and y-axes so that they become symmetrical about the zero point. However, if an axis does not need both positive and negative values, it will not be adjusted.

ParameterDefaultDescription
originModeXYAxisAtOriginpredefined constants to determine which axis needs to move to intersect with the zero point of the other axis.
symmetryMode0Flags to determine if the axes need to be symmetrical about the origin.

Some examples using this method:

CDXYChartMBS.setClipping(margin as Integer = 0)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ChartDirector MBS ChartDirector Plugin 8.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Enables clipping on the plot area.

In normal usage, ChartDirector will auto-scale the axis to ensure all the data points will be within the plot area.

However, if manual scaling is used (e.g. using Axis.setLinearScale), it is possible to choose an axis scale such that some data points will be outside the plot area. So some of the data representation (bars, lines, etc) will be outside the plot area.

This method can be used to clip the plot area, so that any data representation that is outside the plot area will not be drawn.

ParameterDefaultDescription
margin0Additional margin, measured in pixels, to be added to the 4 sides of the plot area for the purpose of clipping. A positive value means the clipping region will be larger than the plot area. A negative value means the clipping region will be smaller than the plot area. The default value of 0 means the clipping region is equal to the plot area.

Some examples using this method:

CDXYChartMBS.setPlotArea(x as Integer, y as Integer, width as Integer, height as Integer, bgColor as Integer = &hff000000, altBgColor as Integer = -1, edgeColor as Integer = -1, hGridColor as Integer = &hc0c0c0, vGridColor as Integer = &hff000000) as CDPlotAreaMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ChartDirector MBS ChartDirector Plugin 8.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sets the position, size, background colors, edge color and grid colors of the plot area.

ParameterDefaultDescription
x(Mandatory)The x coordinate of the left of the plot area.
y(Mandatory)The y coordinate of the top of the plot area.
width(Mandatory)The width of the plot area in pixels.
height(Mandatory)The height of the plot area in pixels.
bgColorTransparentThe background color of the plot area.
altBgColor-1The second background color of the plot area. -1 means there is no second background color. If there is a second background color, the two background colors will be used alternatively as horizontal bands on the background grid.
edgeColor-1The border color of the plot area. -1 means to use the default, which is LineColor. However, if the axes are configured in 4 quadrant mode (see XYChart.setAxisAtOrigin), the default will change to Transparent.
hGridColorC0C0C0The horizontal grid color.
vGridColorTransparentThe vertical grid color.

Return Value
A PlotArea object representing the plot area.

See also:

CDXYChartMBS.setTrimData(startPos as Integer, len as Integer = &h7fffffff)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ChartDirector MBS ChartDirector Plugin 8.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Uses only a subset of the data series to draw charts.

In finance charts, "lead data" are commonly needed to plot technical indicators. For example, to show a 20-days moving average line for 30 days, one needs 50 days of data. It is because computing 20-days moving average requires 20 days of "lead data". The setTrimData method is a convenience method for trimming off these "lead data" so they will not appear on the chart.

ParameterDefaultDescription
startPos(Mandatory)The index for the first data position to use for plotting charts.
len7FFFFFFFThe length of the data points used for plotting charts.

CDXYChartMBS.setXAxisOnTop(value as boolean=true)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ChartDirector MBS ChartDirector Plugin 8.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Interchange the position of the primary x-axis and the secondary x-axis.

By default, the primary x-axis is the x-axis on the bottom side of the plot area (left side if XYChart.swapXY is in effect), and the secondary x-axis is on the top side of the plot area (right side if XYChart.swapXY is in effect). This method can be used to interchange their positions.

ParameterDefaultDescription
btrueA true value means to interchange the positions of the primary and secondary x-axes. A false value means using the default positions for the primary and secondary x-axes.

Some examples using this method:

CDXYChartMBS.setYAxisOnRight(value as boolean=true)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ChartDirector MBS ChartDirector Plugin 8.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Interchange the position of the primary y-axis and the secondary y-axis.

By default, the primary y-axis is the y-axis on the left side of the plot area (bottom side if XYChart.swapXY is in effect), and the secondary y-axis is on the right side of the plot area (top side if XYChart.swapXY is in effect). This method can be used to interchange their positions.

ParameterDefaultDescription
btrueA true value means to interchange the positions of the primary and secondary y-axes. A false value means using the default positions for the primary and secondary y-axes.

Some examples using this method:

CDXYChartMBS.swapXY(value as boolean=true)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ChartDirector MBS ChartDirector Plugin 8.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Swap the position of the x and y axes, so the x-axes will become vertical, and the y-axes will become horizontal.

After swapping the x and y axes, the charts will appear rotated. For example, the bars in a bar chart will become horizontal instead of vertical, and the area in a stacked area chart will grow from left to right (instead of bottom to top).

ParameterDefaultDescription
btrueA true value means the x and y axes will be swapped. A false value means the x and y axes not be swapped.

Some examples using this method:

CDXYChartMBS.syncYAxis(slope as Double = 1, intercept as Double = 0)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ChartDirector MBS ChartDirector Plugin 8.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sets a linear formula to synchronize the secondary y-axis scale to the primary y-axis scale.

The formula is in the format:

y2 = y1 * slope + intercept

This method is usually used if the two y-axes represent the same measurement using different units. Examples including temperature in Celsius and in Fahrenheit, and length in meters and feet.

ParameterDefaultDescription
slope1The slope parameter for the formula linking the secondary y-axis to the primary y-axis.
intercept0The intercept parameter for the formula linking the secondary y-axis to the primary y-axis.

Some examples using this method:

CDXYChartMBS.xScaleColor(scale() as double) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ChartDirector MBS ChartDirector Plugin 21.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates an x-scale color. An x-scale is a color that will vary depending on the x value of the pixel.

ArgumentDefaultDescription
colorStops(Mandatory)An array that defines the mapping from data values to colors. Please refer to ColorAxis.setColorScale for the format of this array.

Returns a 32-bit integer representing the x scale color.

CDXYChartMBS.xZoneColor(threshold as Double, belowColor as color, aboveColor as color) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ChartDirector MBS ChartDirector Plugin 11.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Same as the other xZoneColor method, but uses color instead of integer data type for passing color values.

See also:

CDXYChartMBS.xZoneColor(threshold as Double, belowColor as Integer, aboveColor as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ChartDirector MBS ChartDirector Plugin 8.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates a x-zone color. A x-zone will change from one color to another depending on a threshold value on the x-axis.

For example, if a x-zone color is used as the line color in a line layer, the line will switch from one color to another when its passes through a certain value on the x-axis. Similarly, if a x-zone color is used as the fill color in an area layer, the area will switch from one color to another when it passes through a certain value on the x-axis.

The two colors used in a x-zone color can be other dynamic colors. For example, one color could be a solid color, while the other color could be a dash line color (see !BaseChart.dashLineColor). When this x-zone color is as the line color, the line will change from a solid style to a dash line style when the line passes through a certain value on the x-axis

You may create x-zone colors with more than 2 zones by cascading multiple x-zone colors.

For a 3D chart, this method will get the zone color at the top surface of the chart. Use Layer.xZoneColor to obtain the zone color for a particular chart layer.

threshold(Mandatory)The x value serving as the threshold for switching between two colors.
belowColor(Mandatory)The color to use when the x-axis value of the pixel is smaller than the threshold.
aboveColor(Mandatory)The color to use when the x-axis value of the pixel is greater than the threshold.

Return Value
A 32-bit integer representing the x-zone color.

See also:

CDXYChartMBS.yScaleColor(scale() as double, yAxis as CDAxisMBS = nil) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ChartDirector MBS ChartDirector Plugin 21.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates a y-scale color. An y-scale is a color that will vary depending on the y value of the pixel.

ArgumentDefaultDescription
colorStops(Mandatory)An array that defines the mapping from data values to colors. Please refer to ColorAxis.setColorScale for the format of this array.
yAxisnilThe y-axis to use to determine the pixel coordinates of data values. The y-axis may be obtained using XYChart.yAxis, XYChart.yAxis2 or XYChart.addAxis. The default is to use the primary y-axis.

Returns a 32-bit integer representing the y scale color.

CDXYChartMBS.yZoneColor(threshold as Double, belowColor as color, aboveColor as color, yAxis as CDAxisMBS=nil) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ChartDirector MBS ChartDirector Plugin 11.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Same as the other yZoneColor method, but uses color instead of integer data type for passing color values.

See also:

CDXYChartMBS.yZoneColor(threshold as Double, belowColor as Integer, aboveColor as Integer, yAxis as CDAxisMBS=nil) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ChartDirector MBS ChartDirector Plugin 8.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates a x-zone color. A x-zone will change from one color to another depending on a threshold value on the x-axis.

For example, if a x-zone color is used as the line color in a line layer, the line will switch from one color to another when its passes through a certain value on the x-axis. Similarly, if a x-zone color is used as the fill color in an area layer, the area will switch from one color to another when it passes through a certain value on the x-axis.

The two colors used in a x-zone color can be other dynamic colors. For example, one color could be a solid color, while the other color could be a dash line color (see !BaseChart.dashLineColor). When this x-zone color is as the line color, the line will change from a solid style to a dash line style when the line passes through a certain value on the x-axis

You may create x-zone colors with more than 2 zones by cascading multiple x-zone colors.

For a 3D chart, this method will get the zone color at the top surface of the chart. Use Layer.xZoneColor to obtain the zone color for a particular chart layer.

ParameterDefaultDescription
threshold(Mandatory)The x value serving as the threshold for switching between two colors.
belowColor(Mandatory)The color to use when the x-axis value of the pixel is smaller than the threshold.
aboveColor(Mandatory)The color to use when the x-axis value of the pixel is greater than the threshold.

Return Value
A 32-bit integer representing the x-zone color.

See also:

Previous items

The items on this page are in the following plugins: MBS ChartDirector Plugin.


The biggest plugin in space...