<html>
	<head>
		<title>setConfig with JSON</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({
				data: {
					dataSets: [ {
							id: "dataSet1",
							sourceUrl: "./csv/csco_daily.csv",
							csvSettings: {
								ignoreFirstRow: true,
								rowsSeparator: "\n",
								columnsSeparator: ","
							},
							locale: {
								dateTime: {
									format: "%yyyy%MM%dd"
								}
							}
						}
					],
					dataProviders: {
						generalDataProviders: [ {
								dataSet: "dataSet1",
								id: "dp1",
								fields: [ {
										type: "Close",
										column: 1,
										approximationType: "Close"
									}
								]
							}
						],
						scrollerDataProviders: [ {
								dataSet: "dataSet1",
								column: 1
							}
						]
					}
				},
				settings: {
					outsideMargin: {
						all: 1
					},
					insideMargin: {
						all: 0,
						right: 30
					},
					timeScale: {
						isOrdinal: true,
						maxTicksCount: 20,
						selectedRange: {
							type: "Custom",
							startDate: "2004-01-01 00:00:00.000"
						}
					},
					dataGrouping: {
						enabled: true,
						maxVisiblePoints: 720
					},
					rangeSelector: {
						enabled: true
					},
					charts: [ {
							seriesList: [ {
									type: "Line",
									name: "CSCO",
									lineSeries: {
										thickness: 2
									},
									dataProvider: "dp1",
									color: "#253992"
								}
							],
							xAxis: {
								majorGrid: {
									line: {
										opacity: 1,
										color: "#D9D9D9"
									}
								},
								minorGrid: {
									line: {
										dashed: true,
										dashLength: 3,
										dashSpace: 3,
										pixelHinting: true
									}
								}
							},
							technicalIndicators: [ {
									type: "SMA",
									dataProvider: "dp1",
									smaIndicator: {
										period: 20,
										series: {
											type: "Spline",
											color: "#DB2A0E",
											name: "SMA(20)"
										}
									}
								},
								{
									type: "SMA",
									dataProvider: "dp1",
									smaIndicator: {
										period: 50,
										series: {
											type: "Spline",
											color: "#0066DD",
											name: "SMA(50)"
										}
									}
								}
							],
							legend: {
								dateTime: {
									enabled: false
								}
							},
							valueAxes: {
								primary: {
									position: "Right",
									labels: {
										valign: "Center",
										format: "{%Value}{numDecimals:2,trailingZeros:false}",
										padding: 3,
										font: {
											bold: true,
											size: 9,
											family: "Verdana",
											color: "#444444"
										},
										showFirst: true,
										showLast: true,
										position: "Outside"
									},
									scale: {
										minimumOffset: 0
									},
									grid: {
										line: {
											dashed: true,
											dashLength: 3,
											dashSpace: 3,
											pixelHinting: true
										}
									},
									tickmarks: {
										pixelHinting: true,
										enabled: true,
										color: "#333333",
										thickness: 1,
										showFirst: true,
										size: 3,
										showLast: true
									}
								}
							}
						}
					]
				}
			});
			// 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 JS Object with settings, 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 JS Object using setConfig method.

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

Note: JS object is a part of JavaScript code within the page 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.