Java Code Examples for com.github.mikephil.charting.charts.LineChart#getContext()

The following examples show how to use com.github.mikephil.charting.charts.LineChart#getContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TrainedModelViewBinder.java    From Synapse with Apache License 2.0 5 votes vote down vote up
private void changeStyle(long id, LineChart chart, LineDataSet set) {
    final int index = (int) (id % FG.length);
    final Context context = chart.getContext();

    final int fg = ContextCompat.getColor(context, FG[index]);
    set.setColor(fg);
    set.setFillColor(fg);

    chart.setGridBackgroundColor(ContextCompat.getColor(context, BG[index]));
}
 
Example 2
Source File: PlayActivity.java    From Synapse with Apache License 2.0 5 votes vote down vote up
private void changeStyle(long id, LineChart chart, LineDataSet set) {
    final int index = (int) (id % FG.length);
    final Context context = chart.getContext();

    final int fg = ContextCompat.getColor(context, FG[index]);
    set.setColor(fg);
    set.setFillColor(fg);
    mLowerBg.setBackgroundColor(fg);

    getWindow().setBackgroundDrawableResource(BG[index]);
}
 
Example 3
Source File: Utils.java    From Aria2App with GNU General Public License v3.0 4 votes vote down vote up
public static void setupChart(@NonNull LineChart chart, boolean small, @ColorRes @Nullable Integer fgColorRes) {
    chart.clear();

    int fgColor;
    Context context = chart.getContext();
    if (fgColorRes == null)
        fgColor = CommonUtils.resolveAttrAsColor(context, R.attr.colorOnSurface);
    else
        fgColor = ContextCompat.getColor(context, fgColorRes);

    chart.setDescription(null);
    chart.setDrawGridBackground(false);
    chart.setBackgroundColor(Color.alpha(0));
    chart.setTouchEnabled(false);

    Legend legend = chart.getLegend();
    legend.setTextColor(fgColor);
    legend.setEnabled(true);

    LineData data = new LineData();
    data.setValueTextColor(fgColor);
    chart.setData(data);

    YAxis ya = chart.getAxisLeft();
    ya.setAxisLineColor(fgColor);
    ya.setTextColor(fgColor);
    ya.setTextSize(small ? 8 : 9);
    ya.setAxisMinimum(0);
    ya.setDrawAxisLine(false);
    ya.setLabelCount(small ? 4 : 8, true);
    ya.setEnabled(true);
    ya.setDrawGridLines(true);
    ya.setGridColor(fgColor);
    ya.setValueFormatter(new CustomYAxisValueFormatter());

    chart.getAxisRight().setEnabled(false);
    chart.getXAxis().setEnabled(false);

    data.addDataSet(initUploadSet(context));
    data.addDataSet(initDownloadSet(context));

    chart.invalidate();
}