本文整理汇总了Java中com.github.mikephil.charting.components.YAxis.setStartAtZero方法的典型用法代码示例。如果您正苦于以下问题:Java YAxis.setStartAtZero方法的具体用法?Java YAxis.setStartAtZero怎么用?Java YAxis.setStartAtZero使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.components.YAxis
的用法示例。
在下文中一共展示了YAxis.setStartAtZero方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void initChart(BarChart chart) {
float scaledDensity = getResources().getDisplayMetrics().scaledDensity;
chart.setDragEnabled(true);
chart.setScaleYEnabled(false);
chart.setScaleXEnabled(false);
chart.setDoubleTapToZoomEnabled(false);
chart.setPinchZoom(false);
chart.setHighlightPerDragEnabled(false);
chart.setHighlightPerTapEnabled(false);
chart.setDrawGridBackground(false);
chart.setDrawBorders(false);
chart.setDrawValueAboveBar(false);
chart.getAxisLeft().setEnabled(false);
XAxis xAxis = chart.getXAxis();
xAxis.setDrawAxisLine(true);
xAxis.setDrawGridLines(false);
xAxis.setDrawLabels(false);
xAxis.setDrawLimitLinesBehindData(false);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
YAxis yAxis = chart.getAxisRight();
yAxis.setDrawAxisLine(false);
yAxis.setStartAtZero(false);
yAxis.setSpaceTop(10f);
yAxis.setSpaceBottom(0f);
yAxis.setTextSize(10 * scaledDensity);
yAxis.setTextColor(ContextCompat.getColor(this, R.color.text));
chart.getLegend().setEnabled(false);
chart.setDescription(" ");
chart.setNoDataText("Can't see sh*t captain!");
Paint p = chart.getPaint(Chart.PAINT_INFO);
DisplayMetrics dm = getResources().getDisplayMetrics();
int size = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 18, dm); //TODO use styles
p.setTextSize(size);
p.setColor(ContextCompat.getColor(this, R.color.gray600));
p.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
}
示例2: onCreateView
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的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);
}
示例3: onCreate
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_barchart_noseekbar);
mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setBackgroundColor(Color.WHITE);
mChart.setExtraTopOffset(-30f);
mChart.setExtraBottomOffset(10f);
mChart.setExtraLeftOffset(70f);
mChart.setExtraRightOffset(70f);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.setDescription("");
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTypeface(mTf);
xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(false);
xAxis.setSpaceBetweenLabels(2);
xAxis.setTextColor(Color.LTGRAY);
xAxis.setTextSize(13f);
YAxis left = mChart.getAxisLeft();
left.setDrawLabels(false);
left.setStartAtZero(false);
left.setSpaceTop(25f);
left.setSpaceBottom(25f);
left.setDrawAxisLine(false);
left.setDrawGridLines(false);
left.setDrawZeroLine(true); // draw a zero line
left.setZeroLineColor(Color.GRAY);
left.setZeroLineWidth(0.7f);
mChart.getAxisRight().setEnabled(false);
mChart.getLegend().setEnabled(false);
// THIS IS THE ORIGINAL DATA YOU WANT TO PLOT
List<Data> data = new ArrayList<>();
data.add(new Data(0, -224.1f, "12-29"));
data.add(new Data(1, 238.5f, "12-30"));
data.add(new Data(2, 1280.1f, "12-31"));
data.add(new Data(3, -442.3f, "01-01"));
data.add(new Data(4, -2280.1f, "01-02"));
setData(data);
}
示例4: initChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
public void initChart() {
mChart.setDescription("");
mChart.setDragEnabled(false);
mChart.setScaleEnabled(false);
mChart.setPinchZoom(false);
GraphMarkerView markerView = new GraphMarkerView(mChart.getContext(), R.layout.trackdota_graph_marker);
mChart.setMarkerView(markerView);
mChart.setHighlightEnabled(false);
XAxis xAxis = mChart.getXAxis();
xAxis.removeAllLimitLines();
xAxis.setDrawLimitLinesBehindData(true);
xAxis.setDrawGridLines(true);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.removeAllLimitLines();
leftAxis.setStartAtZero(false);
LimitLine limitLine = new LimitLine(0f);
limitLine.setLineColor(Color.WHITE);
limitLine.setLineWidth(2f);
leftAxis.addLimitLine(limitLine);
mChart.setBackgroundColor(Color.BLACK);
mChart.setDrawBorders(false);
mChart.getLegend().setEnabled(false);
mChart.setDoubleTapToZoomEnabled(false);
mChart.setDrawGridBackground(false);
leftAxis.setValueFormatter(new ValueFormatter() {
@Override
public String getFormattedValue(float value) {
return String.valueOf((int) value);
}
});
leftAxis.setTextColor(Color.WHITE);
mChart.getAxisRight().setEnabled(false);
//mChart.animateX(2500);
clearChart();
}
示例5: SetupChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
public void SetupChart() {
lineChart = (LineChart) myLayout.findViewById(R.id.chart);
lineChart.setDescription("");
lineChart.setDrawBorders(false);
lineChart.setNoDataTextDescription("You need to provide data for the chart.");
lineChart.setDrawGridBackground(false);
lineChart.setOnChartValueSelectedListener(this);
lineChart.setTouchEnabled(true);
lineChart.setDragEnabled(false);
lineChart.setPinchZoom(false);
lineChart.setScaleXEnabled(true);
lineChart.setScaleYEnabled(true);
lineChart.invalidate();
LineData data = new LineData();
data.setValueTextColor(Color.WHITE);
// add empty data
lineChart.setData(data);
// get the legend (only possible after setting data)
Legend l = lineChart.getLegend();
l.setEnabled(false);
// x axis setup
XAxis xl = lineChart.getXAxis();
xl.setTextColor(Color.WHITE);
xl.setDrawGridLines(false);
xl.setAvoidFirstLastClipping(false);
xl.setSpaceBetweenLabels(3);
xl.setEnabled(true);
xl.setDrawAxisLine(false);
xl.removeAllLimitLines();
//right y axis setup
YAxis rightAxis = lineChart.getAxisRight();
rightAxis.setEnabled(false);
//left y axis setup
YAxis leftAxis = lineChart.getAxisLeft();
leftAxis.setTextColor(Color.WHITE);
leftAxis.setLabelCount(6, true);
leftAxis.setAxisMaxValue(400f);
leftAxis.setAxisMinValue(0f);
leftAxis.setDrawGridLines(false);
leftAxis.setStartAtZero(false);
leftAxis.setEnabled(true);
leftAxis.setDrawAxisLine(false);
leftAxis.setDrawZeroLine(false);
leftAxis.setGranularityEnabled(false);
//define min max line
LimitLine max = new LimitLine(150f);
max.enableDashedLine(10f, 10f, 0f);
LimitLine min = new LimitLine(50f);
min.enableDashedLine(10f, 10f, 0f);
// reset all limit lines to avoid overlapping lines
leftAxis.removeAllLimitLines();
//add min max line
leftAxis.addLimitLine(max);
leftAxis.addLimitLine(min);
lineChart.invalidate();
}