<html>
	<head>
		<title>Getting information from Candlestick and OHLC series</title>
		<meta http-equiv="content-type" content="text/html;charset=utf-8"/>	
		<script type="text/javascript" language="javascript" src="./../js/AnyChartStock.js?v=1.9.0r9317"></script>
		<!-- chart size settings -->
		<style type="text/css">
			#chartContainer {
				width: 800px;
				height: 400px;
			}
		</style>
		<script type="text/javascript" language="javascript">
			// Creating new chart object. 
			var chart = new AnyChartStock("./../swf/AnyChartStock.swf?v=1.9.0r9317", "./../swf/Preloader.swf?v=1.9.0r9317");
			// Setting XML config file.
			chart.setXMLFile("config.xml");
			// Writing the flash object into the page DOM.
			chart.write("chartContainer");
			
			//--------------------------------------------------------------------------------
			//		Auxiliary Functions
			//--------------------------------------------------------------------------------
			
			// Rounding
			function formatNumber(val) {
				return Math.round(val*100)/100;
			}
			
			//--------------------------------------------------------------------------------
			//		HTML Formatting
			//--------------------------------------------------------------------------------
			
			/*
				Open Price Value show Function
			 */
			function showOpenValues(showCurrent) {
				// values are obtained using getSeriesOpenValue method. returns object.
				var info = chart.getSeriesOpenValue("main", "idSeriesA");
				
				document.getElementById("valCurrentOpen").innerHTML = (showCurrent && info.current != undefined && !isNaN(info.current)) ? formatNumber(info.current) : "N/A"; // current open value
				document.getElementById("valMinOpen").innerHTML = formatNumber(info.min); // minimal open in range
				document.getElementById("valMinVisibleOpen").innerHTML = formatNumber(info.minVisible); // minimal open in visible range
				document.getElementById("valMaxOpen").innerHTML = formatNumber(info.max);  // maximal open in whole range
				document.getElementById("valMaxVisibleOpen").innerHTML = formatNumber(info.maxVisible); // maximal open in visible range
				document.getElementById("valFirstOpen").innerHTML = formatNumber(info.first); // first point open value
				document.getElementById("valFirstVisibleOpen").innerHTML = formatNumber(info.firstVisible); // first visible point open value
				document.getElementById("valLastOpen").innerHTML = formatNumber(info.last); // last point open value
				document.getElementById("valLastVisibleOpen").innerHTML = formatNumber(info.lastVisible); // last visible open value
			}
			
			/*
				Close Price show Function
			 */
			function showCloseValues(showCurrent) {
				// values are obtained using getSeriesCloseValue method. returns object.
				var info = chart.getSeriesCloseValue("main", "idSeriesA");
				
				document.getElementById("valCurrentClose").innerHTML = (showCurrent && info.current != undefined && !isNaN(info.current)) ? formatNumber(info.current) : "N/A"; // current Close value
				document.getElementById("valMinClose").innerHTML = formatNumber(info.min); // minimal close in range
				document.getElementById("valMinVisibleClose").innerHTML = formatNumber(info.minVisible); // minimal close in visible range
				document.getElementById("valMaxClose").innerHTML = formatNumber(info.max);  // maximal close in range
				document.getElementById("valMaxVisibleClose").innerHTML = formatNumber(info.maxVisible); // maximal close in visible range
				document.getElementById("valFirstClose").innerHTML = formatNumber(info.first); // first point close
				document.getElementById("valFirstVisibleClose").innerHTML = formatNumber(info.firstVisible); // first visible point close value
				document.getElementById("valLastClose").innerHTML = formatNumber(info.last); // last point close value
				document.getElementById("valLastVisibleClose").innerHTML = formatNumber(info.lastVisible); // last visible point close value
			}
			
			/*
				High Price show Function
			 */
			function showHighValues(showCurrent) {
				// values are obtained using getSeriesHighValue method. returns object.
				var info = chart.getSeriesHighValue("main", "idSeriesA");
				
				document.getElementById("valCurrentHigh").innerHTML = (showCurrent && info.current != undefined && !isNaN(info.current)) ? formatNumber(info.current) : "N/A"; // current High
				document.getElementById("valMinHigh").innerHTML = formatNumber(info.min); // минимальное значение High на всем промежутке
				document.getElementById("valMinVisibleHigh").innerHTML = formatNumber(info.minVisible); // минимальное значение High на видимом промежутке 
				document.getElementById("valMaxHigh").innerHTML = formatNumber(info.max);  // максимальное значение High на всем промежутке
				document.getElementById("valMaxVisibleHigh").innerHTML = formatNumber(info.maxVisible); // макисимальное значение High на видимом промежутке
				document.getElementById("valFirstHigh").innerHTML = formatNumber(info.first); // значение High у первой точки
				document.getElementById("valFirstVisibleHigh").innerHTML = formatNumber(info.firstVisible); // значение High у первой видимой точки
				document.getElementById("valLastHigh").innerHTML = formatNumber(info.last); // значение High у последней точки
				document.getElementById("valLastVisibleHigh").innerHTML = formatNumber(info.lastVisible); // значение High у последней видимой точки
			}
			
			/*
				Low Price show Function
			 */
			function showLowValues(showCurrent) {
				// values are obtained using getSeriesLowValue method. returns object.
				var info = chart.getSeriesLowValue("main", "idSeriesA");
				
				document.getElementById("valCurrentLow").innerHTML = (showCurrent && info.current != undefined && !isNaN(info.current)) ? formatNumber(info.current) : "N/A"; // current Low value
				document.getElementById("valMinLow").innerHTML = formatNumber(info.min); // minimal Low in range
				document.getElementById("valMinVisibleLow").innerHTML = formatNumber(info.minVisible); // minimal Low in visible range
				document.getElementById("valMaxLow").innerHTML = formatNumber(info.max);  // maximal Low in range
				document.getElementById("valMaxVisibleLow").innerHTML = formatNumber(info.maxVisible); // maximal Low in visible range
				document.getElementById("valFirstLow").innerHTML = formatNumber(info.first); // first point Low value
				document.getElementById("valFirstVisibleLow").innerHTML = formatNumber(info.firstVisible); // first visible point Low value
				document.getElementById("valLastLow").innerHTML = formatNumber(info.last); // last point in range Low value
				document.getElementById("valLastVisibleLow").innerHTML = formatNumber(info.lastVisible); // last visible range point Low
			}
			
			/* 
				Show data function
				
				showCurrent - show current info or no
			 */
			function showInfo(showCurrent) {
				showOpenValues(showCurrent);
				showCloseValues(showCurrent);
				showHighValues(showCurrent);
				showLowValues(showCurrent);
			}
			
			//--------------------------------------------------------------------------------
			//		Events handling
			//--------------------------------------------------------------------------------
			
			// onChartDraw event handler
			chart.onChartDraw = function() {
				showInfo(false);
			};
			
			// onSelectedRangeChange event handler
			chart.onSelectedRangeChange = function() {
				showInfo(false);
			};
			
			// onChartMouseOver event handler
			chart.onChartMouseOver = function() {
				showInfo(true);
			};
			
			// onChartMouseOut event handler
			chart.onChartMouseOut = function() {
				showInfo(false);
			};
			
			// onChartMouseMove event handler
			chart.onChartMouseMove = function() {
				showInfo(true);
			};
		</script>
		
		<!-- style settings -->
		<style type="text/css">
			table.settings  {
				border-style: solid;
				border-width: 1px;
				border-color: #D0CDC9;
			}

			table.settings tr th {
				font:normal 60% Verdana;
				background-color: #DCD9D5;
				font-weight:bold;
				padding-bottom:5px;
				padding-top:5px;
				padding-left:10px;
				text-align:left;
			}
			table.settings tr td {
				background-color: #F8F4F0;
				font:normal 70% Verdana;
				padding-bottom:2px;
				padding-top:2px;
				padding-left:10px;
				text-align:left;	
			}
		</style>
	</head>
	<body>
		<div id="chartContainer"><!-- Chart Container --></div>
		<table class="settings">
			<tr>
				<th width="200">On mouse over values</td>
				<th width="100">Open</th>
				<th width="100">High</th>
				<th width="100">Low</th>
				<th width="100">Close</th>
			</tr>
			<tr>
				<td>Hovered Point:</td>
				<td id="valCurrentOpen"></td>
				<td id="valCurrentHigh"></td>
				<td id="valCurrentLow"></td>
				<td id="valCurrentClose"></td>
			</tr>
			<tr>
				<th>Visible data range</th>
				<th>Open</th>
				<th>High</th>
				<th>Low</th>
				<th>Close</th>
			</tr>
			<tr>
				<td>Min visible:</td>
				<td id="valMinVisibleOpen"></td>
				<td id="valMinVisibleHigh"></td>
				<td id="valMinVisibleLow"></td>
				<td id="valMinVisibleClose"></td>
			</tr>
			<tr>
				<td>Max visible:</td>
				<td id="valMaxVisibleOpen"></td>
				<td id="valMaxVisibleHigh"></td>
				<td id="valMaxVisibleLow"></td>
				<td id="valMaxVisibleClose"></td>
			</tr>
			<tr>
				<td>First visible:</td>
				<td id="valFirstVisibleOpen"></td>
				<td id="valFirstVisibleHigh"></td>
				<td id="valFirstVisibleLow"></td>
				<td id="valFirstVisibleClose"></td>
			</tr>
			<tr>
				<td>Last visible:</td>
				<td id="valLastVisibleOpen"></td>
				<td id="valLastVisibleHigh"></td>
				<td id="valLastVisibleLow"></td>
				<td id="valLastVisibleClose"></td>
			</tr>
			<tr>
				<th>Full range info</th>
				<th>Open</th>
				<th>High</th>
				<th>Low</th>
				<th>Close</th>
			</tr>
			<tr>
				<td>Min:</td>
				<td id="valMinOpen"></td>
				<td id="valMinHigh"></td>
				<td id="valMinLow"></td>
				<td id="valMinClose"></td>
			</tr>
			<tr>
				<td>Max:</td>
				<td id="valMaxOpen"></td>
				<td id="valMaxHigh"></td>
				<td id="valMaxLow"></td>
				<td id="valMaxClose"></td>
			</tr>
			<tr>
				<td>First:</td>
				<td id="valFirstOpen"></td>
				<td id="valFirstHigh"></td>
				<td id="valFirstLow"></td>
				<td id="valFirstClose"></td>
			</tr>
			<tr>
				<td>Last:</td>
				<td id="valLastOpen"></td>
				<td id="valLastHigh"></td>
				<td id="valLastLow"></td>
				<td id="valLastClose"></td>
			</tr>
			
		</table>
	</body>
</html>

Sample Description

How to use this sample?

Hover points and/or change selected range using any method and see values details in the table below the chart.

to top

How it works

This sample handles onChartMouseMove, onChartMouseOut, onChartMouseOver, onChartDraw and onSelectedRangeChange events and invokes getSeriesOpenValue, getSeriesCloseValue, getSeriesHighValue and getSeriesLowValue method to obtain values details.

These methods are intened to obtain values from four values series - Candlestick or OHLC.

To understand everything about obtaining actual chart data refer to Obtaining Actual Chart Information article.

to top

AnyChartStock JavaScript API

This sample uses the following methods, properties and events from AnyChartStock JavaScript API:

Item Type Description
getSeriesCloseValue Method Gets info about "close" field of the series.
getSeriesHighValue Method Gets info about "high" field of the series.
getSeriesLowValue Method Gets info about "low" field of the series.
getSeriesOpenValue Method Gets info about "open" field of the series.
setXMLFile Method Sets chart XML configuration file path.
write Method Adds the chart to HTML DOM as a child of the specified container.
onChartDraw Event This event is dispatched when the AnyChart Stock is drawn.
onChartMouseMove Event This event is dispatched when the mouse is moving over the chart plotting area.
onChartMouseOut Event This event is dispatched when the mouse leaves the chart plotting area.
onChartMouseOver Event This event is dispatched when the chart plotting area is hovered by the mouse.
onSelectedRangeChange Event This event is dispatched when the selected range of the chart is changed.

to top

Prerequisites

This section lists all configuration, data and auxiliary files required for this sample.

Configuration file

CSV files

SWF files

  • AnyChartStock.swf - AnyChart Stock component.
  • Preloader.swf - AnyChart Stock helper component that loads the main component (AnyChartStock.swf) and displays loading progress.

JavaScript Libraries

  • AnyChartStock.js - A JavaScript library that is shipped with AnyChart Stock component. It is used to embed the component into HTML DOM and to comunicate with the Flash part.

to top

The information contained in this website is for general information purposes only. All sample data provided on this site is for demonstration purposes only.

The logos and names of other companies and products mentioned on this site are copyright and/or trademarks of their respective owners.

The content on this site, including news, quotes, data and other information, is provided for your personal information only, and is intended for demonstration purposes only. Content on this site is not appropriate for the purposes of making a decision to carry out a transaction or trade. Nor does it provide any form of advice (investment, tax, legal) amounting to investment advice, or make any recommendations regarding particular financial instruments, investments or products.

In no event AnyChart will be liable for any loss or damage including without limitation, indirect or consequential loss or damage, or any loss or damage whatsoever arising from loss of data or profits arising out of, or in connection with, the use of this website.

This site may point to other Internet sites that may be of interest to you, however AnyChart does not endorse or take responsibility for the content on such other sites

Market data and News provided by and copyright RediNews, Incorporated.