将数字输入变量放入 JQplot 数组 (PieChart)

Putting a numeric input variable in JQplot array (PieChart)

想知道是否有人知道如何将变量放入数组中。我尝试了以下技术。如果脚本中存在图形,则该图目前可以很好地生成图形。但是它不会在那里放置变量。变量是值。

$(document).keyup(function() {
  var ac = $("#ac1").val();
  var data = [ //Insert data here
    ['Accomodation', ac],
    ['Retail', 9],
    ['Light Industry', 14],
    ['Out of home', 16],
    ['Commuting', 7],
    ['Orientation', 9]
  ];
  var plot1 = jQuery.jqplot('pie1', [data], //pie1 is the id for the html section
    {
      seriesDefaults: {
        // Make this a pie chart.
        renderer: jQuery.jqplot.PieRenderer,
        rendererOptions: {
          // Put data labels on the pie slices.
          // By default, labels show the percentage of the slice.
          showDataLabels: true
        }
      },
      legend: {
        show: true,
        location: 'e'
      }
    }
  );
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script language="javascript" type="text/javascript" src="js_plug/jquery.jqplot.min.js"></script>
<script type="text/javascript" src="js_plug/jqplot.pieRenderer.min.js"></script>
<script type="text/javascript" src="js_plug/jqplot.donutRenderer.min.js"></script>

<div class="item" id="income_item_1">Item 1
    <input id="ac1" type="text" class="sub_input" />
</div>
<div class="item" id="income_item_1">Item 1
    <input name="ac2" type="text" class="sub_input">
</div>
<div class="pie1" id="pie1" style="height:200px;width:500px;"></div>

要将变量添加到图表中,下面的代码似乎有效。

$(document).keyup(function() {
      var ic = $('#ic').val();
      var ex = $('#ex').val();


      var data = [ //Insert data here
        ['income', ic],
        ['expense', ex]
      ];
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>