Platforms to show: All Mac Windows Linux Cross-Platform
Back to CDXYChartMBS class.
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 |
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.
Argument | Default | Description |
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 |
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.
Parameter | Default | Description |
v | (Mandatory) | The y data value. |
yAxis | nil | The 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 |
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.
Argument | Default | Description |
yCoor | (Mandatory) | The y pixel coordinate. |
yAxis | nil | The 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:
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | ChartDirector | MBS ChartDirector Plugin | 9.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
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 |
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:
Argument | Default | Description |
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. |
minWidth | 0 | The minimum width the plot area can adjust to. |
minHeight | 0 | The 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 |
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:
Constant | Value | Description |
XAxisAtOrigin | 1 | Move the x-axis so that it will intersect with the zero point of the y-axis, if that point exists. |
YAxisAtOrigin | 2 | Move the y-axis so that it will intersect with the zero point of the x-axis, if that point exists. |
XYAxisAtOrigin | 3 | Move 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.
Constant | Value | Description |
XAxisSymmetric | 1 | 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. |
XAxisSymmetricIfNeeded | 2 | Adjust the x-axis will be symmetrical about the zero point if the axis scale needs both positive and negative values. |
YAxisSymmetric | 4 | 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. |
YAxisSymmetricIfNeeded | 8 | Adjust the y-axis will be symmetrical about the zero point if the axis scale needs both positive and negative values. |
XYAxisSymmetric | 16 | Adjust 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. |
XYAxisSymmetricIfNeeded | 32 | Adjust 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. |
Parameter | Default | Description |
originMode | XYAxisAtOrigin | predefined constants to determine which axis needs to move to intersect with the zero point of the other axis. |
symmetryMode | 0 | Flags 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 |
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.
Parameter | Default | Description |
margin | 0 | Additional 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:
- /ChartDirector/ChartDirector Control
- /ChartDirector/ChartDirector Control for Web
- /ChartDirector/ChartDirector Control Retina
- /ChartDirector/math function plot centered
- /ChartDirector/math function plot centered and axes
- /ChartDirector/RealTime ViewPort
- /ChartDirector/symbolline datezoom
- /ChartDirector/symbolline datezoom with date
- /ChartDirector/symbolline zoom
- /ChartDirector/symbolline zoom improved
CDXYChartMBS.setPlotArea(x as Integer, y as Integer, width as Integer, height as Integer, bgColor as color, altBgColor as color, edgeColor as color, hGridColor as color, vGridColor as color) as CDPlotAreaMBS
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | ChartDirector | MBS ChartDirector Plugin | 11.1 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
See also:
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 |
Parameter | Default | Description |
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. |
bgColor | Transparent | The background color of the plot area. |
altBgColor | -1 | The 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 | -1 | The 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. |
hGridColor | C0C0C0 | The horizontal grid color. |
vGridColor | Transparent | The 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 |
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.
Parameter | Default | Description |
startPos | (Mandatory) | The index for the first data position to use for plotting charts. |
len | 7FFFFFFF | The 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 |
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.
Parameter | Default | Description |
b | true | A 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 |
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.
Parameter | Default | Description |
b | true | A 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 |
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).
Parameter | Default | Description |
b | true | A 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 |
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.
Parameter | Default | Description |
slope | 1 | The slope parameter for the formula linking the secondary y-axis to the primary y-axis. |
intercept | 0 | The 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 |
Argument | Default | Description |
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 |
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 |
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 |
Argument | Default | Description |
colorStops | (Mandatory) | An array that defines the mapping from data values to colors. Please refer to ColorAxis.setColorScale for the format of this array. |
yAxis | nil | The 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 |
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 |
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.
Parameter | Default | Description |
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:
The items on this page are in the following plugins: MBS ChartDirector Plugin.
