Java Code Examples for com.github.mikephil.charting.components.XAxis#setEnabled()
The following examples show how to use
com.github.mikephil.charting.components.XAxis#setEnabled() .
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: 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 2
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 3
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 4
Source File: ScatterChartFrag.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_scatter, container, false); chart = v.findViewById(R.id.scatterChart1); chart.getDescription().setEnabled(false); Typeface tf = Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf"); MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view); mv.setChartView(chart); // For bounds control chart.setMarker(mv); chart.setDrawGridBackground(false); chart.setData(generateScatterData(6, 10000, 200)); XAxis xAxis = chart.getXAxis(); xAxis.setEnabled(true); xAxis.setPosition(XAxisPosition.BOTTOM); YAxis leftAxis = chart.getAxisLeft(); leftAxis.setTypeface(tf); YAxis rightAxis = chart.getAxisRight(); rightAxis.setTypeface(tf); rightAxis.setDrawGridLines(false); Legend l = chart.getLegend(); l.setWordWrapEnabled(true); l.setTypeface(tf); l.setFormSize(14f); l.setTextSize(9f); // increase the space between legend & bottom and legend & content l.setYOffset(13f); chart.setExtraBottomOffset(16f); return v; }
Example 5
Source File: RecordingFragment.java From go-bees with GNU General Public License v3.0 | 5 votes |
/** * Configure styles of weather charts. * * @param entries chart data. * @param formatter value formatter. * @param minVal min value to show. * @param maxVal max value to show. * @return chart formatted. */ private LineDataSet configureWeatherChart( LineChart chart, int chartName, int colorLineTempChart, int colorFillTempChart, List<Entry> entries, IAxisValueFormatter formatter, double minVal, double maxVal) { LineDataSet lineDataSet = new LineDataSet(entries, getString(chartName)); lineDataSet.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER); lineDataSet.setDrawValues(false); lineDataSet.setValueTextSize(10f); lineDataSet.setDrawCircles(false); lineDataSet.setLineWidth(1.8f); lineDataSet.setColor(ContextCompat.getColor(getContext(), colorLineTempChart)); lineDataSet.setLineWidth(2f); lineDataSet.setDrawFilled(true); lineDataSet.setFillColor(ContextCompat.getColor(getContext(), colorFillTempChart)); lineDataSet.setFillAlpha(255); // General setup chart.setDrawGridBackground(false); chart.setDrawBorders(false); chart.setViewPortOffsets(0, 0, 0, 0); chart.getDescription().setEnabled(false); chart.getLegend().setEnabled(false); chart.setTouchEnabled(false); // X axis setup XAxis xAxis = chart.getXAxis(); xAxis.setEnabled(false); xAxis.setAxisMinimum(0); xAxis.setAxisMaximum(lastTimestamp); // Y axis setup YAxis leftAxis = chart.getAxisLeft(); leftAxis.setEnabled(false); leftAxis.setAxisMaximum((float) (maxVal)); leftAxis.setAxisMinimum((float) (minVal)); YAxis rightAxis = chart.getAxisRight(); rightAxis.setAxisMaximum((float) (maxVal)); rightAxis.setAxisMinimum((float) (minVal)); rightAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART); rightAxis.setValueFormatter(formatter); return lineDataSet; }
Example 6
Source File: ScatterChartFrag.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_scatter, container, false); mChart = (ScatterChart) v.findViewById(R.id.scatterChart1); mChart.setDescription(""); Typeface tf = Typeface.createFromAsset(getActivity().getAssets(),"OpenSans-Light.ttf"); MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view); mChart.setMarkerView(mv); mChart.setDrawGridBackground(false); mChart.setData(generateScatterData(6, 10000, 200)); XAxis xAxis = mChart.getXAxis(); xAxis.setEnabled(true); xAxis.setPosition(XAxisPosition.BOTTOM); YAxis leftAxis = mChart.getAxisLeft(); leftAxis.setTypeface(tf); YAxis rightAxis = mChart.getAxisRight(); rightAxis.setTypeface(tf); rightAxis.setDrawGridLines(false); Legend l = mChart.getLegend(); l.setWordWrapEnabled(true); l.setTypeface(tf); l.setFormSize(14f); l.setTextSize(9f); // increase the space between legend & bottom and legend & content l.setYOffset(13f); mChart.setExtraBottomOffset(16f); return v; }
Example 7
Source File: ModelDetailActivity.java From Synapse with Apache License 2.0 | 5 votes |
private void setXAxis(int epochs) { final XAxis axis = mChart.getXAxis(); axis.setEnabled(true); axis.setAxisMinimum(1F); axis.setAxisMaximum(epochs); axis.setPosition(XAxis.XAxisPosition.BOTTOM); axis.setDrawAxisLine(true); axis.setDrawGridLines(false); axis.setGranularity(1F); axis.setAvoidFirstLastClipping(true); mChart.getAxisRight().setDrawAxisLine(true); }
Example 8
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 9
Source File: CubicLineChartActivity.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.setViewPortOffsets(0, 20, 0, 0); mChart.setBackgroundColor(Color.rgb(104, 241, 175)); // no description text mChart.setDescription(""); // enable touch gestures mChart.setTouchEnabled(true); // enable scaling and dragging mChart.setDragEnabled(true); mChart.setScaleEnabled(true); // if disabled, scaling can be done on x- and y-axis separately mChart.setPinchZoom(false); mChart.setDrawGridBackground(false); tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf"); XAxis x = mChart.getXAxis(); x.setEnabled(false); YAxis y = mChart.getAxisLeft(); y.setTypeface(tf); y.setLabelCount(6, false); y.setTextColor(Color.WHITE); y.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART); y.setDrawGridLines(false); y.setAxisLineColor(Color.WHITE); mChart.getAxisRight().setEnabled(false); // add data setData(45, 100); mChart.getLegend().setEnabled(false); mChart.animateXY(2000, 2000); // dont forget to refresh the drawing mChart.invalidate(); }
Example 10
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 11
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 12
Source File: GraphUtils.java From your-local-weather with GNU General Public License v3.0 | 4 votes |
public static void setupXAxis(XAxis x, List<DetailedWeatherForecast> weatherForecastList, int textColorId, Float textSize, AppPreference.GraphGridColors gridColor, Locale locale) { x.removeAllLimitLines(); Map<Integer, Long> hourIndexes = new HashMap<>(); int lastDayOflimitLine = 0; for (int i = 0; i < weatherForecastList.size(); i++) { hourIndexes.put(i, weatherForecastList.get(i).getDateTime()); Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(weatherForecastList.get(i).getDateTime() * 1000); if (cal.get(Calendar.DAY_OF_YEAR) != lastDayOflimitLine) { Calendar calOfPreviousRecord = Calendar.getInstance(); int previousRecordHour = 24; if (i > 0) { calOfPreviousRecord.setTimeInMillis(weatherForecastList.get(i - 1).getDateTime() * 1000); previousRecordHour = calOfPreviousRecord.get(Calendar.HOUR_OF_DAY); } int currentHour = cal.get(Calendar.HOUR_OF_DAY); float timeSpan = (24 - previousRecordHour) + currentHour; float dayLine = currentHour / timeSpan; float midnight = i - dayLine; float hour6 = midnight + (6 / timeSpan); float hour12 = midnight + (12 / timeSpan); float hour18 = midnight + (18 / timeSpan); LimitLine limitLine = new LimitLine(midnight); limitLine.setLineColor(gridColor.getMainGridColor()); limitLine.setLineWidth(0.5f); x.addLimitLine(limitLine); /*LimitLine limitLine6 = new LimitLine(hour6, ""); limitLine6.setLineColor(Color.LTGRAY); limitLine6.setLineWidth(0.5f); x.addLimitLine(limitLine6);*/ LimitLine limitLine12 = new LimitLine(hour12); limitLine12.setLineColor(gridColor.getSecondaryGridColor()); limitLine12.setLineWidth(0.5f); x.addLimitLine(limitLine12); /*LimitLine limitLine18 = new LimitLine(hour18, ""); limitLine18.setLineColor(Color.LTGRAY); limitLine18.setLineWidth(0.5f); x.addLimitLine(limitLine18);*/ lastDayOflimitLine = cal.get(Calendar.DAY_OF_YEAR); } } x.setEnabled(true); x.setPosition(XAxis.XAxisPosition.BOTTOM); x.setDrawGridLines(false); x.setLabelCount(25, true); x.setTextColor(textColorId); x.setValueFormatter(new XAxisValueFormatter(hourIndexes, locale)); x.setDrawLimitLinesBehindData(true); if (textSize != null) { x.setTextSize(textSize); } }
Example 13
Source File: CubicLineChartActivity.java From StockChart-MPAndroidChart with MIT License | 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); setTitle("CubicLineChartActivity"); tvX = findViewById(R.id.tvXMax); tvY = findViewById(R.id.tvYMax); seekBarX = findViewById(R.id.seekBar1); seekBarY = findViewById(R.id.seekBar2); chart = findViewById(R.id.chart1); chart.setViewPortOffsets(0, 0, 0, 0); chart.setBackgroundColor(Color.rgb(104, 241, 175)); // no description text chart.getDescription().setEnabled(false); // enable touch gestures chart.setTouchEnabled(true); // enable scaling and dragging chart.setDragEnabled(true); chart.setScaleEnabled(true); // if disabled, scaling can be done on x- and y-axis separately chart.setPinchZoom(false); chart.setDrawGridBackground(false); chart.setMaxHighlightDistance(300); XAxis x = chart.getXAxis(); x.setEnabled(false); YAxis y = chart.getAxisLeft(); y.setTypeface(tfLight); y.setLabelCount(6, false); y.setTextColor(Color.WHITE); y.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART); y.setDrawGridLines(false); y.setAxisLineColor(Color.WHITE); chart.getAxisRight().setEnabled(false); // add data seekBarY.setOnSeekBarChangeListener(this); seekBarX.setOnSeekBarChangeListener(this); // lower max, as cubic runs significantly slower than linear seekBarX.setMax(700); seekBarX.setProgress(45); seekBarY.setProgress(100); chart.getLegend().setEnabled(false); chart.animateXY(2000, 2000); // don't forget to refresh the drawing chart.invalidate(); }
Example 14
Source File: RealtimeLineChartActivity.java From StockChart-MPAndroidChart with MIT License | 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); setTitle("RealtimeLineChartActivity"); chart = findViewById(R.id.chart1); chart.setOnChartValueSelectedListener(this); // enable description text chart.getDescription().setEnabled(true); // enable touch gestures chart.setTouchEnabled(true); // enable scaling and dragging chart.setDragEnabled(true); chart.setScaleEnabled(true); chart.setDrawGridBackground(false); // if disabled, scaling can be done on x- and y-axis separately chart.setPinchZoom(true); // set an alternative background color chart.setBackgroundColor(Color.LTGRAY); LineData data = new LineData(); data.setValueTextColor(Color.WHITE); // add empty data chart.setData(data); // get the legend (only possible after setting data) Legend l = chart.getLegend(); // modify the legend ... l.setForm(LegendForm.LINE); l.setTypeface(tfLight); l.setTextColor(Color.WHITE); XAxis xl = chart.getXAxis(); xl.setTypeface(tfLight); xl.setTextColor(Color.WHITE); xl.setDrawGridLines(false); xl.setAvoidFirstLastClipping(true); xl.setEnabled(true); YAxis leftAxis = chart.getAxisLeft(); leftAxis.setTypeface(tfLight); leftAxis.setTextColor(Color.WHITE); leftAxis.setAxisMaximum(100f); leftAxis.setAxisMinimum(0f); leftAxis.setDrawGridLines(true); YAxis rightAxis = chart.getAxisRight(); rightAxis.setEnabled(false); }
Example 15
Source File: BarChartActivitySinus.java From StockChart-MPAndroidChart with MIT License | 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); setTitle("BarChartActivitySinus"); data = FileUtils.loadBarEntriesFromAssets(getAssets(), "othersine.txt"); tvX = findViewById(R.id.tvValueCount); seekBarX = findViewById(R.id.seekbarValues); chart = findViewById(R.id.chart1); chart.setDrawBarShadow(false); chart.setDrawValueAboveBar(true); chart.getDescription().setEnabled(false); // if more than 60 entries are displayed in the chart, no values will be // drawn chart.setMaxVisibleValueCount(60); // scaling can now only be done on x- and y-axis separately chart.setPinchZoom(false); // draw shadows for each bar that show the maximum value // chart.setDrawBarShadow(true); // chart.setDrawXLabels(false); chart.setDrawGridBackground(false); // chart.setDrawYLabels(false); XAxis xAxis = chart.getXAxis(); xAxis.setEnabled(false); YAxis leftAxis = chart.getAxisLeft(); leftAxis.setTypeface(tfLight); leftAxis.setLabelCount(6, false); leftAxis.setAxisMinimum(-2.5f); leftAxis.setAxisMaximum(2.5f); leftAxis.setGranularityEnabled(true); leftAxis.setGranularity(0.1f); YAxis rightAxis = chart.getAxisRight(); rightAxis.setDrawGridLines(false); rightAxis.setTypeface(tfLight); rightAxis.setLabelCount(6, false); rightAxis.setAxisMinimum(-2.5f); rightAxis.setAxisMaximum(2.5f); rightAxis.setGranularity(0.1f); seekBarX.setOnSeekBarChangeListener(this); seekBarX.setProgress(150); // set data Legend l = chart.getLegend(); l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM); l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT); l.setOrientation(Legend.LegendOrientation.HORIZONTAL); l.setDrawInside(false); l.setForm(LegendForm.SQUARE); l.setFormSize(9f); l.setTextSize(11f); l.setXEntrySpace(4f); chart.animateXY(1500, 1500); }
Example 16
Source File: FilledLineActivity.java From StockChart-MPAndroidChart with MIT License | 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_noseekbar); setTitle("FilledLineActivity"); chart = findViewById(R.id.chart1); chart.setBackgroundColor(Color.WHITE); chart.setGridBackgroundColor(fillColor); chart.setDrawGridBackground(true); chart.setDrawBorders(true); // no description text chart.getDescription().setEnabled(false); // if disabled, scaling can be done on x- and y-axis separately chart.setPinchZoom(false); Legend l = chart.getLegend(); l.setEnabled(false); XAxis xAxis = chart.getXAxis(); xAxis.setEnabled(false); YAxis leftAxis = chart.getAxisLeft(); leftAxis.setAxisMaximum(900f); leftAxis.setAxisMinimum(-250f); leftAxis.setDrawAxisLine(false); leftAxis.setDrawZeroLine(false); leftAxis.setDrawGridLines(false); chart.getAxisRight().setEnabled(false); // add data setData(100, 60); chart.invalidate(); }
Example 17
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; }
Example 18
Source File: ComplexityFragment.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(getComplexity()); 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.setAxisMinValue(0f); // this replaces setStartAtZero(true) mChart.getAxisRight().setEnabled(false); XAxis xAxis = mChart.getXAxis(); xAxis.setEnabled(false); return v; }
Example 19
Source File: ComplexityFragment.java From StockChart-MPAndroidChart with MIT License | 3 votes |
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.frag_simple_line, container, false); chart = v.findViewById(R.id.lineChart1); chart.getDescription().setEnabled(false); chart.setDrawGridBackground(false); chart.setData(getComplexity()); chart.animateX(3000); Typeface tf = Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf"); Legend l = chart.getLegend(); l.setTypeface(tf); YAxis leftAxis = chart.getAxisLeft(); leftAxis.setTypeface(tf); chart.getAxisRight().setEnabled(false); XAxis xAxis = chart.getXAxis(); xAxis.setEnabled(false); return v; }
Example 20
Source File: SineCosineFragment.java From StockChart-MPAndroidChart with MIT License | 3 votes |
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.frag_simple_line, container, false); chart = v.findViewById(R.id.lineChart1); chart.getDescription().setEnabled(false); chart.setDrawGridBackground(false); chart.setData(generateLineData()); chart.animateX(3000); Typeface tf = Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf"); Legend l = chart.getLegend(); l.setTypeface(tf); YAxis leftAxis = chart.getAxisLeft(); leftAxis.setTypeface(tf); leftAxis.setAxisMaximum(1.2f); leftAxis.setAxisMinimum(-1.2f); chart.getAxisRight().setEnabled(false); XAxis xAxis = chart.getXAxis(); xAxis.setEnabled(false); return v; }