求大虾指教:做柱状图时,用一下代码
   for (int z=0;z<len;z++)      
    categorydataset.setValue(ad[0][z],rowKeys[z], columnKeys[z]);
生成数据集结果图中只有一根柱子(还有例外抛出说下标越界,但是检查无误);
不用for循环时,
   categorydataset.setValue(ad[0][0],rowKeys[0], columnKeys[0]);
     categorydataset.setValue(ad[0][1],rowKeys[1], columnKeys[1]);
      categorydataset.setValue(ad[0][2],rowKeys[2], columnKeys[2]);
       categorydataset.setValue(ad[0][7],rowKeys[7], columnKeys[7]);
仍然显示一根柱子,是最后的一组数据(这时显示为ad[0][7]的数据)
急啊!请各位帮忙啊!!!

解决方案 »

  1.   

    只显示最后一组..  貌似是把前面的都覆盖掉了吧.  categorydataset 是数组? 代码不全 只看这些的话 猜测覆盖吧...
      

  2.   

    DefaultCategoryDataset  categorydataset = new DefaultCategoryDataset();
        categorydataset.setValue(ad[0][0],rowKeys[0], columnKeys[0]);
         categorydataset.setValue(ad[0][1],rowKeys[1], columnKeys[1]);
          categorydataset.setValue(ad[0][2],rowKeys[2], columnKeys[2]);
           categorydataset.setValue(ad[0][7],rowKeys[7], columnKeys[7]);
            categorydataset.setValue(ad[0][20],rowKeys[20], columnKeys[20]);
    请再指教,多谢
      

  3.   

    不好意思, 刚才写错了,是   
    categorydataset.addValue(ad[0][0],rowKeys[0], columnKeys[0]);
         categorydataset.addValue(ad[0][1],rowKeys[1], columnKeys[1]);
          categorydataset.addValue(ad[0][2],rowKeys[2], columnKeys[2]);
           categorydataset.addValue(ad[0][7],rowKeys[7], columnKeys[7]);
            categorydataset.addValue(ad[0][20],rowKeys[20], columnKeys[20]);