<html>
	<head>
		<title>Getting Series Custom Values</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;
			}
		
			//--------------------------------------------------------------------------------
			//		Show Functions
			//--------------------------------------------------------------------------------
			
			function showInfo(showCurrent) {
				
				// values are obtained using getSeriesCustomValue. returns object.
				var info1 = chart.getSeriesCustomValue("main", "series0", "ExtraParam1"); // get ExtraParam1
				var info2 = chart.getSeriesCustomValue("main", "series0", "ExtraParam2"); // get ExtraParam2
				var info3 = chart.getSeriesCustomValue("main", "series0", "ExtraParam3"); // get ExtraParam3
							
				// ExtraParam1
				document.getElementById("valCurrent1").innerHTML = (showCurrent && info1.current != undefined && !isNaN(info1.current)) ? formatNumber(info1.current) : "N/A"; // current value
				document.getElementById("valMin1").innerHTML = formatNumber(info1.min); // minimal value
				document.getElementById("valMinVisible1").innerHTML = formatNumber(info1.minVisible); // minmal visible value
				document.getElementById("valMax1").innerHTML = formatNumber(info1.max); // maximal value
				document.getElementById("valMaxVisible1").innerHTML = formatNumber(info1.maxVisible); // maximal visible value
				document.getElementById("valFirst1").innerHTML = formatNumber(info1.first); // first value
				document.getElementById("valFirstVisible1").innerHTML = formatNumber(info1.firstVisible); // first visible value
				document.getElementById("valLast1").innerHTML = formatNumber(info1.last); // last value
				document.getElementById("valLastVisible1").innerHTML = formatNumber(info1.lastVisible); // last visible value
				
				// ExtraParam2
				document.getElementById("valCurrent2").innerHTML = (showCurrent && info2.current != undefined && !isNaN(info2.current)) ? formatNumber(info2.current) : "N/A"; // current value
				document.getElementById("valMin2").innerHTML = formatNumber(info2.min); // minimal value
				document.getElementById("valMinVisible2").innerHTML = formatNumber(info2.minVisible); // minmal visible value
				document.getElementById("valMax2").innerHTML = formatNumber(info2.max); // maximal value
				document.getElementById("valMaxVisible2").innerHTML = formatNumber(info2.maxVisible); // maximal visible value
				document.getElementById("valFirst2").innerHTML = formatNumber(info2.first); // first value
				document.getElementById("valFirstVisible2").innerHTML = formatNumber(info2.firstVisible); // first visible value
				document.getElementById("valLast2").innerHTML = formatNumber(info2.last); // last value
				document.getElementById("valLastVisible2").innerHTML = formatNumber(info2.lastVisible); // last visible value
				
				// ExtraParam3
				document.getElementById("valCurrent3").innerHTML = (showCurrent && info3.current != undefined && !isNaN(info3.current)) ? formatNumber(info3.current) : "N/A"; // current value
				document.getElementById("valMin3").innerHTML = formatNumber(info3.min); // minimal value
				document.getElementById("valMinVisible3").innerHTML = formatNumber(info3.minVisible); // minmal visible value
				document.getElementById("valMax3").innerHTML = formatNumber(info3.max); // maximal value
				document.getElementById("valMaxVisible3").innerHTML = formatNumber(info3.maxVisible); // maximal visible value
				document.getElementById("valFirst3").innerHTML = formatNumber(info3.first); // first value
				document.getElementById("valFirstVisible3").innerHTML = formatNumber(info3.firstVisible); // first visible value
				document.getElementById("valLast3").innerHTML = formatNumber(info3.last); // last value
				document.getElementById("valLastVisible3").innerHTML = formatNumber(info3.lastVisible); // last visible value
			}
			
			//--------------------------------------------------------------------------------
			//		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>
		<!-- Chart Container -->
		<div id="chartContainer"></div>
		<table class="settings">
			<tr>
				<th width="200">On mouse over values</td>
				<th width="100">ExtraParam1</th>
				<th width="100">ExtraParam2</th>
				<th width="100">ExtraParam3</th>
			</tr>
			<tr>
				<td>Hovered Point:</td>
				<td id="valCurrent1"></td>
				<td id="valCurrent2"></td>
				<td id="valCurrent3"></td>
			</tr>
			<tr>
				<th colspan="4">Visible data range</td>
			</tr>
			<tr>
				<td>Min visible:</td>
				<td id="valMinVisible1"></td>
				<td id="valMinVisible2"></td>
				<td id="valMinVisible3"></td>
			</tr>
			<tr>
				<td>Max visible:</td>
				<td id="valMaxVisible1"></td>
				<td id="valMaxVisible2"></td>
				<td id="valMaxVisible3"></td>
			</tr>
			<tr>
				<td>First visible:</td>
				<td id="valFirstVisible1"></td>
				<td id="valFirstVisible2"></td>
				<td id="valFirstVisible3"></td>
			</tr>
			<tr>
				<td>Last visible:</td>
				<td id="valLastVisible1"></td>
				<td id="valLastVisible2"></td>
				<td id="valLastVisible3"></td>
			</tr>
			<tr>
				<th colspan="4">Full data range</th>
			</tr>
			<tr>
				<td>Min:</td>
				<td id="valMin1"></td>
				<td id="valMin2"></td>
				<td id="valMin3"></td>
			</tr>
			<tr>
				<td>Max:</td>
				<td id="valMax1"></td>
				<td id="valMax2"></td>
				<td id="valMax3"></td>
			</tr>
			<tr>
				<td>First:</td>
				<td id="valFirst1"></td>
				<td id="valFirst2"></td>
				<td id="valFirst3"></td>
			</tr>
			<tr>
				<td>Last:</td>
				<td id="valLast1"></td>
				<td id="valLast2"></td>
				<td id="valLast3"></td>
			</tr>
		</table>
	</body>
</html>

Sample Description

How to use this sample?

Move the mouse over the chart to see ExtraParam1, ExtraParam2 and ExtraParam3 details shown in the table below the chart.

to top

How it works

Any series shown on the chart is based on the data set, the nature of the last is described in Understanding Data Model and Data Sets Configuration. Data set may contain a lot of columns, and these columns may contain any additional values could be not shown on the chart, but they can be shown in legend, tooltips or obtained via JavaScript API.

This sample shows how to obtain these values via JavaScript API. onChartMouseMove, onChartMouseOut, onChartMouseOver, onChartDraw are handled and getSeriesCustomValue is used to obtain the value of the custom field.

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
getSeriesCustomValue Method Gets information about custom 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.