0

Goodevening,
我正在开发一个 android 应用程序,我正在使用 achartengine 来绘制我在查询到 sqlite 数据库后检索到的值。如果值是从 0 到 1000,那么我会得到一个加载图标,并且在 10 秒后,最多,我会得到我需要的图表。如果值超过 1000 并且如果我有多线图,那么我会得到一个永远不会离开的加载图标。我使用的代码如下所示。我做错什么了吗?我使用来自 achartengine 的示例代码来制作我自己的代码。

代码:

    public void createGraph(Context ctx){
    // x data
    dateList = DateDataReturn(ctx , table, accessPointList_Filtered);
    Log.d(TAG,"dateList len:" + String.valueOf(dateList.size()));
    // y data
    dataList = yDataReturn(ctx, column, table, accessPointList_Filtered);
    Log.d(TAG, "dataList len:" + String.valueOf(dataList.size()));
    // y axis title
    yaxis = yAxisReturn(column);
    // lines titles
    titles = titleReturn(ctx, column, accessPointList_Filtered);
    Log.d(TAG,"titles length:" + String.valueOf(titles.length));
    // line colors
    colors = retColor(ctx, table, accessPointList_Filtered);
    Log.d(TAG,"colors length:" + String.valueOf(colors.length));
    // line point styles
    styles = retPointStyle(ctx, table, accessPointList_Filtered);
    Log.d(TAG,"style length:" + String.valueOf(styles.length));
    // x axis min value
    xmin = dateList.get(0)[0].getTime();
    Log.d(TAG, "1");
    // x axis max value
    xmax = dateList.get(0)[dateList.get(0).length - 1].getTime();
    Log.d(TAG, "2");
    // Create the renderer
    renderer = buildRenderer(colors, styles);
    // Create the dataset
    dataset = buildDateDataset(titles, dateList, dataList);
    Log.d(TAG, "3");
    for (int i = 0; i < renderer.getSeriesRendererCount(); i++) {
        ((XYSeriesRenderer) renderer.getSeriesRendererAt(i)).setFillPoints(true);
    }

    setChartSettings(renderer, // POINTS
            "Interface Monitoring", // PLOT LABEL
            "Time", // X LABEL
            yAxisTitleReturn(column), // Y LABEL
            xmin, 
            xmax, 
            yaxis[0], // Y AXIS START VALUE
            yaxis[1], // Y AXIS FINISH VALUE
            Color.LTGRAY, // AXIS COLOR
            Color.LTGRAY); // LABELS COLOR

    renderer.setXLabels(10);
    renderer.setYLabels(10);
    renderer.setBackgroundColor(Color.BLACK);
    renderer.setApplyBackgroundColor(true);
    renderer.setXLabelsAlign(Align.CENTER);
    renderer.setYLabelsAlign(Align.RIGHT);
    renderer.setShowGrid(true);
    renderer.setZoomEnabled(true, true);
    renderer.setPanEnabled(true, true);
}


/**
 * 
 * @param context
 * @return GraphicalView, returns the view
 */
public GraphicalView getView(Context context) {
    return (GraphicalView)ChartFactory.getTimeChartView(context, dataset, renderer, "h:mm:ss a");   
}

谢谢

4

1 回答 1

0

当您希望将大量值添加到图表中时,您必须降低详细程度。这是因为大部分时间都花在了渲染上,所以这是你可以改进的地方:

  • 禁用抗锯齿renderer.setAntialiasing(false);
  • 不要使用PointStyles

其他建议:

  • Add only data that is to be displayed into the model. How does a chart with so many points look like?

Also, the 1.1.0 version has a set of performance improvements included. You can download this version here.

于 2013-02-28T08:33:43.463 回答