Java Code Examples for com.github.mikephil.charting.components.YAxis#setAxisMaxValue()
The following examples show how to use
com.github.mikephil.charting.components.YAxis#setAxisMaxValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivitiesChartActivity.java From Mi-Band with GNU General Public License v2.0 | 6 votes |
private void createChartLegend() { /* Legend l = mChart.getLegend(); l.setPosition(Legend.LegendPosition.RIGHT_OF_CHART_INSIDE); l.setYOffset(0f); l.setYEntrySpace(0f); l.setTextSize(8f); */ XAxis x = mChart.getXAxis(); x.setDrawLabels(true); x.setDrawGridLines(false); x.setEnabled(true); x.setDrawLimitLinesBehindData(true); YAxis y = mChart.getAxisLeft(); y.setAxisMaxValue(1f); y.setDrawTopYLabelEntry(false); y.setEnabled(true); mChart.getAxisRight().setEnabled(false); }
Example 2
Source File: SleepChartActivity.java From Mi-Band with GNU General Public License v2.0 | 6 votes |
private void createChartLegend() { /* Legend l = mChart.getLegend(); l.setPosition(Legend.LegendPosition.RIGHT_OF_CHART_INSIDE); l.setYOffset(0f); l.setYEntrySpace(0f); l.setTextSize(8f); */ XAxis x = mChart.getXAxis(); x.setDrawLabels(true); x.setDrawGridLines(false); x.setEnabled(true); x.setDrawLimitLinesBehindData(true); YAxis y = mChart.getAxisLeft(); y.setAxisMaxValue(1f); y.setDrawTopYLabelEntry(false); y.setEnabled(true); mChart.getAxisRight().setEnabled(false); }
Example 3
Source File: MeasurementActivity.java From NoiseCapture with GNU General Public License v3.0 | 5 votes |
public void initVueMeter(){ mChart.setDrawBarShadow(false); mChart.setDescription(""); mChart.setPinchZoom(false); mChart.setDrawGridBackground(false); mChart.setMaxVisibleValueCount(0); mChart.setScaleXEnabled(false); // Disable scaling on the X-axis // XAxis parameters: hide all XAxis xlv = mChart.getXAxis(); xlv.setPosition(XAxisPosition.BOTTOM); xlv.setDrawAxisLine(false); xlv.setDrawGridLines(false); xlv.setDrawLabels(false); // YAxis parameters (left): main axis for dB values representation YAxis ylv = mChart.getAxisLeft(); ylv.setDrawAxisLine(false); ylv.setDrawGridLines(true); ylv.setAxisMaxValue(110.f); ylv.setStartAtZero(true); ylv.setTextColor(Color.WHITE); ylv.setGridColor(Color.WHITE); ylv.setValueFormatter(new dBValueFormatter()); // YAxis parameters (right): no axis, hide all YAxis yrv = mChart.getAxisRight(); yrv.setEnabled(false); //return true; }
Example 4
Source File: Results.java From NoiseCapture with GNU General Public License v3.0 | 5 votes |
public void initSpectrumChart(){ sChart.setPinchZoom(false); sChart.setDoubleTapToZoomEnabled(false); sChart.setDrawBarShadow(false); sChart.setDescription(""); sChart.setPinchZoom(false); sChart.setDrawGridBackground(false); sChart.setHighlightPerTapEnabled(true); sChart.setHighlightPerDragEnabled(false); sChart.setDrawHighlightArrow(true); sChart.setDrawValueAboveBar(true); // XAxis parameters: hide all XAxis xls = sChart.getXAxis(); xls.setPosition(XAxisPosition.BOTTOM); xls.setDrawAxisLine(true); xls.setDrawGridLines(false); xls.setLabelRotationAngle(-90); xls.setDrawLabels(true); xls.setTextColor(Color.WHITE); xls.setLabelsToSkip(0); // YAxis parameters (left): main axis for dB values representation YAxis yls = sChart.getAxisLeft(); yls.setDrawAxisLine(true); yls.setDrawGridLines(true); yls.setAxisMaxValue(110.f); yls.setStartAtZero(true); yls.setTextColor(Color.WHITE); yls.setGridColor(Color.WHITE); // YAxis parameters (right): no axis, hide all YAxis yrs = sChart.getAxisRight(); yrs.setEnabled(false); //return true; }
Example 5
Source File: BarChartActivitySinus.java From Stayfit with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_barchart_sinus); mSinusData = FileUtils.loadBarEntriesFromAssets(getAssets(),"othersine.txt"); tvX = (TextView) findViewById(R.id.tvValueCount); mSeekBarX = (SeekBar) findViewById(R.id.seekbarValues); mChart = (BarChart) findViewById(R.id.chart1); 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); mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf"); XAxis xAxis = mChart.getXAxis(); xAxis.setPosition(XAxisPosition.BOTTOM); xAxis.setTypeface(mTf); xAxis.setDrawGridLines(false); xAxis.setEnabled(false); YAxis leftAxis = mChart.getAxisLeft(); leftAxis.setTypeface(mTf); leftAxis.setLabelCount(6, false); leftAxis.setAxisMinValue(-2.5f); leftAxis.setAxisMaxValue(2.5f); YAxis rightAxis = mChart.getAxisRight(); rightAxis.setDrawGridLines(false); rightAxis.setTypeface(mTf); rightAxis.setLabelCount(6, false); rightAxis.setAxisMinValue(-2.5f); rightAxis.setAxisMaxValue(2.5f); mSeekBarX.setOnSeekBarChangeListener(this); mSeekBarX.setProgress(150); // set data Legend l = mChart.getLegend(); l.setPosition(LegendPosition.BELOW_CHART_LEFT); l.setForm(LegendForm.SQUARE); l.setFormSize(9f); l.setTextSize(11f); l.setXEntrySpace(4f); mChart.animateXY(2000, 2000); }
Example 6
Source File: RealtimeLineChartActivity.java From Stayfit with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_realtime_linechart); mChart = (LineChart) findViewById(R.id.chart1); mChart.setOnChartValueSelectedListener(this); // no description text mChart.setDescription(""); mChart.setNoDataTextDescription("You need to provide data for the chart."); // enable touch gestures mChart.setTouchEnabled(true); // enable scaling and dragging mChart.setDragEnabled(true); mChart.setScaleEnabled(true); mChart.setDrawGridBackground(false); // if disabled, scaling can be done on x- and y-axis separately mChart.setPinchZoom(true); // set an alternative background color mChart.setBackgroundColor(Color.LTGRAY); LineData data = new LineData(); data.setValueTextColor(Color.WHITE); // add empty data mChart.setData(data); Typeface tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf"); // get the legend (only possible after setting data) Legend l = mChart.getLegend(); // modify the legend ... // l.setPosition(LegendPosition.LEFT_OF_CHART); l.setForm(LegendForm.LINE); l.setTypeface(tf); l.setTextColor(Color.WHITE); XAxis xl = mChart.getXAxis(); xl.setTypeface(tf); xl.setTextColor(Color.WHITE); xl.setDrawGridLines(false); xl.setAvoidFirstLastClipping(true); xl.setSpaceBetweenLabels(5); xl.setEnabled(true); YAxis leftAxis = mChart.getAxisLeft(); leftAxis.setTypeface(tf); leftAxis.setTextColor(Color.WHITE); leftAxis.setAxisMaxValue(100f); leftAxis.setAxisMinValue(0f); leftAxis.setDrawGridLines(true); YAxis rightAxis = mChart.getAxisRight(); rightAxis.setEnabled(false); }
Example 7
Source File: LineChartActivity2.java From Stayfit with Apache License 2.0 | 4 votes |
@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); // no description text mChart.setDescription(""); mChart.setNoDataTextDescription("You need to provide data for the chart."); // enable touch gestures mChart.setTouchEnabled(true); mChart.setDragDecelerationFrictionCoef(0.9f); // enable scaling and dragging mChart.setDragEnabled(true); mChart.setScaleEnabled(true); mChart.setDrawGridBackground(false); mChart.setHighlightPerDragEnabled(true); // if disabled, scaling can be done on x- and y-axis separately mChart.setPinchZoom(true); // set an alternative background color mChart.setBackgroundColor(Color.LTGRAY); // add data setData(20, 30); mChart.animateX(2500); Typeface tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf"); // get the legend (only possible after setting data) Legend l = mChart.getLegend(); // modify the legend ... // l.setPosition(LegendPosition.LEFT_OF_CHART); l.setForm(LegendForm.LINE); l.setTypeface(tf); l.setTextSize(11f); l.setTextColor(Color.WHITE); l.setPosition(LegendPosition.BELOW_CHART_LEFT); // l.setYOffset(11f); XAxis xAxis = mChart.getXAxis(); xAxis.setTypeface(tf); xAxis.setTextSize(12f); xAxis.setTextColor(Color.WHITE); xAxis.setDrawGridLines(false); xAxis.setDrawAxisLine(false); xAxis.setSpaceBetweenLabels(1); YAxis leftAxis = mChart.getAxisLeft(); leftAxis.setTypeface(tf); leftAxis.setTextColor(ColorTemplate.getHoloBlue()); leftAxis.setAxisMaxValue(200f); leftAxis.setAxisMinValue(0f); leftAxis.setDrawGridLines(true); YAxis rightAxis = mChart.getAxisRight(); rightAxis.setTypeface(tf); rightAxis.setTextColor(Color.RED); rightAxis.setAxisMaxValue(900); rightAxis.setAxisMinValue(-200); rightAxis.setDrawGridLines(false); rightAxis.setDrawZeroLine(false); }
Example 8
Source File: YAxisChartBase.java From react-native-mp-android-chart with MIT License | 4 votes |
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"))); } } }
Example 9
Source File: MeasurementSpectrumFragment.java From NoiseCapture with GNU General Public License v3.0 | 4 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if(view == null) { // Inflate the layout for this fragment view = inflater.inflate(R.layout.fragment_measurement_spectrum, container, false); BarChart sChart = (BarChart) view.findViewById(R.id.spectrumChart); sChart.setDrawBarShadow(false); sChart.setDescription(""); sChart.getLegend().setEnabled(false); sChart.setTouchEnabled(false); sChart.setPinchZoom(false); sChart.setDrawGridBackground(false); sChart.setMaxVisibleValueCount(0); sChart.setHorizontalScrollBarEnabled(false); sChart.setVerticalScrollBarEnabled(false); sChart.setNoDataTextDescription(getText(R.string.no_data_text_description).toString()); // XAxis parameters: XAxis xls = sChart.getXAxis(); xls.setPosition(XAxis.XAxisPosition.BOTTOM); xls.setDrawAxisLine(true); xls.setDrawGridLines(false); xls.setDrawLabels(true); xls.setTextColor(Color.WHITE); xls.setAvoidFirstLastClipping(false); // YAxis parameters (left): main axis for dB values representation YAxis yls = sChart.getAxisLeft(); yls.setDrawAxisLine(true); yls.setDrawGridLines(true); yls.setAxisMaxValue(100.f); yls.setAxisMinValue(0f); yls.setTextColor(Color.WHITE); yls.setGridColor(Color.WHITE); yls.setSpaceBottom(0); yls.setSpaceTop(0); yls.setValueFormatter(new SPLValueFormatter()); // YAxis parameters (right): no axis, hide all YAxis yrs = sChart.getAxisRight(); yrs.setEnabled(false); } return view; }
Example 10
Source File: CalibrationLinearityActivity.java From NoiseCapture with GNU General Public License v3.0 | 4 votes |
private void updateBarChart() { BarChart barChart = getBarChart(); if(barChart == null) { return; } if(freqLeqStats.size() <= 2) { return; } double[] pearsons = computePearson(); if(pearsons == null) { return; } float YMin = Float.MAX_VALUE; float YMax = Float.MIN_VALUE; ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>(); // Read all white noise values for indexing before usage ArrayList<BarEntry> yMeasure = new ArrayList<BarEntry>(); int idfreq = 0; for (double value : pearsons) { YMax = Math.max(YMax, (float)value); YMin = Math.min(YMin, (float)value); yMeasure.add(new BarEntry((float)value, idfreq++)); } BarDataSet freqSet = new BarDataSet(yMeasure, "Pearson's correlation"); freqSet.setColor(ColorTemplate.COLORFUL_COLORS[0]); freqSet.setValueTextColor(Color.WHITE); freqSet.setDrawValues(true); dataSets.add(freqSet); ArrayList<String> xVals = new ArrayList<String>(); double[] freqs = FFTSignalProcessing.computeFFTCenterFrequency(AudioProcess.REALTIME_SAMPLE_RATE_LIMITATION); for (double freqValue : freqs) { xVals.add(Spectrogram.formatFrequency((int)freqValue)); } // create a data object with the datasets BarData data = new BarData(xVals, dataSets); barChart.setData(data); YAxis yl = barChart.getAxisLeft(); yl.setAxisMinValue(YMin - 0.1f); yl.setAxisMaxValue(YMax + 0.1f); barChart.invalidate(); }
Example 11
Source File: CalibrationLinearityActivity.java From NoiseCapture with GNU General Public License v3.0 | 4 votes |
private void updateLineChart() { LineChart lineChart = getLineChart(); if(lineChart == null) { return; } if(freqLeqStats.isEmpty()) { return; } float YMin = Float.MAX_VALUE; float YMax = Float.MIN_VALUE; ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>(); // Read all white noise values for indexing before usage int idStep = 0; double referenceLevel = freqLeqStats.get(0).whiteNoiseLevel.getGlobaldBaValue(); for(LinearCalibrationResult result : freqLeqStats) { ArrayList<Entry> yMeasure = new ArrayList<Entry>(); int idfreq = 0; for (LeqStats leqStat : result.measure) { float dbLevel = (float)leqStat.getLeqMean(); YMax = Math.max(YMax, dbLevel); YMin = Math.min(YMin, dbLevel); yMeasure.add(new Entry(dbLevel, idfreq++)); } LineDataSet freqSet = new LineDataSet(yMeasure, String.format(Locale.getDefault(),"%d dB", (int)(result.whiteNoiseLevel.getGlobaldBaValue() - referenceLevel))); freqSet.setColor(ColorTemplate.COLORFUL_COLORS[idStep % ColorTemplate.COLORFUL_COLORS.length]); freqSet.setFillColor(ColorTemplate.COLORFUL_COLORS[idStep % ColorTemplate.COLORFUL_COLORS.length]); freqSet.setValueTextColor(Color.WHITE); freqSet.setCircleColorHole(ColorTemplate.COLORFUL_COLORS[idStep % ColorTemplate.COLORFUL_COLORS.length]); freqSet.setDrawValues(false); freqSet.setDrawFilled(true); freqSet.setFillAlpha(255); freqSet.setDrawCircles(true); freqSet.setMode(LineDataSet.Mode.LINEAR); dataSets.add(freqSet); idStep++; } ArrayList<String> xVals = new ArrayList<String>(); double[] freqs = FFTSignalProcessing.computeFFTCenterFrequency(AudioProcess.REALTIME_SAMPLE_RATE_LIMITATION); for (double freqValue : freqs) { xVals.add(Spectrogram.formatFrequency((int)freqValue)); } // create a data object with the datasets LineData data = new LineData(xVals, dataSets); lineChart.setData(data); YAxis yl = lineChart.getAxisLeft(); yl.setAxisMinValue(YMin - 3); yl.setAxisMaxValue(YMax + 3); lineChart.invalidate(); }
Example 12
Source File: SineCosineFragment.java From Stayfit with Apache License 2.0 | 3 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.frag_simple_line, container, false); mChart = (LineChart) v.findViewById(R.id.lineChart1); mChart.setDescription(""); mChart.setDrawGridBackground(false); mChart.setData(generateLineData()); mChart.animateX(3000); Typeface tf = Typeface.createFromAsset(getActivity().getAssets(),"OpenSans-Light.ttf"); Legend l = mChart.getLegend(); l.setTypeface(tf); YAxis leftAxis = mChart.getAxisLeft(); leftAxis.setTypeface(tf); leftAxis.setAxisMaxValue(1.2f); leftAxis.setAxisMinValue(-1.2f); mChart.getAxisRight().setEnabled(false); XAxis xAxis = mChart.getXAxis(); xAxis.setEnabled(false); return v; }