當前位置: 首頁>>代碼示例>>Java>>正文


Java XAxis.setDrawLabels方法代碼示例

本文整理匯總了Java中com.github.mikephil.charting.components.XAxis.setDrawLabels方法的典型用法代碼示例。如果您正苦於以下問題:Java XAxis.setDrawLabels方法的具體用法?Java XAxis.setDrawLabels怎麽用?Java XAxis.setDrawLabels使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.github.mikephil.charting.components.XAxis的用法示例。


在下文中一共展示了XAxis.setDrawLabels方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: dataSortedOnDay

import com.github.mikephil.charting.components.XAxis; //導入方法依賴的package包/類
private void dataSortedOnDay(int year, int month, int dayOfMonth) {
    if (graphValuesQuery != null)
        graphValuesQuery.removeEventListener(graphValuesListener);

    XAxis xaxis = chart.getXAxis();
    //xaxis.setTextSize(18f);
    xaxis.setDrawLabels(true);
    xaxis.setAxisMinimum(-0.5f);
    xaxis.setAxisMaximum(23.5f);
    xaxis.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);

    chart.getData().getDataSetByIndex(0).clear();
    getBarData().getDataSetByIndex(0).setLabel(getString(R.string.hour_of_day_string));

    String path = String.format("/cow_data/%s/%d/%d/%d", cowId, year, month, dayOfMonth);
    graphValuesQuery = FirebaseHelper.getInstance().getDatabase().getReference().child(path).orderByKey();

    graphValuesQuery.addChildEventListener(graphValuesListener);
}
 
開發者ID:ekalyvio,項目名稱:CowBit,代碼行數:20,代碼來源:CowDetailsActivity.java

示例2: dataSortedOnYear

import com.github.mikephil.charting.components.XAxis; //導入方法依賴的package包/類
private void dataSortedOnYear(int year) {
    if (graphValuesQuery != null)
        graphValuesQuery.removeEventListener(graphValuesListener);

    XAxis xaxis = chart.getXAxis();
    //xaxis.setTextSize(18f);
    xaxis.setDrawLabels(true);
    xaxis.setAxisMinimum(0.5f);
    xaxis.setAxisMaximum(12.5f);
    xaxis.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);

    chart.getData().getDataSetByIndex(0).clear();
    getBarData().getDataSetByIndex(0).setLabel(getString(R.string.month_of_year_string));

    String path = String.format("/cow_data/%s/%d", cowId, year);
    graphValuesQuery = FirebaseHelper.getInstance().getDatabase().getReference().child(path).orderByKey();

    graphValuesQuery.addChildEventListener(graphValuesListener);
}
 
開發者ID:ekalyvio,項目名稱:CowBit,代碼行數:20,代碼來源:CowDetailsActivity.java

示例3: dataSortedOnMonth

import com.github.mikephil.charting.components.XAxis; //導入方法依賴的package包/類
private void dataSortedOnMonth(int year, int month) {
    if (graphValuesQuery != null)
        graphValuesQuery.removeEventListener(graphValuesListener);

    int iMonth = month - 1; // 1 (months begin with 0)

    // Create a calendar object and set year and month
    Calendar mycal = new GregorianCalendar(year, iMonth, 1);

    // Get the number of days in that month
    int daysInMonth = mycal.getActualMaximum(Calendar.DAY_OF_MONTH);

    XAxis xaxis = chart.getXAxis();
    //xaxis.setTextSize(18f);
    xaxis.setDrawLabels(true);
    xaxis.setAxisMinimum(0.5f);
    xaxis.setAxisMaximum(daysInMonth + 0.5f);
    xaxis.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);

    chart.getData().getDataSetByIndex(0).clear();
    getBarData().getDataSetByIndex(0).setLabel(getString(R.string.day_of_month_string));

    String path = String.format("/cow_data/%s/%d/%d", cowId, year, month);
    graphValuesQuery = FirebaseHelper.getInstance().getDatabase().getReference().child(path).orderByKey();

    graphValuesQuery.addChildEventListener(graphValuesListener);
}
 
開發者ID:ekalyvio,項目名稱:CowBit,代碼行數:28,代碼來源:CowDetailsActivity.java

示例4: setupActivityChart

import com.github.mikephil.charting.components.XAxis; //導入方法依賴的package包/類
private void setupActivityChart() {
        mActivityChart.setBackgroundColor(BACKGROUND_COLOR);
        mActivityChart.setDescriptionColor(DESCRIPTION_COLOR);
        configureBarLineChartDefaults(mActivityChart);

        XAxis x = mActivityChart.getXAxis();
        x.setDrawLabels(true);
        x.setDrawGridLines(false);
        x.setEnabled(true);
        x.setTextColor(CHART_TEXT_COLOR);
        x.setDrawLimitLinesBehindData(true);

        YAxis y = mActivityChart.getAxisLeft();
        y.setDrawGridLines(false);
//        y.setDrawLabels(false);
        // TODO: make fixed max value optional
        y.setAxisMaxValue(1f);
        y.setAxisMinValue(0);
        y.setDrawTopYLabelEntry(false);
        y.setTextColor(CHART_TEXT_COLOR);

//        y.setLabelCount(5);
        y.setEnabled(true);

        YAxis yAxisRight = mActivityChart.getAxisRight();
        yAxisRight.setDrawGridLines(false);
        yAxisRight.setEnabled(supportsHeartrate(getChartsHost().getDevice()));
        yAxisRight.setDrawLabels(true);
        yAxisRight.setDrawTopYLabelEntry(true);
        yAxisRight.setTextColor(CHART_TEXT_COLOR);
        yAxisRight.setAxisMaxValue(HeartRateUtils.MAX_HEART_RATE_VALUE);
        yAxisRight.setAxisMinValue(HeartRateUtils.MIN_HEART_RATE_VALUE);
    }
 
開發者ID:scifiswapnil,項目名稱:gadgetbridge_artikcloud,代碼行數:34,代碼來源:SleepChartFragment.java

示例5: setupWeekStepsChart

import com.github.mikephil.charting.components.XAxis; //導入方法依賴的package包/類
private void setupWeekStepsChart() {
    mWeekStepsChart.setBackgroundColor(BACKGROUND_COLOR);
    mWeekStepsChart.setDescriptionColor(DESCRIPTION_COLOR);
    mWeekStepsChart.setDescription("");

    configureBarLineChartDefaults(mWeekStepsChart);

    XAxis x = mWeekStepsChart.getXAxis();
    x.setDrawLabels(true);
    x.setDrawGridLines(false);
    x.setEnabled(true);
    x.setTextColor(CHART_TEXT_COLOR);
    x.setDrawLimitLinesBehindData(true);

    YAxis y = mWeekStepsChart.getAxisLeft();
    y.setDrawGridLines(false);
    y.setDrawTopYLabelEntry(false);
    y.setTextColor(CHART_TEXT_COLOR);

    y.setEnabled(true);

    YAxis yAxisRight = mWeekStepsChart.getAxisRight();
    yAxisRight.setDrawGridLines(false);
    yAxisRight.setEnabled(false);
    yAxisRight.setDrawLabels(false);
    yAxisRight.setDrawTopYLabelEntry(false);
    yAxisRight.setTextColor(CHART_TEXT_COLOR);
}
 
開發者ID:scifiswapnil,項目名稱:gadgetbridge_artikcloud,代碼行數:29,代碼來源:WeekStepsChartFragment.java

示例6: setupChart

import com.github.mikephil.charting.components.XAxis; //導入方法依賴的package包/類
private void setupChart() {
        mChart.setBackgroundColor(BACKGROUND_COLOR);
        mChart.setDescriptionColor(DESCRIPTION_COLOR);
        configureBarLineChartDefaults(mChart);


        XAxis x = mChart.getXAxis();
        x.setDrawLabels(true);
        x.setDrawGridLines(false);
        x.setEnabled(true);
        x.setTextColor(CHART_TEXT_COLOR);
        x.setDrawLimitLinesBehindData(true);

        YAxis y = mChart.getAxisLeft();
        y.setDrawGridLines(false);
//        y.setDrawLabels(false);
        // TODO: make fixed max value optional
        y.setAxisMaxValue(1f);
        y.setAxisMinValue(0);
        y.setDrawTopYLabelEntry(false);
        y.setTextColor(CHART_TEXT_COLOR);

//        y.setLabelCount(5);
        y.setEnabled(true);

        YAxis yAxisRight = mChart.getAxisRight();
        yAxisRight.setDrawGridLines(false);
        yAxisRight.setEnabled(supportsHeartrate(getChartsHost().getDevice()));
        yAxisRight.setDrawLabels(true);
        yAxisRight.setDrawTopYLabelEntry(true);
        yAxisRight.setTextColor(CHART_TEXT_COLOR);
        yAxisRight.setAxisMaxValue(HeartRateUtils.MAX_HEART_RATE_VALUE);
        yAxisRight.setAxisMinValue(HeartRateUtils.MIN_HEART_RATE_VALUE);

        // refresh immediately instead of use refreshIfVisible(), for perceived performance
        refresh();
    }
 
開發者ID:scifiswapnil,項目名稱:gadgetbridge_artikcloud,代碼行數:38,代碼來源:ActivitySleepChartFragment.java

示例7: initChart

import com.github.mikephil.charting.components.XAxis; //導入方法依賴的package包/類
private void initChart(BarChart chart) {
    float scaledDensity = getResources().getDisplayMetrics().scaledDensity;
    chart.setDragEnabled(true);
    chart.setScaleYEnabled(false);
    chart.setScaleXEnabled(false);
    chart.setDoubleTapToZoomEnabled(false);
    chart.setPinchZoom(false);
    chart.setHighlightPerDragEnabled(false);
    chart.setHighlightPerTapEnabled(false);

    chart.setDrawGridBackground(false);
    chart.setDrawBorders(false);
    chart.setDrawValueAboveBar(false);
    chart.getAxisLeft().setEnabled(false);
    XAxis xAxis = chart.getXAxis();
    xAxis.setDrawAxisLine(true);
    xAxis.setDrawGridLines(false);
    xAxis.setDrawLabels(false);
    xAxis.setDrawLimitLinesBehindData(false);
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);

    YAxis yAxis = chart.getAxisRight();
    yAxis.setDrawAxisLine(false);
    yAxis.setStartAtZero(false);
    yAxis.setSpaceTop(10f);
    yAxis.setSpaceBottom(0f);
    yAxis.setTextSize(10 * scaledDensity);
    yAxis.setTextColor(ContextCompat.getColor(this, R.color.text));
    chart.getLegend().setEnabled(false);
    chart.setDescription(" ");

    chart.setNoDataText("Can't see sh*t captain!");
    Paint p = chart.getPaint(Chart.PAINT_INFO);
    DisplayMetrics dm = getResources().getDisplayMetrics();
    int size = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 18, dm); //TODO use styles
    p.setTextSize(size);
    p.setColor(ContextCompat.getColor(this, R.color.gray600));
    p.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
}
 
開發者ID:stanleyguevara,項目名稱:beaconradar,代碼行數:40,代碼來源:DetailsActivity.java

示例8: setUI

import com.github.mikephil.charting.components.XAxis; //導入方法依賴的package包/類
public void setUI() {
        final Description des = new Description();
        des.setText(".");
        lineChart.setDescription(des);
        lineChart.setDrawGridBackground(false);
        lineChart.setExtraBottomOffset(-50);

        XAxis x = lineChart.getXAxis();
        x.setPosition(XAxis.XAxisPosition.TOP);
        x.setDrawGridLines(false);
        x.setDrawAxisLine(false);
        x.setDrawLabels(true);
        x.setYOffset(25);


        x.setLabelRotationAngle(270);
        x.setTextSize(12);
        x.setTextColor(Color.WHITE);
        x.setValueFormatter(new IAxisValueFormatter() {
            @Override
            public String getFormattedValue(float value, AxisBase axis) {
//                Date dt = new Date((long) value);
//                Log.d(Const.TAG2, "sVF Next is "+dt.toString());
//                SimpleDateFormat simpleDateFormat = new SimpleDateFormat(" hh:mm aaa");
//                String newValue = simpleDateFormat.format(dt);
//                return Const.NO_BREAK + newValue;

                if(uHi==(int)value){
                    return "";
                }else {
                    uHi= (int) value;
                }

                Date d= new Date(dt[(int) value]);
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat(" hh:mm aaa");
                String newValue = simpleDateFormat.format(d);
                return Const.NO_BREAK + newValue;
            }
        });


        YAxis yLeft = lineChart.getAxis(YAxis.AxisDependency.LEFT);
        yLeft.setDrawGridLines(false);
        yLeft.setDrawAxisLine(false);
        yLeft.setDrawLabels(false);

        YAxis yRight = lineChart.getAxis(YAxis.AxisDependency.RIGHT);
        yRight.setDrawGridLines(false);
        yRight.setDrawAxisLine(false);
        yRight.setDrawLabels(false);

        lineChart.setDoubleTapToZoomEnabled(false);

        setData();
    }
 
開發者ID:shivam301296,項目名稱:True-Weather,代碼行數:56,代碼來源:WeatherGraph.java

示例9: initChart

import com.github.mikephil.charting.components.XAxis; //導入方法依賴的package包/類
/**
     * 初始化報表
     *
     * @param showAnimation 是否顯示動畫
     */
    void initChart(boolean showAnimation) {

        int screenWidth = Utils.getScreenWidth(mContext);
        combinedChart.getLayoutParams().height = screenWidth * 300 / 640;

        //啟用縮放和拖動
        combinedChart.setDragEnabled(true);//拖動
        combinedChart.setScaleEnabled(false);//縮放
        combinedChart.setOnChartValueSelectedListener(this);
        combinedChart.getDescription().setEnabled(false);
        combinedChart.setBackgroundColor(ContextCompat.getColor(mContext, R.color.co10));
        combinedChart.setDrawGridBackground(false);
        combinedChart.setDrawBarShadow(false);
        combinedChart.setHighlightFullBarEnabled(false);

        Legend l = combinedChart.getLegend();
        l.setForm(Legend.LegendForm.NONE);//底部樣式
        l.setTextColor(ContextCompat.getColor(mContext, R.color.transparent));
        l.setWordWrapEnabled(false);
        l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
        l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
        l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
        l.setDrawInside(false);

        YAxis rightAxis = combinedChart.getAxisRight();
        rightAxis.setEnabled(false);

        YAxis leftAxis = combinedChart.getAxisLeft();
        leftAxis.setDrawGridLines(false);
        leftAxis.setGranularityEnabled(false);
        leftAxis.setDrawAxisLine(false);
        leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
        leftAxis.setTextColor(ContextCompat.getColor(mContext, R.color.co4));

        updateTitle(items.get(dateSelected));
        XAxis xAxis = combinedChart.getXAxis();
        xAxis.setTypeface(mTfLight);
        xAxis.setEnabled(true);//設置軸啟用或禁用 如果禁用以下的設置全部不生效
        xAxis.setDrawAxisLine(true);//是否繪製軸線
        xAxis.setDrawGridLines(false);//設置x軸上每個點對應的線
        xAxis.setDrawLabels(true);//繪製標簽  指x軸上的對應數值
        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);//設置x軸的顯示位置
        xAxis.setTextSize(10f); //設置X軸文字大小
        xAxis.setGranularityEnabled(true);//是否允許X軸上值重複出現
        xAxis.setTextColor(ContextCompat.getColor(this, R.color.co4));//設置X軸文字顏色
//        //設置豎線的顯示樣式為虛線
//        //lineLength控製虛線段的長度
//        //spaceLength控製線之間的空間
        xAxis.enableGridDashedLine(10f, 10f, 0f);
        xAxis.setAxisMinimum(0f);//設置x軸的最小值
        xAxis.setAxisMaximum(mDatas.length);//設置最大值
        xAxis.setAvoidFirstLastClipping(true);//圖表將避免第一個和最後一個標簽條目被減掉在圖表或屏幕的邊緣
        xAxis.setLabelRotationAngle(0f);//設置x軸標簽字體的旋轉角度
//        設置x軸顯示標簽數量  還有一個重載方法第二個參數為布爾值強製設置數量 如果啟用會導致繪製點出現偏差
        xAxis.setLabelCount(10);
        xAxis.setGridLineWidth(10f);//設置豎線大小
//        xAxis.setGridColor(Color.RED);//設置豎線顏色
        xAxis.setAxisLineColor(Color.GRAY);//設置x軸線顏色
        xAxis.setAxisLineWidth(1f);//設置x軸線寬度

        CombinedData combinedData = new CombinedData();
        combinedData.setData(generateLineData());
        combinedData.setData(generateBarData());
        combinedData.setValueTypeface(mTfLight);
        xAxis.setAxisMaximum(combinedData.getXMax() + 0.25f);
        //X軸的數據格式
        ValueFormatter xAxisFormatter = new ValueFormatter(combinedChart);
        xAxisFormatter.setmValues(xAxisValue);
        xAxis.setValueFormatter(xAxisFormatter);//格式化x軸標簽顯示字符
        combinedChart.setData(combinedData);
        combinedChart.invalidate();
        if (showAnimation) {
            combinedChart.animateY(2000);
        }
    }
 
開發者ID:jay16,項目名稱:shengyiplus-android,代碼行數:81,代碼來源:HomeTricsActivity.java

示例10: setupHistoryChart

import com.github.mikephil.charting.components.XAxis; //導入方法依賴的package包/類
private void setupHistoryChart(BarLineChartBase chart) {
    configureBarLineChartDefaults(chart);

    chart.setTouchEnabled(false); // no zooming or anything, because it's updated all the time
    chart.setBackgroundColor(BACKGROUND_COLOR);
    chart.setDescriptionColor(DESCRIPTION_COLOR);
    chart.setDescription(getString(R.string.live_activity_steps_per_minute_history));
    chart.setNoDataText(getString(R.string.live_activity_start_your_activity));
    chart.getLegend().setEnabled(false);
    Paint infoPaint = chart.getPaint(Chart.PAINT_INFO);
    infoPaint.setTextSize(Utils.convertDpToPixel(20f));
    infoPaint.setFakeBoldText(true);
    chart.setPaint(infoPaint, Chart.PAINT_INFO);

    XAxis x = chart.getXAxis();
    x.setDrawLabels(true);
    x.setDrawGridLines(false);
    x.setEnabled(true);
    x.setTextColor(CHART_TEXT_COLOR);
    x.setDrawLimitLinesBehindData(true);

    YAxis y = chart.getAxisLeft();
    y.setDrawGridLines(false);
    y.setDrawTopYLabelEntry(false);
    y.setTextColor(CHART_TEXT_COLOR);
    y.setEnabled(true);
    y.setAxisMinValue(0);

    YAxis yAxisRight = chart.getAxisRight();
    yAxisRight.setDrawGridLines(false);
    yAxisRight.setEnabled(true);
    yAxisRight.setDrawLabels(true);
    yAxisRight.setDrawTopYLabelEntry(false);
    yAxisRight.setTextColor(CHART_TEXT_COLOR);
    yAxisRight.setAxisMaxValue(HeartRateUtils.MAX_HEART_RATE_VALUE);
    yAxisRight.setAxisMinValue(HeartRateUtils.MIN_HEART_RATE_VALUE);

    mHistorySet = new LineDataSet(new ArrayList<Entry>(), getString(R.string.live_activity_steps_history));
    mHistorySet.setAxisDependency(YAxis.AxisDependency.LEFT);
    mHistorySet.setColor(akActivity.color);
    mHistorySet.setDrawCircles(false);
    mHistorySet.setDrawCubic(true);
    mHistorySet.setDrawFilled(true);
    mHistorySet.setDrawValues(false);

    mHeartRateSet = createHeartrateSet(new ArrayList<Entry>(), getString(R.string.live_activity_heart_rate));
    mHeartRateSet.setDrawValues(false);
}
 
開發者ID:scifiswapnil,項目名稱:gadgetbridge_artikcloud,代碼行數:49,代碼來源:LiveActivityFragment.java

示例11: setLineChartStylingAndRefreshChart

import com.github.mikephil.charting.components.XAxis; //導入方法依賴的package包/類
/**
 * Set the line charts styling
 *
 * @param lineData the data to style
 */
private void setLineChartStylingAndRefreshChart(LineData lineData) {
    // style axis
    YAxis leftAxis = chart.getAxisLeft();
    leftAxis.setAxisMinValue(0f);
    leftAxis.setDrawGridLines(false);
    leftAxis.setTextSize(15);

    YAxis rightAxis = chart.getAxisRight();
    rightAxis.setDrawLabels(false);
    rightAxis.setDrawGridLines(false);

    XAxis xAxis = chart.getXAxis();
    xAxis.setDrawGridLines(false);
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setDrawLabels(false);

    // add threshold limit line
    String thresholdDescription = "";
    LimitLine limitLine = new LimitLine(100f, thresholdDescription);
    limitLine.setLineColor(Color.RED);
    limitLine.setLineWidth(1f);
    limitLine.setTextColor(Color.RED);
    limitLine.setTextSize(15f);

    if (leftAxis.getLimitLines().size() < 1)
        leftAxis.addLimitLine(limitLine);

    // add legend
    Legend l = chart.getLegend();
    l.setFormSize(10f);
    l.setForm(Legend.LegendForm.CIRCLE);
    l.setPosition(Legend.LegendPosition.BELOW_CHART_LEFT);
    l.setTextSize(12f);
    l.setTextColor(Color.BLACK);
    l.setXEntrySpace(5f);
    l.setYEntrySpace(5f);
    String[] labels = {Strings.getStringByRId(R.string.median_performance), Strings.getStringByRId(R.string.median_performance_forecast), Strings.getStringByRId(R.string.pre_operation_performance)};
    int[] colors = {ContextCompat.getColor(activity.getApplicationContext(), R.color.colorPrimary), ContextCompat.getColor(activity.getApplicationContext(), R.color.colorPrimaryLight), Color.RED};
    l.setCustom(colors, labels);


    // style chart and refresh
    chart.setDescription("");
    chart.setPinchZoom(false);
    chart.setDoubleTapToZoomEnabled(false);
    chart.setDrawGridBackground(false);
    chart.setData(lineData);
    chart.invalidate();
}
 
開發者ID:lidox,項目名稱:reaction-test,代碼行數:55,代碼來源:ReactionTimeLineChartWithForecast.java


注:本文中的com.github.mikephil.charting.components.XAxis.setDrawLabels方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。