2012-12-07 42 views
3

刪除域值我有一個情節的設置是這樣的:AndroidPlot - 從GraphWidget

aHistoryPlot = (XYPlot) findViewById(R.id.plot); 
    aHistoryPlot.setRangeBoundaries(0, 255, BoundaryMode.FIXED); 
    aHistoryPlot.setDomainBoundaries(0, HISTORY_SIZE, BoundaryMode.FIXED); 
    aHistoryPlot.addSeries(YHistorySeries, new LineAndPointFormatter(Color.rgb(100, 200, 100), Color.TRANSPARENT, null)); 
    aHistoryPlot.getGraphWidget().setMarginTop(10); 
    aHistoryPlot.setDomainStepValue(5); 
    aHistoryPlot.setTicksPerRangeLabel(3); 
    aHistoryPlot.setDomainLabel(getResources().getString(R.string.string_time)); 
    aHistoryPlot.getDomainLabelWidget().pack(); 
    aHistoryPlot.setRangeLabel(getResources().getString(R.string.string_value)); 
    aHistoryPlot.getRangeLabelWidget().pack(); 
    aHistoryPlot.disableAllMarkup(); 

如何從情節刪除域值?

在此先感謝!

回答

6

您可以輸入:

aHistoryPlot.getGraphWidget().getDomainLabelPaint.setColor(Color.TRANSPARENT); 
+0

謝謝!我剛剛添加了'aHistoryPlot.getGraphWidget()。getDomainOriginLabelPaint()。setColor(Color.TRANSPARENT);'它創造了我正在尋找的東西。 – amp

8

設置漆爲null我相信是一個好一點你也有後排空間的標貼佔用。以下是我的速度測試代碼中用於打開和關閉所有這些位的代碼。

if (!mBackgroundOn) { 
     // remove the background stuff. 
     mDynamicPlot.setBackgroundPaint(null); 
     mDynamicPlot.getGraphWidget().setBackgroundPaint(null); 
     mDynamicPlot.getGraphWidget().setGridBackgroundPaint(null); 
    } 

    if (!mKeyOn) 
     mDynamicPlot.getLayoutManager() 
       .remove(mDynamicPlot.getLegendWidget()); 
    if (!mDomainLabelOn) 
     mDynamicPlot.getLayoutManager().remove(
       mDynamicPlot.getDomainLabelWidget()); 
    if (!mDomainAxisOn) { 
     mDynamicPlot.getGraphWidget().setDomainLabelPaint(null); 
     mDynamicPlot.getGraphWidget().setDomainOriginLabelPaint(null); 
    } 
    if (!mBoarderOn){ 
     //mDynamicPlot.setDrawBorderEnabled(false); 
     mDynamicPlot.setBorderPaint(null); 
    }if (!mRangeLabelOn) 
     mDynamicPlot.getLayoutManager().remove(
       mDynamicPlot.getRangeLabelWidget()); 
    if (!mRangeAxisOn) { 
     mDynamicPlot.getGraphWidget().setRangeLabelPaint(null); 
     mDynamicPlot.getGraphWidget().setRangeOriginLabelPaint(null); 
     //mDynamicPlot.getGraphWidget().setRangeLabelVerticalOffset(rangeLabelVerticalOffset); 
    } 
    if (!mGridOn) { 
     //mDynamicPlot.getGraphWidget().setGridLinePaint(null); 
     mDynamicPlot.getGraphWidget().setDomainOriginLinePaint(null); 
     mDynamicPlot.getGraphWidget().setRangeOriginLinePaint(null); 
    } 
    if (!mTitleOn) { 
     mDynamicPlot.getLayoutManager().remove(mDynamicPlot.getTitleWidget()); 
    } 
+0

它現在工作你的代碼?我想刪除「RangeLabelWidget」和「DomainLabelWidget」以全屏設置「GraphWidget」。 – optimusfrenk

+0

我還沒有更新到最新的版本,所以事情有變化的危險如果結構發生了變化,但我不知道。試試看看。 – Ifor

2

設置此項,將使您擺脫所有網格/邊框的東西,並使您有一個透明的圖形樣式。

aprHistoryPlot.setPlotMargins(0, 0, 0, 0); 
aprHistoryPlot.setPlotPadding(0, 0, 0, 0); 
aprHistoryPlot.setDomainLabelWidget(null); 
aprHistoryPlot.setRangeLabelWidget(null); 

aprHistoryPlot.setBackgroundPaint(null); 
aprHistoryPlot.getGraphWidget().setBackgroundPaint(null); 
aprHistoryPlot.getGraphWidget().setGridBackgroundPaint(null); 
aprHistoryPlot.setBorderPaint(null); 

//aprHistoryPlot.setDomainLabel(null); // crash 
//aprHistoryPlot.setRangeLabel(null); 

aprHistoryPlot.getGraphWidget().setDomainLabelWidth(0.0f); 
aprHistoryPlot.getGraphWidget().setRangeLabelWidth(0.0f); 

aprHistoryPlot.getGraphWidget().setDomainLabelPaint(null); 
aprHistoryPlot.getGraphWidget().setDomainOriginLabelPaint(null); 

aprHistoryPlot.getGraphWidget().setRangeLabelPaint(null); 
aprHistoryPlot.getGraphWidget().setRangeOriginLabelPaint(null); 

aprHistoryPlot.getGraphWidget().setDomainOriginLinePaint(null); 
aprHistoryPlot.getGraphWidget().setRangeOriginLinePaint(null); 

aprHistoryPlot.getLayoutManager().remove(aprHistoryPlot.getTitleWidget()); 

aprHistoryPlot.getGraphWidget().getDomainGridLinePaint().setColor(Color.TRANSPARENT); 
aprHistoryPlot.getGraphWidget().getRangeGridLinePaint().setColor(Color.TRANSPARENT); 
aprHistoryPlot.getGraphWidget().getRangeSubGridLinePaint().setColor(Color.TRANSPARENT); 

aprHistoryPlot.getLayoutManager().remove(aprHistoryPlot.getLegendWidget()); 
aprHistoryPlot.getLayoutManager().remove(aprHistoryPlot.getDomainLabelWidget()); 
aprHistoryPlot.getLayoutManager().remove(aprHistoryPlot.getRangeLabelWidget());