本文整理匯總了Java中com.github.mikephil.charting.components.XAxis.setGridLineWidth方法的典型用法代碼示例。如果您正苦於以下問題:Java XAxis.setGridLineWidth方法的具體用法?Java XAxis.setGridLineWidth怎麽用?Java XAxis.setGridLineWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.github.mikephil.charting.components.XAxis
的用法示例。
在下文中一共展示了XAxis.setGridLineWidth方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createChart
import com.github.mikephil.charting.components.XAxis; //導入方法依賴的package包/類
private static void createChart(Chart barChart, List<Pair<String, Integer>> chartData, String title, Context context){
int count = chartData.size() > 10 ? 10 : chartData.size();
String[] stateNames = new String[count];
for (int i=0; i<count; ++i) {
Pair<String, Integer> record = chartData.get(i);
stateNames[i] = record.first;
}
StateAxisValueFormatter stateAxisValueFormatter = new StateAxisValueFormatter(stateNames);
barChart.getDescription().setEnabled(false);
barChart.setTouchEnabled(false);
XAxis xl = barChart.getXAxis();
xl.setPosition(XAxis.XAxisPosition.BOTTOM);
xl.setDrawAxisLine(true);
xl.setDrawGridLines(true);
xl.setGridLineWidth(0.3f);
xl.setTextSize(11f);
xl.setTextColor(Color.BLACK);
xl.setLabelCount(count);
xl.setValueFormatter(stateAxisValueFormatter);
// setting data
Legend l = barChart.getLegend();
l.setDirection(Legend.LegendDirection.LEFT_TO_RIGHT);
l.setFormSize(11f);
l.setTextSize(11f);
l.setXEntrySpace(4f);
setData(barChart, chartData, title,context);
}
示例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);
}
}
示例3: 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_horizontalbarchart);
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mChart = (HorizontalBarChart) findViewById(R.id.chart1);
mChart.setOnChartValueSelectedListener(this);
// mChart.setHighlightEnabled(false);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.setDescription("");
// if more than 60 entries are displayed in the chart, no values will be
// drawn
mChart.setMaxVisibleValueCount(60);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
// draw shadows for each bar that show the maximum value
// mChart.setDrawBarShadow(true);
// mChart.setDrawXLabels(false);
mChart.setDrawGridBackground(false);
// mChart.setDrawYLabels(false);
tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
XAxis xl = mChart.getXAxis();
xl.setPosition(XAxisPosition.BOTTOM);
xl.setTypeface(tf);
xl.setDrawAxisLine(true);
xl.setDrawGridLines(true);
xl.setGridLineWidth(0.3f);
YAxis yl = mChart.getAxisLeft();
yl.setTypeface(tf);
yl.setDrawAxisLine(true);
yl.setDrawGridLines(true);
yl.setGridLineWidth(0.3f);
yl.setAxisMinValue(0f); // this replaces setStartAtZero(true)
// yl.setInverted(true);
YAxis yr = mChart.getAxisRight();
yr.setTypeface(tf);
yr.setDrawAxisLine(true);
yr.setDrawGridLines(false);
yr.setAxisMinValue(0f); // this replaces setStartAtZero(true)
// yr.setInverted(true);
setData(12, 50);
mChart.animateY(2500);
// setting data
mSeekBarY.setProgress(50);
mSeekBarX.setProgress(12);
mSeekBarY.setOnSeekBarChangeListener(this);
mSeekBarX.setOnSeekBarChangeListener(this);
Legend l = mChart.getLegend();
l.setPosition(LegendPosition.BELOW_CHART_LEFT);
l.setFormSize(8f);
l.setXEntrySpace(4f);
// mChart.setDrawLegend(false);
}