Java Code Examples for com.github.mikephil.charting.charts.BarChart#setDrawGridBackground()
The following examples show how to use
com.github.mikephil.charting.charts.BarChart#setDrawGridBackground() .
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: BarChartFrag.java From StockChart-MPAndroidChart with MIT License | 5 votes |
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.frag_simple_bar, container, false); // create a new chart object chart = new BarChart(getActivity()); chart.getDescription().setEnabled(false); chart.setOnChartGestureListener(this); MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view); mv.setChartView(chart); // For bounds control chart.setMarker(mv); chart.setDrawGridBackground(false); chart.setDrawBarShadow(false); Typeface tf = Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf"); chart.setData(generateBarData(1, 20000, 12)); Legend l = chart.getLegend(); l.setTypeface(tf); YAxis leftAxis = chart.getAxisLeft(); leftAxis.setTypeface(tf); leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true) chart.getAxisRight().setEnabled(false); XAxis xAxis = chart.getXAxis(); xAxis.setEnabled(false); // programmatically add the chart FrameLayout parent = v.findViewById(R.id.parentLayout); parent.addView(chart); return v; }
Example 2
Source File: BarChartFrag.java From Stayfit with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.frag_simple_bar, container, false); // create a new chart object mChart = new BarChart(getActivity()); mChart.setDescription(""); mChart.setOnChartGestureListener(this); MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view); mChart.setMarkerView(mv); mChart.setDrawGridBackground(false); mChart.setDrawBarShadow(false); Typeface tf = Typeface.createFromAsset(getActivity().getAssets(),"OpenSans-Light.ttf"); mChart.setData(generateBarData(1, 20000, 12)); Legend l = mChart.getLegend(); l.setTypeface(tf); YAxis leftAxis = mChart.getAxisLeft(); leftAxis.setTypeface(tf); leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true) mChart.getAxisRight().setEnabled(false); XAxis xAxis = mChart.getXAxis(); xAxis.setEnabled(false); // programatically add the chart FrameLayout parent = (FrameLayout) v.findViewById(R.id.parentLayout); parent.addView(mChart); return v; }
Example 3
Source File: ScrollViewActivity.java From Stayfit with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_scrollview); mChart = (BarChart) findViewById(R.id.chart1); mChart.setDescription(""); // scaling can now only be done on x- and y-axis separately mChart.setPinchZoom(false); mChart.setDrawBarShadow(false); mChart.setDrawGridBackground(false); XAxis xAxis = mChart.getXAxis(); xAxis.setPosition(XAxisPosition.BOTTOM); xAxis.setLabelsToSkip(0); xAxis.setDrawGridLines(false); mChart.getAxisLeft().setDrawGridLines(false); mChart.getLegend().setEnabled(false); setData(10); }
Example 4
Source File: ActivitiesChartActivity.java From Mi-Band with GNU General Public License v2.0 | 5 votes |
private void createGraph() { mChart = (BarChart) findViewById(R.id.chart1); mChart.setDescription(""); // scaling can now only be done on x- and y-axis separately mChart.setPinchZoom(false); mChart.setDrawBarShadow(false); mChart.setDrawGridBackground(false); }
Example 5
Source File: CalibrationLinearityActivity.java From NoiseCapture with GNU General Public License v3.0 | 5 votes |
private void initBar() { BarChart barChart = getBarChart(); if(barChart == null) { return; } barChart.setDescription(""); barChart.setDrawGridBackground(false); barChart.setMaxVisibleValueCount(200); Legend l = barChart.getLegend(); l.setPosition(Legend.LegendPosition.ABOVE_CHART_LEFT); l.setTextColor(Color.WHITE); YAxis yl = barChart.getAxisLeft(); yl.setTextColor(Color.WHITE); yl.setGridColor(Color.WHITE); barChart.getAxisRight().setEnabled(false); XAxis xl = barChart.getXAxis(); xl.setDrawGridLines(false); xl.setTextColor(Color.WHITE); xl.setGridColor(Color.WHITE); xl.setPosition(XAxis.XAxisPosition.BOTTOM); xl.setDrawAxisLine(true); xl.setLabelRotationAngle(-90); xl.setDrawLabels(true); xl.setLabelsToSkip(0); }
Example 6
Source File: StackedBarActivity.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); 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 = (BarChart) findViewById(R.id.chart1); mChart.setOnChartValueSelectedListener(this); 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); mChart.setDrawGridBackground(false); mChart.setDrawBarShadow(false); mChart.setDrawValueAboveBar(false); // change the position of the y-labels YAxis leftAxis = mChart.getAxisLeft(); leftAxis.setValueFormatter(new MyYAxisValueFormatter()); leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true) mChart.getAxisRight().setEnabled(false); XAxis xLabels = mChart.getXAxis(); xLabels.setPosition(XAxisPosition.TOP); // mChart.setDrawXLabels(false); // mChart.setDrawYLabels(false); // setting data mSeekBarX.setProgress(12); mSeekBarY.setProgress(100); Legend l = mChart.getLegend(); l.setPosition(LegendPosition.BELOW_CHART_RIGHT); l.setFormSize(8f); l.setFormToTextSpace(4f); l.setXEntrySpace(6f); // mChart.setDrawLegend(false); }
Example 7
Source File: BarChartActivity.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); 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 = (BarChart) findViewById(R.id.chart1); mChart.setOnChartValueSelectedListener(this); 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); 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.setSpaceBetweenLabels(2); YAxisValueFormatter custom = new MyYAxisValueFormatter(); YAxis leftAxis = mChart.getAxisLeft(); leftAxis.setTypeface(mTf); leftAxis.setLabelCount(8, false); leftAxis.setValueFormatter(custom); leftAxis.setPosition(YAxisLabelPosition.OUTSIDE_CHART); leftAxis.setSpaceTop(15f); leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true) YAxis rightAxis = mChart.getAxisRight(); rightAxis.setDrawGridLines(false); rightAxis.setTypeface(mTf); rightAxis.setLabelCount(8, false); rightAxis.setValueFormatter(custom); rightAxis.setSpaceTop(15f); rightAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true) Legend l = mChart.getLegend(); l.setPosition(LegendPosition.BELOW_CHART_LEFT); l.setForm(LegendForm.SQUARE); l.setFormSize(9f); l.setTextSize(11f); l.setXEntrySpace(4f); // l.setExtra(ColorTemplate.VORDIPLOM_COLORS, new String[] { "abc", // "def", "ghj", "ikl", "mno" }); // l.setCustom(ColorTemplate.VORDIPLOM_COLORS, new String[] { "abc", // "def", "ghj", "ikl", "mno" }); setData(12, 50); // setting data mSeekBarY.setProgress(50); mSeekBarX.setProgress(12); mSeekBarY.setOnSeekBarChangeListener(this); mSeekBarX.setOnSeekBarChangeListener(this); // mChart.setDrawLegend(false); }
Example 8
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 9
Source File: BarChartActivityMultiDataset.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); 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 = (BarChart) findViewById(R.id.chart1); mChart.setOnChartValueSelectedListener(this); mChart.setDescription(""); // mChart.setDrawBorders(true); // scaling can now only be done on x- and y-axis separately mChart.setPinchZoom(false); mChart.setDrawBarShadow(false); mChart.setDrawGridBackground(false); // create a custom MarkerView (extend MarkerView) and specify the layout // to use for it MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view); // define an offset to change the original position of the marker // (optional) // mv.setOffsets(-mv.getMeasuredWidth() / 2, -mv.getMeasuredHeight()); // set the marker to the chart mChart.setMarkerView(mv); mSeekBarX.setProgress(10); mSeekBarY.setProgress(100); tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf"); Legend l = mChart.getLegend(); l.setPosition(LegendPosition.RIGHT_OF_CHART_INSIDE); l.setTypeface(tf); l.setYOffset(0f); l.setYEntrySpace(0f); l.setTextSize(8f); XAxis xl = mChart.getXAxis(); xl.setTypeface(tf); YAxis leftAxis = mChart.getAxisLeft(); leftAxis.setTypeface(tf); leftAxis.setValueFormatter(new LargeValueFormatter()); leftAxis.setDrawGridLines(false); leftAxis.setSpaceTop(30f); leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true) mChart.getAxisRight().setEnabled(false); }
Example 10
Source File: BarChartPositiveNegative.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_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); }
Example 11
Source File: AnotherBarActivity.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); 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 = (BarChart) findViewById(R.id.chart1); 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); mChart.setDrawBarShadow(false); mChart.setDrawGridBackground(false); XAxis xAxis = mChart.getXAxis(); xAxis.setPosition(XAxisPosition.BOTTOM); xAxis.setSpaceBetweenLabels(0); xAxis.setDrawGridLines(false); mChart.getAxisLeft().setDrawGridLines(false); // setting data mSeekBarX.setProgress(10); mSeekBarY.setProgress(100); // add a nice and smooth animation mChart.animateY(2500); mChart.getLegend().setEnabled(false); // Legend l = mChart.getLegend(); // l.setPosition(LegendPosition.BELOW_CHART_CENTER); // l.setFormSize(8f); // l.setFormToTextSpace(4f); // l.setXEntrySpace(6f); // mChart.setDrawLegend(false); }
Example 12
Source File: BarChartCard.java From ResearchStack with Apache License 2.0 | 4 votes |
private void initializeViews() { titleTextView = (TextView) findViewById(R.id.view_chart_bar_title); titleTextView.setText(titleText); titleTextView.setTextColor(titleTextColor); titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleTextSize); titleTextView.setTypeface(Typeface.create(titleTextTypeface, Typeface.NORMAL)); expand = (ImageView) findViewById(R.id.view_chart_line_expand); if (expandTintColor != 0) { Drawable drawable = expand.getDrawable(); drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTint(drawable, expandTintColor); expand.setImageDrawable(drawable); } chart = (BarChart) findViewById(R.id.view_chart_bar); chart.getLegend().setEnabled(false); chart.setDescription(""); chart.setDrawBorders(false); chart.setDrawValueAboveBar(false); chart.setDrawGridBackground(false); chart.setDrawBarShadow(false); chart.setDrawHighlightArrow(false); chart.setPinchZoom(false); chart.setExtraLeftOffset(0); chart.setExtraRightOffset(0); chart.setExtraBottomOffset(8); chart.setExtraTopOffset(0); chart.setTouchEnabled(true); chart.setDragEnabled(true); XAxis xAxis = chart.getXAxis(); xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); xAxis.setDrawAxisLine(false); xAxis.setYOffset(16); xAxis.setDrawGridLines(false); xAxis.setLabelsToSkip(0); xAxis.setTextSize(chartXAxisTextSize); xAxis.setTextColor(chartXAxisTextColor); xAxis.setTypeface(Typeface.create(chartXAxisTextTypeface, Typeface.NORMAL)); YAxis yAxisLeft = chart.getAxisLeft(); yAxisLeft.setDrawAxisLine(false); yAxisLeft.setDrawGridLines(false); yAxisLeft.setDrawZeroLine(false); yAxisLeft.setDrawLabels(false); YAxis yAxisRight = chart.getAxisRight(); yAxisRight.setDrawAxisLine(false); yAxisRight.setDrawGridLines(false); yAxisRight.setDrawZeroLine(false); yAxisRight.setDrawLabels(false); }
Example 13
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 14
Source File: SleepChartActivity.java From Mi-Band with GNU General Public License v2.0 | 3 votes |
private void createGraph() { mChart = (BarChart) findViewById(R.id.chart1); mChart.setDescription(""); // scaling can now only be done on x- and y-axis separately mChart.setPinchZoom(false); mChart.setDrawBarShadow(false); mChart.setDrawGridBackground(false); pieChart = (PieChart) findViewById(R.id.pieChart); }