首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> 更多程式語言 >> 程式設計綜合問答

MPAndroidChart 圖表客製化設定:隱藏網格、Y 軸標籤與起始數值

     編輯:程式設計綜合問答

常見設定

// 是否啟用網格背景
mChart.setDrawGridBackground(false);
// 是否繪製 Y 軸標籤
mChart.setDrawYLabels(false);
// 網格垂直線是否顯示
mChart.setDrawVerticalGrid(false);
// Y 軸是否從 0 開始
mChart.setStartAtZero(false);
// 是否在 Y 軸顯示數據值
mChart.setDrawYValues(true);
// 設定邊框
mChart.setDrawBorder(false);
mChart.setBorderPositions(new BarLineChartBase.BorderPosition[]{
    BarLineChartBase.BorderPosition.BOTTOM
});
// 設定單位
mChart.setUnit("°C");
// 設定透明度
mChart.setAlpha(0.8f);

X 軸與 Y 軸標籤

XLabels xl = mChart.getXLabels();
xl.setPosition(XLabels.XLabelPosition.BOTTOM);
xl.setTextSize(10f);
xl.setSpaceBetweenLabels(3);

YLabels yl = mChart.getYLabels();
yl.setTextSize(10f);
yl.setLabelCount(5);

動畫與圖例

mChart.animateX(2000);
mChart.animateY(2000);
Legend l = mChart.getLegend();
l.setForm(Legend.LegendForm.LINE);
l.setTextSize(15);
l.setTextColor(Color.rgb(104, 241, 175));

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved