MPAndroidChart - 网格线和限制线在后台保持闪烁

时间:2015-06-10 06:38:17

标签: android mpandroidchart

我正在尝试使用MPAndroidChart库绘制实时图表。虽然我能够成功绘制图形,但是在绘制图形时,网格线和限制线会一直闪烁。

LineData data = myGraph.getData();

if (data != null) {
    LineDataSet set = data.getDataSetByIndex(0);

    if (set == null) {
        set = createSet();
        data.addDataSet(set);
    }
    // add a new x-value first
    DecimalFormat df = new DecimalFormat("#.0");
    String xVal = df.format(theRunningTime);
    data.addXValue(xVal+"s");
    data.addEntry(new Entry( yValue, set.getEntryCount()), 0);

    // let the chart know it's data has changed
    audioGraph.notifyDataSetChanged();
    audioGraph.invalidate();
}

以下代码介绍了图表中的限制线

YAxis yl = myGraph.getAxisLeft();
yl.setTextColor(Color.WHITE);
yl.setTextSize(8f);
yl.setAxisMinValue(0);
yl.setDrawGridLines(false);
yl.setDrawAxisLine(true);
yl.setValueFormatter(new MyValueFormatter());     
yl.setStartAtZero(true);
//Remove any previous limit lines
yl.removeAllLimitLines();

LimitLine ll = new LimitLine(getThresholdValue(), "Threshold Value");
ll.setLineColor(Color.MAGENTA);
ll.setLineWidth(1f);
ll.setTextColor(Color.RED);
ll.setTextSize(7f);

yl.addLimitLine(ll);

0 个答案:

没有答案