Java Code Examples for com.github.mikephil.charting.charts.LineChart#setDescription()
The following examples show how to use
com.github.mikephil.charting.charts.LineChart#setDescription() .
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: TrafficFragment.java From gito-github-client with Apache License 2.0 | 6 votes |
@SuppressWarnings("deprecation") private void chartStyling(LineChart chart) { chart.setTouchEnabled(false); chart.setDescription(""); chart.setAutoScaleMinMaxEnabled(false); chart.setNoDataTextColor(SettingsActivity.ThemePreferenceFragment.isLight(getContext()) ? Color.BLACK : Color.WHITE); YAxis axisRight = chart.getAxisRight(); axisRight.setEnabled(false); chart.getLegend().setEnabled(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { chart.setNestedScrollingEnabled(false); } XAxis xAxis = chart.getXAxis(); chartXAxisStyling(xAxis); YAxis yAxis = chart.getAxisLeft(); chartYAxisStyling(yAxis); }
Example 2
Source File: DynamicalAddingActivity.java From Stayfit with Apache License 2.0 | 6 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); mChart = (LineChart) findViewById(R.id.chart1); mChart.setOnChartValueSelectedListener(this); mChart.setDrawGridBackground(false); mChart.setDescription(""); // add an empty data object mChart.setData(new LineData()); // mChart.getXAxis().setDrawLabels(false); // mChart.getXAxis().setDrawGridLines(false); mChart.invalidate(); }
Example 3
Source File: LineChartHelper.java From Ticket-Analysis with MIT License | 5 votes |
public LineChart generateLineChartConfig(LineChart lineChart) { //XY轴配置 XAxis xAxis = lineChart.getXAxis(); xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); //定制X轴是在图表上方还是下方。 xAxis.setDrawGridLines(false); xAxis.setGranularity(1); YAxis yAxisRight = lineChart.getAxisRight(); yAxisRight.setEnabled(false); YAxis yAxisLeft = lineChart.getAxisLeft(); yAxisLeft.setAxisMinimum(0); yAxisLeft.setGranularity(1); //背景设置 lineChart.setDrawGridBackground(false);//表格背景绘制 lineChart.setBackgroundColor(AppContext.getContext().getResources().getColor(R.color.white)); //Legend定制 lineChart.getLegend().setPosition(Legend.LegendPosition.ABOVE_CHART_LEFT); lineChart.getLegend().setForm(Legend.LegendForm.CIRCLE);//Legend样式 //图表描述 lineChart.setDescription(null); // 设置无数据文本提示 lineChart.setNoDataText("暂无数据"); //设置单方向和双方向缩放 true x,y方向可以同时控制,false只能控制x方向的缩小放大或者Y方向的缩小放大 lineChart.setPinchZoom(true); return lineChart; }
Example 4
Source File: CalibrationLinearityActivity.java From NoiseCapture with GNU General Public License v3.0 | 5 votes |
private void initLine() { LineChart lineChart = getLineChart(); if(lineChart == null) { return; } lineChart.setDescription(""); lineChart.setDrawGridBackground(false); // enable scaling and dragging Legend l = lineChart.getLegend(); l.setPosition(Legend.LegendPosition.RIGHT_OF_CHART); l.setTextColor(Color.WHITE); YAxis yl = lineChart.getAxisLeft(); yl.setTextColor(Color.WHITE); yl.setGridColor(Color.WHITE); lineChart.getAxisRight().setEnabled(false); XAxis xl = lineChart.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 5
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 6
Source File: ReportAdapter.java From privacy-friendly-pedometer with GNU General Public License v3.0 | 5 votes |
public ChartViewHolder(View itemView) { super(itemView); mChart = (LineChart) itemView.findViewById(R.id.chart); mChart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM); mChart.getAxisRight().setEnabled(false); mChart.setTouchEnabled(false); mChart.setDoubleTapToZoomEnabled(false); mChart.setPinchZoom(false); mChart.setDescription(""); }
Example 7
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 8
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 9
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 10
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 11
Source File: InvertedLineChartActivity.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); mChart.setDrawGridBackground(false); // 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(true); // set an alternative background color // mChart.setBackgroundColor(Color.GRAY); // create a custom MarkerView (extend MarkerView) and specify the layout // to use for it MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view); // set the marker to the chart mChart.setMarkerView(mv); XAxis xl = mChart.getXAxis(); xl.setAvoidFirstLastClipping(true); YAxis leftAxis = mChart.getAxisLeft(); leftAxis.setInverted(true); leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true) YAxis rightAxis = mChart.getAxisRight(); rightAxis.setEnabled(false); // add data setData(25, 50); // // restrain the maximum scale-out factor // mChart.setScaleMinima(3f, 3f); // // // center the view to a specific position inside the chart // mChart.centerViewPort(10, 50); // 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); // dont forget to refresh the drawing mChart.invalidate(); }
Example 12
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; }
Example 13
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 14
Source File: Proxmark3TuneResultActivity.java From Walrus with GNU General Public License v3.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_proxmark3_tune_results); Proxmark3Device.TuneResult tuneResult = Parcels.unwrap(getIntent().getParcelableExtra( EXTRA_TUNE_RESULT)); setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); } if (tuneResult.lf) { setResultInfo(tuneResult.peakV, 2.948f, 14.730f, R.id.lfOk); ((TextView) findViewById(R.id.lf125)).setText( getResources().getString(R.string.tune_voltage, tuneResult.v125)); ((TextView) findViewById(R.id.lf134)).setText( getResources().getString(R.string.tune_voltage, tuneResult.v134)); ((TextView) findViewById(R.id.lfOptimal)).setText( getResources().getString(R.string.tune_peak_voltage, tuneResult.peakV, (tuneResult.peakF / 1000))); LineChart lfChart = findViewById(R.id.lfChart); if (tuneResult.lfVoltages != null) { List<Entry> entries = new ArrayList<>(); for (int i = 255; i >= 19; --i) { entries.add(new Entry(12e6f / (i + 1) / 1e3f, tuneResult.lfVoltages[i])); } LineDataSet lineDataSet = new LineDataSet(entries, getString(R.string.lf)); lineDataSet.setColor(Color.BLACK); lineDataSet.setCircleColor(Color.BLUE); LineData lineData = new LineData(lineDataSet); lfChart.setData(lineData); lfChart.setDescription(null); lfChart.getLegend().setEnabled(false); lfChart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM); lfChart.getAxisRight().setEnabled(false); lfChart.invalidate(); } else { lfChart.setVisibility(View.GONE); } } else { findViewById(R.id.lf).setVisibility(View.GONE); } if (tuneResult.hf) { setResultInfo(tuneResult.hfVoltage, 3.167f, 7.917f, R.id.hfOk); ((TextView) findViewById(R.id.hfV)).setText( getResources().getString(R.string.tune_voltage, tuneResult.hfVoltage)); } else { findViewById(R.id.hf).setVisibility(View.GONE); } }
Example 15
Source File: GraphActivity.java From Simple-Accounting with GNU General Public License v3.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_graph); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { // Show the Up button in the action bar. actionBar.setDisplayHomeAsUpEnabled(true); } // programmatically create a LineChart LineChart chart = findViewById(R.id.chart); Session session = getIntent().getParcelableExtra(GRAPH_SESSION); int[] updateDate = {getIntent().getIntExtra(GRAPH_UPDATE_MONTH, -1), getIntent().getIntExtra(GRAPH_UPDATE_YEAR, -1)}; ((TextView) findViewById(R.id.title)).setText(Utils.INSTANCE.getTitle(this, session, updateDate)); loadMonthAsyncTask = new LoadMonthAsyncTask(session, null, new TableGeneral(this), (result) -> { if(result.getDbRows().length > 0) { List<Entry> entries = new ArrayList<>(); BigDecimal bigDecimal = BigDecimal.ZERO; for (String[] s : result.getDbRows()) { if(s[0] != null) { int day = parseInt(s[0]); float credit = s[2] != null ? Float.parseFloat(s[2]) : 0, debit = s[3] != null ? Float.parseFloat(s[3]) : 0; bigDecimal = bigDecimal.add(new BigDecimal(credit)); bigDecimal = bigDecimal.subtract(new BigDecimal(debit)); entries.add(new Entry(day, bigDecimal.floatValue())); } } if(entries.size() > 0) { for(int i = 0; i < entries.size(); i++) { int entriesInDay = 0, day = (int) entries.get(i).getX(); for(int j = i; j < entries.size() && day == entries.get(j).getX(); j++) { entriesInDay++; } for(int j = i, k = 0; j < entries.size() && day == entries.get(j).getX(); j++, k++) { float separationWidth = 1 / (entriesInDay + 1f);//the amount of space between points in the same day (X axis) entries.get(j).setX(day + (k+1) * separationWidth); } while(day == entries.get(i).getX()) i++; } LineDataSet dataSet = new LineDataSet(entries, null); dataSet.setValueFormatter(new MoneyFormatter()); chart.setData(new LineData(dataSet)); } else { chart.setNoDataText(getString(R.string.nothing_to_graph)); Snackbar.make(chart, R.string.without_day_data_is_not_charted, Snackbar.LENGTH_LONG).show(); } } else { chart.setNoDataText(getString(R.string.nothing_to_graph)); } chart.notifyDataSetChanged(); chart.invalidate(); }); loadMonthAsyncTask.execute(); chart.getAxisRight().setEnabled(false); chart.getXAxis().setValueFormatter(new DeleteNonWholeFormatter()); chart.getXAxis().setAxisMinimum(0); chart.getXAxis().setAxisMaximum(32); chart.getXAxis().setDrawGridLines(false); chart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM); chart.getLegend().setEnabled(false); chart.setDescription(null); chart.setNoDataText(getString(R.string.loading)); }
Example 16
Source File: LineChartCard.java From ResearchStack with Apache License 2.0 | 4 votes |
private void initializeViews() { titleTextView = (TextView) findViewById(R.id.view_chart_line_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 = (LineChart) findViewById(R.id.view_chart_line); chart.getLegend().setEnabled(false); chart.setDescription(""); chart.setDrawBorders(false); chart.setDrawGridBackground(false); chart.setPinchZoom(false); chart.setTouchEnabled(true); chart.setDragEnabled(true); chart.setExtraLeftOffset(0); chart.setExtraBottomOffset(8); chart.setExtraTopOffset(0); XAxis xAxis = chart.getXAxis(); xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); xAxis.setDrawAxisLine(false); xAxis.setDrawGridLines(false); xAxis.setLabelsToSkip(0); xAxis.setXOffset(16); 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(true); yAxisLeft.setShowOnlyMinMax(true); yAxisLeft.setXOffset(16); yAxisLeft.setTextSize(chartYAxisTextSize); yAxisLeft.setTextColor(chartYAxisTextColor); yAxisLeft.setTypeface(Typeface.create(chartYAxisTextTypeface, Typeface.NORMAL)); YAxis yAxisRight = chart.getAxisRight(); yAxisRight.setDrawAxisLine(false); yAxisRight.setDrawGridLines(false); yAxisRight.setDrawZeroLine(false); yAxisRight.setDrawLabels(false); yAxisRight.setSpaceTop(0); }
Example 17
Source File: Utils.java From Aria2App with GNU General Public License v3.0 | 4 votes |
public static void setupChart(@NonNull LineChart chart, boolean small, @ColorRes @Nullable Integer fgColorRes) { chart.clear(); int fgColor; Context context = chart.getContext(); if (fgColorRes == null) fgColor = CommonUtils.resolveAttrAsColor(context, R.attr.colorOnSurface); else fgColor = ContextCompat.getColor(context, fgColorRes); chart.setDescription(null); chart.setDrawGridBackground(false); chart.setBackgroundColor(Color.alpha(0)); chart.setTouchEnabled(false); Legend legend = chart.getLegend(); legend.setTextColor(fgColor); legend.setEnabled(true); LineData data = new LineData(); data.setValueTextColor(fgColor); chart.setData(data); YAxis ya = chart.getAxisLeft(); ya.setAxisLineColor(fgColor); ya.setTextColor(fgColor); ya.setTextSize(small ? 8 : 9); ya.setAxisMinimum(0); ya.setDrawAxisLine(false); ya.setLabelCount(small ? 4 : 8, true); ya.setEnabled(true); ya.setDrawGridLines(true); ya.setGridColor(fgColor); ya.setValueFormatter(new CustomYAxisValueFormatter()); chart.getAxisRight().setEnabled(false); chart.getXAxis().setEnabled(false); data.addDataSet(initUploadSet(context)); data.addDataSet(initDownloadSet(context)); chart.invalidate(); }
Example 18
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 19
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 20
Source File: FragmentHome.java From AndroidSmartHome with Apache License 2.0 | 3 votes |
private void setupChart(){ // Setup chart suhu chartSuhu = (LineChart) mainView.findViewById(R.id.home_chart_suhu); chartPDAM = (LineChart) mainView.findViewById(R.id.home_chart_pdam); chartSuhu.setDescription(""); chartPDAM.setDescription(""); updateChart(); }