Java Code Examples for com.github.mikephil.charting.components.XAxis#removeAllLimitLines()

The following examples show how to use com.github.mikephil.charting.components.XAxis#removeAllLimitLines() . 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: FragmentPrice.java    From bcm-android with GNU General Public License v3.0 4 votes vote down vote up
private void setupChart(LineChart chart, LineData data, int color) {
    ((LineDataSet) data.getDataSetByIndex(0)).setCircleColorHole(color);
    chart.getDescription().setEnabled(false);
    chart.setDrawGridBackground(false);
    chart.setTouchEnabled(false);
    chart.setDragEnabled(false);
    chart.setScaleEnabled(true);
    chart.setPinchZoom(false);
    chart.setBackgroundColor(color);
    chart.setViewPortOffsets(0, 23, 0, 0);
    chart.setData(data);
    Legend l = chart.getLegend();
    l.setEnabled(false);

    chart.getAxisLeft().setEnabled(true);
    chart.getAxisLeft().setDrawGridLines(false);
    chart.getAxisLeft().setDrawAxisLine(false);
    chart.getAxisLeft().setSpaceTop(10);
    chart.getAxisLeft().setSpaceBottom(30);
    chart.getAxisLeft().setAxisLineColor(0xFFFFFF);
    chart.getAxisLeft().setTextColor(0xFFFFFF);
    chart.getAxisLeft().setDrawTopYLabelEntry(true);
    chart.getAxisLeft().setLabelCount(10);

    chart.getXAxis().setEnabled(true);
    chart.getXAxis().setDrawGridLines(false);
    chart.getXAxis().setDrawAxisLine(false);
    chart.getXAxis().setAxisLineColor(0xFFFFFF);
    chart.getXAxis().setTextColor(0xFFFFFF);

    Typeface tf = Typeface.DEFAULT;

    // X Axis
    XAxis xAxis = chart.getXAxis();
    xAxis.setTypeface(tf);
    xAxis.removeAllLimitLines();

    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);

    xAxis.setTextColor(Color.argb(150, 255, 255, 255));

    if (displayType == 1 || displayType == 2) // Week and Month
        xAxis.setValueFormatter(new WeekXFormatter());
    else if (displayType == 0) //  Day
        xAxis.setValueFormatter(new HourXFormatter());
    else
        xAxis.setValueFormatter(new YearXFormatter()); // Year

    // Y Axis
    YAxis leftAxis = chart.getAxisLeft();
    leftAxis.removeAllLimitLines();
    leftAxis.setTypeface(tf);
    leftAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
    leftAxis.setTextColor(Color.argb(150, 255, 255, 255));
    leftAxis.setValueFormatter(new DontShowNegativeFormatter(displayInUsd));
    chart.getAxisRight().setEnabled(false); // Deactivates horizontal lines

    chart.animateX(1300);
    chart.notifyDataSetChanged();
}
 
Example 2
Source File: GraphUtils.java    From your-local-weather with GNU General Public License v3.0 4 votes vote down vote up
public static void setupXAxis(XAxis x,
                              List<DetailedWeatherForecast> weatherForecastList,
                              int textColorId,
                              Float textSize,
                              AppPreference.GraphGridColors gridColor,
                              Locale locale) {
    x.removeAllLimitLines();
    Map<Integer, Long> hourIndexes = new HashMap<>();

    int lastDayOflimitLine = 0;
    for (int i = 0; i < weatherForecastList.size(); i++) {
        hourIndexes.put(i, weatherForecastList.get(i).getDateTime());
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(weatherForecastList.get(i).getDateTime() * 1000);
        if (cal.get(Calendar.DAY_OF_YEAR) != lastDayOflimitLine) {
            Calendar calOfPreviousRecord = Calendar.getInstance();
            int previousRecordHour = 24;
            if (i > 0) {
                calOfPreviousRecord.setTimeInMillis(weatherForecastList.get(i - 1).getDateTime() * 1000);
                previousRecordHour = calOfPreviousRecord.get(Calendar.HOUR_OF_DAY);
            }
            int currentHour = cal.get(Calendar.HOUR_OF_DAY);
            float timeSpan = (24 - previousRecordHour) + currentHour;
            float dayLine = currentHour / timeSpan;
            float midnight = i - dayLine;
            float hour6 = midnight + (6 / timeSpan);
            float hour12 = midnight + (12 / timeSpan);
            float hour18 = midnight + (18 / timeSpan);
            LimitLine limitLine = new LimitLine(midnight);
            limitLine.setLineColor(gridColor.getMainGridColor());
            limitLine.setLineWidth(0.5f);
            x.addLimitLine(limitLine);
            /*LimitLine limitLine6 = new LimitLine(hour6, "");
            limitLine6.setLineColor(Color.LTGRAY);
            limitLine6.setLineWidth(0.5f);
            x.addLimitLine(limitLine6);*/
            LimitLine limitLine12 = new LimitLine(hour12);
            limitLine12.setLineColor(gridColor.getSecondaryGridColor());
            limitLine12.setLineWidth(0.5f);
            x.addLimitLine(limitLine12);
            /*LimitLine limitLine18 = new LimitLine(hour18, "");
            limitLine18.setLineColor(Color.LTGRAY);
            limitLine18.setLineWidth(0.5f);
            x.addLimitLine(limitLine18);*/
            lastDayOflimitLine = cal.get(Calendar.DAY_OF_YEAR);
        }
    }

    x.setEnabled(true);
    x.setPosition(XAxis.XAxisPosition.BOTTOM);
    x.setDrawGridLines(false);
    x.setLabelCount(25, true);
    x.setTextColor(textColorId);
    x.setValueFormatter(new XAxisValueFormatter(hourIndexes, locale));
    x.setDrawLimitLinesBehindData(true);

    if (textSize != null) {
        x.setTextSize(textSize);
    }
}
 
Example 3
Source File: FragmentPrice.java    From Lunary-Ethereum-Wallet with GNU General Public License v3.0 4 votes vote down vote up
private void setupChart(LineChart chart, LineData data, int color) {
    ((LineDataSet) data.getDataSetByIndex(0)).setCircleColorHole(color);
    chart.getDescription().setEnabled(false);
    chart.setDrawGridBackground(false);
    chart.setTouchEnabled(false);
    chart.setDragEnabled(false);
    chart.setScaleEnabled(true);
    chart.setPinchZoom(false);
    chart.setBackgroundColor(color);
    chart.setViewPortOffsets(0, 23, 0, 0);
    chart.setData(data);
    Legend l = chart.getLegend();
    l.setEnabled(false);

    chart.getAxisLeft().setEnabled(true);
    chart.getAxisLeft().setDrawGridLines(false);
    chart.getAxisLeft().setDrawAxisLine(false);
    chart.getAxisLeft().setSpaceTop(10);
    chart.getAxisLeft().setSpaceBottom(30);
    chart.getAxisLeft().setAxisLineColor(0xFFFFFF);
    chart.getAxisLeft().setTextColor(0xFFFFFF);
    chart.getAxisLeft().setDrawTopYLabelEntry(true);
    chart.getAxisLeft().setLabelCount(10);

    chart.getXAxis().setEnabled(true);
    chart.getXAxis().setDrawGridLines(false);
    chart.getXAxis().setDrawAxisLine(false);
    chart.getXAxis().setAxisLineColor(0xFFFFFF);
    chart.getXAxis().setTextColor(0xFFFFFF);

    Typeface tf = Typeface.DEFAULT;

    // X Axis
    XAxis xAxis = chart.getXAxis();
    xAxis.setTypeface(tf);
    xAxis.removeAllLimitLines();

    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);

    xAxis.setTextColor(Color.argb(150, 255, 255, 255));

    if (displayType == 1 || displayType == 2) // Week and Month
        xAxis.setValueFormatter(new WeekXFormatter());
    else if (displayType == 0) //  Day
        xAxis.setValueFormatter(new HourXFormatter());
    else
        xAxis.setValueFormatter(new YearXFormatter()); // Year

    // Y Axis
    YAxis leftAxis = chart.getAxisLeft();
    leftAxis.removeAllLimitLines();
    leftAxis.setTypeface(tf);
    leftAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
    leftAxis.setTextColor(Color.argb(150, 255, 255, 255));
    leftAxis.setValueFormatter(new DontShowNegativeFormatter(displayInUsd));
    chart.getAxisRight().setEnabled(false); // Deactivates horizontal lines

    chart.animateX(1300);
    chart.notifyDataSetChanged();
}