private void previewY() {
   Viewport tempViewport = new Viewport(recordChart.getMaximumViewport());
   float dy = (tempViewport.height() + 0.2f) / 4;
   tempViewport.inset(0, dy);
   recordPreviewChart.setCurrentViewportWithAnimation(tempViewport);
   recordPreviewChart.setZoomType(ZoomType.VERTICAL);
 }
 private void previewXY() {
   // Better to not modify viewport of any recordChart directly so create a copy.
   Viewport tempViewport = new Viewport(recordChart.getMaximumViewport());
   // Make temp viewport smaller.
   float dx = tempViewport.width() / 4;
   float dy = tempViewport.height() / 4;
   tempViewport.inset(dx, dy);
   recordPreviewChart.setCurrentViewportWithAnimation(tempViewport);
 }
 ///////// VIEWPORT RELATED//////////////
 public Viewport advanceViewport(Chart chart, Chart previewChart) {
   viewport = new Viewport(previewChart.getMaximumViewport());
   viewport.inset((float) ((86400000 / 2.5) / FUZZER), 0);
   double distance_to_move =
       ((new Date().getTime()) / FUZZER)
           - viewport.left
           - (((viewport.right - viewport.left) / 2));
   viewport.offset((float) distance_to_move, 0);
   return viewport;
 }
Ejemplo n.º 4
0
 private void previewX(boolean animate) {
   Viewport tempViewport = new Viewport(chart.getMaximumViewport());
   float dx = tempViewport.width() / 4;
   tempViewport.inset(dx, 0);
   if (animate) {
     previewChart.setCurrentViewportWithAnimation(tempViewport);
   } else {
     previewChart.setCurrentViewport(tempViewport);
   }
   previewChart.setZoomType(ZoomType.HORIZONTAL);
 }
    @Override
    public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      View rootView = inflater.inflate(R.layout.fragment_view_pager_charts, container, false);
      RelativeLayout layout = (RelativeLayout) rootView;
      int sectionNum = getArguments().getInt(ARG_SECTION_NUMBER);
      switch (sectionNum) {
        case 1:
          LineChartView lineChartView = new LineChartView(getActivity());
          lineChartView.setLineChartData(generateLineChartData());
          lineChartView.setZoomType(ZoomType.HORIZONTAL);

          /** Note: Chart is within ViewPager so enable container scroll mode. * */
          lineChartView.setContainerScrollEnabled(true, ContainerScrollType.HORIZONTAL);

          layout.addView(lineChartView);
          break;
        case 2:
          ColumnChartView columnChartView = new ColumnChartView(getActivity());
          columnChartView.setColumnChartData(generateColumnChartData());
          columnChartView.setZoomType(ZoomType.HORIZONTAL);

          /** Note: Chart is within ViewPager so enable container scroll mode. * */
          columnChartView.setContainerScrollEnabled(true, ContainerScrollType.HORIZONTAL);

          layout.addView(columnChartView);
          break;
        case 3:
          BubbleChartView bubbleChartView = new BubbleChartView(getActivity());
          bubbleChartView.setBubbleChartData(generateBubbleChartData());
          bubbleChartView.setZoomType(ZoomType.HORIZONTAL_AND_VERTICAL);

          /** Note: Chart is within ViewPager so enable container scroll mode. * */
          bubbleChartView.setContainerScrollEnabled(true, ContainerScrollType.HORIZONTAL);

          layout.addView(bubbleChartView);
          break;
        case 4:
          PreviewLineChartView previewLineChartView = new PreviewLineChartView(getActivity());
          previewLineChartView.setLineChartData(generatePreviewLineChartData());

          /** Note: Chart is within ViewPager so enable container scroll mode. * */
          previewLineChartView.setContainerScrollEnabled(true, ContainerScrollType.HORIZONTAL);

          Viewport tempViewport = new Viewport(previewLineChartView.getMaximumViewport());
          float dx = tempViewport.width() / 6;
          tempViewport.inset(dx, 0);
          previewLineChartView.setCurrentViewport(tempViewport);
          previewLineChartView.setZoomType(ZoomType.HORIZONTAL);

          layout.addView(previewLineChartView);
          break;
        case 5:
          PieChartView pieChartView = new PieChartView(getActivity());
          pieChartView.setPieChartData(generatePieChartData());

          /** Note: Chart is within ViewPager so enable container scroll mode. * */
          pieChartView.setContainerScrollEnabled(true, ContainerScrollType.HORIZONTAL);

          layout.addView(pieChartView);
          break;
      }

      return rootView;
    }