Java Examples for com.github.mikephil.charting.charts.LineChart

The following java examples will help you to understand the usage of com.github.mikephil.charting.charts.LineChart. These source code samples are taken from different open source projects.

Example 1
Project: MPAndroidChart-master  File: LineChartActivity1.java View source code
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_linechart);
    tvX = (TextView) findViewById(R.id.tvXMax);
    tvY = (TextView) findViewById(R.id.tvYMax);
    mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
    mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
    mSeekBarX.setProgress(45);
    mSeekBarY.setProgress(100);
    mSeekBarY.setOnSeekBarChangeListener(this);
    mSeekBarX.setOnSeekBarChangeListener(this);
    mChart = (LineChart) findViewById(R.id.chart1);
    mChart.setOnChartGestureListener(this);
    mChart.setOnChartValueSelectedListener(this);
    mChart.setDrawGridBackground(false);
    // no description text
    mChart.getDescription().setEnabled(false);
    // enable touch gestures
    mChart.setTouchEnabled(true);
    // enable scaling and dragging
    mChart.setDragEnabled(true);
    mChart.setScaleEnabled(true);
    // mChart.setScaleXEnabled(true);
    // mChart.setScaleYEnabled(true);
    // if disabled, scaling can be done on x- and y-axis separately
    mChart.setPinchZoom(true);
    // set an alternative background color
    // mChart.setBackgroundColor(Color.GRAY);
    // create a custom MarkerView (extend MarkerView) and specify the layout
    // to use for it
    MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view);
    // For bounds control
    mv.setChartView(mChart);
    // Set the marker to the chart
    mChart.setMarker(mv);
    // x-axis limit line
    LimitLine llXAxis = new LimitLine(10f, "Index 10");
    llXAxis.setLineWidth(4f);
    llXAxis.enableDashedLine(10f, 10f, 0f);
    llXAxis.setLabelPosition(LimitLabelPosition.RIGHT_BOTTOM);
    llXAxis.setTextSize(10f);
    XAxis xAxis = mChart.getXAxis();
    xAxis.enableGridDashedLine(10f, 10f, 0f);
    //xAxis.setValueFormatter(new MyCustomXAxisValueFormatter());
    //xAxis.addLimitLine(llXAxis); // add x-axis limit line
    Typeface tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
    LimitLine ll1 = new LimitLine(150f, "Upper Limit");
    ll1.setLineWidth(4f);
    ll1.enableDashedLine(10f, 10f, 0f);
    ll1.setLabelPosition(LimitLabelPosition.RIGHT_TOP);
    ll1.setTextSize(10f);
    ll1.setTypeface(tf);
    LimitLine ll2 = new LimitLine(-30f, "Lower Limit");
    ll2.setLineWidth(4f);
    ll2.enableDashedLine(10f, 10f, 0f);
    ll2.setLabelPosition(LimitLabelPosition.RIGHT_BOTTOM);
    ll2.setTextSize(10f);
    ll2.setTypeface(tf);
    YAxis leftAxis = mChart.getAxisLeft();
    // reset all limit lines to avoid overlapping lines
    leftAxis.removeAllLimitLines();
    leftAxis.addLimitLine(ll1);
    leftAxis.addLimitLine(ll2);
    leftAxis.setAxisMaximum(200f);
    leftAxis.setAxisMinimum(-50f);
    //leftAxis.setYOffset(20f);
    leftAxis.enableGridDashedLine(10f, 10f, 0f);
    leftAxis.setDrawZeroLine(false);
    // limit lines are drawn behind data (and not on top)
    leftAxis.setDrawLimitLinesBehindData(true);
    mChart.getAxisRight().setEnabled(false);
    //mChart.getViewPortHandler().setMaximumScaleY(2f);
    //mChart.getViewPortHandler().setMaximumScaleX(2f);
    // add data
    setData(45, 100);
    //        mChart.setVisibleXRange(20);
    //        mChart.setVisibleYRange(20f, AxisDependency.LEFT);
    //        mChart.centerViewTo(20, 50, AxisDependency.LEFT);
    mChart.animateX(2500);
    //mChart.invalidate();
    // get the legend (only possible after setting data)
    Legend l = mChart.getLegend();
    // modify the legend ...
    l.setForm(LegendForm.LINE);
// // dont forget to refresh the drawing
// mChart.invalidate();
}
Example 2
Project: asamples-master  File: ChartMain.java View source code
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_chart, container, false);
    chart = (LineChart) rootView.findViewById(R.id.chart);
    chart.setDrawLegend(false);
    chart.animateX(3000);
    chart.setDescription("");
    chart.setDrawVerticalGrid(false);
    chart.setDrawHorizontalGrid(false);
    chart.setDrawYLabels(false);
    chart.setNoDataTextDescription("Loading...");
    chart.setDrawBorder(false);
    GetForecastTask mt = new GetForecastTask(0, 0, this);
    mt.execute();
    return rootView;
}
Example 3
Project: haveyourbac-master  File: CloseTabScreen.java View source code
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_close_tab_screen);
    mChart = (LineChart) findViewById(R.id.ourChart);
    // if enabled, the chart will always start at zero on the y-axis
    mChart.setStartAtZero(true);
    // disable the drawing of values into the chart
    mChart.setDrawYValues(false);
    mChart.setDrawBorder(false);
    mChart.setDrawLegend(false);
    // no description text
    mChart.setDescription("");
    mChart.setUnit(" ");
    // enable value highlighting
    mChart.setHighlightEnabled(true);
    // enable touch gestures
    mChart.setTouchEnabled(true);
    // enable scaling and dragging
    mChart.setDragEnabled(true);
    mChart.setScaleEnabled(true);
    // if disabled, scaling can be done on x- and y-axis separately
    mChart.setPinchZoom(false);
    mChart.setDrawGridBackground(false);
    mChart.setDrawVerticalGrid(false);
    Typeface tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
    mChart.setValueTypeface(tf);
    XLabels x = mChart.getXLabels();
    x.setTypeface(tf);
    YLabels y = mChart.getYLabels();
    y.setTypeface(tf);
    y.setLabelCount(5);
    // add data
    setData(12, 10);
    mChart.animateXY(2000, 2000);
    // dont forget to refresh the drawing
    mChart.invalidate();
}
Example 4
Project: opentraining-master  File: DialogFragmentHistory.java View source code
@SuppressLint("SimpleDateFormat")
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (mFex.getTrainingEntryList().isEmpty()) {
        return new AlertDialog.Builder(getActivity()).setMessage(getString(R.string.no_other_training_entries)).setPositiveButton(getString(android.R.string.ok), new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        }).setCancelable(true).create();
    }
    LayoutInflater inflater = LayoutInflater.from(getActivity());
    final View v = inflater.inflate(R.layout.dialog_training_history_layout, null);
    LineChart mLineChart = (LineChart) v.findViewById(R.id.chart);
    ArrayList<LineDataSet> dataSets = new ArrayList<LineDataSet>();
    ArrayList<Entry> durationList = new ArrayList<Entry>();
    ArrayList<Entry> weightList = new ArrayList<Entry>();
    ArrayList<Entry> repList = new ArrayList<Entry>();
    ArrayList<String> xVals = new ArrayList<String>();
    int setParameterNumber = 0;
    for (TrainingEntry entry : mFex.getTrainingEntryList()) {
        int setNumber = 0;
        for (FSet fset : entry.getFSetList()) {
            // skip sets that haven't been done
            if (!entry.hasBeenDone(fset))
                continue;
            // x value: date
            DateFormat dateformat = new SimpleDateFormat("dd.MM");
            xVals.add(dateformat.format(entry.getDate()) + " (" + setNumber + ")");
            // y values: weight, rep, duration
            for (SetParameter parameter : fset.getSetParameters()) {
                Entry e = new Entry(parameter.getValue(), setParameterNumber);
                if (parameter instanceof SetParameter.Duration) {
                    durationList.add(e);
                } else if (parameter instanceof SetParameter.Repetition) {
                    repList.add(e);
                } else if (parameter instanceof SetParameter.Weight) {
                    e = new Entry(parameter.getValue() / 1000, setParameterNumber);
                    weightList.add(e);
                } else {
                    Log.e(TAG, "Unknown Parameter Type!");
                }
            }
            setParameterNumber++;
            setNumber++;
        }
    }
    LineDataSet dataSetWeight = new LineDataSet(weightList, getString(R.string.weight));
    dataSetWeight.setColors(new int[] { android.R.color.holo_blue_light }, getActivity());
    LineDataSet dataSetRep = new LineDataSet(repList, getString(R.string.repetitions));
    dataSetRep.setColors(new int[] { android.R.color.holo_red_light }, getActivity());
    LineDataSet dataSetDur = new LineDataSet(durationList, getString(R.string.duration));
    dataSetDur.setColors(new int[] { android.R.color.holo_green_light }, getActivity());
    dataSets.add(dataSetWeight);
    dataSets.add(dataSetRep);
    dataSets.add(dataSetDur);
    LineData data = new LineData(xVals, dataSets);
    mLineChart.setData(data);
    mLineChart.setDescription(getString(R.string.history));
    return new AlertDialog.Builder(getActivity()).setView(v).setCancelable(false).create();
}
Example 5
Project: Surviving-with-android-master  File: ChartFragment.java View source code
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View v = inflater.inflate(R.layout.fragment_chart, container, false);
    tempChart = (LineChart) v.findViewById(R.id.chartTemp);
    humChart = (BarChart) v.findViewById(R.id.chartPress);
    initChartTemp(tempChart);
    initChartBar(humChart);
    (new UbidotsClient()).handleUbidots(tempVarId, API_KEY, new UbidotsClient.UbiListener() {

        @Override
        public void onDataReady(List<UbidotsClient.Value> result) {
            Log.d("Chart", "======== On data Ready ===========");
            List<Entry> entries = new ArrayList();
            List<String> labels = new ArrayList<String>();
            for (int i = 0; i < result.size(); i++) {
                Entry be = new Entry(result.get(i).value, i);
                entries.add(be);
                Log.d("Chart", be.toString());
                // Convert timestamp to date
                Date d = new Date(result.get(i).timestamp);
                // Create Labels
                labels.add(sdf.format(d));
            }
            LineDataSet lse = new LineDataSet(entries, "Tempearature");
            lse.setDrawHighlightIndicators(false);
            lse.setDrawValues(false);
            lse.setColor(Color.RED);
            lse.setCircleColor(Color.RED);
            lse.setLineWidth(1f);
            lse.setCircleSize(3f);
            lse.setDrawCircleHole(false);
            lse.setFillAlpha(65);
            lse.setFillColor(Color.RED);
            LineData ld = new LineData(labels, lse);
            tempChart.setData(ld);
            Handler handler = new Handler(ChartFragment.this.getActivity().getMainLooper());
            handler.post(new Runnable() {

                @Override
                public void run() {
                    tempChart.invalidate();
                }
            });
        }
    });
    // Pressure
    (new UbidotsClient()).handleUbidots(humVarId, API_KEY, new UbidotsClient.UbiListener() {

        @Override
        public void onDataReady(List<UbidotsClient.Value> result) {
            Log.d("Chart", "======== On data Ready ===========");
            List<BarEntry> entries = new ArrayList();
            List<String> labels = new ArrayList<String>();
            for (int i = 0; i < result.size(); i++) {
                BarEntry be = new BarEntry(result.get(i).value, i);
                entries.add(be);
                Log.d("Chart", be.toString());
                // Convert timestamp to date
                Date d = new Date(result.get(i).timestamp);
                // Create Labels
                labels.add(sdf.format(d));
            }
            BarDataSet lse = new BarDataSet(entries, "Humidity");
            lse.setDrawValues(false);
            lse.setColor(Color.BLUE);
            BarData bd = new BarData(labels, lse);
            humChart.setData(bd);
            Handler handler = new Handler(ChartFragment.this.getActivity().getMainLooper());
            handler.post(new Runnable() {

                @Override
                public void run() {
                    humChart.invalidate();
                }
            });
        }
    });
    return v;
}
Example 6
Project: CarAssistant-master  File: LineChartDisplayImpl.java View source code
@Override
public void init(LineChart chart, boolean touchEnable) {
    super.init(chart, touchEnable);
    //超过这个值,�显示value
    chart.setMaxVisibleValueCount(MAX_VISIBLE_VALUE_COUNT * 2);
    chart.setDrawGridBackground(false);
    if (touchEnable) {
        // enable scaling and dragging
        // lineChart.setDragEnabled(true);
        // lineChart.setScaleEnabled(true);
        // lineChart.setHighlightPerDragEnabled(true);
        // if disabled, scaling can be done on x- and y-axis separately
        chart.setPinchZoom(true);
    }
    YAxis leftAxis = chart.getAxisLeft();
    leftAxis.setAxisMinimum(1);
    leftAxis.setTextSize(mAxisSize);
    leftAxis.enableGridDashedLine(10f, 10f, 0f);
    leftAxis.setTextColor(Util.getColor(mAppContext, R.color.gray_dark));
    chart.getAxisRight().setEnabled(false);
    XAxis xAxis = chart.getXAxis();
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setDrawGridLines(false);
    xAxis.setTextSize(mAxisSize);
    xAxis.setAxisMinimum(MINIMUM_VALUE);
    xAxis.setTextColor(Util.getColor(mAppContext, R.color.gray_dark));
    chart.getLegend().setForm(Legend.LegendForm.LINE);
    chart.getLegend().setTextSize(mTextSize);
    chart.getLegend().setTextColor(Util.getColor(mAppContext, R.color.gray_dark));
}
Example 7
Project: easy-finance-master  File: PanelChartBalance.java View source code
@Override
public View buildView(Context context, ViewGroup viewGroup, FragmentManager fragmentManager) {
    this.fragmentManager = fragmentManager;
    LineChart chart = new LineChart(context);
    chart.setDescription(getDescription(context));
    chart.setHighlightEnabled(true);
    chart.setTouchEnabled(true);
    chart.setDragDecelerationFrictionCoef(0.9f);
    chart.setDragEnabled(true);
    chart.setScaleEnabled(true);
    chart.setDrawGridBackground(false);
    chart.setHighlightPerDragEnabled(true);
    chart.setPinchZoom(true);
    chart.animateX(2500);
    chart.animateY(2500);
    viewGroup.addView(chart);
    return chart;
}
Example 8
Project: hikingbuddy-android-master  File: StartMissionActivity.java View source code
@Override
public void run() {
    Log.d(TAG, "Mission info acquired.");
    // Prepare everything before displaying the mission
    m = mr.getMission();
    Location startLocation = m.getStartLocation();
    Location endLocation = m.getEndLocation();
    tvInvitation.setText(String.format("%s", m.getName()));
    tvAverageTime.setText(Utils.pretifyAverageTime(m.getAverageTime()));
    tvRouteDistance.setText(Utils.pretifyDistance(m.getDistance()));
    tvMissionStartName.setText(startLocation.getName());
    tvMissionEndName.setText(endLocation.getName());
    btStartMission.setEnabled(true);
    SharedPreferences.Editor prefsEdit = prefs.edit();
    prefsEdit.putInt("mission_id", m.getId());
    prefsEdit.commit();
    // Process the graph
    final LineChart chart = (LineChart) findViewById(R.id.chart);
    chart.setDescription("Terrain Height");
    chart.getAxisLeft().setDrawLabels(false);
    // chart.getAxisRight().setDrawLabels(false);
    chart.getXAxis().setDrawLabels(false);
    chart.getLegend().setEnabled(false);
    missionServiceInfoImpl.getHeightInfo(m.getId(), new Callback<HeightGraph>() {

        @Override
        public void success(HeightGraph heightGraph, Response response) {
            List<Entry> dataSet = heightGraph.getGraphEntries();
            ArrayList<String> xVals = new ArrayList<String>();
            LineDataSet lds;
            for (int i = 0; i < dataSet.size(); i++) {
                xVals.add((i) + "");
            }
            lds = new LineDataSet(heightGraph.getGraphEntries(), "3");
            lds.setColor(Color.BLACK);
            lds.setLineWidth(0.5f);
            lds.setDrawValues(false);
            lds.setDrawCircles(false);
            lds.setDrawCubic(false);
            lds.setDrawFilled(true);
            chart.setData(new LineData(xVals, lds));
            chart.invalidate();
            vSwitcherGraph.showNext();
        }

        @Override
        public void failure(RetrofitError error) {
            Utils.showOkAlertDialog(StartMissionActivity.this, "Problem", error.getMessage(), null);
        }
    });
    vSwitcher.showNext();
}
Example 9
Project: our-alliance-android-master  File: AnalysisFragment.java View source code
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View rootView = inflater.inflate(R.layout.fragment_analysis, container, false);
    chart = (LineChart) rootView.findViewById(R.id.chart);
    chart.setDragEnabled(true);
    chart.setScaleXEnabled(true);
    chart.setScaleYEnabled(false);
    chart.setPinchZoom(true);
    chart.setHighlightEnabled(true);
    chart.setHighlightIndicatorEnabled(true);
    chart.animateXY(3000, 3000);
    return rootView;
}
Example 10
Project: participacidadao-master  File: VereadorCotaFragment.java View source code
private void buildGraph() {
    mChart = (LineChart) mView.findViewById(R.id.chart1);
    mChart.setDrawGridBackground(false);
    mChart.setDescription("");
    mChart.setNoDataTextDescription("You need to provide data for the chart.");
    // enable value highlighting
    mChart.setHighlightEnabled(true);
    // enable touch gestures
    mChart.setTouchEnabled(true);
    // enable scaling and dragging
    mChart.setDragEnabled(true);
    mChart.setScaleEnabled(true);
    // mChart.setScaleXEnabled(true);
    // mChart.setScaleYEnabled(true);
    // if disabled, scaling can be done on x- and y-axis separately
    mChart.setPinchZoom(true);
    // enable/disable highlight indicators (the lines that indicate the
    // highlighted Entry)
    mChart.setHighlightEnabled(false);
    LimitLine ll1 = new LimitLine(130f, "Upper Limit");
    ll1.setLineWidth(4f);
    ll1.enableDashedLine(10f, 10f, 0f);
    ll1.setLabelPosition(LimitLine.LimitLabelPosition.POS_RIGHT);
    ll1.setTextSize(10f);
    LimitLine ll2 = new LimitLine(-30f, "Lower Limit");
    ll2.setLineWidth(4f);
    ll2.enableDashedLine(10f, 10f, 0f);
    ll2.setLabelPosition(LimitLine.LimitLabelPosition.POS_RIGHT);
    ll2.setTextSize(10f);
    YAxis leftAxis = mChart.getAxisLeft();
    // reset all limit lines to avoid overlapping lines
    leftAxis.removeAllLimitLines();
    //leftAxis.addLimitLine(ll1);
    //leftAxis.addLimitLine(ll2);
    leftAxis.setAxisMaxValue(maximo + 200);
    minimo = minimo - 200;
    if (minimo < 0f) {
        minimo = 0f;
    }
    leftAxis.setAxisMinValue(minimo);
    leftAxis.setStartAtZero(false);
    //leftAxis.setYOffset(20f);
    leftAxis.enableGridDashedLine(10f, 10f, 0f);
    // limit lines are drawn behind data (and not on top)
    leftAxis.setDrawLimitLinesBehindData(true);
    mChart.getAxisRight().setEnabled(false);
    // add data
    setData();
    //        mChart.setVisibleXRange(20);
    //        mChart.setVisibleYRange(20f, AxisDependency.LEFT);
    //        mChart.centerViewTo(20, 50, AxisDependency.LEFT);
    mChart.animateX(2500, Easing.EasingOption.EaseInOutQuart);
    //        mChart.invalidate();
    // get the legend (only possible after setting data)
    Legend l = mChart.getLegend();
    // modify the legend ...
    // l.setPosition(LegendPosition.LEFT_OF_CHART);
    l.setForm(Legend.LegendForm.LINE);
}
Example 11
Project: ut_ewh_audiometer_2014-master  File: TestData.java View source code
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        getWindow().setStatusBarColor(getResources().getColor(R.color.primary_dark));
    }
    setContentView(R.layout.activity_test_data);
    Intent intent = getIntent();
    final String fileName = intent.getStringExtra(TestLookup.DESIRED_FILE);
    String[] names = fileName.split("-");
    String fileNameLeft = names[0] + "-Left-" + names[2] + "-" + names[3];
    String time = "";
    for (int j = 0; j < 4; j = j + 2) {
        if (j != 2) {
            time += String.valueOf(names[3].charAt(j)) + String.valueOf(names[3].charAt(j + 1)) + ":";
        } else {
            time += String.valueOf(names[3].charAt(j)) + String.valueOf(names[3].charAt(j + 1));
        }
    }
    String name = "Test at " + time + ", " + names[2].replaceAll("_", ".");
    Button b = (Button) findViewById(R.id.email_button);
    b.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            gotoExport(view, fileName);
        }
    });
    TextView title = (TextView) findViewById(R.id.test_title);
    title.setText(name);
    byte testResultsRightByte[] = new byte[7 * 8];
    try {
        FileInputStream fis = openFileInput(fileName);
        fis.read(testResultsRightByte, 0, testResultsRightByte.length);
        fis.close();
    } catch (IOException e) {
    }
    ;
    byte testResultsLeftByte[] = new byte[7 * 8];
    try {
        FileInputStream fis = openFileInput(fileNameLeft);
        fis.read(testResultsLeftByte, 0, testResultsLeftByte.length);
        fis.close();
    } catch (IOException e) {
    }
    ;
    final double testResultsRight[] = new double[7];
    final double testResultsLeft[] = new double[7];
    int counter = 0;
    for (int i = 0; i < testResultsRight.length; i++) {
        byte tmpByteBuffer[] = new byte[8];
        for (int j = 0; j < 8; j++) {
            tmpByteBuffer[j] = testResultsRightByte[counter];
            counter++;
        }
        testResultsRight[i] = ByteBuffer.wrap(tmpByteBuffer).getDouble();
    }
    counter = 0;
    for (int i = 0; i < testResultsLeft.length; i++) {
        byte tmpByteBuffer[] = new byte[8];
        for (int j = 0; j < 8; j++) {
            tmpByteBuffer[j] = testResultsLeftByte[counter];
            counter++;
        }
        testResultsLeft[i] = ByteBuffer.wrap(tmpByteBuffer).getDouble();
    }
    // Draw Graph
    LineChart chart = (LineChart) findViewById(R.id.chart);
    chart.setNoDataTextDescription("Whoops! No data was found. Try again!");
    chart.setDescription("Hearing Thresholds (dB HL)");
    ArrayList<Entry> dataLeft = new ArrayList<Entry>();
    for (int i = 0; i < testResultsLeft.length; i++) {
        Entry dataPoint = new Entry((float) testResultsLeft[i], i);
        dataLeft.add(dataPoint);
    }
    LineDataSet setLeft = new LineDataSet(dataLeft, "Left");
    ArrayList<Entry> dataRight = new ArrayList<Entry>();
    for (int i = 0; i < testResultsRight.length; i++) {
        Entry dataPoint = new Entry((float) testResultsRight[i], i);
        dataRight.add(dataPoint);
    }
    LineDataSet setRight = new LineDataSet(dataRight, "Right");
    ArrayList<LineDataSet> dataSets = new ArrayList<LineDataSet>();
    dataSets.add(setLeft);
    dataSets.add(setRight);
    ArrayList<String> xVals = new ArrayList<String>();
    for (int i = 0; i < testingFrequencies.length; i++) {
        xVals.add("" + testingFrequencies[i]);
    }
    LineData data = new LineData(xVals, dataSets);
    chart.setData(data);
    // refresh
    chart.invalidate();
// Draw Table
/*
        TableLayout tableResults = (TableLayout) findViewById(R.id.tableResults);
        tableResults.setPadding(15, 3, 15, 3);


        for (int i = 0; i < 7; i ++) {
            TableRow row = new TableRow(this);
            TableLayout.LayoutParams lp = new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT);
            row.setLayoutParams(lp);
            row.setPadding(20, 3, 15, 3);
            row.setBackgroundColor(Color.parseColor("#424242"));
            TextView Values = new TextView(this);
            Values.setPadding(20, 0, 15, 0);
            Values.setGravity(Gravity.LEFT);
            Values.setTextSize(25.0f);
            Values.setTextColor(Color.parseColor("#FFFFFF"));
            Values.setText(testingFrequencies[i] + " Hz: " + String.format("%.2f", testResultsLeft[i]) + "dB HL Left");
            row.addView(Values);
            tableResults.addView(row);

            TableRow row2 = new TableRow(this);
            row2.setLayoutParams(lp);
            row2.setPadding(20, 3, 15, 3);
            row2.setBackgroundColor(Color.parseColor("#424242"));
            TextView Values2 = new TextView(this);
            Values2.setPadding(20, 0, 15, 0);
            Values2.setGravity(Gravity.LEFT);
            Values2.setTextSize(25.0f);
            Values2.setTextColor(Color.parseColor("#FFFFFF"));
            Values2.setText(testingFrequencies[i] + " Hz: " + String.format("%.2f", testResultsRight[i]) + "db HL Right" );
            row2.addView(Values2);
            tableResults.addView(row2);
        }
        */
}
Example 12
Project: VITacademics-for-Android-master  File: GradesFragment.java View source code
void initialize() {
    semesterWiseGrades = ((MainApplication) getActivity().getApplication()).getDataHolderInstanceInitialized().getSemesterWiseGrades();
    Collections.sort(semesterWiseGrades, new SemCompare());
    chart = (LineChart) rootView.findViewById(R.id.grades_chart);
    Cgpa = ((MainApplication) getActivity().getApplication()).getDataHolderInstanceInitialized().getCgpa();
    initializeChart();
    pager = (ViewPager) rootView.findViewById(R.id.view_pager_grades);
    pagerAdapter = new GradesPagerAdapter(getActivity(), getActivity().getSupportFragmentManager(), semesterWiseGrades);
    pager.setAdapter(pagerAdapter);
    pager.addOnPageChangeListener(new semCardChangeListener());
    String Title = getActivity().getResources().getString(R.string.fragment_grades_title);
    getActivity().setTitle(Title);
}
Example 13
Project: jzgs-master  File: HistoryActivity.java View source code
@Override
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    setContentView(R.layout.activity_history);
    mLineChart = (LineChart) findViewById(R.id.lineChart);
    btn_month = (TextView) findViewById(R.id.btn_month);
    btn_season = (TextView) findViewById(R.id.btn_season);
    btn_half = (TextView) findViewById(R.id.btn_half);
    btn_year = (TextView) findViewById(R.id.btn_year);
    tv_net_value = (TextView) findViewById(R.id.tv_net_value);
    tv_grow_value = (TextView) findViewById(R.id.tv_grow_value);
    tv_range_grow_value = (TextView) findViewById(R.id.tv_range_grow_value);
    tv_date_value = (TextView) findViewById(R.id.tv_date_value);
    tv_label_range = (TextView) findViewById(R.id.tv_label_range_grow);
    btn_month.setOnClickListener(this);
    btn_season.setOnClickListener(this);
    btn_half.setOnClickListener(this);
    btn_year.setOnClickListener(this);
    btn_month.setSelected(true);
    setLineChart();
    api.setAsyncCallBack(new AsyncCallBack<HistoryNetValue>() {

        @Override
        public void onSuccess(HistoryNetValue t) {
            List<NetValue> list = t.getNetValues();
            dataCache.put(range, list);
            setLineData(list);
            showSelectData(list.get(0));
            showRangeData();
        }

        @Override
        public void onFailed(Error error) {
            String text = error.getMessage();
            if (StringUtil.isEmpty(text)) {
                text = "数�加载失败";
            }
            showToast(text);
        }
    });
    try {
        fund = (FundHold) getIntent().getSerializableExtra(FUND);
    } catch (Exception e) {
        showToast("传入数�有误 :" + e.toString());
    }
    if (fund != null) {
        setTitle(fund.fundName);
        get(fund.fundCode);
    }
}
Example 14
Project: Open-Vehicle-Android-master  File: PowerFragment.java View source code
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Init data storage:
    logData = new GPSLogData();
    // Load prefs:
    appPrefes = new AppPrefes(getActivity(), "ovms");
    mShowPower = appPrefes.getData("power_show_power").equals("on");
    mShowEnergy = appPrefes.getData("power_show_energy").equals("on");
    if (!mShowPower && !mShowEnergy)
        mShowPower = true;
    // Setup UI:
    ProgressOverlay progressOverlay = createProgressOverlay(inflater, container, false);
    progressOverlay.setOnCancelListener(this);
    View rootView = inflater.inflate(R.layout.fragment_power, null);
    XAxis xAxis;
    YAxis yAxis;
    LineChart chart;
    //
    // Setup trip chart:
    //
    tripChart = chart = (LineChart) rootView.findViewById(R.id.chart_trip);
    chart.setDescription(getString(R.string.power_trip_description));
    chart.getPaint(LineChart.PAINT_DESCRIPTION).setColor(Color.LTGRAY);
    chart.setDrawGridBackground(false);
    chart.setDrawBorders(true);
    chart.setHighlightEnabled(false);
    xAxis = chart.getXAxis();
    xAxis.setTextColor(Color.WHITE);
    // altitude
    yAxis = chart.getAxisLeft();
    yAxis.setTextColor(COLOR_ALTITUDE);
    yAxis.setGridColor(COLOR_ALTITUDE_GRID);
    yAxis.setStartAtZero(false);
    yAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
    // speed
    yAxis = chart.getAxisRight();
    yAxis.setTextColor(COLOR_SPEED);
    yAxis.setGridColor(COLOR_SPEED_GRID);
    yAxis.setStartAtZero(true);
    yAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
    //
    // Setup power chart:
    //
    powerChart = chart = (LineChart) rootView.findViewById(R.id.chart_power);
    chart.setDescription(getString(R.string.power_power_description));
    chart.getPaint(LineChart.PAINT_DESCRIPTION).setColor(Color.LTGRAY);
    chart.setDrawGridBackground(false);
    chart.setDrawBorders(true);
    chart.setHighlightEnabled(false);
    xAxis = chart.getXAxis();
    xAxis.setTextColor(Color.WHITE);
    yAxis = chart.getAxisLeft();
    yAxis.setTextColor(Color.WHITE);
    yAxis.setGridColor(Color.LTGRAY);
    yAxis.setStartAtZero(false);
    yAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
    yAxis.setValueFormatter(new ValueFormatter() {

        @Override
        public String getFormattedValue(float value) {
            return String.format("%.0fkW", value / 1000f);
        }
    });
    yAxis = chart.getAxisRight();
    yAxis.setTextColor(Color.WHITE);
    yAxis.setGridColor(Color.LTGRAY);
    yAxis.setStartAtZero(false);
    yAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
    yAxis.setValueFormatter(new ValueFormatter() {

        @Override
        public String getFormattedValue(float value) {
            return String.format("%.0fkW", value / 1000f);
        }
    });
    //
    // Setup energy chart:
    //
    energyChart = chart = (LineChart) rootView.findViewById(R.id.chart_energy);
    chart.setDescription(getString(R.string.power_energy_description));
    chart.getPaint(LineChart.PAINT_DESCRIPTION).setColor(Color.LTGRAY);
    chart.setDrawGridBackground(false);
    chart.setDrawBorders(true);
    chart.setHighlightEnabled(false);
    xAxis = chart.getXAxis();
    xAxis.setTextColor(Color.WHITE);
    yAxis = chart.getAxisLeft();
    yAxis.setTextColor(Color.WHITE);
    yAxis.setGridColor(Color.LTGRAY);
    yAxis.setStartAtZero(false);
    yAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
    yAxis = chart.getAxisRight();
    yAxis.setTextColor(Color.WHITE);
    yAxis.setGridColor(Color.LTGRAY);
    yAxis.setStartAtZero(false);
    yAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
    //
    // Couple chart viewports:
    //
    tripChart.setOnChartGestureListener(chartCoupler = new CoupleChartGestureListener(tripChart, new Chart[] { powerChart, energyChart }));
    powerChart.setOnChartGestureListener(new CoupleChartGestureListener(powerChart, new Chart[] { tripChart, energyChart }));
    energyChart.setOnChartGestureListener(new CoupleChartGestureListener(energyChart, new Chart[] { tripChart, powerChart }));
    // attach menu:
    setHasOptionsMenu(true);
    return rootView;
}
Example 15
Project: SmartChair-master  File: StatisticsFragment.java View source code
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    final View v = inflater.inflate(R.layout.statistics_fragment, container, false);
    encoderChart = (LineChart) v.findViewById(R.id.chart1);
    angleChart = (LineChart) v.findViewById(R.id.chart2);
    setUpEncoderChart();
    setUpAngleChart();
    return v;
}
Example 16
Project: thermospy-master  File: RealtimeChartFragment.java View source code
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View v = inflater.inflate(R.layout.fragment_realtime_chart, container, false);
    mImageButton = (ImageButton) v.findViewById(R.id.imageButton);
    mLogSessionText = (TextView) v.findViewById(R.id.txt_startstop_logsession);
    final LinearLayout layout = (LinearLayout) v.findViewById(R.id.log_session_layout);
    layout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!mActiveLogSession) {
                mListener.onShowCreateLogSessionDialog(RealtimeChartFragment.this);
            } else {
                requestStopLogSession();
            }
        }
    });
    mChart = (LineChart) v.findViewById(R.id.chart);
    mChart.setOnChartValueSelectedListener(this);
    // no description text
    mChart.setDescription("");
    mChart.setNoDataTextDescription("You need to provide data for the chart.");
    // enable value highlighting
    mChart.setHighlightEnabled(true);
    // enable touch gestures
    mChart.setTouchEnabled(true);
    // enable scaling and dragging
    mChart.setDragEnabled(true);
    mChart.setScaleEnabled(true);
    mChart.setDrawGridBackground(false);
    // if disabled, scaling can be done on x- and y-axis separately
    mChart.setPinchZoom(true);
    // set an alternative background color
    mChart.setBackgroundColor(Color.WHITE);
    LineData data = new LineData();
    data.setValueTextColor(Color.BLACK);
    // add empty data
    mChart.setData(data);
    //Typeface tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
    // get the legend (only possible after setting data)
    Legend l = mChart.getLegend();
    // modify the legend ...
    // l.setPosition(LegendPosition.LEFT_OF_CHART);
    l.setForm(Legend.LegendForm.LINE);
    // l.setTypeface(tf);
    l.setTextColor(Color.BLACK);
    XAxis xl = mChart.getXAxis();
    //xl.setTypeface(tf);
    xl.setTextColor(Color.BLACK);
    xl.setDrawGridLines(false);
    xl.setAvoidFirstLastClipping(true);
    YAxis leftAxis = mChart.getAxisLeft();
    //leftAxis.setTypeface(tf);
    leftAxis.setTextColor(Color.BLACK);
    leftAxis.setAxisMaxValue(120f);
    leftAxis.setDrawGridLines(true);
    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setEnabled(false);
    return v;
}
Example 17
Project: walt-master  File: ScreenResponseFragment.java View source code
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    timesToBlink = getIntPreference(getContext(), R.string.preference_screen_blinks, 20);
    shouldShowLatencyChart = getBooleanPreference(getContext(), R.string.preference_show_blink_histogram, true);
    enableFullScreen = getBooleanPreference(getContext(), R.string.preference_screen_fullscreen, true);
    if (getBooleanPreference(getContext(), R.string.preference_systrace, true)) {
        traceLogger = TraceLogger.getInstance();
    }
    waltDevice = WaltDevice.getInstance(getContext());
    logger = SimpleLogger.getInstance(getContext());
    // Inflate the layout for this fragment
    final View view = inflater.inflate(R.layout.fragment_screen_response, container, false);
    stopButton = view.findViewById(R.id.button_stop_screen_response);
    startButton = view.findViewById(R.id.button_start_screen_response);
    blackBox = (TextView) view.findViewById(R.id.txt_black_box_screen);
    fastSurfaceView = (FastPathSurfaceView) view.findViewById(R.id.fast_path_surface);
    spinner = (Spinner) view.findViewById(R.id.spinner_screen_response);
    buttonBarView = view.findViewById(R.id.button_bar);
    ArrayAdapter<CharSequence> modeAdapter = ArrayAdapter.createFromResource(getContext(), R.array.screen_response_mode_array, android.R.layout.simple_spinner_item);
    modeAdapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item);
    spinner.setAdapter(modeAdapter);
    stopButton.setEnabled(false);
    blackBox.setMovementMethod(new ScrollingMovementMethod());
    brightnessChartLayout = view.findViewById(R.id.brightness_chart_layout);
    view.findViewById(R.id.button_close_chart).setOnClickListener(this);
    brightnessChart = (LineChart) view.findViewById(R.id.chart);
    latencyChart = (HistogramChart) view.findViewById(R.id.latency_chart);
    if (getBooleanPreference(getContext(), R.string.preference_auto_increase_brightness, true)) {
        increaseScreenBrightness();
    }
    return view;
}
Example 18
Project: andFHEM-master  File: ChartingActivity.java View source code
/**
     * Actually creates the charting view by using the newly read charting data.
     *
     * @param device    concerned device
     * @param graphData used graph data
     */
@SuppressWarnings("unchecked")
private void createChart(FhemDevice device, Map<GPlotSeries, List<GraphEntry>> graphData) {
    handleDiscreteValues(graphData);
    LineData lineData = createLineDataFor(graphData);
    String title;
    if (DisplayUtil.getWidthInDP() < 500) {
        title = device.getAliasOrName() + "\n\r" + DATE_TIME_FORMATTER.print(startDate) + " - " + DATE_TIME_FORMATTER.print(endDate);
    } else {
        title = device.getAliasOrName() + " " + DATE_TIME_FORMATTER.print(startDate) + " - " + DATE_TIME_FORMATTER.print(endDate);
    }
    getSupportActionBar().setTitle(title);
    LineChart lineChart = (LineChart) findViewById(R.id.chart);
    // must be called before setting chart data!
    GPlotDefinition plotDefinition = svgGraphDefinition.getPlotDefinition();
    setRangeFor(plotDefinition.getLeftAxis().getRange(), lineChart.getAxisLeft());
    setRangeFor(plotDefinition.getRightAxis().getRange(), lineChart.getAxisRight());
    XAxis xAxis = lineChart.getXAxis();
    xAxis.setValueFormatter(new IAxisValueFormatter() {

        @Override
        public String getFormattedValue(float value, AxisBase axis) {
            return ANDFHEM_DATE_FORMAT.print((long) value);
        }
    });
    xAxis.setLabelRotationAngle(300);
    int labelCount = DisplayUtil.getWidthInDP() / 150;
    xAxis.setLabelCount(labelCount < 2 ? 2 : labelCount, true);
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    Description description = new Description();
    description.setText("");
    lineChart.setDescription(description);
    lineChart.setNoDataText(getString(R.string.noGraphEntries));
    lineChart.setData(lineData);
    lineChart.setMarkerView(new ChartMarkerView(this));
    lineChart.animateX(200);
}
Example 19
Project: CameraV-master  File: ChartsActivity.java View source code
private void initCharts() {
    try {
        ((IMedia) media).buildJ3M(this, false, null);
        ArrayList<ISensorCapture> listSensorEvents = new ArrayList<ISensorCapture>(media.data.sensorCapture);
        Collections.sort(listSensorEvents, new Comparator<ISensorCapture>() {

            @Override
            public int compare(ISensorCapture lhs, ISensorCapture rhs) {
                if (lhs.timestamp < rhs.timestamp)
                    return -1;
                else if (lhs.timestamp == rhs.timestamp)
                    return 0;
                else
                    return 1;
            }
        });
        DateFormat dateFormat = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG);
        ArrayList<String> alPoints = new ArrayList<String>();
        //do map
        for (ISensorCapture sensor : listSensorEvents) {
            if (sensor.sensorPlayback.has("gps_coords")) {
                String latLon = (String) sensor.sensorPlayback.get("gps_coords");
                alPoints.add(latLon.substring(1, latLon.length() - 1));
            }
        }
        if (alPoints.size() > 0)
            addMap(alPoints);
        //do charts
        final String[] sensorLabels = { getString(R.string.gps_accuracy), getString(R.string.gps_speed), getString(R.string.gps_altitude), getString(R.string.light), getString(R.string.air_pressure), getString(R.string.orientation), getString(R.string.motion), getString(R.string.wifi_networks) };
        final String[][] sensorTypes = { { "gps_accuracy" }, { "gps_speed" }, { "gps_altitude" }, { "lightMeterValue" }, { "pressureHPAOrMBAR" }, { "pitch", "roll", "azimuth" }, { "acc_x", "acc_y", "acc_z" }, { "visibleWifiNetworks" } };
        int labelIdx = 0;
        for (String[] sensorTypeSet : sensorTypes) {
            ArrayList<LineDataSet> dataSets = new ArrayList<LineDataSet>();
            int[] colors = ColorTemplate.JOYFUL_COLORS;
            int colorIdx = 0;
            ArrayList<String> xVals = null;
            for (String sensorType : sensorTypeSet) {
                //only the last time through will set the values
                xVals = new ArrayList<String>();
                int i = 0;
                ArrayList<Entry> yVals = new ArrayList<Entry>();
                long lastTimeStamp = -1;
                for (ISensorCapture sensor : listSensorEvents) {
                    if (sensor.sensorPlayback.has(sensorType)) {
                        Object val = sensor.sensorPlayback.get(sensorType);
                        lastTimeStamp = sensor.timestamp;
                        xVals.add(dateFormat.format(new Date(sensor.timestamp)));
                        if (val instanceof Integer) {
                            yVals.add(new Entry(((Integer) val).intValue(), i++));
                        } else if (val instanceof Double) {
                            yVals.add(new Entry(((Double) val).floatValue(), i++));
                        } else if (val instanceof Float) {
                            yVals.add(new Entry(((Float) val).floatValue(), i++));
                        } else if (val instanceof JSONArray) {
                            yVals.add(new Entry(((JSONArray) val).length(), i++));
                        } else {
                            try {
                                float fval = Float.parseFloat(((String) val));
                                yVals.add(new Entry(fval, i++));
                            } catch (Exception e) {
                                Log.w("Chart", "couldn't parse value: " + val, e);
                            }
                        }
                    }
                }
                if (!yVals.isEmpty()) {
                    if (yVals.size() == 1) {
                        xVals.add(dateFormat.format(new Date(lastTimeStamp + 1)));
                        Entry entry = yVals.get(0).copy();
                        entry.setXIndex(entry.getXIndex() + 1);
                        yVals.add(entry);
                    }
                    LineDataSet dataSet = addLineDataSet(sensorType, yVals);
                    dataSet.setColor(colors[colorIdx++]);
                    // add the datasets	
                    dataSets.add(dataSet);
                }
            }
            if (!dataSets.isEmpty()) {
                // create a data object with the datasets
                LineData data = new LineData(xVals, dataSets);
                LineChart chart = addChart(sensorLabels[labelIdx], data);
                /*
			        LimitLine limitCapture = new LimitLine(media.dcimEntry.timeCaptured, "Capture");
			        limitCapture.setLineColor(Color.RED);
			        limitCapture.setLineWidth(4f);
			        limitCapture.enableDashedLine(10f, 10f, 0f);		        
			        limitCapture.setTextSize(10f);		        
			        chart.getXAxis().addLimitLine(limitCapture);
			        */
                listCharts.add(chart);
            }
            labelIdx++;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Example 20
Project: Osmand-master  File: GpxUiHelper.java View source code
public static void setupGPXChart(OsmandApplication ctx, LineChart mChart, int yLabelsCount) {
    OsmandSettings settings = ctx.getSettings();
    boolean light = settings.isLightContent();
    if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        mChart.setHardwareAccelerationEnabled(false);
    } else {
        mChart.setHardwareAccelerationEnabled(true);
    }
    mChart.setTouchEnabled(true);
    mChart.setDragEnabled(true);
    mChart.setScaleEnabled(true);
    mChart.setPinchZoom(true);
    mChart.setScaleYEnabled(false);
    mChart.setAutoScaleMinMaxEnabled(true);
    mChart.setDrawBorders(false);
    mChart.getDescription().setEnabled(false);
    mChart.setMaxVisibleValueCount(10);
    mChart.setMinOffset(0f);
    mChart.setDragDecelerationEnabled(false);
    mChart.setExtraTopOffset(24f);
    mChart.setExtraBottomOffset(16f);
    // create a custom MarkerView (extend MarkerView) and specify the layout
    // to use for it
    GPXMarkerView mv = new GPXMarkerView(mChart.getContext());
    // For bounds control
    mv.setChartView(mChart);
    // Set the marker to the chart
    mChart.setMarker(mv);
    mChart.setDrawMarkers(true);
    XAxis xAxis = mChart.getXAxis();
    xAxis.setDrawAxisLine(false);
    xAxis.setDrawGridLines(false);
    xAxis.setPosition(BOTTOM);
    xAxis.setTextColor(light ? mChart.getResources().getColor(R.color.secondary_text_light) : mChart.getResources().getColor(R.color.secondary_text_dark));
    YAxis yAxis = mChart.getAxisLeft();
    yAxis.enableGridDashedLine(10f, 5f, 0f);
    yAxis.setGridColor(ActivityCompat.getColor(mChart.getContext(), R.color.divider_color));
    yAxis.setDrawAxisLine(false);
    yAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
    yAxis.setXOffset(16f);
    yAxis.setYOffset(-6f);
    yAxis.setLabelCount(yLabelsCount);
    yAxis.setTextColor(light ? mChart.getResources().getColor(R.color.secondary_text_light) : mChart.getResources().getColor(R.color.secondary_text_dark));
    yAxis = mChart.getAxisRight();
    yAxis.enableGridDashedLine(10f, 5f, 0f);
    yAxis.setGridColor(ActivityCompat.getColor(mChart.getContext(), R.color.divider_color));
    yAxis.setDrawAxisLine(false);
    yAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
    yAxis.setXOffset(16f);
    yAxis.setYOffset(-6f);
    yAxis.setLabelCount(yLabelsCount);
    yAxis.setTextColor(light ? mChart.getResources().getColor(R.color.secondary_text_light) : mChart.getResources().getColor(R.color.secondary_text_dark));
    yAxis.setEnabled(false);
    Legend legend = mChart.getLegend();
    legend.setEnabled(false);
}
Example 21
Project: AmazeFileManager-master  File: ProcessViewer.java View source code
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.processparent, container, false);
    setRetainInstance(false);
    mainActivity = (MainActivity) getActivity();
    accentColor = mainActivity.getColorPreference().getColor(ColorUsage.ACCENT);
    primaryColor = mainActivity.getColorPreference().getColor(ColorUsage.getPrimary(MainActivity.currentTab));
    if (mainActivity.getAppTheme().equals(AppTheme.DARK))
        rootView.setBackgroundResource((R.color.cardView_background));
    mainActivity.updateViews(new ColorDrawable(primaryColor));
    mainActivity.setActionBarTitle(getResources().getString(R.string.process_viewer));
    mainActivity.floatingActionButton.hideMenuButton(true);
    sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
    icons = new IconUtils(sharedPrefs, getActivity());
    mainActivity.supportInvalidateOptionsMenu();
    mCardView = (CardView) rootView.findViewById(R.id.card_view);
    mLineChart = (LineChart) rootView.findViewById(R.id.progress_chart);
    mProgressImage = (ImageView) rootView.findViewById(R.id.progress_image);
    mCancelButton = (ImageButton) rootView.findViewById(R.id.delete_button);
    mProgressTypeText = (TextView) rootView.findViewById(R.id.text_view_progress_type);
    mProgressFileNameText = (TextView) rootView.findViewById(R.id.text_view_progress_file_name);
    mProgressBytesText = (TextView) rootView.findViewById(R.id.text_view_progress_bytes);
    mProgressFileText = (TextView) rootView.findViewById(R.id.text_view_progress_file);
    mProgressSpeedText = (TextView) rootView.findViewById(R.id.text_view_progress_speed);
    mProgressTimer = (TextView) rootView.findViewById(R.id.text_view_progress_timer);
    if (mainActivity.getAppTheme().equals(AppTheme.DARK)) {
        mCancelButton.setImageResource(R.drawable.ic_action_cancel);
        mCardView.setCardBackgroundColor(Utils.getColor(getContext(), R.color.cardView_foreground));
        mCardView.setCardElevation(0f);
    }
    return rootView;
}
Example 22
Project: glucosio-android-master  File: OverviewFragment.java View source code
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    GlucosioApplication app = (GlucosioApplication) getActivity().getApplicationContext();
    presenter = new OverviewPresenter(this, app.getDBHandler());
    if (!presenter.isdbEmpty()) {
        presenter.loadDatabase(isNewGraphEnabled());
    }
    mFragmentView = inflater.inflate(R.layout.fragment_overview, container, false);
    chart = (LineChart) mFragmentView.findViewById(R.id.chart);
    disableTouchTheft(chart);
    Legend legend = chart.getLegend();
    lastReadingTextView = (TextView) mFragmentView.findViewById(R.id.item_history_reading);
    lastDateTextView = (TextView) mFragmentView.findViewById(R.id.fragment_overview_last_date);
    tipTextView = (TextView) mFragmentView.findViewById(R.id.random_tip_textview);
    graphSpinnerRange = (Spinner) mFragmentView.findViewById(R.id.chart_spinner_range);
    Spinner graphSpinnerMetric = (Spinner) mFragmentView.findViewById(R.id.chart_spinner_metrics);
    ImageButton graphExport = (ImageButton) mFragmentView.findViewById(R.id.fragment_overview_graph_export);
    HB1ACTextView = (TextView) mFragmentView.findViewById(R.id.fragment_overview_hb1ac);
    HB1ACDateTextView = (TextView) mFragmentView.findViewById(R.id.fragment_overview_hb1ac_date);
    HB1ACMoreButton = (ImageButton) mFragmentView.findViewById(R.id.fragment_overview_a1c_more);
    graphCheckboxGlucose = (CheckBox) mFragmentView.findViewById(R.id.fragment_overview_graph_glucose);
    graphCheckboxKetones = (CheckBox) mFragmentView.findViewById(R.id.fragment_overview_graph_ketones);
    graphCheckboxCholesterol = (CheckBox) mFragmentView.findViewById(R.id.fragment_overview_graph_cholesterol);
    graphCheckboxA1c = (CheckBox) mFragmentView.findViewById(R.id.fragment_overview_graph_a1c);
    graphCheckboxWeight = (CheckBox) mFragmentView.findViewById(R.id.fragment_overview_graph_weight);
    graphCheckboxPressure = (CheckBox) mFragmentView.findViewById(R.id.fragment_overview_graph_pressure);
    graphCheckboxGlucose.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            setData();
            graphCheckboxWeight.setChecked(false);
            graphCheckboxCholesterol.setChecked(false);
            graphCheckboxKetones.setChecked(false);
            graphCheckboxPressure.setChecked(false);
            graphCheckboxWeight.setChecked(false);
            graphCheckboxA1c.setChecked(false);
            graphCheckboxGlucose.setChecked(b);
        }
    });
    graphCheckboxA1c.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            setData();
            graphCheckboxGlucose.setChecked(false);
            graphCheckboxWeight.setChecked(false);
            graphCheckboxCholesterol.setChecked(false);
            graphCheckboxKetones.setChecked(false);
            graphCheckboxPressure.setChecked(false);
            graphCheckboxWeight.setChecked(false);
            graphSpinnerRange.setEnabled(!b);
            graphCheckboxA1c.setChecked(b);
        }
    });
    graphCheckboxKetones.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            setData();
            graphCheckboxGlucose.setChecked(false);
            graphCheckboxWeight.setChecked(false);
            graphCheckboxCholesterol.setChecked(false);
            graphCheckboxPressure.setChecked(false);
            graphCheckboxWeight.setChecked(false);
            graphCheckboxA1c.setChecked(false);
            graphSpinnerRange.setEnabled(!b);
            graphCheckboxKetones.setChecked(b);
        }
    });
    graphCheckboxWeight.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            setData();
            graphCheckboxGlucose.setChecked(false);
            graphCheckboxWeight.setChecked(false);
            graphCheckboxCholesterol.setChecked(false);
            graphCheckboxKetones.setChecked(false);
            graphCheckboxPressure.setChecked(false);
            graphCheckboxA1c.setChecked(false);
            graphSpinnerRange.setEnabled(!b);
            graphCheckboxWeight.setChecked(b);
        }
    });
    graphCheckboxPressure.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            setData();
            graphCheckboxGlucose.setChecked(false);
            graphCheckboxWeight.setChecked(false);
            graphCheckboxCholesterol.setChecked(false);
            graphCheckboxKetones.setChecked(false);
            graphCheckboxWeight.setChecked(false);
            graphCheckboxA1c.setChecked(false);
            graphSpinnerRange.setEnabled(!b);
            graphCheckboxPressure.setChecked(b);
        }
    });
    graphCheckboxCholesterol.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            setData();
            graphCheckboxGlucose.setChecked(false);
            graphCheckboxWeight.setChecked(false);
            graphCheckboxKetones.setChecked(false);
            graphCheckboxPressure.setChecked(false);
            graphCheckboxWeight.setChecked(false);
            graphCheckboxA1c.setChecked(false);
            graphSpinnerRange.setEnabled(!b);
            graphCheckboxCholesterol.setChecked(b);
        }
    });
    HB1ACMoreButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showA1cDialog();
        }
    });
    // Set array and adapter for graphSpinnerRange
    String[] selectorRangeArray = getActivity().getResources().getStringArray(R.array.fragment_overview_selector_range);
    String[] selectorMetricArray = getActivity().getResources().getStringArray(R.array.fragment_overview_selector_metric);
    ArrayAdapter<String> dataRangeAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, selectorRangeArray);
    ArrayAdapter<String> dataMetricAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, selectorMetricArray);
    dataRangeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    dataMetricAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    graphSpinnerRange.setAdapter(dataRangeAdapter);
    graphSpinnerMetric.setAdapter(dataMetricAdapter);
    graphSpinnerRange.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (!presenter.isdbEmpty()) {
                setData();
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    graphSpinnerRange.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (!presenter.isdbEmpty()) {
                setData();
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    XAxis xAxis = chart.getXAxis();
    xAxis.setDrawGridLines(false);
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setTextColor(getResources().getColor(R.color.glucosio_text_light));
    xAxis.setAvoidFirstLastClipping(true);
    int minGlucoseValue = presenter.getGlucoseMinValue();
    int maxGlucoseValue = presenter.getGlucoseMaxValue();
    LimitLine ll1;
    LimitLine ll2;
    if (("mg/dL").equals(presenter.getUnitMeasuerement())) {
        ll1 = new LimitLine(minGlucoseValue);
        ll2 = new LimitLine(maxGlucoseValue);
    } else {
        ll1 = new LimitLine((float) GlucosioConverter.glucoseToMmolL(maxGlucoseValue), getString(R.string.reading_high));
        ll2 = new LimitLine((float) GlucosioConverter.glucoseToMmolL(minGlucoseValue), getString(R.string.reading_low));
    }
    ll1.setLineWidth(0.8f);
    ll1.setLineColor(getResources().getColor(R.color.glucosio_reading_low));
    ll2.setLineWidth(0.8f);
    ll2.setLineColor(getResources().getColor(R.color.glucosio_reading_high));
    YAxis leftAxis = chart.getAxisLeft();
    leftAxis.setTextColor(getResources().getColor(R.color.glucosio_text_light));
    leftAxis.setStartAtZero(false);
    leftAxis.disableGridDashedLine();
    leftAxis.setDrawGridLines(false);
    leftAxis.addLimitLine(ll1);
    leftAxis.addLimitLine(ll2);
    leftAxis.setDrawLimitLinesBehindData(true);
    chart.getAxisRight().setEnabled(false);
    chart.setBackgroundColor(Color.parseColor("#FFFFFF"));
    chart.setDescription("");
    chart.setGridBackgroundColor(Color.parseColor("#FFFFFF"));
    if (!presenter.isdbEmpty()) {
        setData();
    }
    legend.setEnabled(false);
    graphExport.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                // If we don't have permission, ask the user
                ActivityCompat.requestPermissions(getActivity(), new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
                Snackbar.make(mFragmentView, getString(R.string.fragment_overview_permission_storage), Snackbar.LENGTH_SHORT).show();
            } else {
                // else save the image to gallery
                exportGraphToGallery();
            }
        }
    });
    loadLastReading();
    loadHB1AC();
    loadRandomTip();
    return mFragmentView;
}
Example 23
Project: bowling-companion-master  File: StatsGraphFragment.java View source code
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View rootView = inflater.inflate(R.layout.fragment_stats_graph, container, false);
    if (savedInstanceState != null) {
        mStatCategory = savedInstanceState.getInt(ARG_STAT_CATEGORY, 0);
        mStatIndex = savedInstanceState.getInt(ARG_STAT_INDEX, 0);
        mStatAccumulate = savedInstanceState.getBoolean(ARG_STAT_ACCUMULATE, false);
    } else {
        Bundle arguments = getArguments();
        mStatCategory = arguments.getInt(ARG_STAT_CATEGORY, 0);
        mStatIndex = arguments.getInt(ARG_STAT_INDEX, 0);
    }
    mLineChartStats = (LineChart) rootView.findViewById(R.id.chart_stats);
    mTextViewStat = (TextView) rootView.findViewById(R.id.tv_stat_name);
    mSwitchAccumulate = (Switch) rootView.findViewById(R.id.switch_stat_accumulate);
    mTextViewAccumulate = (TextView) rootView.findViewById(R.id.tv_stat_accumulate);
    setupNavigation(rootView);
    setupAccumulateSwitch();
    if (mStatAccumulate) {
        mSwitchAccumulate.setChecked(true);
        mTextViewAccumulate.setText(R.string.text_stats_accumulate);
    } else {
        mSwitchAccumulate.setChecked(false);
        mTextViewAccumulate.setText(R.string.text_stats_by_week);
    }
    return rootView;
}
Example 24
Project: react-native-charts-wrapper-master  File: LineChartManager.java View source code
@Override
protected LineChart createViewInstance(ThemedReactContext reactContext) {
    LineChart lineChart = new LineChart(reactContext);
    lineChart.setOnChartValueSelectedListener(new RNOnChartValueSelectedListener(lineChart));
    return lineChart;
}
Example 25
Project: admin-assistant-master  File: LineChartActivity.java View source code
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_line_chart);
    lineChart = (LineChart) findViewById(R.id.chart1);
    initLineChart();
}
Example 26
Project: NorrisApp-master  File: LineChartActivity.java View source code
/**
     * This method is performed by android at the creation of the Activity. It will be tasked to initializing its presenter.
     * @param savedInstanceState instance state
     */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_line_chart);
    chart = (LineChart) findViewById(R.id.chart);
    presenter = PresenterImpl.create(PresenterImpl.ChartType.LINECHART_TYPE, this);
}