本文整理汇总了Java中com.github.mikephil.charting.components.XAxis.setAxisMinimum方法的典型用法代码示例。如果您正苦于以下问题:Java XAxis.setAxisMinimum方法的具体用法?Java XAxis.setAxisMinimum怎么用?Java XAxis.setAxisMinimum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.components.XAxis
的用法示例。
在下文中一共展示了XAxis.setAxisMinimum方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dataSortedOnDay
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void dataSortedOnDay(int year, int month, int dayOfMonth) {
if (graphValuesQuery != null)
graphValuesQuery.removeEventListener(graphValuesListener);
XAxis xaxis = chart.getXAxis();
//xaxis.setTextSize(18f);
xaxis.setDrawLabels(true);
xaxis.setAxisMinimum(-0.5f);
xaxis.setAxisMaximum(23.5f);
xaxis.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);
chart.getData().getDataSetByIndex(0).clear();
getBarData().getDataSetByIndex(0).setLabel(getString(R.string.hour_of_day_string));
String path = String.format("/cow_data/%s/%d/%d/%d", cowId, year, month, dayOfMonth);
graphValuesQuery = FirebaseHelper.getInstance().getDatabase().getReference().child(path).orderByKey();
graphValuesQuery.addChildEventListener(graphValuesListener);
}
示例2: dataSortedOnYear
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void dataSortedOnYear(int year) {
if (graphValuesQuery != null)
graphValuesQuery.removeEventListener(graphValuesListener);
XAxis xaxis = chart.getXAxis();
//xaxis.setTextSize(18f);
xaxis.setDrawLabels(true);
xaxis.setAxisMinimum(0.5f);
xaxis.setAxisMaximum(12.5f);
xaxis.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);
chart.getData().getDataSetByIndex(0).clear();
getBarData().getDataSetByIndex(0).setLabel(getString(R.string.month_of_year_string));
String path = String.format("/cow_data/%s/%d", cowId, year);
graphValuesQuery = FirebaseHelper.getInstance().getDatabase().getReference().child(path).orderByKey();
graphValuesQuery.addChildEventListener(graphValuesListener);
}
示例3: setXAxis
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void setXAxis(int epochs) {
final XAxis axis = mChart.getXAxis();
axis.setEnabled(true);
axis.setAxisMinimum(1F);
axis.setAxisMaximum(epochs);
axis.setPosition(XAxis.XAxisPosition.BOTTOM);
axis.setDrawAxisLine(true);
axis.setDrawGridLines(false);
axis.setGranularity(1F);
axis.setAvoidFirstLastClipping(true);
mChart.getAxisRight().setDrawAxisLine(true);
}
示例4: setupXAxis
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void setupXAxis(BarLineChartBase chart, IAxisValueFormatter formatter) {
XAxis x = chart.getXAxis();
x.setGranularity(1.0f);
x.setDrawGridLines(false);
x.setPosition(XAxis.XAxisPosition.BOTTOM);
x.setDrawAxisLine(false);
x.setCenterAxisLabels(true);
x.setAxisMinimum(2.0f);
x.setAxisMaximum(5.0f);
x.setValueFormatter(formatter);
}
示例5: dataSortedOnMonth
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void dataSortedOnMonth(int year, int month) {
if (graphValuesQuery != null)
graphValuesQuery.removeEventListener(graphValuesListener);
int iMonth = month - 1; // 1 (months begin with 0)
// Create a calendar object and set year and month
Calendar mycal = new GregorianCalendar(year, iMonth, 1);
// Get the number of days in that month
int daysInMonth = mycal.getActualMaximum(Calendar.DAY_OF_MONTH);
XAxis xaxis = chart.getXAxis();
//xaxis.setTextSize(18f);
xaxis.setDrawLabels(true);
xaxis.setAxisMinimum(0.5f);
xaxis.setAxisMaximum(daysInMonth + 0.5f);
xaxis.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);
chart.getData().getDataSetByIndex(0).clear();
getBarData().getDataSetByIndex(0).setLabel(getString(R.string.day_of_month_string));
String path = String.format("/cow_data/%s/%d/%d", cowId, year, month);
graphValuesQuery = FirebaseHelper.getInstance().getDatabase().getReference().child(path).orderByKey();
graphValuesQuery.addChildEventListener(graphValuesListener);
}
示例6: configureWeatherChart
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
/**
* Configure styles of weather charts.
*
* @param entries chart data.
* @param formatter value formatter.
* @param minVal min value to show.
* @param maxVal max value to show.
* @return chart formatted.
*/
private LineDataSet configureWeatherChart(
LineChart chart, int chartName, int colorLineTempChart, int colorFillTempChart,
List<Entry> entries, IAxisValueFormatter formatter, double minVal, double maxVal) {
LineDataSet lineDataSet = new LineDataSet(entries, getString(chartName));
lineDataSet.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
lineDataSet.setDrawValues(false);
lineDataSet.setValueTextSize(10f);
lineDataSet.setDrawCircles(false);
lineDataSet.setLineWidth(1.8f);
lineDataSet.setColor(ContextCompat.getColor(getContext(), colorLineTempChart));
lineDataSet.setLineWidth(2f);
lineDataSet.setDrawFilled(true);
lineDataSet.setFillColor(ContextCompat.getColor(getContext(), colorFillTempChart));
lineDataSet.setFillAlpha(255);
// General setup
chart.setDrawGridBackground(false);
chart.setDrawBorders(false);
chart.setViewPortOffsets(0, 0, 0, 0);
chart.getDescription().setEnabled(false);
chart.getLegend().setEnabled(false);
chart.setTouchEnabled(false);
// X axis setup
XAxis xAxis = chart.getXAxis();
xAxis.setEnabled(false);
xAxis.setAxisMinimum(0);
xAxis.setAxisMaximum(lastTimestamp);
// Y axis setup
YAxis leftAxis = chart.getAxisLeft();
leftAxis.setEnabled(false);
leftAxis.setAxisMaximum((float) (maxVal));
leftAxis.setAxisMinimum((float) (minVal));
YAxis rightAxis = chart.getAxisRight();
rightAxis.setAxisMaximum((float) (maxVal));
rightAxis.setAxisMinimum((float) (minVal));
rightAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
rightAxis.setValueFormatter(formatter);
return lineDataSet;
}
示例7: recalculateXAxis
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void recalculateXAxis() {
final XAxis xAxis = barChart.getXAxis();
xAxis.setAxisMinimum(0);
xAxis.setAxisMaximum(histogramData.getNumBins());
barChart.notifyDataSetChanged();
barChart.invalidate();
}
示例8: 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_combined);
mChart = (CombinedChart) findViewById(R.id.chart1);
mChart.getDescription().setEnabled(false);
mChart.setBackgroundColor(Color.WHITE);
mChart.setDrawGridBackground(false);
mChart.setDrawBarShadow(false);
mChart.setHighlightFullBarEnabled(false);
// draw bars behind lines
mChart.setDrawOrder(new DrawOrder[]{
DrawOrder.BAR, DrawOrder.BUBBLE, DrawOrder.CANDLE, DrawOrder.LINE, DrawOrder.SCATTER
});
Legend l = mChart.getLegend();
l.setWordWrapEnabled(true);
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setDrawGridLines(false);
rightAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setDrawGridLines(false);
leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTH_SIDED);
xAxis.setAxisMinimum(0f);
xAxis.setGranularity(1f);
xAxis.setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return mMonths[(int) value % mMonths.length];
}
});
CombinedData data = new CombinedData();
data.setData(generateLineData());
data.setData(generateBarData());
data.setData(generateBubbleData());
data.setData(generateScatterData());
data.setData(generateCandleData());
data.setValueTypeface(mTfLight);
xAxis.setAxisMaximum(data.getXMax() + 0.25f);
mChart.setData(data);
mChart.invalidate();
}
示例9: 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_linechart);
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarX.setProgress(45);
mSeekBarY.setProgress(100);
mSeekBarY.setOnSeekBarChangeListener(this);
mSeekBarX.setOnSeekBarChangeListener(this);
mChart = (LineChart) findViewById(R.id.chart1);
mChart.setOnChartValueSelectedListener(this);
mChart.setDrawGridBackground(false);
// no description text
mChart.getDescription().setEnabled(false);
// enable touch gestures
mChart.setTouchEnabled(true);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
// if disabled, scaling can be done on x- and y-axis separately
mChart.setPinchZoom(true);
// set an alternative background color
// mChart.setBackgroundColor(Color.GRAY);
// create a custom MarkerView (extend MarkerView) and specify the layout
// to use for it
MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view);
mv.setChartView(mChart); // For bounds control
mChart.setMarker(mv); // Set the marker to the chart
XAxis xl = mChart.getXAxis();
xl.setAvoidFirstLastClipping(true);
xl.setAxisMinimum(0f);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setInverted(true);
leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setEnabled(false);
// add data
setData(25, 50);
// // restrain the maximum scale-out factor
// mChart.setScaleMinima(3f, 3f);
//
// // center the view to a specific position inside the chart
// mChart.centerViewPort(10, 50);
// get the legend (only possible after setting data)
Legend l = mChart.getLegend();
// modify the legend ...
l.setForm(LegendForm.LINE);
// dont forget to refresh the drawing
mChart.invalidate();
}
示例10: initChart
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
protected void initChart() {
mCombinedChart.getDescription().setEnabled(false);
mCombinedChart.setBackgroundColor(Color.WHITE);
mCombinedChart.setDrawGridBackground(false);
mCombinedChart.setDrawBarShadow(false);
mCombinedChart.setHighlightFullBarEnabled(false);
// draw bars behind lines
mCombinedChart.setDrawOrder(new CombinedChart.DrawOrder[]{
CombinedChart.DrawOrder.BAR, CombinedChart.DrawOrder.BUBBLE,
CombinedChart.DrawOrder.CANDLE, CombinedChart.DrawOrder.LINE,
CombinedChart.DrawOrder.SCATTER
});
Legend l = mCombinedChart.getLegend();
l.setWordWrapEnabled(true);
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
YAxis rightAxis = mCombinedChart.getAxisRight();
rightAxis.setDrawGridLines(false);
rightAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
YAxis leftAxis = mCombinedChart.getAxisLeft();
leftAxis.setDrawGridLines(false);
leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
XAxis xAxis = mCombinedChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTH_SIDED);
xAxis.setAxisMinimum(0f);
xAxis.setGranularity(1f);
xAxis.setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return mMonths[(int) value % mMonths.length];
}
});
CombinedData data = new CombinedData();
data.setData(generateLineData());
data.setData(generateBarData());
data.setData(generateBubbleData());
data.setData(generateScatterData());
data.setData(generateCandleData());
//data.setValueTypeface(mTfLight);
xAxis.setAxisMaximum(data.getXMax() + 0.25f);
mCombinedChart.setData(data);
mCombinedChart.invalidate();
}
示例11: 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);
}
}
示例12: onCreate
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mChart = (CombinedChart) findViewById(R.id.chart1);
//描述
mChart.getDescription().setEnabled(false);
mChart.setBackgroundColor(Color.WHITE);
mChart.setDrawGridBackground(false);
mChart.setDrawBarShadow(false);
mChart.setHighlightFullBarEnabled(false);
mChart.setScaleEnabled(false);
mChart.setScaleYEnabled(false);
mChart.setScaleXEnabled(false);
mChart.setPinchZoom(false);
// mChart.setScaleMinima(2f, 1f);
// mChart.setAutoScaleMinMaxEnabled(true);
// draw bars behind lines
mChart.setDrawOrder(new CombinedChart.DrawOrder[]{
CombinedChart.DrawOrder.BAR
});
//图例
Legend l = mChart.getLegend();
l.setWordWrapEnabled(true);
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setEnabled(false);
rightAxis.setAxisMinimum(0f);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setEnabled(false);
leftAxis.setAxisMinimum(0f);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setDrawGridLines(false);
// xAxis.setAvoidFirstLastClipping(true);
xAxis.setAxisMinimum(0.5f);
xAxis.setGranularity(1f);
xAxis.setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
if (value % 1 == 0&&value>=1) {
return mMonths[(int) value % mMonths.length-1];
} else {
return "";
}
}
});
CombinedData data = new CombinedData();
data.setData(generateBarData(1f, 1f));
xAxis.setAxisMaximum(data.getXMax() + 0.25f);
mChart.setData(data);
mChart.setVisibleXRange(3, 5);
mChart.setExtraOffsets(10, 0, 0, 0);
mChart.invalidate();
}
示例13: onCreate
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mChart = (CombinedChart) findViewById(R.id.chart1);
//描述
mChart.getDescription().setEnabled(false);
mChart.setBackgroundColor(Color.WHITE);
mChart.setDrawGridBackground(false);
mChart.setDrawBarShadow(false);
mChart.setHighlightFullBarEnabled(false);
mChart.setScaleEnabled(false);
mChart.setScaleYEnabled(false);
mChart.setScaleXEnabled(false);
mChart.setPinchZoom(false);
// mChart.setScaleMinima(2f, 1f);
// mChart.setAutoScaleMinMaxEnabled(true);
// draw bars behind lines
mChart.setDrawOrder(new CombinedChart.DrawOrder[]{
CombinedChart.DrawOrder.BAR
});
//图例
Legend l = mChart.getLegend();
l.setWordWrapEnabled(true);
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setEnabled(false);
rightAxis.setAxisMinimum(0f);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setEnabled(false);
leftAxis.setAxisMinimum(0f);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setDrawGridLines(false);
// xAxis.setAvoidFirstLastClipping(true);
xAxis.setAxisMinimum(0.5f);
xAxis.setGranularity(1f);
xAxis.setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
if (value % 1 == 0&&value>=1) {
return mMonths[(int) value % mMonths.length-1];
} else {
return "";
}
}
});
CombinedData data = new CombinedData();
data.setData(generateBarData(1f, 1f));
xAxis.setAxisMaximum(data.getXMax() + 0.25f);
mChart.setData(data);
mChart.setVisibleXRange(4, 6);
mChart.setExtraOffsets(10, 0, 0, 0);
mChart.invalidate();
}