title: Pass variable to amCharts.loadfile method?
body: <p><strong>Situation</strong> </p>
  
  <p>I am working on a graph where a user will be able to select a value in a dropdown list and data is loaded into a graph. 
  I have found a similar example on amCharts website. 
  <a href="https://www.amcharts.com/kbase/dynamically-loading-chart-datasets/" rel="nofollow noreferrer">https://www.amcharts.com/kbase/dynamically-loading-chart-datasets/</a></p>
  
  <p>The problem with this example is the data is "hard coded" so for each option their must be a pre built link. </p>
  
  <p><strong>What I have done</strong></p>
  
  <p>So far, I have got my charts working and created a controller that counts 3  statuses depending on what "Item" was passed in.</p>
  
  <p>However my item_name variable is always null. </p>
  
  <pre><code>public ActionResult checkPriority(string item_name)
  {
      decimal?[] priCount = { 0, 0, 0 };
  
      priCount[0] = db.vw_priCount.Where(i =&gt; i.itemDescrip == item_name&amp;&amp; i.itemStatus == 1).Count();
      priCount[1] = db.vw_priCount.Where(i =&gt; i.itemDescrip == item_name&amp;&amp; i.itemStatus == 2).Count();
      priCount[2] = db.vw_priCount.Where(i =&gt; i.itemDescrip == item_name&amp;&amp; i.itemStatus == 3).Count(); 
  
  
      return Json(priCount, JsonRequestBehavior.AllowGet);
  
  }
  </code></pre>
  
  <p>This is my index page code</p>
  
  <pre><code> &lt;script&gt;
  
  
  
          var chart;
  
  
              $(document).ready(function () {
  
                  $.ajax({
                      type: "POST",
                      url: '/Home/checkPriority',
                      data:{
                          item_name: "Pens"
                      },
                      dataType: "json",
                      success: OnSuccessBoxCountPri,
                      error: OnErrorCallPri
                  });
  
              });
  
              function OnErrorCallPri(response) {
                  alert('An error occured with the charts, please try again later.');
              }
  
              function OnSuccessBoxCountPri(priCount) {
                  console.log(priCount);
  
  
                    chart = AmCharts.makeChart("pribarchartdiv", {
                      "type": "serial",
                      "theme": "none",
                      "marginRight": 70,
                      "dataProvider": [{
                          "Priority Level": "Low",
                          "cost": priCount[0],
                          "color": "#FF0F00"
                      }, {
                          "Priority Level": "Medium",
                          "cost": priCount[1],
                          "color": "#FF6600"
                      }, {
                          "Priority Level": "High",
                          "cost": priCount[2],
                          "color": "#FF9E01"
                      }, {
                          "Priority Level": "Very High",
                          "cost": priCount[3],
                          "color": "#04D215"
  
  
                      }],
                      "valueAxes": [{
                          "axisAlpha": 0,
                          "position": "left",
                          "title": "Priority"
                      }],
                      "startDuration": 1,
                      "graphs": [{
                          "balloonText": "&lt;b&gt;[[category]]: [[value]]&lt;/b&gt;",
                          "fillColorsField": "color",
                          "fillAlphas": 0.9,
                          "lineAlpha": 0.2,
                          "type": "column",
                          "valueField": "cost"
                      }],
                      "chartCursor": {
                          "categoryBalloonEnabled": false,
                          "cursorAlpha": 0,
                          "zoomable": false
                      },
                      "categoryField": "Priority Level",
                      "categoryAxis": {
                          "gridPosition": "start",
                          "labelRotation": 45
                      },
                      "export": {
                          "enabled": true
                      }
  
                  });
  
  
  
              }
  
  
  
              function setDataSet(dataset_url) {
  
                  AmCharts.loadFile("checkPriority",{}, function (data) {
                      console.log(dataset_url);//itemname in here
                      console.log(data);//0,0,0
                      chart.dataProvider = AmCharts.parseJSON(data);
                  chart.validateData();
              });
          }
  
      &lt;/script&gt;
      &lt;p class="selector"&gt;
          &lt;select onchange="setDataSet(this.options[this.selectedIndex].value);"&gt;
              &lt;option value="Pens"&gt;Data Set #1&lt;/option&gt;
              &lt;option value="Chalk"&gt;Data Set #2&lt;/option&gt;
              &lt;option value="Books"&gt;Data Set #3&lt;/option&gt;
          &lt;/select&gt; &amp;lt; Select a data set
      &lt;/p&gt;
  </code></pre>
  
  <p>I believe this is the line <code>AmCharts.loadFile("checkPriority",{}, function (data) {</code> that I should pass my variable (which is the value of the checkbox) in. Any assistance on how I go about doing this of if it can even be done would be appreciated.</p>