<html>
	<head>
		<title>Progress/Status Messages Customization</title>
		<meta http-equiv="content-type" content="text/html;charset=utf-8"/>	
		<!-- jQuery is used to work with DOM -->
		<script type="text/javascript" src="js/jquery.min.js"></script>
		
		<script type="text/javascript" language="javascript" src="./../js/AnyChartStock.js?v=1.9.0r9317"></script>
		<!-- chart size -->
		<style type="text/css">
			#chartContainer {
				float: left;
				width: 600px;
				height: 400px;
			}
		</style>
		<script type="text/javascript" language="javascript">
			AnyChartStock.swfFile = "./../swf/AnyChartStock.swf?v=1.9.0r9317";
			AnyChartStock.preloaderSWFFile = "./../swf/Preloader.swf?v=1.9.0r9317";
		
			// Creating new chart object. 
			var chart = new AnyChartStock();
			// Setting XML config file.
			chart.setXMLFile("config.xml");
			
			// Writing the flash object into the page DOM.
			chart.write("chartContainer");
			
			// Shows default messages in text inputs.
			// This function is called in <body onload="showMessages()">
			function showMessages() {
				$("#preloaderInit").val(chart.messages.preloaderInit);
				$("#preloaderLoading").val(chart.messages.preloaderLoading);
				$("#init").val(chart.messages.init);
				$("#loadingSettings").val(chart.messages.loadingSettings);
				$("#loadingData").val(chart.messages.loadingData);
				$("#waitingForData").val(chart.messages.waitingForData);
			}
			
			// Sets new messages from text inputs values.
			// Launched in <input type="button" value="Reload" ...
			function applyMessagesChanges() {
			
				// Adding timestamp to swfFile to avoid caching of swf file
				chart.swfFile = AnyChartStock.swfFile+"?tmp="+new Date().getTime();
				// Adding timestamp to preloaderSWFFile timestamp to avoid caching of the swf file
				chart.preloaderSWFFile = AnyChartStock.preloaderSWFFile+"?tmp="+new Date().getTime();
				// Removing chart from the page
				chart.removeFlashObject();
				/* 
					NOTE: we've done it only for demo purposes - to make full reloading 
					and allow you to see custom messages
				*/
				
				// Preloader.swf messages
				chart.messages.preloaderInit = $("#preloaderInit").val();
				chart.messages.preloaderLoading = $("#preloaderLoading").val();
				
				if ($("#enableMessages").is(":checked")) {// Checking if all messages should be hidden
					chart.enablePreloader = true; // Enabling messages
					// Setting new messages
					chart.messages.init = $("#init").val();
					chart.messages.loadingSettings = $("#loadingSettings").val();
					chart.messages.loadingData = $("#loadingData").val();
					chart.messages.waitingForData = $("#waitingForData").val();
				}else {
					chart.enablePreloader = false; // Disabling messages
				}
				
				// Writing chart again into the <div> node with "chartContainer" id.
				chart.write("chartContainer");
			}
			
			// Updating messages input fields states
			function onEnableMessagesChange() {
				if ($("#enableMessages").is(":checked")) {
					$("#init").removeAttr("disabled");
					$("#loadingSettings").removeAttr("disabled");
					$("#loadingData").removeAttr("disabled");
					$("#waitingForData").removeAttr("disabled");
				}else {
					$("#init").attr("disabled","disabled");
					$("#loadingSettings").attr("disabled","disabled");
					$("#loadingData").attr("disabled","disabled");
					$("#waitingForData").attr("disabled","disabled");
				}
			}
			
			//---------------------------------------------------------------------------------------------------
			//		html events binding
			//---------------------------------------------------------------------------------------------------
			
			$(function() {
				$("#enableMessages").change(onEnableMessagesChange);
			});
		</script>
		<!-- table 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;	
			}
			
			table.settings input {
				width: 250px;
			}
			
			table.settings input.checkbox {
				width: auto;
			}
		</style>
	</head>
	<body onload="showMessages()">
		<div id="chartContainer"><!-- Chart Container --></div>
		<table class="settings">
			<tr>
				<th colspan="2">Show messages</th>
			</tr>
			<tr>
				<td>Show messages:</td>
				<td><input id="enableMessages" class="checkbox" type="checkbox" checked="true"/></td>
			</tr>
			<tr>
				<th>Message:</th>
				<th width="250">Text:</th>
			</tr>
			<tr>
				<td>preloaderInit:</td>
				<td><input type="text" id="preloaderInit"/></td>
			</tr>
			<tr>
				<td>preloaderLoading:</td>
				<td><input type="text" id="preloaderLoading"/></td>
			</tr>
			<tr>
				<td>loadingSettings:</td>
				<td><input type="text" id="loadingSettings"/></td>
			</tr>
			<tr>
				<td>loadingData:</td>
				<td><input type="text" id="loadingData"/></td>
			</tr>
			<tr>
				<td>init:</td>
				<td><input type="text" id="init"/></td>
			</tr>
			<tr>
				<td>waitingForData:</td>
				<td><input type="text" id="waitingForData"/></td>
			</tr>
			<tr>
				<td>Reload chart</td>
				<td><input type="button" value="Reload" style="width:auto" onclick="applyMessagesChanges()" /></td>
			</tr>
		</table>
	</body>
</html>

Sample Description

How to use this sample?

Type any custom text for any message into the textfields, hit reload and chart would show them, instead of default messages if "Show messages" checkbox is checked.

to top

How it works

When chart is in process of loading, parsing data or expecting data it shows text messages, that helps chart viewer to undertstand that something is happening and he should either wait or perform some action. These messages can be customized for localization or better undertstanding purposes.

Customizing the messages is just setting one or several fields of the messages property, fields names are pretty self-descriptive and they all are shown in the sample and JS Reference. Also you can hide all messages using enablePreloader property.

to top

AnyChartStock JavaScript API

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

Item Type Description
AnyChartStock.preloaderSWFFile Static property (String) Default path to Preloader.swf file for all charts on the page.
AnyChartStock.swfFile Static property (String) Default path to AnyChartStock.swf file for all charts on the page.
enablePreloader Property (Boolean) Turns component messages about configuration and data loading on or off.
messages Property (Object) Holds the table with auxiliary chart texts.
preloaderSWFFile Property (String) Path to Preloader.swf file.
swfFile Property (String) Path to AnyChartStock swf file.
removeFlashObject Method Removes AnyChart Stock Flash Object from HTML DOM.
setXMLFile Method Sets chart XML configuration file path.
write Method Adds the chart to HTML DOM as a child of the specified container.

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

  • 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.