Web Client 8.0.8

SimpleChartListener

SimpleChartListener

Simple implementation of the ChartListener interface that can be used to automatically adjust the axis of a Chart to center the lines on the Chart.
In case of an X overflow the X axis limits will shift by half of their total length meaning that the next point falls in the middle of the visible area so that the shifting is not continuous for each new value of X.
In case of an Y overflow the Y axis limits are stretched in such a way that the new point falls on the visible part of the Y axis.
Note that in case of an Y overflow all of the ChartLine instances of the listened Chart will be stretched with the same values to keep the view consistent.

Constructor

new SimpleChartListener(xSpanopt, yPercopt)

Creates an object that will handle the positioning of the X axis and Y axis of a Chart based on a few simple configuration parameters.
Note that this listener expects to listen to only one Chart but can correctly handle different lines as long as they can be represented on the same scale.
Methods from the ChartListener interface should not be called directly on instances of this class.

Parameters:
Name Type Attributes Default Description
xSpan Number <optional>
60

The size of the X axis. The units of the value depends on the model of the Chart instance and possibly on the parser configured on the Chart#setXAxis method. If not specified, then 60 will be used.

yPerc Number <optional>
20

A percentage that is used for the first positioning of the Y axis: the Y axis will have as initial maximum position a value that is yPerc% greater than the first Y position and as initial minimum position a value that is yPerc% smaller than it. If not specified, then 20 (meaning 20%) will be used.

Extends

Methods

onListenStart()

onNewLine(key, newChartLine, currentX, currentY)

Event handler that is called each time that, due to an update to the internal model of the Chart this instance is listening to, a new ChartLine is being generated and displayed. By implementing this method, it is possible to configure the appearance of the new line.
A new line can be generated only when a new row enters the model. Moreover, based on the configuration of Chart#addYAxis a new row in the model may generate more than one line resulting in this event being fired more than one time for a single update.

Parameters:
Name Type Description
key String

The key associated with the row that caused the line of this event to be generated (keys are described in AbstractWidget).

newChartLine ChartLine

The object representing the new line that has been generated.

currentX Number

The X-coordinate of the first point of the line of this event.

currentY Number

The Y-coordinate of the first point of the line of this event.

Overrides:

onRemovedLine(key, removedChartLine)

Event handler that is called each time that, due to an update to the internal model of the Chart this instance is listening to, one of the currently active ChartLine is being removed.

Parameters:
Name Type Description
key String

The key associated with the row that was removed causing this event to be fired (keys are described in AbstractWidget).

removedChartLine ChartLine

The object representing the line that has been removed.

Overrides:
See:

onXOverflow(key, lastX, xMin, xMax)

Event handler that is called when a new update has been received such that one or more points have to be added to the chart lines, but cannot be shown because their X-coordinate value is higher than the upper limit set for the X axis. By implementing this event handler, the chart axis can be repositioned through Chart#positionXAxis so that the new points can be shown on the chart.
Note that if a new update is received such that one or more points have to be added to the chart lines but cannot be shown because their X-coordinate value is lower than the lower limit set for the X axis, then this event handler is not called, but rather the new update is ignored. X axis limits should always be set in such a way as to avoid this case.

Parameters:
Name Type Description
key String

The key associated with the row that during its update made the overflow happen.

lastX Number

The X-coordinate value of the new points to be shown on the chart and that exceeds the current upper limit.

xMin Number

The current lower limit for the visible part of the X axis.

xMax Number

The current upper limit for the visible part of the X axis.

Overrides:

onYOverflow(key, toUpdateChartLine, lastY, yMin, yMax)

Event handler that is called when a new update has been received such that a new point for this line has to be added to the chart, but cannot be shown because its Y-coordinate value is higher than the upper limit set for the Y axis on this line, or lower than the lower limit. By implementing this event handler, the line can be repositioned through ChartLine#positionYAxis so that the new point can be shown on the chart.

Parameters:
Name Type Description
key String

The key associated with the row that during its update made the overflow happen.

toUpdateChartLine ChartLine

The object representing the line that made the overflow happen.

lastY Number

The Y-coordinate value of the new point to be shown on the chart and that exceeds the current upper or lower limit.

yMin Number

The current lower limit for the visible part of the Y axis.

yMax Number

The current upper limit for the visible part of the Y axis.

Overrides: