private View createPieChart() {
   String[] code = new String[] {"eclair", "froyo"};
   double[] distribution = {20.0, 40.0};
   int[] color = {Color.WHITE, getResources().getColor(R.color.button_signup_color)};
   CategorySeries distributionSeries = new CategorySeries("Top Blocked Number");
   for (int i = 0; i < distribution.length; i++) {
     distributionSeries.add(code[i], distribution[i]);
   }
   DefaultRenderer defaultRenderer = new DefaultRenderer();
   for (int i = 0; i < distribution.length; i++) {
     SimpleSeriesRenderer seriesRenderer = new SimpleSeriesRenderer();
     seriesRenderer.setColor(color[i]);
     seriesRenderer.setShowLegendItem(false);
     defaultRenderer.addSeriesRenderer(seriesRenderer);
   }
   defaultRenderer.setDisplayValues(false);
   defaultRenderer.setShowLabels(false);
   defaultRenderer.setPanEnabled(false);
   defaultRenderer.setZoomEnabled(false);
   /*defaultRenderer.setChartTitle("Top Blocked Number");
   defaultRenderer.setChartTitleTextSize(20F);
   defaultRenderer.setDisplayValues(true);
   */
   return ChartFactory.getPieChartView(
       getActivity().getApplicationContext(), distributionSeries, defaultRenderer);
 }
    private void drawChart() {
      DefaultRenderer render = new DefaultRenderer();

      CategorySeries incomeSeries = getDataSet();

      for (int i = 0; i < incomeSeries.getItemCount(); i++) {
        SimpleSeriesRenderer incomeSeriesRenderer = new SimpleSeriesRenderer();
        incomeSeriesRenderer.setColor(GraphsHelper.getColorCode(i));
        render.addSeriesRenderer(incomeSeriesRenderer);
      }

      render.setInScroll(true);
      render.setPanEnabled(true);
      render.setClickEnabled(false);
      render.setChartTitleTextSize(26);
      render.setShowLabels(true);
      render.setShowLegend(true);
      render.setShowGrid(true);
      render.setBackgroundColor(Color.BLACK);
      render.setLabelsTextSize(26);
      render.setLabelsColor(Color.BLACK);
      render.setLegendTextSize(26);
      render.setZoomButtonsVisible(true);

      GraphicalView chartView;

      chartView = ChartFactory.getPieChartView(getActivity(), getDataSet(), render);

      LinearLayout layout = (LinearLayout) getActivity().findViewById(R.id.dashboard_chart_layout);
      layout.removeAllViews();
      layout.addView(
          chartView, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT));
    }
 private View CategoryStatistics() {
   int[] _Color =
       new int[] {
         Color.parseColor("#FF5552"),
         Color.parseColor("#2A94F1"),
         Color.parseColor("#F12792"),
         Color.parseColor("#FFFF52"),
         Color.parseColor("#84D911"),
         Color.parseColor("#5255FF")
       };
   DefaultRenderer _DefaultRenderer = BuildCategoryRenderer(_Color);
   CategorySeries _CategorySeries = _BuildCategoryDataset("消费类别统计", mModelCategoryTotal);
   View _PieView = ChartFactory.getPieChartView(this, _CategorySeries, _DefaultRenderer);
   return _PieView;
 }
Beispiel #4
0
  @Override
  protected void onResume() {
    super.onResume();

    if (mChartView == null) {
      LinearLayout layout = (LinearLayout) findViewById(R.id.chart);
      mChartView = ChartFactory.getPieChartView(this, mSeries, mRenderer);
      mRenderer.setClickEnabled(true);

      mChartView.setOnLongClickListener(
          new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
              SeriesSelection seriesSelection = mChartView.getCurrentSeriesAndPoint();
              if (seriesSelection == null) {
                mChartView.repaint();
              } else {
                for (int i = 0; i < mSeries.getItemCount(); i++) {
                  mRenderer
                      .getSeriesRendererAt(i)
                      .setHighlighted(i == seriesSelection.getPointIndex());
                  getcategoryofclicked = mSeries.getCategory(seriesSelection.getPointIndex());
                }
                mChartView.repaint();

                Intent intent = new Intent(getApplicationContext(), PieChartDetails.class);
                intent.putExtra("selectedCategory", getcategoryofclicked);
                intent.putExtra("selectedDate", mdate);

                startActivity(intent);
              }
              return true;
            }
          });

      layout.addView(
          mChartView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
      if (mSeries.getItemCount() == 0)
        textView1.setText("Hey you have not added any data\n\t\tPlease add some");
    } else {
      mChartView.repaint();
    }
  }
Beispiel #5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_room_detail);

    Bundle Title = getIntent().getExtras();
    if (Title != null) {
      mPlace = Title.getString(Constants.PLACE);
    }

    mRoomNameView = (TextView) findViewById(R.id.detail_roomname);
    mSeatnumbnerView = (TextView) findViewById(R.id.detail_seatnumber);
    mDescriptionView = (TextView) findViewById(R.id.detail_description);
    mImageView = (ImageView) findViewById(R.id.detailed_image);
    mHistoryButton = (Button) findViewById(R.id.history_button);

    mPersistanceManager = new PersistanceManager(this);
    r = mPersistanceManager.getCurrentRoom();

    mRoomNameView.setText(r.getName());
    mSeatnumbnerView.setText(r.getNumberOfSeat());
    mDescriptionView.setText(r.getDescription());

    // set the achartengine pie chart parameters, including color, lable size as well as items shown
    // options
    double taken = Double.parseDouble(r.getFullness());
    double notTaken = 100 - taken;
    double[] PIECHARTVALUES = new double[] {taken, notTaken};

    mRenderer.setApplyBackgroundColor(true);
    mRenderer.setBackgroundColor(Color.argb(100, 50, 50, 50));
    mRenderer.setChartTitleTextSize(20);
    mRenderer.setLabelsTextSize(50);
    mRenderer.setShowLegend(false);
    mRenderer.setShowTickMarks(false);
    mRenderer.setZoomButtonsVisible(true);
    mRenderer.setStartAngle(90);

    // show the percentage
    for (int i = 0; i < PIECHARTVALUES.length; i++) {
      mSeries.add(NAME_LIST[i] + " " + PIECHARTVALUES[i] + "%", PIECHARTVALUES[i]);
      SimpleSeriesRenderer renderer = new SimpleSeriesRenderer();
      renderer.setColor(COLORS[(mSeries.getItemCount() - 1) % COLORS.length]);
      mRenderer.addSeriesRenderer(renderer);
    }

    if (mChartView != null) {
      mChartView.repaint();
    }

    // load the pie chart layout with the parameters in mRenderer and mSeries we set before.
    LinearLayout layout = (LinearLayout) findViewById(R.id.chart);
    mChartView = ChartFactory.getPieChartView(this, mSeries, mRenderer);
    mRenderer.setClickEnabled(true);
    mRenderer.setSelectableBuffer(10);

    layout.addView(
        mChartView,
        new AbsListView.LayoutParams(
            AbsListView.LayoutParams.FILL_PARENT, AbsListView.LayoutParams.FILL_PARENT));

    if (!r.getImage().equals("")) {
      Ion.with(mImageView)
          .load(r.getImage())
          .setCallback(
              new FutureCallback<ImageView>() {
                @Override
                public void onCompleted(Exception e, ImageView result) {
                  if (e == null) {
                    // yay

                  } else {
                    // log the error information , helping to check. Then keep running app without
                    // image
                    Log.d(TAG, "image failed to load " + e.toString());
                  }
                }
              });
    }

    // set the extre before going to history activity, helping to save which building and which room
    // to load.
    mHistoryButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(getBaseContext(), HistoryActivity.class);
            intent.putExtra(Constants.ROOM, r.getName());
            intent.putExtra(Constants.PLACE, mPlace);
            startActivity(intent);
          }
        });
  }