Back to amCharts.com

Understanding data sets

Unlike other charts, Stock Chart can support multiple data sets. To understand how multiple data sets work, check this example. There is a dropdown box in the top right corner, called "Select". If you click this box, you will get the list of companies whose stock information can be displayed on the chart. Each company is a separate data set, and the data is loaded only when the viewer selects the company. We'll refer to the currently selected data set as "main".

Stock Chart allows you to not only select the data set, but compare the main data set with others. Under the dropdown box is a "Compare to" list box with the same companies. You can select one or more companies, and the chart will load the data and display the comparison graph.

Notice that the companies (data sets) selected for "comparing" have less rights than the "main" data set. Even if the data set selected for comparing has data for a longer period or has data for the dates that are not available in the main data set, this extra data will not be displayed. Only the data for the same dates will be shown on the chart.

The comparing graph can only be a line graph.

Multiple data sets in the settings file

If you check the settings file of the example mentioned above, you will understand how multiple data sets must be described in the data file:

<settings>
   <data_sets>
      <!-- 1st data set -->
      <data_set>
         <!-- all the 1st data set settings go here -->
      </data_set> 

      <!-- 2nd data set -->
      <data_set>
         <!-- all the 2nd data set settings go here -->
      </data_set> 

      <!-- 3rd data set -->
      <data_set>
         <!-- all the 3rd data set settings go here -->
      </data_set>
   </data_sets>
</settings>

As you see, you can simply copy the <data_set> section as many times as you need, and then modify the settings that are different.

Defining the "main" data set

The "main" data set is the one that is selected in the "select" dropdown. By default, when the chart is loaded the first data set from your settings file is main.

To set a particular data set as "main" when the chart is loaded, you should set selected="true" in the following setting of the data set:

<main_drop_down selected="true">true</main_drop_down>

Defining which data sets must be selected for comparing

By default, when the chart is loaded none of the data sets will be selected for comparing.

To set a particular data set to be selected for comparing (when the chart is loaded), you should set selected="true" for the following setting of the data set:

<compare_list_box selected="true">true</compare_list_box>

Important

  • You can turn off the data set selector (both the dropdown and list box will become invisible) and select / unselect data sets using JavaScript functions. The data set selector can be turned off using this setting:
<data_set_selector>
   <enabled>false</enabled>
Back to top