<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Taimur Kashif</title>
    <description>The latest articles on Forem by Taimur Kashif (@taimurkashif).</description>
    <link>https://forem.com/taimurkashif</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F453624%2Ffe4686c4-2ed7-4da0-b9df-98d9e88979ec.png</url>
      <title>Forem: Taimur Kashif</title>
      <link>https://forem.com/taimurkashif</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/taimurkashif"/>
    <language>en</language>
    <item>
      <title>Introduction to OpenFEC Data Visualization with ChartJs</title>
      <dc:creator>Taimur Kashif</dc:creator>
      <pubDate>Sun, 16 Aug 2020 20:30:39 +0000</pubDate>
      <link>https://forem.com/bitproject/introduction-to-openfec-data-visualization-with-chartjs-4pmi</link>
      <guid>https://forem.com/bitproject/introduction-to-openfec-data-visualization-with-chartjs-4pmi</guid>
      <description>&lt;h2&gt;
  
  
  Purpose
&lt;/h2&gt;

&lt;p&gt;The importance of understanding the implications of being an informed voter is profound. The ability for citizens of a country to understand the financial spending of candidates running for office (at any level—presidential, state, or local) allows one to understand where a candidate's priorities lie. Observing and analyzing financial trends allows one to make predictions about who may win a particular election. A lot of the time, however, it’s easy to get lost in the numbers! &lt;/p&gt;

&lt;p&gt;Thus, being able to visualize this data helps in comparing and understanding the financial spending of candidates. However, how do you verify that the graphs you see online are indeed accurate? &lt;/p&gt;

&lt;p&gt;It’s a catch-22 situation! Either you receive accurate numbers (hard to analyze) or potentially biased graphs. In this tutorial, you’ll learn how to make the graph yourself, using the official financial data available at the OpenFEC API.&lt;/p&gt;

&lt;p&gt;For this tutorial, we’ll walk through how to make a bar graph visualizing various financial information (operating expenses, net receipts, fundraising disbursements, and individual contribution less refunds) for Democrats and Republicans as a whole, as well as specific candidates, for the 2016 presidential election.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Sign up for an OpenFEC API Key at &lt;a href="https://api.data.gov/signup/"&gt;https://api.data.gov/signup/&lt;/a&gt;. This is a government website with the most up-to-date financial information. You'll see a form like this:&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RSbjjJFY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/e6yrn3qvpl3i7fd54gyg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RSbjjJFY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/e6yrn3qvpl3i7fd54gyg.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Check your email for the API Key and save it&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KRlzy9HD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bmvlwj0v6cd25rsinygg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KRlzy9HD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bmvlwj0v6cd25rsinygg.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Download ChartJS &lt;a href="https://www.jsdelivr.com/package/npm/chart.js"&gt;here&lt;/a&gt;. This is done by clicking the download icon (fourth button on the right), which will download a zip file. Once the zip file is downloaded, extract it to the desired location where you will store all your project files.&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nZgD7U-X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2yw6hhxjy8f4zg7yzme1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nZgD7U-X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2yw6hhxjy8f4zg7yzme1.png" alt="Alt Text"&gt;&lt;/a&gt;   &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create one empty HTML file (call it &lt;code&gt;OpenFEC.html&lt;/code&gt;) and one empty JavaScript file (call it &lt;code&gt;OpenFEC.js&lt;/code&gt;) and save these files in the same location as the ChartJS files you downloaded in step 3.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Download a text editor (we like &lt;a href="https://www.sublimetext.com/3"&gt;Sublime&lt;/a&gt;) or an IDE (we prefer &lt;a href="http://brackets.io/"&gt;Brackets&lt;/a&gt; for any HTML/CSS/JavaScript project) if you don’t have one. You'll need one to code everything up!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;At any stage of this tutorial, right-click on the HTML file and open it with your favorite web browser to see the output!&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tROvYMPH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/p9v9raxjna9un38pwzzg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tROvYMPH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/p9v9raxjna9un38pwzzg.png" alt="Alt Text"&gt;&lt;/a&gt; &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Coding!
&lt;/h2&gt;

&lt;p&gt;Now that you have the ChartJS dependency and the HTML (&lt;code&gt;OpenFEC.html&lt;/code&gt;) and JavaScript (&lt;code&gt;OpenFEC.js&lt;/code&gt;) files set up, let’s get to coding!&lt;/p&gt;

&lt;h3&gt;
  
  
  Coding our HTML File
&lt;/h3&gt;

&lt;p&gt;In &lt;code&gt;OpenFEC.html&lt;/code&gt;, add the following lines of code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- Create a canvas object for ChartJS --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;canvas&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"chart"&lt;/span&gt; &lt;span class="na"&gt;width=&lt;/span&gt;&lt;span class="s"&gt;"400"&lt;/span&gt; &lt;span class="na"&gt;height=&lt;/span&gt;&lt;span class="s"&gt;"400"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/canvas&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This line is used to create a canvas (needed for ChartJS) with the specified width and height. This is where our graph will go on the webpage!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- Point the HTML file to Chart.js --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src = &lt;/span&gt;&lt;span class="s"&gt;"./package/dist/Chart.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This line points our HTML file to the ChartJS JavaScript file that was in the zip file we extracted earlier (step 3 of the setup).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- Point the HTML file to our JS file --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src = &lt;/span&gt;&lt;span class="s"&gt;"./OpenFEC.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Our last HTML code line points the HTML file to our personal JavaScript file (&lt;code&gt;OpenFEC.js&lt;/code&gt;), which is where we will do all of our coding to retrieve the information and display the graph. That's it for the HTML file!&lt;/p&gt;

&lt;h3&gt;
  
  
  Using the API
&lt;/h3&gt;

&lt;p&gt;Before we start on the JavaScript file, let’s understand the API request we will make. &lt;/p&gt;

&lt;h4&gt;
  
  
  Getting a Request URL
&lt;/h4&gt;

&lt;p&gt;Go to &lt;a href="https://api.open.fec.gov/developers/"&gt;https://api.open.fec.gov/developers/&lt;/a&gt; and scroll down and click on the &lt;code&gt;presidential&lt;/code&gt; tab.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--P0f4M1mo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hf1387tm1ddburkvqnm4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P0f4M1mo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hf1387tm1ddburkvqnm4.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This should open up a drop down with many options of the different types of information you can obtain. For our purposes, choose the tab seen below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PoianF91--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/twl63j5lf8x5l39eyoa8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PoianF91--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/twl63j5lf8x5l39eyoa8.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This should now populate your screen with a description of the information available for this specific request, as well as certain parameters you can use to filter this information. There is an immense amount of information available on this website and you can specify what information you want by playing around with the parameters and with different tabs (&lt;code&gt;presidential&lt;/code&gt; is just one!). For now, click the &lt;code&gt;Try it out&lt;/code&gt; button and enter the following parameters.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ERpx2tvb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/1tsqobuzo47di1c45q2v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ERpx2tvb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/1tsqobuzo47di1c45q2v.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see from this, we are filtering our financial information to focus on all candidates (&lt;code&gt;-P00000001&lt;/code&gt;) from the 2016 presidential election, organized by decreasing order of net receipts. There will be multiple pages returned, but we want to focus solely on the first 13 results, so we set the &lt;code&gt;per_page&lt;/code&gt; parameter to 13. Before actually getting the results, however, we must also enter the unique API key we signed up for earlier!&lt;/p&gt;

&lt;p&gt;Next, hit the &lt;code&gt;execute&lt;/code&gt; button. You should get a response that has a box labeled &lt;code&gt;Request URL&lt;/code&gt; and looks like this (note the API key has been colored out).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UAPpyBoi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wpaxgq8xhhlfdus0mjr0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UAPpyBoi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wpaxgq8xhhlfdus0mjr0.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Copy and paste this link into any web browser.&lt;/p&gt;

&lt;p&gt;Woah! You should’ve been hit with a big wall of text! What does this all mean?!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--g7EMrJ13--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/oie5ff67mawi32g4sfqe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g7EMrJ13--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/oie5ff67mawi32g4sfqe.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  JSON (and Beautifying It)
&lt;/h4&gt;

&lt;p&gt;What you received is a JSON (JavaScript Object Notation) response after making an API GET request. Essentially, this is the raw format of all the information you "got" from OpenFEC. To make it more readable, copy and paste all the text and enter it into a JSON beautifier (&lt;a href="https://codebeautify.org/jsonviewer"&gt;https://codebeautify.org/jsonviewer&lt;/a&gt;) and hit &lt;code&gt;Beautify&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LQLm4f5N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/r8nxhd86vmekiy96qc5r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LQLm4f5N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/r8nxhd86vmekiy96qc5r.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, that’s much easier to read! As you can see, everything is in key-value pairs. For example, there is a key &lt;code&gt;net_receipts&lt;/code&gt; and a value &lt;code&gt;799419661.15&lt;/code&gt; associated with it. Scroll through the JSON on the right of your screen to see what other information you have found.&lt;/p&gt;

&lt;p&gt;There are few important things to note about JSON. Text surrounded by curly braces indicate a JSON object. Text surrounded by square brackets are elements of an array (an array is synonymous for a list).&lt;/p&gt;

&lt;p&gt;You should notice that there is a &lt;code&gt;results&lt;/code&gt; key whose value is an array (i.e. list) of multiple JSON objects (many key-value pairs grouped by curly braces). Each JSON object has various information (key-value pairs) for different candidates/parties!&lt;/p&gt;

&lt;p&gt;Great, now we have our information! But, how do we get this information into the code?&lt;/p&gt;

&lt;h3&gt;
  
  
  Coding Our JavaScript File
&lt;/h3&gt;

&lt;h4&gt;
  
  
  XMLHttpRequest
&lt;/h4&gt;

&lt;p&gt;Let’s open our JS file and enter the following lines of code. The link will be the &lt;code&gt;Request URL&lt;/code&gt; we got from the OpenFEC website (where the code says &lt;code&gt;YOUR API KEY&lt;/code&gt;, make sure to enter your unique API key).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Create a web request object using an XMLHttpRequest object&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;XMLHttpRequest&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// This is the url we are making the request to&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://api.open.fec.gov/v1/presidential/financial_summary/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;?sort=-net_receipts&amp;amp;election_year=2016&amp;amp;sort_null_only=false&amp;amp;page=1&amp;amp;sort_nulls_last=false&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;&amp;amp;api_key=YOUR API KEY HERE&amp;amp;candidate_id=-P00000001&amp;amp;sort_hide_null=false&amp;amp;per_page=13&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;XMLHttpRequest&lt;/code&gt; is used to create a JavaScript Object which we can use to make a request to the internet! Now, enter the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// open and sending the GET request at the url&lt;/span&gt;
&lt;span class="nx"&gt;http&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;GET&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;http&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This allows us to open a GET request (we want to "GET" information from the webpage) to our specified URL. We then send the request! Note that GET is not the only type of HTTP request, but we won't concern ourselves with the other types of requests here.&lt;/p&gt;

&lt;p&gt;Now that we have made our request, we need to set up the &lt;code&gt;onreadystatechange&lt;/code&gt; function, which will be invoked when we receive a response. We also need to verify that the response we received is valid (&lt;code&gt;this.readyState == 4&lt;/code&gt; and &lt;code&gt;this.status == 200&lt;/code&gt;) before we start using the information we receive from the request. You can learn more about the different HTTP status codes &lt;a href="https://en.wikipedia.org/wiki/List_of_HTTP_status_codes"&gt;here&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// this function will run when we receive a response&lt;/span&gt;
&lt;span class="nx"&gt;http&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onreadystatechange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
  &lt;span class="c1"&gt;// only proceed once we receive a VALID response&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;readyState&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Extracting the Data
&lt;/h4&gt;

&lt;p&gt;Now, we have to extract the data from the response we received from the request. This is done by &lt;code&gt;JSON.parse(this.response)&lt;/code&gt;, which takes the response we received and parses it into a JavaScript Object (&lt;code&gt;raw_data&lt;/code&gt;) that we can use. We then want to focus on the information available under the &lt;code&gt;results&lt;/code&gt; key from the API response, so we index our &lt;code&gt;raw_data&lt;/code&gt; by the key "results".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// obtain all the JSON data and parse it into a JavaScript object raw_data&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;raw_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="c1"&gt;// obtain the results array from the raw_data&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;raw_data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;results&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now that we have our results saved in the &lt;code&gt;results&lt;/code&gt; array our work is almost done! &lt;code&gt;results&lt;/code&gt; stores all the JSON objects of each respective candidate/party with all their financial information.&lt;/p&gt;

&lt;p&gt;To set up for ChartJS (which will be discussed later), we want to get all our candidate/party names in an array and each of our data categories (operating expenditures, net receipts, fundraising disbursements, and individual contributions less refunds) into distinct arrays. This is done as follows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// initialize empty arrays for the fields we are interested in displaying in our chart&lt;/span&gt;
        &lt;span class="nx"&gt;names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
        &lt;span class="nx"&gt;operating_expenditures&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
        &lt;span class="nx"&gt;total_contribution_refunds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
        &lt;span class="nx"&gt;net_receipts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
        &lt;span class="nx"&gt;individual_contributions_less_refunds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
        &lt;span class="nx"&gt;fundraising_disbursements&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;

        &lt;span class="c1"&gt;// loop through all of the results&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;// obtain the current candidate / party from all the results we are traversing&lt;/span&gt;
            &lt;span class="nx"&gt;current_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

            &lt;span class="cm"&gt;/* obtain the candidate name, operating expenditures, etc. by indexing the current_data with
               appropriate key */&lt;/span&gt;
            &lt;span class="nx"&gt;names&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;current_data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;candidate_name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt; 
            &lt;span class="nx"&gt;operating_expenditures&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;current_data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;operating_expenditures&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt; 
            &lt;span class="nx"&gt;net_receipts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;current_data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;net_receipts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
            &lt;span class="nx"&gt;fundraising_disbursements&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;current_data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fundraising_disbursements&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt; 
            &lt;span class="nx"&gt;individual_contributions_less_refunds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;current_data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;individual_contributions_less_refunds&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After initializing all our empty arrays, we loop through all of our results and save the current element (remember, the current element is a JSON object which has the information for a specific candidate/party). We then index this element by the keys associated with our desired information (see the API response shown earlier for the various keys) and push the information into the appropriate arrays. After doing this for every respective element of the &lt;code&gt;results&lt;/code&gt; array, we have successfully saved all of the information that we desire from the API. Onto using the information in ChartJS! &lt;/p&gt;

&lt;h2&gt;
  
  
  ChartJS Bar Graph
&lt;/h2&gt;

&lt;p&gt;Now that we have our data from the API integrated, we will be creating and customizing the graph. &lt;/p&gt;

&lt;h4&gt;
  
  
  Creating the Graph
&lt;/h4&gt;

&lt;p&gt;To create the graph, we want to instantiate the chart by passing in the 2d context of the canvas where the chart will be drawn. We want to create a bar graph.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Save the chart from HTML in JavaScript&lt;/span&gt;
        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;ctx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;chart&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;getContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;2d&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="c1"&gt;// Create a new Chart (will be a bar chart) object&lt;/span&gt;
        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;chart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Chart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;    
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;bar&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Customizing the Graph
&lt;/h4&gt;

&lt;p&gt;Once we’ve instantiated it, we start customizing the graph. &lt;code&gt;labels: names&lt;/code&gt; uses the &lt;code&gt;names&lt;/code&gt; array we created earlier to ensure that the name of each candidate/party is on the x-axis of our graph. Once we’ve set the x-axis, we begin setting our data for each data category of interest (operating expenditures, net receipts, etc.). Each category will be one object  in the &lt;code&gt;datasets&lt;/code&gt; array. Each element of this &lt;code&gt;datasets&lt;/code&gt; array will have attributes such as a label, an array which holds the desired data, and various aesthetic attributes. Since we already have arrays storing all of the different financial information desired, we can use those arrays as the values for the &lt;code&gt;data&lt;/code&gt; attribute of the appropriate data category. For the aesthetic attributes involving colors, we can set the value as a general color (e.g. &lt;code&gt;black&lt;/code&gt;, &lt;code&gt;white&lt;/code&gt;, &lt;code&gt;yellow&lt;/code&gt;) or a specific color (&lt;code&gt;rgba(0, 0, 0, 0.1)&lt;/code&gt;). See &lt;a href="https://www.hexcolortool.com/"&gt;https://www.hexcolortool.com/&lt;/a&gt; to reference any color you desire! &lt;/p&gt;

&lt;p&gt;Repeat this customization procedure for every data set you have.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;// x-axis will be labeled with names&lt;/span&gt;
            &lt;span class="nl"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;names&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="cm"&gt;/* create an array of different data values for each name, each having respective labels, colors,
               and data that we obtained from the API response earlier*/&lt;/span&gt;
            &lt;span class="nx"&gt;datasets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
                &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Operating Expenditures&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;operating_expenditures&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rgba(106, 220, 123, 1)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;borderColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;black&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;borderWidth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
                    &lt;span class="p"&gt;},&lt;/span&gt;
                    &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Net Receipts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;net_receipts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rgba(71, 175, 255, 1)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;borderColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;black&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   
                &lt;span class="na"&gt;borderWidth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;                  
                &lt;span class="p"&gt;},&lt;/span&gt;
                &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Fundraising Disbursements&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;net_receipts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rgba(136, 0, 240, 1)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;borderColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;black&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    
                &lt;span class="na"&gt;borderWidth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;                  
                &lt;span class="p"&gt;},&lt;/span&gt;
                &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Individual Contributions Less Refunds&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;individual_contributions_less_refunds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rgba(233, 114, 114, 1)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;borderColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;black&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    
                &lt;span class="na"&gt;borderWidth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;                  
                &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Once you’re done labeling and customizing each data category, you can add options to create a title for the graph.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;        &lt;span class="c1"&gt;// tinker with various options for the chart&lt;/span&gt;
        &lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;// set a title&lt;/span&gt;
            &lt;span class="nl"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="na"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;OpenFEC Data Visualization&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;That's it! You've completed the coding!&lt;/p&gt;

&lt;h2&gt;
  
  
  Expected Output
&lt;/h2&gt;

&lt;p&gt;Let's see how the graph looks! Save your &lt;code&gt;OpenFEC.html&lt;/code&gt; and &lt;code&gt;OpenFEC.js&lt;/code&gt; files. Look for &lt;code&gt;OpenFEC.html&lt;/code&gt; in your file directory and right click it. Open the file with a web browser and it should look like below!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8xCp_oMJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3nzyvp1nvj9vmxtoloeu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8xCp_oMJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3nzyvp1nvj9vmxtoloeu.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;From this tutorial, you should have learned technical skills such as&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How to use the OpenFEC API to obtain desired information&lt;/li&gt;
&lt;li&gt;What JSON is&lt;/li&gt;
&lt;li&gt;How to make an API request from your JavaScript code using &lt;code&gt;XMLHttpRequest&lt;/code&gt; and how to extract information from the response&lt;/li&gt;
&lt;li&gt;How to visualize data using ChartJS in order to make a bar chart&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Moreover, in terms of themes, you should have learned&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The importance of using reliable financial data so that you can be an informed voter, make accurate predictions, and draw unbiased conclusions&lt;/li&gt;
&lt;li&gt;The importance of visualizing financial data so that you can see and analyze complex information in an easy to understand manner&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While this example was simple, it served to illustrate the power of understanding how to use APIs to extract information and how to use this information to create your own charts. The variety of information you can explore even within one API and how you can visualize the information for trend analysis is an extremely powerful tool that helps in discovering a multitude of information.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;p&gt;As next steps, the reader is encouraged to&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Graph data comparing specific financial information from the 2016 election and 2020 election in order to find similarities and differences&lt;/li&gt;
&lt;li&gt;Explore coloring and other ChartJS features&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>beginners</category>
      <category>datascience</category>
      <category>productivity</category>
      <category>api</category>
    </item>
  </channel>
</rss>
