我试图做到这一点:
http://s11.postimg.org/4jfa3bpxf/graph.png,
到目前为止我有这个:
http://s23.postimg.org/4tizcnqyj/current_graph.png
(不要介意颜色,以便更容易识别不同的组件)。
我几乎没有问题:
提前致谢!
@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;
}
答案 0 :(得分:0)
我现在正在使用android plot,并且在使用它时也有一些塞子。但我会根据我的成就部分回答你。
要删除灰色区域,您可以使用以下代码:
//space for all space
// FILL mode with values of 0 means fill 100% of container:
SizeMetrics sm = new SizeMetrics(0, SizeLayoutType.FILL, 0, SizeLayoutType.FILL);
plot.getGraphWidget().setSize(sm);
您想要只有一个Y网格线还是只隐藏顶部网格线?如果您有超过3行怎么办?