Java Code Examples for com.github.mikephil.charting.components.YAxis#setTextSize()
The following examples show how to use
com.github.mikephil.charting.components.YAxis#setTextSize() .
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: RealmBaseActivity.java From Stayfit with Apache License 2.0 | 5 votes |
protected void setup(Chart<?> chart) { mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf"); // no description text chart.setDescription(""); chart.setNoDataTextDescription("You need to provide data for the chart."); // enable touch gestures chart.setTouchEnabled(true); if (chart instanceof BarLineChartBase) { BarLineChartBase mChart = (BarLineChartBase) chart; mChart.setDrawGridBackground(false); // 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); YAxis leftAxis = mChart.getAxisLeft(); leftAxis.removeAllLimitLines(); // reset all limit lines to avoid overlapping lines leftAxis.setTypeface(mTf); leftAxis.setTextSize(8f); leftAxis.setTextColor(Color.DKGRAY); leftAxis.setValueFormatter(new PercentFormatter()); XAxis xAxis = mChart.getXAxis(); xAxis.setTypeface(mTf); xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); xAxis.setTextSize(8f); xAxis.setTextColor(Color.DKGRAY); mChart.getAxisRight().setEnabled(false); } }
Example 2
Source File: PowerChart.java From AndroidApp with GNU Affero General Public License v3.0 | 5 votes |
private void setFormatting() { powerChart.setDrawGridBackground(false); powerChart.getLegend().setEnabled(false); powerChart.getAxisRight().setEnabled(false); powerChart.getDescription().setEnabled(false); powerChart.setNoDataText(""); powerChart.setHardwareAccelerationEnabled(true); YAxis yAxis = powerChart.getAxisLeft(); yAxis.setEnabled(true); yAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART); yAxis.setDrawTopYLabelEntry(false); yAxis.setDrawGridLines(false); yAxis.setDrawAxisLine(false); yAxis.setTextColor(ContextCompat.getColor(context, R.color.lightGrey)); yAxis.setTextSize(context.getResources().getInteger(R.integer.chartDateTextSize)); yAxis.setValueFormatter(new IntegerYAxisValueFormatter()); XAxis xAxis = powerChart.getXAxis(); xAxis.setDrawAxisLine(false); xAxis.setDrawGridLines(false); xAxis.setDrawLabels(true); xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); xAxis.setTextColor(ContextCompat.getColor(context, R.color.lightGrey)); xAxis.setValueFormatter(new HoursMinutesXAxisValueFormatter(chartLabels)); xAxis.setTextSize(context.getResources().getInteger(R.integer.chartDateTextSize)); }
Example 3
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 4
Source File: RadarChartActivity.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_radarchart); setTitle("RadarChartActivity"); chart = findViewById(R.id.chart1); chart.setBackgroundColor(Color.rgb(60, 65, 82)); chart.getDescription().setEnabled(false); chart.setWebLineWidth(1f); chart.setWebColor(Color.LTGRAY); chart.setWebLineWidthInner(1f); chart.setWebColorInner(Color.LTGRAY); chart.setWebAlpha(100); // create a custom MarkerView (extend MarkerView) and specify the layout // to use for it MarkerView mv = new RadarMarkerView(this, R.layout.radar_markerview); mv.setChartView(chart); // For bounds control chart.setMarker(mv); // Set the marker to the chart setData(); chart.animateXY(1400, 1400, Easing.EaseInOutQuad); XAxis xAxis = chart.getXAxis(); xAxis.setTypeface(tfLight); xAxis.setTextSize(9f); xAxis.setYOffset(0f); xAxis.setXOffset(0f); xAxis.setValueFormatter(new ValueFormatter() { private final String[] mActivities = new String[]{"Burger", "Steak", "Salad", "Pasta", "Pizza"}; @Override public String getFormattedValue(float value) { return mActivities[(int) value % mActivities.length]; } }); xAxis.setTextColor(Color.WHITE); YAxis yAxis = chart.getYAxis(); yAxis.setTypeface(tfLight); yAxis.setLabelCount(5, false); yAxis.setTextSize(9f); yAxis.setAxisMinimum(0f); yAxis.setAxisMaximum(80f); yAxis.setDrawLabels(false); Legend l = chart.getLegend(); l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP); l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER); l.setOrientation(Legend.LegendOrientation.HORIZONTAL); l.setDrawInside(false); l.setTypeface(tfLight); l.setXEntrySpace(7f); l.setYEntrySpace(5f); l.setTextColor(Color.WHITE); }
Example 5
Source File: QuotationFragment.java From bitshares_wallet with MIT License | 4 votes |
private void initChart() { int colorHomeBg = getResources().getColor(android.R.color.transparent); int colorLine = getResources().getColor(R.color.common_divider); int colorText = getResources().getColor(R.color.text_grey_light); mChart.setDescription(null); mChart.setDrawGridBackground(true); mChart.setBackgroundColor(colorHomeBg); mChart.setGridBackgroundColor(colorHomeBg); mChart.setScaleYEnabled(false); mChart.setPinchZoom(true); mChart.setNoDataText(getString(R.string.main_activity_loading)); mChart.setAutoScaleMinMaxEnabled(true); mChart.setDragEnabled(true); mChart.setDoubleTapToZoomEnabled(false); XAxis xAxis = mChart.getXAxis(); xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); xAxis.setDrawGridLines(true); xAxis.setGridColor(colorLine); xAxis.setTextColor(colorText); xAxis.setLabelCount(3); //xAxis.setSpaceBetweenLabels(4); YAxis leftAxis = mChart.getAxisLeft(); leftAxis.setLabelCount(4, false); leftAxis.setDrawGridLines(true); leftAxis.setDrawAxisLine(true); leftAxis.setGridColor(colorLine); leftAxis.setTextColor(colorText); YAxis rightAxis = mChart.getAxisRight(); rightAxis.setTextSize(8); rightAxis.setLabelCount(5, false); rightAxis.setDrawGridLines(false); rightAxis.setDrawAxisLine(true); rightAxis.setGridColor(colorLine); rightAxis.setTextColor(colorText); rightAxis.setAxisMinimum(0); }
Example 6
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 7
Source File: RadarChartActivitry.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_radarchart); mChart = (RadarChart) findViewById(R.id.chart1); tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf"); mChart.setDescription(""); mChart.setWebLineWidth(1.5f); mChart.setWebLineWidthInner(0.75f); mChart.setWebAlpha(100); // 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); setData(); mChart.animateXY( 1400, 1400, Easing.EasingOption.EaseInOutQuad, Easing.EasingOption.EaseInOutQuad); XAxis xAxis = mChart.getXAxis(); xAxis.setTypeface(tf); xAxis.setTextSize(9f); YAxis yAxis = mChart.getYAxis(); yAxis.setTypeface(tf); yAxis.setLabelCount(5, false); yAxis.setTextSize(9f); yAxis.setAxisMinValue(0f); Legend l = mChart.getLegend(); l.setPosition(LegendPosition.RIGHT_OF_CHART); l.setTypeface(tf); l.setXEntrySpace(7f); l.setYEntrySpace(5f); }
Example 8
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); }