@Override
 protected void setupChart() {
   super.setupChart();
   lineChart.setData(setupTheeComponentData("X", "Y", "Z"));
   lineChart.getLegend().setEnabled(true);
   lineChart.getLegend().setPosition(Legend.LegendPosition.BELOW_CHART_LEFT);
   LimitLine line = new LimitLine(FeatureAcceleration.DATA_MIN, "timestamp (ms)");
   line.setLineColor(Color.BLACK);
   line.setLineWidth(1f);
   line.setTextColor(Color.BLACK);
   line.setTextSize(12f);
   line.setLabelPosition(LimitLine.LimitLabelPosition.RIGHT_TOP);
   lineChart.getAxisLeft().addLimitLine(line);
 }
Пример #2
0
  @Override
  public View getView(int position, View convertView, Context c) {

    ViewHolder holder = null;

    if (convertView == null) {

      holder = new ViewHolder();

      convertView = LayoutInflater.from(c).inflate(R.layout.list_item_linechart, null);
      holder.chart = (LineChart) convertView.findViewById(R.id.chart);

      convertView.setTag(holder);

    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    // apply styling
    // holder.chart.setValueTypeface(mTf);
    holder.chart.setDescription("");
    holder.chart.setDrawGridBackground(false);

    XAxis xAxis = holder.chart.getXAxis();
    xAxis.setPosition(XAxisPosition.BOTTOM);
    xAxis.setTypeface(mTf);
    xAxis.setDrawGridLines(false);
    xAxis.setDrawAxisLine(true);

    YAxis leftAxis = holder.chart.getAxisLeft();
    leftAxis.setTypeface(mTf);
    leftAxis.setLabelCount(5, false);

    YAxis rightAxis = holder.chart.getAxisRight();
    rightAxis.setTypeface(mTf);
    rightAxis.setLabelCount(5, false);
    rightAxis.setDrawGridLines(false);

    // set data
    holder.chart.setData((LineData) mChartData);

    // do not forget to refresh the chart
    // holder.chart.invalidate();
    holder.chart.animateX(750);
    // at 20151130
    // at 20151117
    //        if(mType==0) {
    //        	LimitLine ll = new LimitLine(30, "目标温度");
    //        	ll.setLineWidth(4f);
    //        	ll.enableDashedLine(10f, 10f, 0f);
    //        	ll.setLabelPosition(LimitLabelPosition.LEFT_BOTTOM);
    //        	ll.setTextSize(10f);
    //        	leftAxis.addLimitLine(ll);
    //        } else {
    //            LimitLine ll = new LimitLine(60, "目标湿度");
    //            ll.setLineWidth(4f);
    //            ll.enableDashedLine(10f, 10f, 0f);
    //            ll.setLabelPosition(LimitLabelPosition.LEFT_BOTTOM);
    //            ll.setTextSize(10f);
    //            leftAxis.addLimitLine(ll);
    //        }

    // end 20151117
    LimitLine ll = new LimitLine(this.aimValue, this.aimName);
    ll.setLineWidth(4f);
    ll.enableDashedLine(10f, 10f, 0f);
    ll.setLabelPosition(LimitLabelPosition.LEFT_BOTTOM);
    ll.setTextSize(10f);
    leftAxis.addLimitLine(ll);
    // end 20151130
    return convertView;
  }