Exemplo n.º 1
0
  private LineDataSet createSet() {
    LineDataSet set = new LineDataSet(null, "Dynamic Data");
    set.setAxisDependency(YAxis.AxisDependency.LEFT);
    set.setColor(ColorTemplate.getHoloBlue());
    set.setCircleColor(Color.WHITE);
    set.setLineWidth(2f);
    set.setCircleSize(4f);
    set.setFillAlpha(65);
    set.setFillColor(ColorTemplate.getHoloBlue());
    set.setHighLightColor(Color.rgb(244, 117, 117));
    set.setValueTextColor(Color.WHITE);
    set.setValueTextSize(9f);
    set.setDrawValues(false);

    return set;
  }
  private void setData(int start, int count, float range) {

    ArrayList<String> xVals = new ArrayList<String>();
    for (int i = 0; i < count; i++) {
      xVals.add((start + i) + "日");
    }

    ArrayList<Entry> vals1 = new ArrayList<Entry>();

    for (int i = 0; i < count; i++) {
      vals1.add(new Entry(TurnControl.PunchPerDay[9 - i], i));
    }

    // create a dataset and give it a type
    LineDataSet set1 = new LineDataSet(vals1, "近期打卡情况");
    set1.setDrawCubic(true);
    set1.setCubicIntensity(0.2f);
    set1.setDrawFilled(true);
    set1.setDrawCircles(true);
    set1.setLineWidth(2f);
    set1.setCircleSize(5f);
    set1.setHighLightColor(Color.rgb(244, 117, 117));
    set1.setColor(Color.rgb(104, 241, 175));
    set1.setFillColor(ColorTemplate.getHoloBlue());

    // create a data object with the datasets
    LineData data = new LineData(xVals, set1);
    data.setValueTypeface(tf);
    data.setValueTextSize(9f);
    data.setDrawValues(false);

    // set data
    mChart.setData(data);
  }
Exemplo n.º 3
0
  private LineDataSet createSet() {

    LineDataSet set = new LineDataSet(null, "Realtime Beschleunigungskraefte");
    set.setDrawCubic(true);
    set.setCubicIntensity(0.2f);
    set.setAxisDependency(YAxis.AxisDependency.LEFT);
    set.setColor(ColorTemplate.getHoloBlue());
    set.setCircleColor(Color.BLACK);
    set.setLineWidth(2f);
    set.setCircleSize(4f);
    set.setFillAlpha(65);
    set.setFillColor(ColorTemplate.getHoloBlue());
    set.setHighLightColor(Color.rgb(244, 117, 117));
    set.setValueTextColor(Color.BLACK);
    set.setValueTextSize(10f);
    return set;
  }
Exemplo n.º 4
0
 private SpannableString generateCenterText() {
   SpannableString s = new SpannableString("Food Waste\\ndistribution");
   s.setSpan(new RelativeSizeSpan(1.6f), 0, 14, 0);
   s.setSpan(new ForegroundColorSpan(ColorTemplate.VORDIPLOM_COLORS[0]), 0, 14, 0);
   s.setSpan(new RelativeSizeSpan(1.4f), 25, s.length(), 0);
   s.setSpan(new ForegroundColorSpan(ColorTemplate.getHoloBlue()), 25, s.length(), 0);
   return s;
 }
Exemplo n.º 5
0
  private void setData() {

    // LINE-CHART
    RealmResults<Score> results = mRealm.allObjects(Score.class);

    RealmLineDataSet<Score> lineDataSet =
        new RealmLineDataSet<Score>(results, "totalScore", "scoreNr");
    lineDataSet.setDrawCubic(false);
    lineDataSet.setLabel("Realm LineDataSet");
    lineDataSet.setDrawCircleHole(false);
    lineDataSet.setColor(ColorTemplate.rgb("#FF5722"));
    lineDataSet.setCircleColor(ColorTemplate.rgb("#FF5722"));
    lineDataSet.setLineWidth(1.8f);
    lineDataSet.setCircleSize(3.6f);

    ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
    dataSets.add(lineDataSet);

    RealmLineData lineData = new RealmLineData(results, "playerName", dataSets);
    styleData(lineData);

    // set data
    lineChart.setData(lineData);
    lineChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);

    // BAR-CHART
    RealmBarDataSet<Score> barDataSet =
        new RealmBarDataSet<Score>(results, "totalScore", "scoreNr");
    barDataSet.setColors(new int[] {ColorTemplate.rgb("#FF5722"), ColorTemplate.rgb("#03A9F4")});
    barDataSet.setLabel("Realm BarDataSet");

    ArrayList<IBarDataSet> barDataSets = new ArrayList<IBarDataSet>();
    barDataSets.add(barDataSet);

    RealmBarData barData = new RealmBarData(results, "playerName", barDataSets);
    styleData(barData);

    barChart.setData(barData);
    barChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
  }
Exemplo n.º 6
0
  public void addData() {
    ArrayList<Entry> yVals1 = new ArrayList<Entry>();

    for (int i = 0; i < yData.length; i++) yVals1.add(new Entry(yData[i], i));

    ArrayList<String> xVals = new ArrayList<String>();

    for (int i = 0; i < xData.length; i++) xVals.add(xData[i]);

    // create pie data set
    PieDataSet dataSet = new PieDataSet(yVals1, "Sentiment");
    dataSet.setSliceSpace(3);
    dataSet.setSelectionShift(5);

    // add many colors
    ArrayList<Integer> colors = new ArrayList<Integer>();

    for (int c : ColorTemplate.VORDIPLOM_COLORS) colors.add(c);

    for (int c : ColorTemplate.JOYFUL_COLORS) colors.add(c);
    for (int c : ColorTemplate.COLORFUL_COLORS) colors.add(c);

    for (int c : ColorTemplate.LIBERTY_COLORS) colors.add(c);
    for (int c : ColorTemplate.PASTEL_COLORS) colors.add(c);
    colors.add(ColorTemplate.getHoloBlue());
    dataSet.setColors(colors);

    // instantiate pie data object
    PieData data = new PieData(xVals, dataSet);
    data.setValueFormatter(new PercentFormatter());
    data.setValueTextSize(11f);
    data.setValueTextColor(Color.GRAY);

    mChart.setData(data);

    // undo all highlights
    mChart.highlightValue(null);

    // update pie chart
    mChart.invalidate();

    /* FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });*/
  }
  private void setData() {
    RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();

    RealmLineDataSet<RealmDemoData> set =
        new RealmLineDataSet<RealmDemoData>(result, "xValue", "yValue");
    set.setDrawCubic(false);
    set.setLabel("Realm LineDataSet");
    set.setDrawCircleHole(false);
    set.setColor(ColorTemplate.rgb("#FF5722"));
    set.setCircleColor(ColorTemplate.rgb("#FF5722"));
    set.setLineWidth(1.8f);
    //        set.setCircleSize(3.6f); // TODO

    ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
    dataSets.add(set); // add the dataset

    // create a data object with the dataset list
    LineData data = new LineData(dataSets);
    styleData(data);

    // set data
    mChart.setData(data);
    mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
  }
Exemplo n.º 8
0
  /**
   * Busca o dataset para colocar no grafico PIE
   *
   * @param gastos gastos do pollitico selecionado
   * @return dataset
   */
  public PieData pieDataGastos(List<ParseObject> gastos) {
    ArrayList<Entry> yVals1 = new ArrayList<Entry>();

    // IMPORTANT: In a PieChart, no values (Entry) should have the same
    // xIndex (even if from different DataSets), since no values can be
    // drawn above each other.
    for (int i = 0; i < gastos.size(); i++) {
      yVals1.add(new Entry(gastos.get(i).getNumber("total").floatValue(), i));
    }

    ArrayList<String> xVals = new ArrayList<String>();

    for (int i = 0; i < gastos.size(); i++) xVals.add(gastos.get(i).getString("tpCota"));

    PieDataSet dataSet = new PieDataSet(yVals1, "Gastos");
    dataSet.setSliceSpace(2f);
    dataSet.setSelectionShift(5f);

    // add a lot of colors

    ArrayList<Integer> colors = new ArrayList<Integer>();

    // for (int c : ColorTemplate.VORDIPLOM_COLORS)
    //   colors.add(c);

    for (int c : ColorTemplate.JOYFUL_COLORS) colors.add(c);

    for (int c : ColorTemplate.COLORFUL_COLORS) colors.add(c);

    for (int c : ColorTemplate.LIBERTY_COLORS) colors.add(c);

    for (int c : ColorTemplate.PASTEL_COLORS) colors.add(c);

    colors.add(ColorTemplate.getHoloBlue());

    dataSet.setColors(colors);
    // dataSet.setSelectionShift(0f);

    PieData data = new PieData(xVals, dataSet);
    data.setValueFormatter(new PercentFormatter());
    data.setValueTextSize(11f);
    data.setValueTextColor(Color.WHITE);
    data.setValueTypeface(tf);
    return data;
  }
  private void initPieChartData() {
    // add a lot of colors
    for (int c : ColorTemplate.JOYFUL_COLORS) {
      colors.add(c);
    }
    for (int c : ColorTemplate.VORDIPLOM_COLORS) {
      colors.add(c);
    }
    for (int c : ColorTemplate.COLORFUL_COLORS) {
      colors.add(c);
    }
    for (int c : ColorTemplate.LIBERTY_COLORS) {
      colors.add(c);
    }
    for (int c : ColorTemplate.PASTEL_COLORS) {
      colors.add(c);
    }
    colors.add(ColorTemplate.getHoloBlue());

    new QueryDataTask().execute();
  }
Exemplo n.º 10
0
  private void setPieChartData(Map obj, int sum) {

    Iterator it = obj.keySet().iterator();

    int count = obj.keySet().size();

    if (count > 0) {
      float range = sum;

      float mult = range;

      ArrayList<Entry> yVals1 = new ArrayList<Entry>();

      ArrayList<String> xVals = new ArrayList<String>();

      // for (int i = 0; i < count + 1; i++)
      // xVals.add("A");

      int idx = 0;

      while (it.hasNext()) {
        String key = it.next().toString();
        int value = (int) Float.parseFloat(obj.get(key).toString());

        float yVal = (value / mult) * 100;

        yVals1.add(new Entry((float) yVal, idx));

        for (int i = 0; i < mKeywords.size(); i++) {
          KeywordIcon icon = mKeywords.get(i);
          if (key.equals(icon.get_id())) {
            xVals.add(icon.getKeyword());
            continue;
          }
        }

        idx++;
      }

      PieDataSet dataSet = new PieDataSet(yVals1, "");
      dataSet.setSliceSpace(3f);
      dataSet.setSelectionShift(5f);

      // add a lot of colors

      ArrayList<Integer> colors = new ArrayList<Integer>();

      for (int c : ColorTemplate.VORDIPLOM_COLORS) colors.add(c);

      for (int c : ColorTemplate.JOYFUL_COLORS) colors.add(c);

      for (int c : ColorTemplate.COLORFUL_COLORS) colors.add(c);

      for (int c : ColorTemplate.LIBERTY_COLORS) colors.add(c);

      for (int c : ColorTemplate.PASTEL_COLORS) colors.add(c);

      colors.add(ColorTemplate.getHoloBlue());

      dataSet.setColors(colors);

      PieData data = new PieData(xVals, dataSet);
      data.setValueFormatter(new PercentFormatter());
      data.setValueTextSize(11f);
      data.setValueTextColor(Color.BLACK);
      // data.setValueTypeface(tf);
      mPieChart.setData(data);

      // undo all highlights
      mPieChart.highlightValues(null);

      mPieChart.invalidate();
    }
  }
Exemplo n.º 11
0
  // page 页数 receivedMum收到赞或评论个数 sendNum点赞或评论个数 sex性别1男2女
  private void setData(int page, int receivedMum, int sendNum, int sex) {

    switch (page) {
      case 0:
        tv_received.setText("收到的赞");
        tv_send.setText("发出的赞");
        break;
      case 1:
        tv_received.setText("收到评论");
        tv_send.setText("发出评论");
        break;

      default:
        break;
    }

    switch (sex) {
      case 1: // 男
        switch (page) {
          case 0:
            if (receivedMum >= sendNum) {
              img_head.setImageResource(R.drawable.praise_man);
            } else {
              img_head.setImageResource(R.drawable.thumb_up_man);
            }
            break;
          case 1:
            if (receivedMum >= sendNum) {
              img_head.setImageResource(R.drawable.good_comments_man);
            } else {
              img_head.setImageResource(R.drawable.comments_man);
            }
            break;

          default:
            break;
        }

        break;

      case 2: // 女
        switch (page) {
          case 0:
            if (receivedMum >= sendNum) {
              img_head.setImageResource(R.drawable.praise_women);
            } else {
              img_head.setImageResource(R.drawable.thumb_up_women);
            }
            break;
          case 1:
            if (receivedMum >= sendNum) {
              img_head.setImageResource(R.drawable.good_comments_women);
            } else {
              img_head.setImageResource(R.drawable.comments_women);
            }
            break;

          default:
            break;
        }
        break;

      default:
        break;
    }

    tv_received_num.setText(receivedMum + "");
    tv_send_num.setText(sendNum + "");

    ArrayList<Entry> yVals1 = new ArrayList<Entry>();
    yVals1.add(new Entry((float) receivedMum / (receivedMum + sendNum), 0));
    yVals1.add(new Entry((float) sendNum / (receivedMum + sendNum), 1));

    ArrayList<String> xVals = new ArrayList<String>();

    for (int i = 0; i < 2; i++) xVals.add(mParties[i % mParties.length]);

    PieDataSet dataSet = new PieDataSet(yVals1, "");
    dataSet.setSliceSpace(3f);
    dataSet.setSelectionShift(5f);
    ArrayList<Integer> colors = new ArrayList<Integer>();

    colors.add(Color.parseColor("#81c31c"));
    colors.add(Color.parseColor("#3eaedb"));
    colors.add(ColorTemplate.getHoloBlue());

    dataSet.setColors(colors);

    PieData data = new PieData(xVals, dataSet);
    data.setValueFormatter(new PercentFormatter());
    data.setValueTextSize(15f);
    data.setValueTextColor(Color.WHITE);
    mChart.setData(data);
    mChart.highlightValues(null);
    mChart.invalidate();

    mChart.animateY(2000, Easing.EasingOption.EaseInOutQuad);
    mChart.getLegend().setEnabled(false);
  }