ChartCanvasSerie.getPointByPosition

Syntax

getPointByPosition(index: Number);

Parameters

index. Item position in X axis.

Description

The getPointByPosition method returns an item of the chart data series by its position in X axis.

Comments

The method returns value of the PP.Ui.ChartPoint type.

If there is no item in the specified position, the method returns null.

Example

To execute the example, the HTML page must contain the Chart component named chart (see Example of Creating a Histogram). Get item of chart data series by its position, show item value and hide the data series:

var serieNumber = 0;
// Get data series
var serie = chart.getSeries()[serieNumber];
// Get series data for the X axis
var xData = serie.getXData();
// Get item position in the X axis 
var xPosition = xData[xData.length - 1];
// Get data series item by position in the X axis
var point = serie.getPointByPosition(xPosition);
// Get series data for the Y axis
var yData = serie.getYData();
// Show value for the obtained data series item
var pointNumber = point.getIndex();
console.log("Series: " + serieNumber + " item: " + pointNumber + " value: " + yData[pointNumber]);
// Hide the data series
serie.setIsVisible(false, true);

After executing the example one of the chart data series is hidden:

The browser console displays value of one of the chart series items:

Series: 0 item: 4 value: -30

See also:

ChartCanvasSerie