AndroidPlot - 从GraphWidget中删除域值

时间:2012-12-07 10:41:39

标签: java android graph androidplot android-graphview

我有一个这样的情节设置:

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();

如何从图中删除域值?

提前致谢!

3 个答案:

答案 0 :(得分: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());
    }

答案 1 :(得分:6)

您可以输入:

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

答案 2 :(得分: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());