<title>Using Simple HTML Tooltips for Event Markers</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>
			This sample uses jquery library to work with DOM  
		<script type="text/javascript" language="javascript" src="./js/jquery.min.js"></script>
		<style type="text/css">
			/* chart size */
			#chartContainer {
				width: 800px;
				height: 400px;
			/* tooltip and other elements style */
			html,body {
			    padding: 0;
			    margin: 0;
			div#tooltip {
			  background-color: #FFFFFF;

			  border-style: solid;
			  border-width: 1px;
			  border-color: rgb(175,175,175);

			  padding: 0px;

			  width: 215px;
			  height: auto;

			  position: absolute;
			  display: none;

			  font-family: Arial;

			#tooltipHead {
			  background-color: #949494;
			  color: #FFFFFF;
			  font-weight: bold;
			  width: auto;
			  height: auto;
			  font-size: 11px;
			  line-height: 12px;
			  padding-left: 10px;
			  padding-top: 4px;
			  padding-right: 3px;
			  padding-bottom: 5px;

			#tooltipContent {
			  color: rgb(20,20,20);
			  font-size: 11px;
			  height: auto;
			  padding: 5px;
			  padding-left: 15px;

			#tooltipContent span {
			  font-size: 9px;
			  color: rgb(150, 150, 150);
			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: #F8F4F0;
				font:normal 70% 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");
			// Setting XML config file.
			// wmode is set to opaque to show HTML tooltip above the chart
			chart.wMode = "opaque";
			// Writing the flash object into the page DOM.
			//		Date time formatting
			var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
			// format datetime. Mask is %dd %MMMM %yyyy. e.g. 22 January 1987
			function formatDateTime(date) {
				return date.getUTCDate() + " " + monthNames[date.getUTCMonth()] + " " + date.getUTCFullYear();
			//		Tooltip
			function showTooltip(eventMarker) {
				// link to <div id="tooltip" />
				var tooltip = $("#tooltip");
				// tooltip header content
				$("#tooltipHead").html("Analyst Opinion Change<br />"+formatDateTime(eventMarker.date));

				// tooltip content
				var content = "<b><font color=\"";
				switch (eventMarker.customAttributes.action) { // color text depending on the action type (set in custom attributes)
					case "init": content += "Black\">Initiated"; break;
					case "up": content += "Green\">Upgrade"; break;
					case "down": content += "Red\">Downgrade";break;
				content += "</font></b> by "+eventMarker.customAttributes.researchFirm; // get researchFirm  from custom attributes
				if (eventMarker.customAttributes.action == "up" || eventMarker.customAttributes.action == "down") { // if action is up or down - add from and to from custom attributes
					content += "<br />";
					content += "from "+eventMarker.customAttributes.from+" to "+eventMarker.customAttributes.to;
				// tooltip position
				var offset = $(chart.target).offset(); // componenet offset
				// component offset added to event marker position
				var x = eventMarker.bounds.x + eventMarker.bounds.width + offset.left + 10; 
				var y = eventMarker.bounds.y + offset.top; 
				// set tooltip position 
				// and make it visible
			// hide tooltip
			function hideTooltip() {
			//		Events handling
			// eventMarkerMouseOver handler
			chart.onEventMarkerMouseOver = function(eventMarker) {
			// eventMarkerMoseOut handler
			chart.onEventMarkerMouseOut = function() {
		<table class="settings">
			<tr><th>Hover the event marker to see the details</th></tr>
			<tr><td id="chartContainer"><!-- Chart Container --></td></tr>
			HTML tooltip container goes below.
			It is added at the very bottom of the page to avoid Z-index issues.
		<div id="tooltip">
			<div id="tooltipHead">Head</div>
			<div id="tooltipContent">content</div>

Sample Description

How to use this sample?

Hover any event marker to see custom HTML tooltip with event information. All event information comes from config.xml. Click on merged event markers stack to expand it and see tooltip for each event marker.

to top

How it works

Besides defining internal event marker tooltips, you can create HTML-based tooltips using mouse events and some special AnyStock functions.

In this sample HTML-based tooltips are created and two event marker events are handled: onEventMarkerMouseOver and onEventMarkerMouseOut - the first one triggers creation of custom HTML tooltip and the second one hides it.

HTML tooltip itself is just a simple div element, that is dynamically populated with data, that is obtained from eventMarker object, that comes from onEventMarkerMouseOver event.

You can read more about custom event marker tooltips at: HTML Tooltips for Event Markers article.

to top

AnyChartStock JavaScript API

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

Item Type Description
target Property (DOM Object) Link to a chart container DOM object.
wMode Property (String) Sets the Window Mode property of the Flash movie for transparency, layering, and positioning in the browser.
setXMLFile Method Sets chart XML configuration file path.
write Method Adds the chart to HTML DOM as a child of the specified container.
onEventMarkerMouseOut Event This event is dispatched when the mouse leaves an event marker.
onEventMarkerMouseOver Event This event is dispatched when an event marker is hovered by the mouse.

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.

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.