<title>Using  Event Markers Custom Attributes</title>
		<meta http-equiv="content-type" content="text/html;charset=utf-8"/>	
			This sample uses jquery library to work with DOM 
		<script type="text/javascript" language="javascript" src="./js/jquery.min.js"></script>
		<script type="text/javascript" language="javascript" src="./../js/AnyChartStock.js?v=1.9.0r9317"></script>
		<style type="text/css">
			html, body {
				background-color: white;
			/* chart size */
			#chartContainer {
				width: 800px;
				height: 500px;
			/* other settings */
			table.settings {
				border-style: solid;
				border-width: 1px;
				border-color: #D0CDC9;

			table.settings tr th {
				font:normal 60% Verdana;
				background-color: #DCD9D5;
			table.settings tr td {
				background-color: #ffffff;
				font:normal 70% Verdana;
			/* Event table list settings */
			/* firefox outline fix */
			* {
				outline: none;
			#info {
				width: 400px;
				height: 490px;
				overflow-y: scroll;
				padding-top: 10px;
				background-color: white;
			.event {
				width: 354px;
				height: 50px;
				border: 1px solid #d2d2d2;
				padding: 10px;
				margin-bottom: 5px;
			#info td {
				background: none;
				padding: 0px;
				margin: 0px;
			.event .icon {
				width: 37px;
			.event .icon p {
				width: 27px;
				height: 26px;
				padding: 0;
				margin: 0;
				background-image: url(letters_strip.png);
				background-repeat: no-repeat;
			.event .iconSelected {
				background-position: 0px 0px;
			.event .iconNormal {
				background-position: 0px -29px;
			.event .title a, .event .title a:visited {
				color: #1e399d;
				font: 8pt Verdana;
			a {
				text-decoration: none;
			.event .date a, .date .event a:visited {
				color: #595959;
			.event .date a:hover, .event .title a:hover {
				text-decoration: underline;
			.event .date {
				padding-top: 5px !important;
				font: 8pt Verdana;
		<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");
			// needConfig allows to use chart object model, which is needed to get information about event markers
			chart.needConfig = true;
			// Setting XML config file.
			//		Auxiliary Date Time Functions 
			var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
			// Function to format date according to "%MMM %dd, %yyyy" mask. (e.g. 15 May, 2010)
			function formatDate(date) {
				return months[date.getUTCMonth()] + " "+date.getUTCDate()+", "+date.getUTCFullYear();
			///		Showing list of event markers visible range
			function updateVisibleEventMarkers(start, end) {

				// Get all event markers from zero indexed group
				var eventMarkers = chart.objectModel.eventMarkers.groups[0].events;
				// show them
				for (var i = eventMarkers.length-1; i>=0 ;i--) {
					// get link to event marker info
					var eventMarker = eventMarkers[i];
					var date = eventMarker.date.getTime(); // get event marker date
					if (date < start || date > end) continue; // if event marker date is out of visible range - don't show it
					// create list element
					var htmlCode = "<div class=\"event\" id=\"e_"+eventMarker.id+"\">" // event markers id
+"						<table cellspacing=\"0\" cellpadding=\"0\">"
+"							<tr valign=\"top\">"
+"								<td class=\"icon\"><a href=\"#\"><p class=\"iconNormal\">&nbsp;</p></a></td>"
+"								<td class=\"title\"><a href=\""+eventMarker.attributes.Link + "\" target=\"_blank\">"+eventMarker.attributes.Title+"</a></td>" // title attribute (see config.xml)
+"							</tr>"
+"							<tr>"
+"								<td>&nbsp;</td>"
+"								<td class=\"date\"><a href=\"http://oracle.com\" target=\"_blank\">www.oracle.com</a> - "+formatDate(eventMarker.date)+"</td>" //link attribute (see config.xml) and date
+"							</tr>"
+"						</table>"
+"					</div>";

					// and add it into <div id="info"/>
					// get link to this div (it contains event marker info)
					var e = $("#e_"+eventMarker.id);
					// set letter (A-Z)
					e.find(".icon p").css("backgroundPosition","-"+(30*(i%26))+"px -29px");
			//		Events handling
			chart.onSelectedRangeChange = function(startDate, endDate, phase) {
				if (phase == "finish")
					updateVisibleEventMarkers(startDate.getTime(), endDate.getTime());

			chart.onChartDraw = function() {
				updateVisibleEventMarkers(chart.getFirstVisibleDate().getTime(), chart.getLastVisibleDate().getTime());
				chart.onChartDraw = null;
			// Writing the flash object into the page DOM.
			<tr valign="top">
					<table class="settings">
							<th>Historical Prices for Oracle Corporation</th>
							<td id="chartContainer"><!-- Chart Container --></td>
					<table class="settings">
							<th>Key Developments in selected date range</th>
							<td><div id="info"></div></td>

Sample Description

How to use this sample?

Use drag and scroll navigation on the chart to select some period - list to the right of the chart shows the list of event markers that are visible on the chart.

to top

How it works

In this sample when onChartDraw event happens chart object model in updateVisibleEventMarkers function is used to get information about event markers from the chart.

When the information is gathered onSelectedRangeChange event is listened and updateVisibleEventMarkers is called to maintain the correct list of visible event markers.

updateVisibleEventMarkers uses object model to loop through the list of event markers and compares their date to startDate and endDate values received in onSelectedRangeChange event.

You can read more about event markers in Event Markers section and about object model in Updating Chart using Object Model article.

to top

AnyChartStock JavaScript API

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

Item Type Description
needConfig Property (Boolean) Defines whether the access to full chart configuration object model is required.
objectModel Property (Object) Gets chart configuration as an Object.
getFirstVisibleDate Method Gets the first visible date.
getLastVisibleDate Method Gets the last visible date.
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.
onSelectedRangeChange Event This event is dispatched when the selected range of the chart is changed.

to top


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

  • jquery.min.js - A JavaScript jQuery library. Learn more at jQuery official site.
  • 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.

Additional Files

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.