Androidplot中arraylist中断行中的空值

时间:2014-08-17 13:26:24

标签: androidplot

我使用androidplot绘制图形。从数据库调用值在arraylist中具有空值。 x轴值具有两个对应的y值。空y值没有绘制(哪个完美)但是将该行分成两行。我希望该行加入而不输出空值(点{5,5}应该连接点{7,8}而不会中断)

    Number[] xAlertseries1={3,4,5,6,7,8,9};
    Number[] yAlertseries2={4,10,5,null,8,9,10};
    Number[] yActionseries={4,10,11,13,14,15,16};

XYSeries alertseries = new SimpleXYSeries(Arrays.asList(xAlertseries1), Arrays.asList(yAlertseries2),"ALERT");
XYSeries actionseries = new SimpleXYSeries(Arrays.asList(xAlertseries1), Arrays.asList(yActionseries),"ACTION");


        labprogplotter.addSeries(alertseries, actionalertformat);
        labprogplotter.addSeries(actionseries, actionalertformat);

        labprogplotter.redraw();

1 个答案:

答案 0 :(得分:0)

有趣的是我必须回答我自己的问题。是的,伯特

Number[] xAlertseries1={3,4,5,6,7,8,9};

//created a new xActionseries so that all have their own x-values
Number[] xActionseries={3,4,5,6,7,8,9};


Number[] yAlertseries2={4,10,5,null,8,9,10};
Number[] yActionseries={4,10,11,13,14,15,16};


 //iterated to remove null values in yAlertseries2 and its corresponding value in its x-values

 for(int i=0;i<yAlertseries2.size();i++)
    { if(yAlertseries2.get(i)==null) 
    {
        yAlertseries2.remove(i); 
        xAlertseries1.remove(i);
        i--;
    } }

XYSeries alertseries = new SimpleXYSeries(Arrays.asList(xAlertseries1),    Arrays.asList(yAlertseries2),"ALERT");
XYSeries actionseries = new SimpleXYSeries(Arrays.asList(xActionseries), Arrays.asList(yActionseries),"ACTION");


    labprogplotter.addSeries(alertseries, actionalertformat);
    labprogplotter.addSeries(actionseries, actionalertformat);

    labprogplotter.redraw()