Java Code Examples for com.github.mikephil.charting.components.XAxis#setSpaceBetweenLabels()
The following examples show how to use
com.github.mikephil.charting.components.XAxis#setSpaceBetweenLabels() .
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: ChartBaseManager.java From react-native-mp-android-chart with MIT License | 6 votes |
/** * xAxis config details: https://github.com/PhilJay/MPAndroidChart/wiki/XAxis */ @ReactProp(name = "xAxis") public void setXAxis(Chart chart, ReadableMap propMap) { XAxis axis = chart.getXAxis(); setCommonAxisConfig(chart, axis, propMap); if (BridgeUtils.validate(propMap, ReadableType.Number, "labelsToSkip")) { axis.setLabelsToSkip(propMap.getInt("labelsToSkip")); } if (BridgeUtils.validate(propMap, ReadableType.Boolean, "avoidFirstLastClipping")) { axis.setAvoidFirstLastClipping(propMap.getBoolean("avoidFirstLastClipping")); } if (BridgeUtils.validate(propMap, ReadableType.Number, "spaceBetweenLabels")) { axis.setSpaceBetweenLabels(propMap.getInt("spaceBetweenLabels")); } if (BridgeUtils.validate(propMap, ReadableType.String, "position")) { axis.setPosition(XAxisPosition.valueOf(propMap.getString("position"))); } }
Example 2
Source File: RadarChart.java From iMoney with Apache License 2.0 | 5 votes |
@Override protected void init() { super.init(); mYAxis = new YAxis(AxisDependency.LEFT); mXAxis = new XAxis(); mXAxis.setSpaceBetweenLabels(0); mWebLineWidth = Utils.convertDpToPixel(1.5f); mInnerWebLineWidth = Utils.convertDpToPixel(0.75f); mRenderer = new RadarChartRenderer(this, mAnimator, mViewPortHandler); mYAxisRenderer = new YAxisRendererRadarChart(mViewPortHandler, mYAxis, this); mXAxisRenderer = new XAxisRendererRadarChart(mViewPortHandler, mXAxis, this); }
Example 3
Source File: RadarChart.java From Stayfit with Apache License 2.0 | 5 votes |
@Override protected void init() { super.init(); mYAxis = new YAxis(AxisDependency.LEFT); mXAxis = new XAxis(); mXAxis.setSpaceBetweenLabels(0); mWebLineWidth = Utils.convertDpToPixel(1.5f); mInnerWebLineWidth = Utils.convertDpToPixel(0.75f); mRenderer = new RadarChartRenderer(this, mAnimator, mViewPortHandler); mYAxisRenderer = new YAxisRendererRadarChart(mViewPortHandler, mYAxis, this); mXAxisRenderer = new XAxisRendererRadarChart(mViewPortHandler, mXAxis, this); }
Example 4
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 5
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 6
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 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: 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 9
Source File: CandleStickChartActivity.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_candlechart); 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 = (CandleStickChart) findViewById(R.id.chart1); mChart.setBackgroundColor(Color.WHITE); 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); XAxis xAxis = mChart.getXAxis(); xAxis.setPosition(XAxisPosition.BOTTOM); xAxis.setSpaceBetweenLabels(2); xAxis.setDrawGridLines(false); YAxis leftAxis = mChart.getAxisLeft(); // leftAxis.setEnabled(false); leftAxis.setLabelCount(7, false); leftAxis.setDrawGridLines(false); leftAxis.setDrawAxisLine(false); YAxis rightAxis = mChart.getAxisRight(); rightAxis.setEnabled(false); // rightAxis.setStartAtZero(false); // setting data mSeekBarX.setProgress(40); mSeekBarY.setProgress(100); 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); }