1
我試圖做到的是:
http://s11.postimg.org/4jfa3bpxf/graph.png,
到目前爲止我有:
http://s23.postimg.org/4tizcnqyj/current_graph.png
(心中永遠的顏色,它是更容易識別不同的組件) 。AndroidPlot造型和定位
我有幾個問題:
- 我想移動的範圍內的標籤,但似乎myPlot.getRangeLabelWidget()位置(< ...>)不動他們
- 。我怎樣才能使灰色區域(白色圖形和紅色邊框之間)消失?我試圖玩所有的邊距/填充沒有成功
- 如何保持只有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;
}
原來我實現了我自己的圖庫,因爲我只需要很少的元素。 – mbmc