2014-06-11 1 views
0

androidplot-core-0.6.1.jar를 사용하고 있으며 빠른 시작 자습서에서 SimpleXYPlotActivity 예제를 수정하고 있습니다. 일부 항목과 여백/패딩을 제거했지만 수행 할 방법과 방법을 찾을 수없는 것은 차트의 왼쪽 공간을 제거하는 것입니다. 아래 이미지에서 빨간색으로 제거 할 공간을 표시했습니다. 이 작업을 수행 할 수 있습니까? 활동에서 Androidplot : 차트의 왼쪽 공간을 제거하십시오.

How it looks

Red shows what I want to remove

코드 :

public class MyXYPlotActivity extends Activity { 

    private XYPlot plot; 

    @Override 
    public void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState); 

     requestWindowFeature(Window.FEATURE_NO_TITLE); 
     getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
     WindowManager.LayoutParams.FLAG_FULLSCREEN); 

     setContentView(R.layout.simple_xy_plot_example); 

     setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); 

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

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

     XYSeries series1 = new SimpleXYSeries(
       Arrays.asList(series1Numbers),   // SimpleXYSeries takes a List so turn our array into a List 
       SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, // Y_VALS_ONLY means use the element index as the x value 
       "Foo");        // Set the display title of the series 

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

     plot.addSeries(series1, series1Format); 

     plot.setDomainValueFormat(new DecimalFormat("#")); 
     plot.setRangeValueFormat(new DecimalFormat("#")); 

     plot.setTitle("Title"); 
     plot.setRangeBoundaries(0,10, BoundaryMode.FIXED); 

     int length = 30; 
     plot.setDomainBoundaries(1,length, BoundaryMode.FIXED); 

     plot.setRangeStep(XYStepMode.INCREMENT_BY_VAL, 1); 

     plot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 1); 

     plot.setMarkupEnabled(true); 

     plot.setTicksPerRangeLabel(1); 
     plot.setTicksPerDomainLabel(1); 
     plot.getGraphWidget().setDomainLabelOrientation(90); 

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

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

     plot.setBorderStyle(Plot.BorderStyle.SQUARE, null, null); 

     plot.getRangeLabelWidget().setHeight(0); 
     plot.getRangeLabelWidget().setWidth(0); 
     plot.getRangeLabelWidget().setPadding(0, 0, 0, 0); 
     plot.getRangeLabelWidget().setMargins(0, 0, 0, 0); 

     plot.getDomainLabelWidget().setHeight(0); 
     plot.getDomainLabelWidget().setWidth(0); 
     plot.getDomainLabelWidget().setPadding(0, 0, 0, 0); 
     plot.getDomainLabelWidget().setMargins(0, 0, 0, 0); 

    } 
} 

편집 :

XYGraphWidget g = plot.getGraphWidget(); 
g.setRangeLabelWidth(25); 
g.setDomainLabelWidth(25); 

이 위 작품 : 나는 해결책을 찾아 냈다.

답변

0

그래프 위젯의 여백 및/또는 패딩을 줄이거 나 제거하려는 것처럼 보입니다.

plot.getGraphWidget().setMarginLeft(0); 
plot.getGraphWidget().setPaddingLeft(0); 

는 또한 이러한 유사한 질문에서 살펴 :

귀하의 응용 프로그램에 적합 제로가 아닌 값을 사용할 필요가 분명히 있습니다 ... 그것은 원하는 효과를가 있는지 확인하려면 코드에 다음을 추가하십시오

Have a GraphWidget fill the entire View in AndroidPlot

How do I remove all space around a chart in AndroidPlot?

+0

setMarginsLeft (0)와 setPaddingLeft (0) – BlueCat

+0

당신이 정교한 원하는 효과가 없었어요? 효과가 없습니까, 효과가 너무 많았습니까, 너무 적 었습니까, 원하는 영역 또는 위의 일부 조합에 맞지 않았습니까? – Nick

+0

Nick : 코드를 사용해 보았지만 시각적으로 전혀 변화가 없었습니다. 내가 제공 한 링크 중 하나를 확인하고 일부를 둘러보고 나서 작업 한 것을 발견했습니다. 솔루션을 포함하도록 초기 질문을 편집했습니다. 고맙습니다. – BlueCat