Java Code Examples for com.github.mikephil.charting.charts.LineChart#setNoDataTextDescription()
The following examples show how to use
com.github.mikephil.charting.charts.LineChart#setNoDataTextDescription() .
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: PerformanceLineChart.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_performance_linechart); mTvCount = (TextView) findViewById(R.id.tvValueCount); mSeekBarValues = (SeekBar) findViewById(R.id.seekbarValues); mTvCount.setText("500"); mSeekBarValues.setProgress(500); mSeekBarValues.setOnSeekBarChangeListener(this); mChart = (LineChart) findViewById(R.id.chart1); mChart.setDrawGridBackground(false); // 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); // if disabled, scaling can be done on x- and y-axis separately mChart.setPinchZoom(false); mChart.getAxisLeft().setDrawGridLines(false); mChart.getAxisRight().setEnabled(false); mChart.getXAxis().setDrawGridLines(true); mChart.getXAxis().setDrawAxisLine(false); // dont forget to refresh the drawing mChart.invalidate(); }
Example 2
Source File: ChartFragment.java From Liapp with Apache License 2.0 | 4 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.inflate(R.layout.fragment_lastscanchart, container, false); LineChart cv_LastScan = (LineChart) view.findViewById(R.id.cv_LastScan); cv_LastScan.setOnChartGestureListener(new myChartGestureListener(cv_LastScan)); XAxis xAxis = cv_LastScan.getXAxis(); xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); xAxis.setTextSize(10f); xAxis.setTextColor(getResources().getColor(R.color.colorGlucoseNow)); xAxis.enableGridDashedLine(5f, 5f, 0f); xAxis.setDrawLimitLinesBehindData(true); YAxis yAxisLeft = cv_LastScan.getAxisLeft(); YAxis yAxisRight = cv_LastScan.getAxisRight(); yAxisRight.setEnabled(false); yAxisLeft.setTextSize(18f); // set the textsize yAxisLeft.setTextColor(getResources().getColor(R.color.colorGlucoseNow)); yAxisLeft.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART); yAxisLeft.setStartAtZero(true); yAxisLeft.setYOffset(-6f); yAxisLeft.setAxisMinValue(0.0f); Legend legend = cv_LastScan.getLegend(); legend.setEnabled(false); // no description text cv_LastScan.setDescription(""); cv_LastScan.setNoDataText(getResources().getString(R.string.no_data)); cv_LastScan.setNoDataTextDescription(""); // enable touch gestures cv_LastScan.setTouchEnabled(true); // enable scaling and dragging cv_LastScan.setDragEnabled(true); cv_LastScan.setScaleEnabled(true); cv_LastScan.setDrawGridBackground(false); // if disabled, scaling can be done on x- and y-axis separately cv_LastScan.setPinchZoom(true); MyMarkerView mv = new MyMarkerView(view.getContext(), R.layout.custom_marker_view); // set the marker to the chart cv_LastScan.setMarkerView(mv); try { int sdk = android.os.Build.VERSION.SDK_INT; if (sdk < android.os.Build.VERSION_CODES.HONEYCOMB) { cv_LastScan.setHardwareAccelerationEnabled(false); } else { cv_LastScan.setHardwareAccelerationEnabled(true); } } catch (Exception e) { } refresh(); return (view); }
Example 3
Source File: LineChartActivityColored.java From Stayfit with Apache License 2.0 | 4 votes |
private void setupChart(LineChart chart, LineData data, int color) { // no description text chart.setDescription(""); chart.setNoDataTextDescription("You need to provide data for the chart."); // mChart.setDrawHorizontalGrid(false); // // enable / disable grid background chart.setDrawGridBackground(false); // chart.getRenderer().getGridPaint().setGridColor(Color.WHITE & 0x70FFFFFF); // 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.setBackgroundColor(color); // set custom chart offsets (automatic offset calculation is hereby disabled) chart.setViewPortOffsets(10, 0, 10, 0); // add data chart.setData(data); // get the legend (only possible after setting data) Legend l = chart.getLegend(); l.setEnabled(false); chart.getAxisLeft().setEnabled(false); chart.getAxisRight().setEnabled(false); chart.getXAxis().setEnabled(false); // animate calls invalidate()... chart.animateX(2500); }
Example 4
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 5
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 6
Source File: ChartsActivity.java From CameraV with GNU General Public License v3.0 | 4 votes |
private LineChart addChart (String label, LineData data) { LineChart chart = new LineChart(this); //chart.setOnChartGestureListener(this); //chart.setOnChartValueSelectedListener(this); chart.getAxisLeft().setStartAtZero(false); // no description text chart.setDescription(""); chart.setNoDataTextDescription(""); // enable value highlighting chart.setHighlightEnabled(true); // enable touch gestures chart.setTouchEnabled(true); // enable scaling and dragging chart.setDragEnabled(true); chart.setScaleEnabled(true); // chart.setScaleXEnabled(true); // chart.setScaleYEnabled(true); // if disabled, scaling can be done on x- and y-axis separately chart.setPinchZoom(true); // set data chart.setData(data); TextView tv = new TextView (this); tv.setText(label); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); viewChartGroup.addView(tv,params); int dpHeight = 300; int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpHeight, getResources().getDisplayMetrics()); params = new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, height); int dpMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3, getResources().getDisplayMetrics()); params.setMargins(dpMargin,dpMargin,dpMargin,dpMargin); chart.setLayoutParams(params); viewChartGroup.addView(chart,params); return chart; }