<html>
	<head>
		<title>setConfig with XML string</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: 550px;
			}
		</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 chart configuration
			chart.setConfig("<stock xmlns=\"http://anychart.com/products/stock/schemas/1.0.0/schema.xsd\">"
			+"	<data>"
			+"		<data_sets>"
			+"			<data_set id=\"dataSetORCL\" source_url=\"./csv/orcl_daily.csv\">"
			+"				<csv_settings ignore_first_row=\"true\" rows_separator=\"\n\" columns_separator=\",\"/>"
			+"				<locale>"
			+"					<date_time>"
			+"						<format><![CDATA[%yyyy%MM%dd]]></format>"
			+"					</date_time>"
			+"				</locale>"
			+"			</data_set>"
			+"		</data_sets>"
			+"		<data_providers>"
			+"			<general_data_providers>"
			+"				<data_provider data_set=\"dataSetORCL\" id=\"dpORCL\">"
			+"					<fields>"
			+"						<field type=\"Open\" column=\"1\" approximation_type=\"Open\"/>"
			+"						<field type=\"High\" column=\"2\" approximation_type=\"High\"/>"
			+"						<field type=\"Low\" column=\"3\" approximation_type=\"Low\"/>"
			+"						<field type=\"Close\" column=\"4\" approximation_type=\"Close\"/>"
			+"						<field type=\"Volume\" column=\"5\" approximation_type=\"Sum\"/>"
			+"					</fields>"
			+"				</data_provider>"
			+"			</general_data_providers>"
			+"			<scroller_data_providers>"
			+"				<data_provider id=\"scrDp\" data_set=\"dataSetORCL\" column=\"4\"/>"
			+"			</scroller_data_providers>"
			+"		</data_providers>"
			+"	</data>"
			+"	<settings>"
			+"		<data_grouping enabled=\"true\" max_visible_points=\"700\"/>"
			+"		<inside_margin left=\"15\" top=\"8\" bottom=\"8\" right=\"55\"/>"
			+"		<outside_margin left=\"0\" top=\"0\" right=\"0\" bottom=\"0\"/>"
			+"		<charts>"
			+"			<chart id=\"main\" height=\"100\">"
			+"				<value_axes>"
			+"					<primary enabled=\"true\" position=\"Right\">"
			+"						<labels enabled=\"true\" position=\"Outside\" padding=\"5\" valign=\"Center\" show_first=\"true\" show_last=\"true\" positive_color=\"#167316\">"
			+"							<format><![CDATA[{%Value}{numDecimals:1}]]></format>"
			+"						</labels>"
			+"						<scale mode=\"Values\" type=\"Linear\" minimum_offset=\"0\"/>"
			+"						<zero_line enabled=\"true\" color=\"DarkRed\" opacity=\"0.3\"/>"
			+"						<tickmarks enabled=\"true\" inside=\"false\" outside=\"true\" size=\"3\" pixel_hinting=\"true\"/>"
			+"						<grid>"
			+"							<line dashed=\"true\" dash_length=\"3\" dash_space=\"3\" pixel_hinting=\"true\"/>"
			+"						</grid>"
			+"					</primary>"
			+"				</value_axes>"
			+"				<legend>"
			+"					<date_time enabled=\"false\"/>"
			+"					<labels falling_color=\"DarkRed\" rising_color=\"#005500\"/>"
			+"				</legend>"
			+"				<series_list>"
			+"					<series enabled=\"true\" id=\"orcl\" type=\"Line\" data_provider=\"dpORCL\" color=\"#3463B0\">"
			+"						<name><![CDATA[ORCL]]></name>"
			+"						<line_series thickness=\"2\"/>"
			+"					</series>"
			+"				</series_list>"
			+"				<series_settings_defaults>"
			+"					<line_series thickness=\"1\"/>"
			+"					<area_series>"
			+"						<fill opacity=\"0.45\" color=\"%Color\"/>"
			+"						<line thickness=\"1\" color=\"DarkColor(%Color)\"/>"
			+"					</area_series>"
			+"				</series_settings_defaults>"
			+"				<x_axis>"
			+"					<major_grid>"
			+"						<line opacity=\"1\" color=\"#CCCCCC\"/>"
			+"					</major_grid>"
			+"					<minor_grid>"
			+"						<line dashed=\"true\" dash_length=\"3\" dash_space=\"3\" pixel_hinting=\"true\"/>"
			+"					</minor_grid>"
			+"				</x_axis>"
			+"			</chart>"
			+"			<chart height=\"50\">"
			+"				<technical_indicators>"
			+"					<technical_indicator type=\"Volume\" data_provider=\"dpORCL\">"
			+"					</technical_indicator>"
			+"				</technical_indicators>"
			+"				<legend>"
			+"					<date_time enabled=\"false\"/>"
			+"					<title enabled=\"false\"/>"
			+"				</legend>"
			+"				<x_axis>"
			+"					<major_grid>"
			+"						<line opacity=\"1\" color=\"#CCCCCC\"/>"
			+"					</major_grid>"
			+"					<minor_grid>"
			+"						<line dashed=\"true\" dash_length=\"3\" dash_space=\"3\" pixel_hinting=\"true\"/>"
			+"					</minor_grid>"
			+"					<labels enabled=\"false\"/>"
			+"				</x_axis>"
			+"				<value_axes>"
			+"					<primary enabled=\"true\" position=\"Right\">"
			+"						<labels position=\"Outside\" padding=\"3\" valign=\"Center\" show_first=\"true\" show_last=\"true\">"
			+"							<format><![CDATA[{%Value}{scale:(1000)(1000)(1000)|( K)( M)( B),numDecimals:2,trailingZeros:false}]]></format>"
			+"						</labels>"
			+"						<scale mode=\"Values\" type=\"Linear\" minimum_offset=\"0\"/>"
			+"						<zero_line enabled=\"true\" color=\"DarkRed\" opacity=\"0.3\"/>"
			+"						<tickmarks enabled=\"true\" inside=\"false\" outside=\"true\" size=\"3\" pixel_hinting=\"true\"/>"
			+"						<grid>"
			+"							<line dashed=\"true\" dash_length=\"3\" dash_space=\"3\" pixel_hinting=\"true\"/>"
			+"						</grid>"
			+"					</primary>"
			+"				</value_axes>"
			+"			</chart>"
			+"		</charts>"
			+"		<range_selector enabled=\"true\"/>"
			+"		<time_scale is_ordinal=\"true\">"
			+"			<selected_range type=\"Custom\" start_date=\"2000-01-02\" end_date=\"2009-07-02\"/>"
			+"		</time_scale>"
			+"		<scroller data_provider=\"scrDp\"/>"
			+"	</settings>"
			+"</stock>");
			// Writing the flash object into the page DOM.
			chart.write("chartContainer");
		</script>
	</head>
	<body>
		<div id="chartContainer"><!-- Chart Container --></div>
	</body>
</html>

Sample Description

How to use this sample?

This sample shows the chart based on XML configuration string, showing the basic use of setConfig method.

to top

How it works

AnyChart Stock Component offers you a lot of ways to set chart configuration, difference between the ways and all available options are described in XML/JSON Configuration Options and Set Configuration as XML String or JS Object articles.

This sample shows how set configuration from XML string using setConfig method.

This method can be invoked either before or after the write method.

Note: XML string is stored as JS variable in the JavaScript and in this case you don't need any config files - it may be useful for some types of applications.

to top

AnyChartStock JavaScript API

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

Item Type Description
setConfig Method Updates chart configuration.
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.

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.