本文整理汇总了Java中com.github.mikephil.charting.components.YAxis.setDrawZeroLine方法的典型用法代码示例。如果您正苦于以下问题:Java YAxis.setDrawZeroLine方法的具体用法?Java YAxis.setDrawZeroLine怎么用?Java YAxis.setDrawZeroLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.components.YAxis
的用法示例。
在下文中一共展示了YAxis.setDrawZeroLine方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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_linechart_noseekbar);
mChart = (LineChart) findViewById(R.id.chart1);
mChart.setBackgroundColor(Color.WHITE);
mChart.setGridBackgroundColor(mFillColor);
mChart.setDrawGridBackground(true);
mChart.setDrawBorders(true);
// no description text
mChart.getDescription().setEnabled(false);
// if disabled, scaling can be done on x- and y-axis separately
mChart.setPinchZoom(false);
Legend l = mChart.getLegend();
l.setEnabled(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setEnabled(false);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setAxisMaximum(900f);
leftAxis.setAxisMinimum(-250f);
leftAxis.setDrawAxisLine(false);
leftAxis.setDrawZeroLine(false);
leftAxis.setDrawGridLines(false);
mChart.getAxisRight().setEnabled(false);
// add data
setData(100, 60);
mChart.invalidate();
}
示例2: setupYAxes
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void setupYAxes(BarLineChartBase chart) {
YAxis y = chart.getAxisLeft();
y.setDrawZeroLine(true);
y.setDrawLabels(false);
y.setDrawGridLines(false);
y.setDrawAxisLine(false);
y.setAxisMinimum(0);
y = chart.getAxisRight();
y.setDrawZeroLine(true);
y.setDrawLabels(false);
y.setDrawGridLines(false);
y.setDrawAxisLine(false);
y.setAxisMinimum(0);
}
示例3: init
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs, int defStyle) {
getDescription().setEnabled(false);
LimitLine llXAxis = new LimitLine(10f, "Index 10");
llXAxis.setLineWidth(4f);
llXAxis.enableDashedLine(10f, 10f, 0f);
llXAxis.setLabelPosition(LimitLine.LimitLabelPosition.RIGHT_BOTTOM);
llXAxis.setTextSize(10f);
XAxis xAxis = getXAxis();
// xAxis.enableGridDashedLine(10f, 10f, 0f);
xAxis.setDrawGridLines(false);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setTextColor(Color.GRAY);
LimitLine ll1 = new LimitLine(80f, "Avg");
ll1.setLineWidth(1f);
ll1.enableDashedLine(10f, 10f, 0f);
ll1.setLabelPosition(LimitLine.LimitLabelPosition.RIGHT_TOP);
ll1.setTextSize(10f);
YAxis leftAxis = getAxisLeft();
leftAxis.removeAllLimitLines();
leftAxis.addLimitLine(ll1);
leftAxis.setAxisMaximum(160f);
leftAxis.setAxisMinimum(0f);
leftAxis.setDrawGridLines(false);
leftAxis.setDrawZeroLine(false);
leftAxis.setTextColor(Color.GRAY);
leftAxis.setDrawLimitLinesBehindData(true);
getAxisRight().setEnabled(false);
Legend l = getLegend();
l.setForm(Legend.LegendForm.LINE);
}
示例4: initTemperatureChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void initTemperatureChart(LineChart mChart) {
// mChart.setOnChartValueSelectedListener(this);
mChart.setDescription("Skin Temperature");
mChart.setNoDataTextDescription("You need to provide data for the chart.");
mChart.setTouchEnabled(true);
mChart.setDragDecelerationFrictionCoef(0.9f);
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
mChart.setDrawGridBackground(false);
mChart.setHighlightPerDragEnabled(true);
mChart.setPinchZoom(true);
mChart.setBackgroundColor(getResources().getColor(R.color.blue_light_pressed));
mChart.animateX(2500);
Legend l = mChart.getLegend();
l.setForm(Legend.LegendForm.LINE);
l.setTypeface(BandApplication.INSTANCE.getTfLight());
l.setTextSize(11f);
l.setTextColor(Color.WHITE);
l.setPosition(Legend.LegendPosition.BELOW_CHART_LEFT);
mChart.getXAxis().setEnabled(false);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(BandApplication.INSTANCE.getTfLight());
leftAxis.setTextColor(Color.RED);
leftAxis.setDrawGridLines(true);
leftAxis.setGranularityEnabled(true);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setTypeface(BandApplication.INSTANCE.getTfLight());
rightAxis.setTextColor(Color.RED);
rightAxis.setDrawGridLines(false);
rightAxis.setDrawZeroLine(false);
rightAxis.setGranularityEnabled(false);
}
示例5: initResistanceChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void initResistanceChart(LineChart mChart) {
// mChart.setOnChartValueSelectedListener(this);
mChart.setDescription("Skin Resistance");
mChart.setNoDataTextDescription("You need to provide data for the chart.");
mChart.setTouchEnabled(true);
mChart.setDragDecelerationFrictionCoef(0.9f);
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
mChart.setDrawGridBackground(false);
mChart.setHighlightPerDragEnabled(true);
mChart.setPinchZoom(true);
mChart.setBackgroundColor(getResources().getColor(R.color.green_pressed));
mChart.animateX(2500);
Legend l = mChart.getLegend();
l.setForm(Legend.LegendForm.LINE);
l.setTypeface(BandApplication.INSTANCE.getTfLight());
l.setTextSize(11f);
l.setTextColor(Color.WHITE);
l.setPosition(Legend.LegendPosition.BELOW_CHART_LEFT);
mChart.getXAxis().setEnabled(false);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(BandApplication.INSTANCE.getTfLight());
leftAxis.setTextColor(Color.RED);
leftAxis.setDrawGridLines(true);
leftAxis.setGranularityEnabled(true);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setTypeface(BandApplication.INSTANCE.getTfLight());
rightAxis.setTextColor(Color.RED);
rightAxis.setDrawGridLines(false);
rightAxis.setDrawZeroLine(false);
rightAxis.setGranularityEnabled(false);
}
示例6: 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_bubblechart);
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarX.setOnSeekBarChangeListener(this);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarY.setOnSeekBarChangeListener(this);
mChart = (BubbleChart) findViewById(R.id.chart1);
mChart.getDescription().setEnabled(false);
mChart.setOnChartValueSelectedListener(this);
mChart.setDrawGridBackground(false);
mChart.setTouchEnabled(true);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
mChart.setMaxVisibleValueCount(200);
mChart.setPinchZoom(true);
mSeekBarX.setProgress(10);
mSeekBarY.setProgress(50);
Legend l = mChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setDrawInside(false);
l.setTypeface(mTfLight);
YAxis yl = mChart.getAxisLeft();
yl.setTypeface(mTfLight);
yl.setSpaceTop(30f);
yl.setSpaceBottom(30f);
yl.setDrawZeroLine(false);
mChart.getAxisRight().setEnabled(false);
XAxis xl = mChart.getXAxis();
xl.setPosition(XAxis.XAxisPosition.BOTTOM);
xl.setTypeface(mTfLight);
}
示例7: 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.getDescription().setEnabled(false);
// 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.setTextColor(Color.LTGRAY);
xAxis.setTextSize(13f);
xAxis.setLabelCount(5);
xAxis.setCenterAxisLabels(true);
xAxis.setGranularity(1f);
YAxis left = mChart.getAxisLeft();
left.setDrawLabels(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
final List<Data> data = new ArrayList<>();
data.add(new Data(0f, -224.1f, "12-29"));
data.add(new Data(1f, 238.5f, "12-30"));
data.add(new Data(2f, 1280.1f, "12-31"));
data.add(new Data(3f, -442.3f, "01-01"));
data.add(new Data(4f, -2280.1f, "01-02"));
xAxis.setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return data.get(Math.min(Math.max((int) value, 0), data.size()-1)).xAxisValue;
}
});
setData(data);
}
示例8: 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_bubblechart);
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarX.setOnSeekBarChangeListener(this);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarY.setOnSeekBarChangeListener(this);
mChart = (BubbleChart) findViewById(R.id.chart1);
mChart.setDescription("");
tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
mChart.setOnChartValueSelectedListener(this);
mChart.setDrawGridBackground(false);
mChart.setTouchEnabled(true);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
mChart.setMaxVisibleValueCount(200);
mChart.setPinchZoom(true);
mSeekBarX.setProgress(5);
mSeekBarY.setProgress(50);
Legend l = mChart.getLegend();
l.setPosition(LegendPosition.RIGHT_OF_CHART);
l.setTypeface(tf);
YAxis yl = mChart.getAxisLeft();
yl.setTypeface(tf);
yl.setSpaceTop(30f);
yl.setSpaceBottom(30f);
yl.setDrawZeroLine(false);
mChart.getAxisRight().setEnabled(false);
XAxis xl = mChart.getXAxis();
xl.setPosition(XAxis.XAxisPosition.BOTTOM);
xl.setTypeface(tf);
}
示例9: 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);
}
示例10: 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();
}
示例11: setYAxisConfig
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
protected void setYAxisConfig(YAxis axis, ReadableMap propMap) {
if (BridgeUtils.validate(propMap, ReadableType.Number, "axisMaxValue")) {
axis.setAxisMaxValue((float) propMap.getDouble("axisMaxValue"));
}
if (BridgeUtils.validate(propMap, ReadableType.Number, "axisMinValue")) {
axis.setAxisMinValue((float) propMap.getDouble("axisMinValue"));
}
if (BridgeUtils.validate(propMap, ReadableType.Boolean, "inverted")) {
axis.setInverted(propMap.getBoolean("inverted"));
}
if (BridgeUtils.validate(propMap, ReadableType.Number, "spaceTop")) {
axis.setSpaceTop((float) propMap.getDouble("spaceTop"));
}
if (BridgeUtils.validate(propMap, ReadableType.Number, "spaceBottom")) {
axis.setSpaceBottom((float) propMap.getDouble("spaceBottom"));
}
if (BridgeUtils.validate(propMap, ReadableType.Boolean, "showOnlyMinMax")) {
axis.setShowOnlyMinMax(propMap.getBoolean("showOnlyMinMax"));
}
if (BridgeUtils.validate(propMap, ReadableType.Number, "labelCount")) {
boolean labelCountForce = false;
if (BridgeUtils.validate(propMap, ReadableType.Boolean, "labelCountForce")) {
labelCountForce = propMap.getBoolean("labelCountForce");
}
axis.setLabelCount(propMap.getInt("labelCount"), labelCountForce);
}
if (BridgeUtils.validate(propMap, ReadableType.String, "position")) {
axis.setPosition(YAxis.YAxisLabelPosition.valueOf(propMap.getString("position")));
}
if (BridgeUtils.validate(propMap, ReadableType.Number, "granularity")) {
axis.setGranularity((float) propMap.getDouble("granularity"));
}
if (BridgeUtils.validate(propMap, ReadableType.Boolean, "granularityEnabled")) {
axis.setGranularityEnabled(propMap.getBoolean("granularityEnabled"));
}
// formatting
if (BridgeUtils.validate(propMap, ReadableType.String, "valueFormatter")) {
String valueFormatter = propMap.getString("valueFormatter");
if ("largeValue".equals(valueFormatter)) {
axis.setValueFormatter(new LargeValueFormatter());
} else if ("percent".equals(valueFormatter)) {
axis.setValueFormatter(new PercentFormatter());
} else {
axis.setValueFormatter(new CustomFormatter(valueFormatter));
}
}
// TODO docs says the remaining config needs to be applied before setting data. Test it
// zero line
if (BridgeUtils.validate(propMap, ReadableType.Map, "zeroLine")) {
ReadableMap zeroLineConfig = propMap.getMap("zeroLine");
if (BridgeUtils.validate(zeroLineConfig, ReadableType.Boolean, "enabled")) {
axis.setDrawZeroLine(zeroLineConfig.getBoolean("enabled"));
}
if (BridgeUtils.validate(zeroLineConfig, ReadableType.Number, "lineWidth")) {
axis.setZeroLineWidth((float) zeroLineConfig.getDouble("lineWidth"));
}
if (BridgeUtils.validate(zeroLineConfig, ReadableType.String, "lineColor")) {
axis.setZeroLineColor(Color.parseColor(zeroLineConfig.getString("lineColor")));
}
}
}
示例12: updateLineChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
public static LineChart updateLineChart(LineChart chart, int max, List<Entry> entries, List<String> xValues)
{
Resources res = chart.getContext().getResources();
chart.setDrawBorders(false);
XAxis xAxis = chart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setDrawAxisLine(false);
xAxis.setYOffset(32f);
xAxis.setDrawGridLines(false);
xAxis.setLabelsToSkip(0);
xAxis.setTextSize(14);
xAxis.setTextColor(res.getColor(R.color.mm_warm_grey));
xAxis.setTypeface(Typeface.create("sans-serif-medium", Typeface.NORMAL));
YAxis yAxis = chart.getAxisLeft();
yAxis.setDrawAxisLine(false);
yAxis.setDrawGridLines(false);
yAxis.setDrawZeroLine(false);
yAxis.setAxisMaxValue(max + 2);
yAxis.setAxisMinValue(0);
yAxis.setShowOnlyMinMax(true);
yAxis.setTextSize(14);
yAxis.setTextColor(res.getColor(R.color.mm_warm_grey));
yAxis.setTypeface(Typeface.create("sans-serif-medium", Typeface.NORMAL));
chart.getAxisRight().setEnabled(false);
chart.getLegend().setEnabled(false);
chart.setDescription("");
LineDataSet set = new LineDataSet(entries, "");
set.setCircleColor(res.getColor(R.color.mm_colorPrimary));
set.setCircleRadius(4f);
set.setDrawCircleHole(false);
set.setColor(res.getColor(R.color.mm_colorPrimary));
set.setLineWidth(2f);
set.setDrawValues(false);
LineData data = new LineData(xValues, set);
chart.setData(data);
chart.setVisibleXRange(0, 7);
return chart;
}