AndroidPlot造型和定位

AndroidPlot造型和定位,android,charts,position,styling,androidplot,Android,Charts,Position,Styling,Androidplot,我正在努力做到这一点: , 到目前为止,我已经做到了: (不用担心颜色,这是为了更容易识别不同的组件) 我有几个问题: 我想移动范围标签,但myPlot.getRangeLabelWidget().position()似乎没有移动它们 如何使灰色区域(白色图形和红色边框之间)消失?我试图利用所有的边距/填充物,但没有成功 如何只保留1条蓝色虚线?(中间的那个)。我可以利用边距使其消失,但随后数字10.0也消失了 要删除域标签,最好将标签颜色设置为透明,还是使小部件不可见 提前谢谢 @Ove

我正在努力做到这一点:

到目前为止,我已经做到了:

(不用担心颜色,这是为了更容易识别不同的组件)

我有几个问题:

  • 我想移动范围标签,但myPlot.getRangeLabelWidget().position()似乎没有移动它们
  • 如何使灰色区域(白色图形和红色边框之间)消失?我试图利用所有的边距/填充物,但没有成功
  • 如何只保留1条蓝色虚线?(中间的那个)。我可以利用边距使其消失,但随后数字10.0也消失了
  • 要删除域标签,最好将标签颜色设置为透明,还是使小部件不可见
提前谢谢

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.chart, container, false);

    plot = (XYPlot) view.findViewById(R.id.mySimpleXYPlot);

    Number[] series1Numbers = {3, 8, 5, 2, 7, 4};

    XYSeries series1 = new SimpleXYSeries(
            Arrays.asList(series1Numbers),
            SimpleXYSeries.ArrayFormat.Y_VALS_ONLY,
            ""); 

    LineAndPointFormatter series1Format = new LineAndPointFormatter();
    series1Format.setPointLabelFormatter(new PointLabelFormatter());
    series1Format.configure(getActivity().getApplicationContext(), R.xml.line_point_formatter_with_plf1);

    plot.addSeries(series1, series1Format);

    plot.getLegendWidget().setVisible(false); // remove legend

    plot.setRangeStep(XYStepMode.SUBDIVIDE, 3);
    plot.setDomainStep(XYStepMode.SUBDIVIDE, 1);

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

    plot.getGraphWidget().getDomainOriginLabelPaint().setColor(Color.TRANSPARENT);

    plot.getGraphWidget().getBackgroundPaint().setColor(Color.WHITE);
    plot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE);

    plot.setRangeBottomMax(0);
    plot.setRangeTopMin(10);

    plot.getGraphWidget().getDomainGridLinePaint().setColor(Color.BLACK);
    plot.getGraphWidget().getRangeGridLinePaint().setColor(Color.BLUE);

    plot.getGraphWidget().getRangeOriginLinePaint().setColor(Color.GREEN);
    plot.getGraphWidget().getDomainOriginLinePaint().setColor(Color.YELLOW);

    plot.getGraphWidget().getRangeGridLinePaint().setPathEffect(new DashPathEffect(new float[]{6, 10}, 1));

    plot.getGraphWidget().getRangeOriginLabelPaint().setColor(Color.GREEN);
    plot.getGraphWidget().getRangeLabelPaint().setColor(Color.RED);

    plot.getBorderPaint().setColor(Color.RED);

    plot.setPlotMargins(0, 0, 0, 0);
    plot.setPlotPadding(0, 0, 0, 0);

    plot.getGraphWidget().position(
            0, XLayoutStyle.ABSOLUTE_FROM_LEFT,
            0, YLayoutStyle.ABSOLUTE_FROM_TOP,
            AnchorPosition.LEFT_TOP);

    plot.getRangeLabelWidget().position(
            50, XLayoutStyle.ABSOLUTE_FROM_LEFT,
            50, YLayoutStyle.ABSOLUTE_FROM_TOP,
            AnchorPosition.LEFT_TOP);

    //plot.redraw();

    return view;
}

我现在也在使用android plot,在使用它的时候也有一些塞子。但我将根据我的成就部分回答你

  • 移动范围标签是什么意思?要将其移动到y轴的右侧
  • 要删除灰色区域,您可以使用以下代码:
    
    //所有空间的空间
    //值为0的填充模式表示100%填充容器:
    SizeMetrics sm=新的SizeMetrics(0,SizeLayoutType.FILL,0,SizeLayoutType.FILL)
    plot.getGraphWidget().setSize(sm);

  • 您希望只使用一条Y轴网线,还是只隐藏顶部的Y轴网线?如果你有超过3行呢

  • 我最好让标签不可见/消失

我实现了自己的图形库,因为我只需要很少的元素。