Class: YAxis

YAxis

YAxis is an object that represents the range of the value being plotted. There can be multiple instances of a YAxis on a chart. The YAxis is interactable. It can be zoomed in and out. Various switches control how the YAxis behaves:

  • It can be made to display in log or percent scale.
  • It can be set to display on the left or right, or not at all.
  • It can display in different fonts or colors.
  • It can display labels corresponding to the current value of a plot. The YAxis can be configured to use different algorithms for rendering the dates on the ticks. A robust algorithm comes with compact chart and is found in modules/axes.js. A custom algorithm can be written but instructions for that are beyond this documentation at the present time.
Since:
  • 9.4.0

Type Definitions


HR

Configuration for the current price label. Set to false to disable.

Type:
  • boolean | object
Properties:
Name Type Argument Description
up object <optional>

Colors to use when value is increasing.

Properties
Name Type Argument Description
color object <optional>

Text color

backgroundColor object <optional>

Background color

down object <optional>

Colors to use when value is decreasing.

Properties
Name Type Argument Description
color object <optional>

Text color

backgroundColor object <optional>

Background color

Since:
  • 9.4.0


YAxisConfig

All configurations, including themeing, relating to the YAxis object go here. Note: The YAxisInit object this inherits from has all optional properties.

Type:
Properties:
Name Type Argument Description
drawFn YAxisDrawFunction <optional>

Axis drawing function from Axes import (Axes.drawYAxis), or custom function.

fontSize string <optional>

Axis font size.

fontFamily string <optional>

Axis font family.

fontStyle string <optional>

Axis font style (e.g. italic).

fontWeight string <optional>

Axis font weight (e.g. bold).

backgroundColor string <optional>

Axis background color.

color string <optional>

Axis text color.

gridLine LineTheme <optional>

Axis grid line treatment.

gridDivider LineTheme <optional>

Axis grid divider treatment.

Since:
  • 9.4.0

Example

Setting up the default drawFn:

import * as Axes from "../js/modules/axes.js";
const config = {
	...
	yaxis: {
		drawFn: Axes.drawYAxis,
		...
	}
};

YAxisDrawFunction(panel [, parameters])

Draw function for y axis. Function's this is a CompactChart instance.

Parameters:
Name Type Argument Description
panel Panel

Panel of axis.

parameters YAxisInit <optional>

Y Axis parameters.

Since:
  • 9.4.0


YAxisFormatter(qc, panel [, price] [, defaultText])

Formatting function for y axis labels.

Parameters:
Name Type Argument Description
qc CompactChart

CompactChart instance.

panel Panel

Panel of axis.

price number <optional>

Value to format.

defaultText string <optional>

Text that would be displayed without formatter function.

Since:
  • 9.4.0 Introduced
  • 10.1.0 Added parameter defaultText.
Returns:

Formatted value as a string.

Type
string

YAxisInit

Properties relating to the y axis that are set by default to certain values. The YAxis object controls anything going on the canvas.

Type:
  • object
Properties:
Name Type Argument Default Description
bottomOffset number <optional>
0

Number of pixels to pad bottom of y-axis.

chartAxisMarginMultiplier number <optional>
2.5

When computing axis scroll and zoom, this value scales the number of pixels for the main chart panel.

decimalPlaces number <optional>

Set to fix the number of decimal places for an axis label.

displayGridLines boolean <optional>

Set to false to not draw horizontal gridlines (panel's main axis only).

drawCurrentPriceLabel boolean <optional>
<nullable>

Set to false to not put a distinct label for the current prices. Set to true to force one even when no y axis is drawn.

drawPriceLabels boolean <optional>

Set to false to suppress drawing of all labels on the axis.

drawSeriesPriceLabels boolean <optional>

Set to false to not put a distinct label for series price at rightmost bar.

flipped boolean <optional>

Set to true to flip axis (and all pplots on the axis) upside down (not supported).

?formatter YAxisFormatter <optional>

Optional function to format a price display on the axis.

goldenRatio boolean <optional>

Set to false to turn off the setting of the ratio of vertical gridline spacing to horizontal gridline spacing to 1.618.

ground boolean <optional>

Set to true to limit axis zooming to the the top of axis only.

heightFactor number <optional>
1

Scale factor for zoom.

hr HR <optional>

Allows styling of the current price label.

idealTickSizePixels number <optional>

Set to force spacing between labels on the axis to a set number of pixels.

increments Array.<number> <optional>
[1,2.5,5]

Depending on range of axis and spacing of labels, value of labels will increment by these values, from smallest to largest]. Note these increments are multiplied by a factor of 10.

initialMarginBottom number <optional>
10

Number of pixels to pad bottom of plots using y-axis.

initialMarginTop number <optional>
10

Number of pixels to pad top of plots using y-axis.

justifyRight boolean <optional>

When axis is on right side, set to true to align labels to right. When axis is on left side, set to false to align labels to left.

labelStyle string <optional>
<nullable>

Rendering style of the current price label. Values are: "roundRect", "roundRectArrow", "semiRoundRect", "tickedRect", "rect", "noop", null.

lockScale boolean <optional>

Set to true to disable auto-zooming when scrolling.

max number <optional>
<nullable>

When set, determines maximum price of the axis.

maxDecimalPlaces number <optional>
<nullable>

Set to fix the maximum number of decimal places for an axis label.

min number <optional>
<nullable>

When set, determines minimum price of the axis.

name string <optional>

Unique name of axis.

noDraw boolean <optional>

Set to true to hide the axis (but its footprint is preserved).

position string <optional>
<nullable>
'right'

Where the axis appears ("left", "right", "none").

range Array.<number> <optional>

Used to specify a functional range for the axis.

Elements
Index Type Argument Description
0 number <optional>

Minimum value.

1 number <optional>

Maximum value.

scroll number <optional>
0

Number of pixels to shift the axis from its centered position.

shadowBreaks Array.<Array.<number>> <optional>

Array of number pairs. Array is iterated to determine number of decimal places to display. Given a value, if it is below the first element of an array entry, display the number of decimal places in the second entry. Default is [ [1000, 2], [5, 4], [0.001, 8] ].

textBackground string <optional>
<nullable>

Optional CSS color of text background.

textStyle string <optional>
<nullable>

Optional CSS color of text.

topOffset number <optional>
0

Number of pixels to pad top of y-axi.

width number <optional>
1

Initial pixel width of axis. Width changes dynamically with respect to label widths.

zoom number <optional>
0

Number of pixels to spread the axis range.

Since:
  • 9.4.0