本文整理汇总了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);
}