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


Java XAxis.setAxisLineWidth方法代碼示例

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


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

示例1: setUpBarChart

import com.github.mikephil.charting.components.XAxis; //導入方法依賴的package包/類
private void setUpBarChart() {
    BarData barData = generateBarData(project.getTimeSpent());

    XAxis xAxis = barChart.getXAxis();
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setAxisLineColor(Color.WHITE);
    xAxis.setTextColor(Color.WHITE);
    xAxis.setDrawGridLines(false);
    xAxis.setGranularity(1f);
    xAxis.setValueFormatter(new FormatUtils().getBarXAxisValueFormatterInstance(referenceTime));
    xAxis.setAxisLineWidth(2f);

    YAxis leftAxis = barChart.getAxisLeft();
    leftAxis.removeAllLimitLines();
    leftAxis.setDrawGridLines(false);
    leftAxis.setAxisLineColor(Color.WHITE);
    leftAxis.setTextColor(Color.WHITE);
    leftAxis.setGranularity(60 * 60);
    leftAxis.setValueFormatter(new IAxisValueFormatter() {
        @Override
        public String getFormattedValue(float value, AxisBase axis) {

            int hours = (int) TimeUnit.SECONDS.toHours((long) Math.ceil(value));

            return (hours == 0)
                    ? "" : context.getString(R.string.hours, hours);
        }
    });
    leftAxis.setAxisLineWidth(2f);

    int maxYData = (int) (Math.ceil(barData.getYMax()) + 3600);

    leftAxis.setAxisMaximum(maxYData);
    leftAxis.setAxisMinimum(0f);

    CustomMarkerView customMarkerView = new CustomMarkerView(context, R.layout.marker_view, referenceTime);
    barChart.setMarker(customMarkerView);

    barChart.getAxisRight().setEnabled(false);
    barChart.getLegend().setEnabled(false);
    barChart.getDescription().setEnabled(false);
    barChart.setBackground(context.getResources().getDrawable(R.color.colorPrimaryDark));
    barChart.setDrawGridBackground(false);
    barChart.setDragEnabled(false);
    barChart.setScaleEnabled(false);
    barChart.setDragDecelerationEnabled(false);
    barChart.setPinchZoom(false);
    barChart.setDoubleTapToZoomEnabled(false);
    barChart.setDrawBorders(false);
    barChart.setData(barData);

    customMarkerView.setChartView(barChart);

    barChart.setVisibility(View.VISIBLE);
    barChart.animateY(1500, Easing.EasingOption.Linear);
}
 
開發者ID:Protino,項目名稱:CodeWatch,代碼行數:57,代碼來源:ProjectDetailsFragment.java

示例2: setUpBarChart

import com.github.mikephil.charting.components.XAxis; //導入方法依賴的package包/類
private void setUpBarChart(int dailyGoal, List<Integer> progressSoFar) {

        BarData barData = generateBarData(dailyGoal, progressSoFar);

        //Set up a limit line indicating the goal
        LimitLine limitLine = new LimitLine(dailyGoal * 60 * 60, context.getString(R.string.goal));
        limitLine.setLineWidth(4f);
        limitLine.setLineColor(blue400);
        limitLine.setTextSize(12f);
        limitLine.setTextColor(Color.WHITE);

        //Format Xaxis
        XAxis xAxis = goalBarChart.getXAxis();
        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
        xAxis.setDrawGridLines(false);
        xAxis.setAxisLineColor(Color.WHITE);
        xAxis.setTextColor(Color.WHITE);
        xAxis.setGranularity(1f);
        xAxis.setValueFormatter(new FormatUtils().getBarXAxisValueFormatterInstance(referenceTime));
        xAxis.setAxisLineWidth(2f);

        //Format Yaxis
        YAxis leftAxis = goalBarChart.getAxisLeft();
        leftAxis.removeAllLimitLines();
        leftAxis.addLimitLine(limitLine);
        leftAxis.setDrawGridLines(false);
        leftAxis.setAxisLineColor(Color.WHITE);
        leftAxis.setTextColor(Color.WHITE);
        leftAxis.setGranularity(60 * 60);
        leftAxis.setValueFormatter(new IAxisValueFormatter() {
            @Override
            public String getFormattedValue(float value, AxisBase axis) {

                /* Do not display zero value and format the value as time*/
                return (value == 0)
                        ? "" : FormatUtils.getFormattedTime(context, (int) value);
            }
        });
        leftAxis.setAxisLineWidth(2f);

        //Set a maximum value on purpose so that marker view is visible
        int maximum;
        int maxYData = (int) TimeUnit.SECONDS.toHours((long) Math.ceil(barData.getYMax()));
        maximum = (maxYData > dailyGoal) ? maxYData : dailyGoal;
        maximum += 2;
        leftAxis.setAxisMaximum(maximum * 60 * 60);
        leftAxis.setAxisMinimum(0f);

        // Setup a marker view to display details of the selected dataItem
        CustomMarkerView customMarkerView = new CustomMarkerView(context, R.layout.marker_view, referenceTime);
        goalBarChart.setMarker(customMarkerView);

        // Disable interactions
        goalBarChart.getAxisRight().setEnabled(false);
        goalBarChart.getLegend().setEnabled(false);
        goalBarChart.getDescription().setEnabled(false);
        goalBarChart.setBackgroundColor(windowColor);
        goalBarChart.setDrawGridBackground(false);
        goalBarChart.setDragEnabled(false);
        goalBarChart.setScaleEnabled(false);
        goalBarChart.setDragDecelerationEnabled(false);
        goalBarChart.setPinchZoom(false);
        goalBarChart.setDoubleTapToZoomEnabled(false);
        goalBarChart.setDrawBorders(false);
        goalBarChart.setData(barData);

        customMarkerView.setChartView(goalBarChart);

        goalBarChart.setVisibility(View.VISIBLE);
        goalBarChart.animateY(1500, Easing.EasingOption.Linear);
    }
 
開發者ID:Protino,項目名稱:CodeWatch,代碼行數:72,代碼來源:GoalsDetailFragment.java

示例3: setUpActivityChart

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

        Legend l = lineChart.getLegend();
        l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
        l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
        l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
        l.setDrawInside(false);
        l.setTextColor(Color.WHITE);
        l.setTextSize(12);
        l.setWordWrapEnabled(true);
        l.setXEntrySpace(UiUtils.dpToPx(4));
        l.setYEntrySpace(UiUtils.dpToPx(4));

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

        YAxis leftAxis = lineChart.getAxisLeft();
        leftAxis.setDrawGridLines(false);
        leftAxis.setAxisMinimum(0);
        leftAxis.setValueFormatter(new IAxisValueFormatter() {
            @Override
            public String getFormattedValue(float value, AxisBase axis) {
                return value == 0 ? "" : String.valueOf(FormatUtils.getFormattedTime(context, (int) value));
            }
        });
        leftAxis.setGranularityEnabled(true);
        leftAxis.setGranularity(3600f); // FIXME: 12-04-2017 granularity not respected
        leftAxis.setAxisLineWidth(2f);
        leftAxis.setTextColor(Color.WHITE);
        leftAxis.setAxisLineColor(Color.WHITE);

        XAxis xAxis = lineChart.getXAxis();
        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
        xAxis.setDrawGridLines(false);
        xAxis.setTextColor(Color.WHITE);
        xAxis.setSpaceMin(0.5f);
        xAxis.setSpaceMax(0.5f);
        xAxis.setYOffset(UiUtils.dpToPx(4));
        xAxis.setAxisLineWidth(2f);
        xAxis.setAxisLineColor(Color.WHITE);

        lineChart.getDescription().setEnabled(false);
        lineChart.setDrawGridBackground(false);
        lineChart.setBackground(context.getResources().getDrawable(R.color.colorPrimaryDark));
        lineChart.setDragEnabled(false);
        lineChart.setScaleEnabled(false);
        lineChart.setDragDecelerationEnabled(false);
        lineChart.setPinchZoom(false);
        lineChart.setDoubleTapToZoomEnabled(false);
        lineChart.setDrawBorders(false);
        lineChart.setExtraOffsets(16, 0, 16, 0);
    }
 
開發者ID:Protino,項目名稱:CodeWatch,代碼行數:53,代碼來源:DashboardFragment.java

示例4: setUpActivityChart

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

        Legend l = lineChart.getLegend();
        l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
        l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
        l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
        l.setDrawInside(false);
        l.setTextColor(Color.WHITE);
        l.setTextSize(12);
        l.setWordWrapEnabled(true);
        l.setXEntrySpace(UiUtils.dpToPx(4));
        l.setYEntrySpace(UiUtils.dpToPx(4));

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

        YAxis leftAxis = lineChart.getAxisLeft();
        leftAxis.setDrawGridLines(false);
        leftAxis.setAxisMinimum(0);
        leftAxis.setValueFormatter(new IAxisValueFormatter() {
            @Override
            public String getFormattedValue(float value, AxisBase axis) {
                return value == 0 ? "" : String.valueOf(FormatUtils.getFormattedTime(context, (int) value));
            }
        });
        leftAxis.setGranularityEnabled(true);
        leftAxis.setGranularity(3600f); // FIXME: 12-04-2017 granularity not respected
        leftAxis.setAxisLineWidth(2f);
        leftAxis.setTextColor(Color.WHITE);
        leftAxis.setAxisLineColor(Color.WHITE);

        long referenceTime = new DateTime().plusDays(-7).getMillis();
        XAxis xAxis = lineChart.getXAxis();
        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
        xAxis.setValueFormatter(new FormatUtils().getBarXAxisValueFormatterInstance(referenceTime));
        xAxis.setDrawGridLines(false);
        xAxis.setTextColor(Color.WHITE);
        xAxis.setSpaceMin(0.5f);
        xAxis.setSpaceMax(0.5f);
        xAxis.setYOffset(UiUtils.dpToPx(4));
        xAxis.setAxisLineWidth(2f);
        xAxis.setAxisLineColor(Color.WHITE);


        CustomMarkerView customMarkerView = new CustomMarkerView(context, R.layout.marker_view, referenceTime);
        lineChart.setMarker(customMarkerView);
        lineChart.getDescription().setEnabled(false);
        lineChart.setDrawGridBackground(false);
        lineChart.setBackground(context.getResources().getDrawable(R.color.colorPrimaryDark));
        lineChart.setDragEnabled(false);
        lineChart.setScaleEnabled(false);
        lineChart.setDragDecelerationEnabled(false);
        lineChart.setPinchZoom(false);
        lineChart.setDoubleTapToZoomEnabled(false);
        lineChart.setDrawBorders(false);
        lineChart.setExtraOffsets(16, 0, 16, 0);

        customMarkerView.setChartView(lineChart);
    }
 
開發者ID:Protino,項目名稱:CodeWatch,代碼行數:60,代碼來源:DashboardFragment.java

示例5: onCreate

import com.github.mikephil.charting.components.XAxis; //導入方法依賴的package包/類
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_coin_detail);
//        overridePendingTransition(R.anim.right_in, R.anim.stay);
        initToolbar("Coin Details", R.drawable.ic_back_arrow);
        initUserAction("", 0, false);

        Bundle bundle = getIntent().getExtras();

        if (bundle != null) {
            coinTag = bundle.getString(Constants.COIN_TAG, "");
            coinName = bundle.getString(Constants.COIN_NAME, "");
        }

        tvCoinName.setText(coinName);

        mChart = (LineChart) findViewById(R.id.chart);
//        mChart.setPadding(4,4,4,4);

        // FIXME calculate offset for right
        mChart.setViewPortOffsets(6, 30, 90, 60);

        // no description text
        mChart.getDescription().setEnabled(false);
        mChart.setNoDataText("");

        // 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.setMaxHighlightDistance(300);

        XAxis x = mChart.getXAxis();
        x.setTextColor(ContextCompat.getColor(this, R.color.colorText));
        x.setPosition(XAxis.XAxisPosition.BOTTOM);
        x.setAxisLineColor(Color.TRANSPARENT);
        x.setDrawGridLines(false);
        x.setAxisLineWidth(0f);
        x.setGranularity(1f);
        x.setValueFormatter(new MyXAxisValueFormatter());
        x.setLabelRotationAngle(315);

        YAxis y = mChart.getAxisRight();
//        y.setTypeface();
        y.setLabelCount(6, false);
        y.setTextColor(ContextCompat.getColor(this, R.color.colorText));
        y.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
        y.setDrawGridLines(true);
        y.setAxisLineColor(Color.TRANSPARENT);
        y.setAxisLineWidth(0f);
        y.setValueFormatter(new MyYAxisValueFormatter());

        mChart.getAxisLeft().setEnabled(false);

        // add data
        getCoinDetails(coinTag);

//        setData(45, 100);
        mChart.getLegend().setEnabled(false);
        mChart.animateX(1500);

        // dont forget to refresh the drawing
//        mChart.invalidate();
    }
 
開發者ID:mayuroks,項目名稱:Coin-Tracker,代碼行數:73,代碼來源:CoinDetailsActivity.java

示例6: onCreate

import com.github.mikephil.charting.components.XAxis; //導入方法依賴的package包/類
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_coin_details);
        initToolbar("Coin Graph", 0);

        mChart = (LineChart) findViewById(R.id.chart);
        mChart.setBackgroundColor(Color.TRANSPARENT);

        // no description text
        mChart.getDescription().setEnabled(false);

        // 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.setMaxHighlightDistance(300);

        XAxis x = mChart.getXAxis();
        x.setTextColor(Color.RED);
        x.setPosition(XAxis.XAxisPosition.BOTTOM);
        x.setAxisLineColor(Color.BLUE);
        x.setDrawGridLines(false);
        x.setAxisLineWidth(2f);

        YAxis y = mChart.getAxisRight();
//        y.setTypeface();
        y.setLabelCount(6, false);
        y.setTextColor(Color.RED);
        y.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
        y.setDrawGridLines(false);
        y.setAxisLineColor(Color.BLUE);
        y.setAxisLineWidth(2f);

        mChart.getAxisLeft().setEnabled(false);

        // add data
        setData(45, 100);
        mChart.getLegend().setEnabled(false);
        mChart.animateX(1000);

        // dont forget to refresh the drawing
        mChart.invalidate();

        // TODO Testing
        if (mChart.getData() != null) {
            mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled());
            mChart.invalidate();
        }
    }
 
開發者ID:mayuroks,項目名稱:Coin-Tracker,代碼行數:60,代碼來源:CubicLineChartActivity.java

示例7: 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


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