ACE值未显示

时间:2012-11-15 13:39:31

标签: android achartengine

使用achartengine,我需要在时间图上显示值。根据我放置命令行的位置,不显示任何值或显示错误值。我想这是因为List在库中的使用方式(排序),但我不知道如何处理它。

以下是代码:

public GraphicalView getViewTime(Context context, int spinnerSelection, List<myObject> myDataSrc) {

    // *********************
    // SET Graphical objects
    // *********************
    XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
    XYMultipleSeriesDataset mDataSet = new XYMultipleSeriesDataset();

    // **************
    // AUTOSCALING
    // **************
    AutoScaling<E> AutoScaled = new AutoScaling<E>(spinnerSelection, myDataSrc);

    // *************
    // mdataset
    // *************
    List<Date[]> X_serie = AutoScaled.getXserie();
    List<double[]> Y_serie = AutoScaled.getYserie();

    String[] titles = new String[] { ""/* spinnerSelection */};
    mDataSet = buildDateDataset(titles, X_serie, Y_serie);


    // **************
    // mRenderers
    // **************
    // LEGENDS
    String ChartTitle = getTitle(context, spinnerSelection);
    //mRenderer.setDisplayChartValues(true);

    setChartSettings(mRenderer, ChartTitle, XlegendText, YlegendText, AutoScaled.getFirstRecordDate(), AutoScaled.getLastRecordDate(), 0.0, AutoScaled.getYmax(),
                Color.GRAY, Color.LTGRAY);

    // if command line is here, no values are shown
    // mRenderer.setDisplayChartValues(true);

    // LABELS
    mRenderer.setYLabels(YlabelsCount);
    mRenderer.setXLabels(XlabelsCount);
    mRenderer.setShowLabels(true);
    mRenderer.setXLabelsAlign(Align.RIGHT);
    // renderer.setXLabelsAngle(270L);
    mRenderer.setYLabelsAlign(Align.RIGHT);

    // COLORS
    int[] Colors = new int[] { curveColors[spinnerSelection] };
    mRenderer = buildRenderer(Colors, styles);

     // Shows values at the wrong "place", like random because of List I guess
    // mRenderer.setDisplayChartValues(true);

    // ZOOM
    double[] panLimits = AutoScaled.getPanLimits();
    mRenderer.setZoomEnabled(XenabledZoom, YenabledZoom);
    mRenderer.setZoomButtonsVisible(showZoomButtons);
    mRenderer.setZoomRate(ZoomRate);
    mRenderer.setPanLimits(panLimits);
    mRenderer.setZoomLimits(panLimits);

    // SHOW ONLY last WEEK even after Zoom reset
    mRenderer.setXAxisMin( AutoScaled.getDateOneWeekAgo() );
    mRenderer.setInitialRange(AutoScaled.getXYRange());

    // GRID
    mRenderer.setShowGrid(showGrid);

    // VIEW
    GraphicalView BasicView = ChartFactory.getTimeChartView(context, mDataSet, mRenderer, DateFormat);

    return BasicView;
}

编辑: 即使在显示值的情况下,如果我将图表向左滑动,也会出现此致命错误:

  

11-15 14:55:54.746:E / AndroidRuntime(1555):   java.lang.ArrayIndexOutOfBoundsException:length = 135; index = -82 11-15   14:55:54.746:E / AndroidRuntime(1555):at   java.util.ArrayList.get(ArrayList.java:306)11-15 14:55:54.746:   E / AndroidRuntime(1555):at   org.achartengine.util.IndexXYMap.getYByIndex(IndexXYMap.java:80)11-15   14:55:54.746:E / AndroidRuntime(1555):at   org.achartengine.model.XYSeries.getY(XYSeries.java:169)11-15   14:55:54.746:E / AndroidRuntime(1555):at   org.achartengine.chart.XYChart.drawChartValuesText(XYChart.java:539)   11-15 14:55:54.746:E / AndroidRuntime(1555):at   org.achartengine.chart.XYChart.drawSeries(XYChart.java:502)11-15   14:55:54.746:E / AndroidRuntime(1555):at   org.achartengine.chart.XYChart.draw(XYChart.java:286)11-15   14:55:54.746:E / AndroidRuntime(1555):at   org.achartengine.GraphicalView.onDraw(GraphicalView.java:166)

编辑2:代码中使用的值

int XlabelsCount = 7;
int YlabelsCount = 10;
float ZoomRate = 1.20f;
String DateFormat = "dd MMM yy\n HH:mm";

11-16 15:46:34.935: I/TwoAxisVsTime(2316): LIST DUMP X_serie (94 datas in total): 
11-16 15:46:34.935: I/TwoAxisVsTime(2316): i=0 =>Thu Oct 25 20:16:06 UTC+02:00 2012,
11-16 15:46:34.935: I/TwoAxisVsTime(2316): i=1 =>Sun Oct 28 10:53:41 UTC+01:00 2012,
11-16 15:46:34.935: I/TwoAxisVsTime(2316): i=2 =>Wed Nov 07 13:06:43 UTC+01:00 2012,
11-16 15:46:34.935: I/TwoAxisVsTime(2316): i=3 =>Wed Sep 26 16:42:39 UTC+02:00 2012,
11-16 15:46:34.935: I/TwoAxisVsTime(2316): i=4 =>Sun Sep 30 16:49:00 UTC+02:00 2012,
11-16 15:46:34.935: I/TwoAxisVsTime(2316): i=5 =>Mon Oct 29 12:14:59 UTC+01:00 2012,
11-16 15:46:34.935: I/TwoAxisVsTime(2316): i=6 =>Sun Oct 28 14:54:21 UTC+01:00 2012,
11-16 15:46:34.935: I/TwoAxisVsTime(2316): i=7 =>Thu Nov 01 20:24:32 UTC+01:00 2012,
11-16 15:46:34.935: I/TwoAxisVsTime(2316): i=8 =>Sat Oct 27 20:22:26 UTC+02:00 2012,
11-16 15:46:34.935: I/TwoAxisVsTime(2316): i=9 =>Wed Nov 14 15:16:10 UTC+01:00 2012,
11-16 15:46:34.935: I/TwoAxisVsTime(2316): i=10 =>Wed Nov 14 12:04:38 UTC+01:00 2012,

11-16 15:46:34.945: I/TwoAxisVsTime(2316): DUMP Y_serie (94 datas in total): 
11-16 15:46:34.945: I/TwoAxisVsTime(2316): 152.0,
11-16 15:46:34.945: I/TwoAxisVsTime(2316): 81.0,
11-16 15:46:34.945: I/TwoAxisVsTime(2316): 178.0,
11-16 15:46:34.945: I/TwoAxisVsTime(2316): 120.0,
11-16 15:46:34.945: I/TwoAxisVsTime(2316): 89.0,
11-16 15:46:34.945: I/TwoAxisVsTime(2316): 329.0,
11-16 15:46:34.945: I/TwoAxisVsTime(2316): 63.0,
11-16 15:46:34.945: I/TwoAxisVsTime(2316): 68.0,
11-16 15:46:34.945: I/TwoAxisVsTime(2316): 85.0,
11-16 15:46:34.945: I/TwoAxisVsTime(2316): 252.0,

11-16 15:46:34.965: I/TwoAxisVsTime(2316): _________________
11-16 15:46:34.965: I/TwoAxisVsTime(2316): getFirstRecordDate
11-16 15:46:34.965: I/TwoAxisVsTime(2316): 1.34747055E12
11-16 15:46:34.965: I/TwoAxisVsTime(2316): _________________
11-16 15:46:34.965: I/TwoAxisVsTime(2316): getLastRecordDate
11-16 15:46:34.965: I/TwoAxisVsTime(2316): 1.35304991E12
11-16 15:46:34.965: I/TwoAxisVsTime(2316): ____________________
11-16 15:46:34.965: I/TwoAxisVsTime(2316): AutoScaled.getYmax()
11-16 15:46:34.965: I/TwoAxisVsTime(2316): 442.0
11-16 15:46:34.965: I/TwoAxisVsTime(2316): ___________
11-16 15:46:34.965: I/TwoAxisVsTime(2316): panLimits
11-16 15:46:34.965: I/TwoAxisVsTime(2316): ARRAY DUMP : 
11-16 15:46:34.965: I/TwoAxisVsTime(2316): 1.34747055E12,
11-16 15:46:34.965: I/TwoAxisVsTime(2316): 1.35304991E12,
11-16 15:46:34.965: I/TwoAxisVsTime(2316): 0.0,
11-16 15:46:34.965: I/TwoAxisVsTime(2316): 442.0,
11-16 15:46:34.965: I/TwoAxisVsTime(2316): _______________________
11-16 15:46:34.965: I/TwoAxisVsTime(2316): AutoScaled.getXYRange()
11-16 15:46:34.965: I/TwoAxisVsTime(2316): ARRAY DUMP : 
11-16 15:46:34.965: I/TwoAxisVsTime(2316): 1.35244511E12,
11-16 15:46:34.965: I/TwoAxisVsTime(2316): 1.35304991E12,
11-16 15:46:34.965: I/TwoAxisVsTime(2316): 0.0,
11-16 15:46:34.965: I/TwoAxisVsTime(2316): 442.0,

0 个答案:

没有答案