title: Using Delphi TChart to display information from a database
body: <p>I want to create a pie chart in Delphi that will show the user the number of people who play a specific sport. </p>
  
  <p>The following SQL statements gets the information from the database and stores the number of people in a variable. The data type in the database is yes/no, so those who play a specific sport will have a tick and those who don't won't. The sql statement will determine how many people play a specific sport (if there is a tick in the database)</p>
  
  <pre><code>qry.sql.clear;
  qry.sql.add('SELECT Count(tennis) AS [NoTennis] FROM [Sports] WHERE Tennis = True');
  qry.Open;
  iTennis := qry['NoTennis'];   {integer variable}
  </code></pre>
  
  <p>This repeats for all the other sports, such as swimming, hockey, etc</p>
  
  <p>Afterwards this data must be represented in the pie chart. I have the following code...</p>
  
  <pre><code>Chart1.Series[0].AddXY(iTennis, 1, 'Tennis', clTeeColor);
  </code></pre>
  
  <p>This also obviously repeats for all the other sports. But instead of displaying my data during run time, it still displays random data about keyboards and motorists, etc. To see what I am talking about click <a href="https://i.stack.imgur.com/8cf3K.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8cf3K.gif" alt="here"></a><br>
  <sub>(source: <a href="https://www.asiplease.net/computing/delphi/images/chart_pie2.gif" rel="nofollow noreferrer">asiplease.net</a>)</sub>  </p>
  
  <p>How do I get TChart to change it's data? Is it the SQL statement or adding the x and y values that is causing the problem?</p>