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


Java YAxis.setStartAtZero方法代碼示例

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


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

示例1: initChart

import com.github.mikephil.charting.components.YAxis; //導入方法依賴的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

示例2: onCreateView

import com.github.mikephil.charting.components.YAxis; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    view = inflater.inflate(R.layout.fragment_lastscanchart, container, false);

    LineChart cv_LastScan = (LineChart) view.findViewById(R.id.cv_LastScan);

    cv_LastScan.setOnChartGestureListener(new myChartGestureListener(cv_LastScan));

    XAxis xAxis = cv_LastScan.getXAxis();
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setTextSize(10f);
    xAxis.setTextColor(getResources().getColor(R.color.colorGlucoseNow));
    xAxis.enableGridDashedLine(5f, 5f, 0f);
    xAxis.setDrawLimitLinesBehindData(true);

    YAxis yAxisLeft = cv_LastScan.getAxisLeft();
    YAxis yAxisRight = cv_LastScan.getAxisRight();

    yAxisRight.setEnabled(false);

    yAxisLeft.setTextSize(18f); // set the textsize
    yAxisLeft.setTextColor(getResources().getColor(R.color.colorGlucoseNow));
    yAxisLeft.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
    yAxisLeft.setStartAtZero(true);
    yAxisLeft.setYOffset(-6f);
    yAxisLeft.setAxisMinValue(0.0f);

    Legend legend = cv_LastScan.getLegend();
    legend.setEnabled(false);

    // no description text
    cv_LastScan.setDescription("");
    cv_LastScan.setNoDataText(getResources().getString(R.string.no_data));
    cv_LastScan.setNoDataTextDescription("");

    // enable touch gestures
    cv_LastScan.setTouchEnabled(true);

    // enable scaling and dragging
    cv_LastScan.setDragEnabled(true);
    cv_LastScan.setScaleEnabled(true);
    cv_LastScan.setDrawGridBackground(false);

    // if disabled, scaling can be done on x- and y-axis separately
    cv_LastScan.setPinchZoom(true);


    MyMarkerView mv = new MyMarkerView(view.getContext(), R.layout.custom_marker_view);

    // set the marker to the chart
    cv_LastScan.setMarkerView(mv);

    try {
        int sdk = android.os.Build.VERSION.SDK_INT;
        if (sdk < android.os.Build.VERSION_CODES.HONEYCOMB) {
            cv_LastScan.setHardwareAccelerationEnabled(false);

        } else {
           cv_LastScan.setHardwareAccelerationEnabled(true);
        }
    } catch (Exception e) {
    }

    refresh();

    return (view);
}
 
開發者ID:CMKlug,項目名稱:Liapp,代碼行數:70,代碼來源:ChartFragment.java

示例3: onCreate

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

    mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
    mChart = (BarChart) findViewById(R.id.chart1);
    mChart.setBackgroundColor(Color.WHITE);
    mChart.setExtraTopOffset(-30f);
    mChart.setExtraBottomOffset(10f);
    mChart.setExtraLeftOffset(70f);
    mChart.setExtraRightOffset(70f);

    mChart.setDrawBarShadow(false);
    mChart.setDrawValueAboveBar(true);

    mChart.setDescription("");

    // scaling can now only be done on x- and y-axis separately
    mChart.setPinchZoom(false);

    mChart.setDrawGridBackground(false);

    XAxis xAxis = mChart.getXAxis();
    xAxis.setPosition(XAxisPosition.BOTTOM);
    xAxis.setTypeface(mTf);
    xAxis.setDrawGridLines(false);
    xAxis.setDrawAxisLine(false);
    xAxis.setSpaceBetweenLabels(2);
    xAxis.setTextColor(Color.LTGRAY);
    xAxis.setTextSize(13f);

    YAxis left = mChart.getAxisLeft();
    left.setDrawLabels(false);
    left.setStartAtZero(false);
    left.setSpaceTop(25f);
    left.setSpaceBottom(25f);
    left.setDrawAxisLine(false);
    left.setDrawGridLines(false);
    left.setDrawZeroLine(true); // draw a zero line
    left.setZeroLineColor(Color.GRAY);
    left.setZeroLineWidth(0.7f);
    mChart.getAxisRight().setEnabled(false);
    mChart.getLegend().setEnabled(false);

    // THIS IS THE ORIGINAL DATA YOU WANT TO PLOT
    List<Data> data = new ArrayList<>();
    data.add(new Data(0, -224.1f, "12-29"));
    data.add(new Data(1, 238.5f, "12-30"));
    data.add(new Data(2, 1280.1f, "12-31"));
    data.add(new Data(3, -442.3f, "01-01"));
    data.add(new Data(4, -2280.1f, "01-02"));

    setData(data);
}
 
開發者ID:rahulmaddineni,項目名稱:Stayfit,代碼行數:58,代碼來源:BarChartPositiveNegative.java

示例4: initChart

import com.github.mikephil.charting.components.YAxis; //導入方法依賴的package包/類
public void initChart() {
    mChart.setDescription("");
    mChart.setDragEnabled(false);
    mChart.setScaleEnabled(false);
    mChart.setPinchZoom(false);

    GraphMarkerView markerView = new GraphMarkerView(mChart.getContext(), R.layout.trackdota_graph_marker);
    mChart.setMarkerView(markerView);
    mChart.setHighlightEnabled(false);

    XAxis xAxis = mChart.getXAxis();
    xAxis.removeAllLimitLines();
    xAxis.setDrawLimitLinesBehindData(true);
    xAxis.setDrawGridLines(true);

    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.removeAllLimitLines();
    leftAxis.setStartAtZero(false);

    LimitLine limitLine = new LimitLine(0f);
    limitLine.setLineColor(Color.WHITE);
    limitLine.setLineWidth(2f);
    leftAxis.addLimitLine(limitLine);

    mChart.setBackgroundColor(Color.BLACK);
    mChart.setDrawBorders(false);
    mChart.getLegend().setEnabled(false);
    mChart.setDoubleTapToZoomEnabled(false);
    mChart.setDrawGridBackground(false);

    leftAxis.setValueFormatter(new ValueFormatter() {
        @Override
        public String getFormattedValue(float value) {
            return String.valueOf((int) value);
        }
    });

    leftAxis.setTextColor(Color.WHITE);

    mChart.getAxisRight().setEnabled(false);
    //mChart.animateX(2500);
    clearChart();
}
 
開發者ID:mrprona92,項目名稱:SecretBrand,代碼行數:44,代碼來源:Graphs.java

示例5: SetupChart

import com.github.mikephil.charting.components.YAxis; //導入方法依賴的package包/類
public void SetupChart() {
    lineChart = (LineChart) myLayout.findViewById(R.id.chart);
    lineChart.setDescription("");
    lineChart.setDrawBorders(false);
    lineChart.setNoDataTextDescription("You need to provide data for the chart.");
    lineChart.setDrawGridBackground(false);
    lineChart.setOnChartValueSelectedListener(this);
    lineChart.setTouchEnabled(true);
    lineChart.setDragEnabled(false);
    lineChart.setPinchZoom(false);
    lineChart.setScaleXEnabled(true);
    lineChart.setScaleYEnabled(true);
    lineChart.invalidate();
    LineData data = new LineData();
    data.setValueTextColor(Color.WHITE);
    // add empty data
    lineChart.setData(data);
    // get the legend (only possible after setting data)
    Legend l = lineChart.getLegend();
    l.setEnabled(false);
    // x axis setup
    XAxis xl = lineChart.getXAxis();
    xl.setTextColor(Color.WHITE);
    xl.setDrawGridLines(false);
    xl.setAvoidFirstLastClipping(false);
    xl.setSpaceBetweenLabels(3);
    xl.setEnabled(true);
    xl.setDrawAxisLine(false);
    xl.removeAllLimitLines();
    //right y axis setup
    YAxis rightAxis = lineChart.getAxisRight();
    rightAxis.setEnabled(false);
    //left y axis setup
    YAxis leftAxis = lineChart.getAxisLeft();
    leftAxis.setTextColor(Color.WHITE);
    leftAxis.setLabelCount(6, true);
    leftAxis.setAxisMaxValue(400f);
    leftAxis.setAxisMinValue(0f);
    leftAxis.setDrawGridLines(false);
    leftAxis.setStartAtZero(false);
    leftAxis.setEnabled(true);
    leftAxis.setDrawAxisLine(false);
    leftAxis.setDrawZeroLine(false);
    leftAxis.setGranularityEnabled(false);
    //define min max line
    LimitLine max = new LimitLine(150f);
    max.enableDashedLine(10f, 10f, 0f);
    LimitLine min = new LimitLine(50f);
    min.enableDashedLine(10f, 10f, 0f);
    // reset all limit lines to avoid overlapping lines
    leftAxis.removeAllLimitLines();
    //add min max line
    leftAxis.addLimitLine(max);
    leftAxis.addLimitLine(min);

    lineChart.invalidate();
}
 
開發者ID:LadyViktoria,項目名稱:wearDrip,代碼行數:58,代碼來源:wearDripWatchFace.java


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