-2

hFollowing 是 barclustered jqplot 的代码。谁能指导我在下面的代码中动态创建一个突出显示的数组

$(document).ready(function(){
// For horizontal bar charts, x an y values must will be "flipped"
// from their vertical bar counterpart.
var plot2 = $.jqplot('chart2', [
    [[2,1], [4,2], [6,3], [3,4]], 
    [[5,1], [1,2], [3,3], [4,4]], 
    [[4,1], [7,2], [1,3], [2,4]]], {
       seriesDefaults: {
           renderer:$.jqplot.BarRenderer,
           // Show point labels to the right ('e'ast) of each bar.
           // edgeTolerance of -15 allows labels flow outside the grid
           // up to 15 pixels.  If they flow out more than that, they 
           // will be hidden.
           pointLabels: { show: true, location: 'e', edgeTolerance: -15 },
           // Rotate the bar shadow as if bar is lit from top right.
           shadowAngle: 135,
           // Here's where we tell the chart it is oriented horizontally.
           rendererOptions: {
               barDirection: 'horizontal'
           }
       },
       axes: {
           yaxis: {
            renderer: $.jqplot.CategoryAxisRenderer
           }
       }
   });
});
4

1 回答 1

1

您的 Javascript 语法和算法有问题。循环应如下所示:

VData="9,453,470,232|488,378,375,142|365,275,255,434|217,317,479,89";
var a = new Array();
var split_fst = VData.split("|")
for(m=0;m<split_fst.length;m++) { 
  var split_snd = split_fst[m].split(",");
  a[m] = new Array();
  for(j=0;j<split_snd.length;j++){ 
     a[m][j]=split_snd[j];
  }
}

你的a变量现在看起来像:`[["9","453","470","232"],["488","378","375","142"],["365"," 275","255","434"],["217","317","479","89"]]

于 2013-03-15T13:25:16.777 回答