本文整理匯總了Java中com.github.mikephil.charting.components.XAxis.enableGridDashedLine方法的典型用法代碼示例。如果您正苦於以下問題:Java XAxis.enableGridDashedLine方法的具體用法?Java XAxis.enableGridDashedLine怎麽用?Java XAxis.enableGridDashedLine使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.github.mikephil.charting.components.XAxis
的用法示例。
在下文中一共展示了XAxis.enableGridDashedLine方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreateView
import com.github.mikephil.charting.components.XAxis; //導入方法依賴的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);
}
示例2: 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);
}
}