想知道是否有人知道如何将变量放入数组中。我尝试过以下技术。如果脚本中存在图形,则图形当前生成的数字很好。但是它并没有把变量放在那里。变量是值。
$(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>
&#13;