Java Code Examples for com.github.mikephil.charting.components.YAxis#setTextColor()
The following examples show how to use
com.github.mikephil.charting.components.YAxis#setTextColor() .
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: ModelDetailActivity.java From Synapse with Apache License 2.0 | 5 votes |
private void prepareChart() { mChart.setTouchEnabled(true); mChart.setDragEnabled(true); mChart.setScaleEnabled(true); mChart.setPinchZoom(true); mChart.setHighlightPerTapEnabled(true); mChart.setDoubleTapToZoomEnabled(false); mChart.setHighlightPerDragEnabled(false); mChart.getDescription().setEnabled(false); mChart.setDrawGridBackground(false); mChart.getLegend().setEnabled(true); mChart.getAxisRight().setEnabled(false); mChart.setMarker(new AMarkView(this, R.layout.ac_detail_mark_view)); final YAxis leftAxis = mChart.getAxisLeft(); leftAxis.setTextColor(ContextCompat.getColor(this, R.color.text_primary)); leftAxis.setAxisMaximum(1F); leftAxis.setDrawGridLines(false); leftAxis.setDrawAxisLine(true); final LimitLine upLine = new LimitLine(0.9F, "Great"); upLine.setLineWidth(2F); upLine.enableDashedLine(10F, 10F, 10F); upLine.setLabelPosition(LimitLine.LimitLabelPosition.RIGHT_TOP); upLine.setLineColor(ContextCompat.getColor(this, R.color.divider)); upLine.setTextColor(ContextCompat.getColor(this, R.color.green$1)); final LimitLine downLine = new LimitLine(0.5F, "Bad"); downLine.setLineWidth(2F); downLine.enableDashedLine(10F, 10F, 10F); downLine.setLabelPosition(LimitLine.LimitLabelPosition.RIGHT_BOTTOM); downLine.setLineColor(ContextCompat.getColor(this, R.color.divider)); downLine.setTextColor(ContextCompat.getColor(this, R.color.pink_$1)); leftAxis.addLimitLine(upLine); leftAxis.addLimitLine(downLine); }
Example 2
Source File: BarGraph.java From fastnfitness with BSD 3-Clause "New" or "Revised" License | 5 votes |
public BarGraph(Context context, BarChart chart, String name) { mChart = chart; mChartName = name; mChart.setHorizontalScrollBarEnabled(true); mChart.setVerticalScrollBarEnabled(true); mChart.setDrawBorders(true); mChart.setNoDataText(context.getString(R.string.no_chart_data_available)); mContext = context; // get the legend (only possible after setting data) Legend l = mChart.getLegend(); l.setEnabled(false); XAxis xAxis = mChart.getXAxis(); xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); xAxis.setTextColor(ColorTemplate.getHoloBlue()); xAxis.setDrawAxisLine(false); xAxis.setGranularityEnabled(true); xAxis.setGranularity(1f); YAxis leftAxis = mChart.getAxisLeft(); leftAxis.setAxisMinimum(0f); leftAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART); leftAxis.setTextColor(ColorTemplate.getHoloBlue()); leftAxis.setGranularityEnabled(true); leftAxis.setGranularity((float) 1); mChart.setFitBars(true); leftAxis.setAxisMinimum(0f); mChart.getAxisRight().setEnabled(false); }
Example 3
Source File: Results.java From NoiseCapture with GNU General Public License v3.0 | 5 votes |
public void initSpectrumChart(){ sChart.setPinchZoom(false); sChart.setDoubleTapToZoomEnabled(false); sChart.setDrawBarShadow(false); sChart.setDescription(""); sChart.setPinchZoom(false); sChart.setDrawGridBackground(false); sChart.setHighlightPerTapEnabled(true); sChart.setHighlightPerDragEnabled(false); sChart.setDrawHighlightArrow(true); sChart.setDrawValueAboveBar(true); // XAxis parameters: hide all XAxis xls = sChart.getXAxis(); xls.setPosition(XAxisPosition.BOTTOM); xls.setDrawAxisLine(true); xls.setDrawGridLines(false); xls.setLabelRotationAngle(-90); xls.setDrawLabels(true); xls.setTextColor(Color.WHITE); xls.setLabelsToSkip(0); // YAxis parameters (left): main axis for dB values representation YAxis yls = sChart.getAxisLeft(); yls.setDrawAxisLine(true); yls.setDrawGridLines(true); yls.setAxisMaxValue(110.f); yls.setStartAtZero(true); yls.setTextColor(Color.WHITE); yls.setGridColor(Color.WHITE); // YAxis parameters (right): no axis, hide all YAxis yrs = sChart.getAxisRight(); yrs.setEnabled(false); //return true; }
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: AnalysisFragment.java From outlay with Apache License 2.0 | 5 votes |
private void initChart() { barChart.setDrawBarShadow(false); barChart.setDrawValueAboveBar(true); barChart.getDescription().setEnabled(false); barChart.setPinchZoom(false); barChart.setMaxVisibleValueCount(60); barChart.getLegend().setEnabled(false); barChart.setDrawGridBackground(false); barChart.getAxisRight().setEnabled(false); barChart.setScaleYEnabled(false); dayAxisValueFormatter = new DayAxisValueFormatter(); XAxis xAxis = barChart.getXAxis(); xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); xAxis.setLabelRotationAngle(270); xAxis.setDrawGridLines(false); xAxis.setGranularity(1f); xAxis.setTextColor(getOutlayTheme().secondaryTextColor); xAxis.setValueFormatter(dayAxisValueFormatter); YAxis leftAxis = barChart.getAxisLeft(); leftAxis.setValueFormatter(new AmountValueFormatter()); leftAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART); leftAxis.setTextColor(getOutlayTheme().secondaryTextColor); leftAxis.setSpaceTop(15f); leftAxis.setAxisMinimum(0f); }
Example 6
Source File: CalibrationLinearityActivity.java From NoiseCapture with GNU General Public License v3.0 | 5 votes |
private void initBar() { BarChart barChart = getBarChart(); if(barChart == null) { return; } barChart.setDescription(""); barChart.setDrawGridBackground(false); barChart.setMaxVisibleValueCount(200); Legend l = barChart.getLegend(); l.setPosition(Legend.LegendPosition.ABOVE_CHART_LEFT); l.setTextColor(Color.WHITE); YAxis yl = barChart.getAxisLeft(); yl.setTextColor(Color.WHITE); yl.setGridColor(Color.WHITE); barChart.getAxisRight().setEnabled(false); XAxis xl = barChart.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 7
Source File: TrafficFragment.java From gito-github-client with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") private void chartYAxisStyling(YAxis yAxis) { yAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART); yAxis.setTextColor(SettingsActivity.ThemePreferenceFragment.isLight(getContext()) ? getResources().getColor(R.color.traffic_chart_text_color_light) : getResources().getColor(R.color.traffic_chart_text_color_dark)); yAxis.setDrawGridLines(false); yAxis.setGranularityEnabled(true); yAxis.setDrawAxisLine(true); }
Example 8
Source File: FragmentBarChart.java From fingen with Apache License 2.0 | 5 votes |
private void setupBarChart() { mBarChart.setDrawBarShadow(false); mBarChart.setDrawValueAboveBar(true); mBarChart.setDescription(""); mBarChart.setMaxVisibleValueCount(Integer.MAX_VALUE); mBarChart.setPinchZoom(false); mBarChart.setDrawGridBackground(false); mBarChart.setOnChartValueSelectedListener(this); mBarChart.setHighlightPerDragEnabled(false); int textColor = ColorUtils.getTextColor(getActivity()); XAxis xl = mBarChart.getXAxis(); xl.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE); xl.setDrawAxisLine(true); xl.setDrawGridLines(true); xl.setGridLineWidth(0.3f); xl.setTextColor(textColor); YAxis yl = mBarChart.getAxisLeft(); yl.setDrawAxisLine(true); yl.setDrawGridLines(true); yl.setGridLineWidth(0.3f); yl.setAxisMinValue(0f); yl.setTextColor(textColor); YAxis yr = mBarChart.getAxisRight(); yr.setDrawAxisLine(true); yr.setDrawGridLines(false); yr.setAxisMinValue(0f); yr.setTextColor(textColor); mBarChart.setXAxisRenderer(new FgHorizontalBarChartRenderer(getActivity(), mBarChart.getViewPortHandler(), mBarChart.getXAxis(), mBarChart.getTransformer(YAxis.AxisDependency.LEFT), mBarChart)); mBarChart.getLegend().setEnabled(false); }
Example 9
Source File: FragmentTimeBarChart.java From fingen with Apache License 2.0 | 5 votes |
private void setupBarChart() { mBarChart.setDrawBarShadow(false); mBarChart.setDrawValueAboveBar(true); mBarChart.setDescription(""); mBarChart.setMaxVisibleValueCount(Integer.MAX_VALUE); mBarChart.setPinchZoom(false); mBarChart.setDrawGridBackground(false); mBarChart.setOnChartValueSelectedListener(this); mBarChart.setHighlightPerDragEnabled(false); int textColor = ColorUtils.getTextColor(getActivity()); XAxis xl = mBarChart.getXAxis(); xl.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE); xl.setDrawAxisLine(true); xl.setDrawGridLines(true); xl.setGridLineWidth(0.3f); xl.setTextColor(textColor); YAxis yl = mBarChart.getAxisLeft(); yl.setDrawAxisLine(true); yl.setDrawGridLines(true); yl.setGridLineWidth(0.3f); yl.setAxisMinValue(0f); yl.setTextColor(textColor); YAxis yr = mBarChart.getAxisRight(); yr.setDrawAxisLine(true); yr.setDrawGridLines(false); yr.setAxisMinValue(0f); yr.setTextColor(textColor); mBarChart.setXAxisRenderer(new FgHorizontalBarChartRenderer(getActivity(), mBarChart.getViewPortHandler(), mBarChart.getXAxis(), mBarChart.getTransformer(YAxis.AxisDependency.LEFT), mBarChart)); mBarChart.getLegend().setEnabled(false); }
Example 10
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 11
Source File: LineChartTime.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_time); setTitle("LineChartTime"); tvX = findViewById(R.id.tvXMax); seekBarX = findViewById(R.id.seekBar1); seekBarX.setOnSeekBarChangeListener(this); chart = findViewById(R.id.chart1); // no description text chart.getDescription().setEnabled(false); // enable touch gestures chart.setTouchEnabled(true); chart.setDragDecelerationFrictionCoef(0.9f); // enable scaling and dragging chart.setDragEnabled(true); chart.setScaleEnabled(true); chart.setDrawGridBackground(false); chart.setHighlightPerDragEnabled(true); // set an alternative background color chart.setBackgroundColor(Color.WHITE); chart.setViewPortOffsets(0f, 0f, 0f, 0f); // add data seekBarX.setProgress(100); // get the legend (only possible after setting data) Legend l = chart.getLegend(); l.setEnabled(false); XAxis xAxis = chart.getXAxis(); xAxis.setPosition(XAxis.XAxisPosition.TOP_INSIDE); xAxis.setTypeface(tfLight); xAxis.setTextSize(10f); xAxis.setTextColor(Color.WHITE); xAxis.setDrawAxisLine(false); xAxis.setDrawGridLines(true); xAxis.setTextColor(Color.rgb(255, 192, 56)); xAxis.setCenterAxisLabels(true); xAxis.setGranularity(1f); // one hour xAxis.setValueFormatter(new ValueFormatter() { private final SimpleDateFormat mFormat = new SimpleDateFormat("dd MMM HH:mm", Locale.ENGLISH); @Override public String getFormattedValue(float value) { long millis = TimeUnit.HOURS.toMillis((long) value); return mFormat.format(new Date(millis)); } }); YAxis leftAxis = chart.getAxisLeft(); leftAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART); leftAxis.setTypeface(tfLight); leftAxis.setTextColor(ColorTemplate.getHoloBlue()); leftAxis.setDrawGridLines(true); leftAxis.setGranularityEnabled(true); leftAxis.setAxisMinimum(0f); leftAxis.setAxisMaximum(170f); leftAxis.setYOffset(-9f); leftAxis.setTextColor(Color.rgb(255, 192, 56)); YAxis rightAxis = chart.getAxisRight(); rightAxis.setEnabled(false); }
Example 12
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 13
Source File: BaseView.java From android-kline with Apache License 2.0 | 4 votes |
protected void initBottomChart(AppCombinedChart chart) { chart.setScaleEnabled(true); chart.setDrawBorders(false); chart.setBorderWidth(1); chart.setDragEnabled(true); chart.setScaleYEnabled(false); chart.setAutoScaleMinMaxEnabled(true); chart.setDragDecelerationEnabled(false); chart.setHighlightPerDragEnabled(false); Legend lineChartLegend = chart.getLegend(); lineChartLegend.setEnabled(false); XAxis xAxisVolume = chart.getXAxis(); xAxisVolume.setDrawLabels(true); xAxisVolume.setDrawAxisLine(false); xAxisVolume.setDrawGridLines(false); xAxisVolume.setTextColor(mAxisColor); xAxisVolume.setPosition(XAxis.XAxisPosition.BOTTOM); xAxisVolume.setLabelCount(3, true); xAxisVolume.setAvoidFirstLastClipping(true); xAxisVolume.setAxisMinimum(-0.5f); xAxisVolume.setValueFormatter(new IAxisValueFormatter() { @Override public String getFormattedValue(float value, AxisBase axis) { if (mData.isEmpty()) { return ""; } if (value < 0) { value = 0; } if (value < mData.size()) { return DateUtils.formatDate(mData.get((int) value).getDate(), mDateFormat); } return ""; } }); YAxis axisLeftVolume = chart.getAxisLeft(); axisLeftVolume.setDrawLabels(true); axisLeftVolume.setDrawGridLines(false); axisLeftVolume.setLabelCount(3, true); axisLeftVolume.setDrawAxisLine(false); axisLeftVolume.setTextColor(mAxisColor); axisLeftVolume.setSpaceTop(10); axisLeftVolume.setSpaceBottom(0); axisLeftVolume.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART); /*axisLeftVolume.setValueFormatter(new IAxisValueFormatter() { @Override public String getFormattedValue(float value, AxisBase axis) { String s; if (value > 10000) { s = (int) (value / 10000) + "w"; } else if (value > 1000) { s = (int) (value / 1000) + "k"; } else { s = (int) value + ""; } return String.format(Locale.getDefault(), "%1$5s", s); } }); */ Transformer leftYTransformer = chart.getRendererLeftYAxis().getTransformer(); ColorContentYAxisRenderer leftColorContentYAxisRenderer = new ColorContentYAxisRenderer(chart.getViewPortHandler(), chart.getAxisLeft(), leftYTransformer); leftColorContentYAxisRenderer.setLabelInContent(true); leftColorContentYAxisRenderer.setUseDefaultLabelXOffset(false); chart.setRendererLeftYAxis(leftColorContentYAxisRenderer); //右边y YAxis axisRightVolume = chart.getAxisRight(); axisRightVolume.setDrawLabels(false); axisRightVolume.setDrawGridLines(false); axisRightVolume.setDrawAxisLine(false); }
Example 14
Source File: FragmentPrice.java From bcm-android with GNU General Public License v3.0 | 4 votes |
private void setupChart(LineChart chart, LineData data, int color) { ((LineDataSet) data.getDataSetByIndex(0)).setCircleColorHole(color); chart.getDescription().setEnabled(false); chart.setDrawGridBackground(false); chart.setTouchEnabled(false); chart.setDragEnabled(false); chart.setScaleEnabled(true); chart.setPinchZoom(false); chart.setBackgroundColor(color); chart.setViewPortOffsets(0, 23, 0, 0); chart.setData(data); Legend l = chart.getLegend(); l.setEnabled(false); chart.getAxisLeft().setEnabled(true); chart.getAxisLeft().setDrawGridLines(false); chart.getAxisLeft().setDrawAxisLine(false); chart.getAxisLeft().setSpaceTop(10); chart.getAxisLeft().setSpaceBottom(30); chart.getAxisLeft().setAxisLineColor(0xFFFFFF); chart.getAxisLeft().setTextColor(0xFFFFFF); chart.getAxisLeft().setDrawTopYLabelEntry(true); chart.getAxisLeft().setLabelCount(10); chart.getXAxis().setEnabled(true); chart.getXAxis().setDrawGridLines(false); chart.getXAxis().setDrawAxisLine(false); chart.getXAxis().setAxisLineColor(0xFFFFFF); chart.getXAxis().setTextColor(0xFFFFFF); Typeface tf = Typeface.DEFAULT; // X Axis XAxis xAxis = chart.getXAxis(); xAxis.setTypeface(tf); xAxis.removeAllLimitLines(); xAxis.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE); xAxis.setTextColor(Color.argb(150, 255, 255, 255)); if (displayType == 1 || displayType == 2) // Week and Month xAxis.setValueFormatter(new WeekXFormatter()); else if (displayType == 0) // Day xAxis.setValueFormatter(new HourXFormatter()); else xAxis.setValueFormatter(new YearXFormatter()); // Year // Y Axis YAxis leftAxis = chart.getAxisLeft(); leftAxis.removeAllLimitLines(); leftAxis.setTypeface(tf); leftAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART); leftAxis.setTextColor(Color.argb(150, 255, 255, 255)); leftAxis.setValueFormatter(new DontShowNegativeFormatter(displayInUsd)); chart.getAxisRight().setEnabled(false); // Deactivates horizontal lines chart.animateX(1300); chart.notifyDataSetChanged(); }
Example 15
Source File: MeasurementSpectrumFragment.java From NoiseCapture with GNU General Public License v3.0 | 4 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if(view == null) { // Inflate the layout for this fragment view = inflater.inflate(R.layout.fragment_measurement_spectrum, container, false); BarChart sChart = (BarChart) view.findViewById(R.id.spectrumChart); sChart.setDrawBarShadow(false); sChart.setDescription(""); sChart.getLegend().setEnabled(false); sChart.setTouchEnabled(false); sChart.setPinchZoom(false); sChart.setDrawGridBackground(false); sChart.setMaxVisibleValueCount(0); sChart.setHorizontalScrollBarEnabled(false); sChart.setVerticalScrollBarEnabled(false); sChart.setNoDataTextDescription(getText(R.string.no_data_text_description).toString()); // XAxis parameters: XAxis xls = sChart.getXAxis(); xls.setPosition(XAxis.XAxisPosition.BOTTOM); xls.setDrawAxisLine(true); xls.setDrawGridLines(false); xls.setDrawLabels(true); xls.setTextColor(Color.WHITE); xls.setAvoidFirstLastClipping(false); // YAxis parameters (left): main axis for dB values representation YAxis yls = sChart.getAxisLeft(); yls.setDrawAxisLine(true); yls.setDrawGridLines(true); yls.setAxisMaxValue(100.f); yls.setAxisMinValue(0f); yls.setTextColor(Color.WHITE); yls.setGridColor(Color.WHITE); yls.setSpaceBottom(0); yls.setSpaceTop(0); yls.setValueFormatter(new SPLValueFormatter()); // YAxis parameters (right): no axis, hide all YAxis yrs = sChart.getAxisRight(); yrs.setEnabled(false); } return view; }
Example 16
Source File: FragmentPrice.java From Lunary-Ethereum-Wallet with GNU General Public License v3.0 | 4 votes |
private void setupChart(LineChart chart, LineData data, int color) { ((LineDataSet) data.getDataSetByIndex(0)).setCircleColorHole(color); chart.getDescription().setEnabled(false); chart.setDrawGridBackground(false); chart.setTouchEnabled(false); chart.setDragEnabled(false); chart.setScaleEnabled(true); chart.setPinchZoom(false); chart.setBackgroundColor(color); chart.setViewPortOffsets(0, 23, 0, 0); chart.setData(data); Legend l = chart.getLegend(); l.setEnabled(false); chart.getAxisLeft().setEnabled(true); chart.getAxisLeft().setDrawGridLines(false); chart.getAxisLeft().setDrawAxisLine(false); chart.getAxisLeft().setSpaceTop(10); chart.getAxisLeft().setSpaceBottom(30); chart.getAxisLeft().setAxisLineColor(0xFFFFFF); chart.getAxisLeft().setTextColor(0xFFFFFF); chart.getAxisLeft().setDrawTopYLabelEntry(true); chart.getAxisLeft().setLabelCount(10); chart.getXAxis().setEnabled(true); chart.getXAxis().setDrawGridLines(false); chart.getXAxis().setDrawAxisLine(false); chart.getXAxis().setAxisLineColor(0xFFFFFF); chart.getXAxis().setTextColor(0xFFFFFF); Typeface tf = Typeface.DEFAULT; // X Axis XAxis xAxis = chart.getXAxis(); xAxis.setTypeface(tf); xAxis.removeAllLimitLines(); xAxis.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE); xAxis.setTextColor(Color.argb(150, 255, 255, 255)); if (displayType == 1 || displayType == 2) // Week and Month xAxis.setValueFormatter(new WeekXFormatter()); else if (displayType == 0) // Day xAxis.setValueFormatter(new HourXFormatter()); else xAxis.setValueFormatter(new YearXFormatter()); // Year // Y Axis YAxis leftAxis = chart.getAxisLeft(); leftAxis.removeAllLimitLines(); leftAxis.setTypeface(tf); leftAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART); leftAxis.setTextColor(Color.argb(150, 255, 255, 255)); leftAxis.setValueFormatter(new DontShowNegativeFormatter(displayInUsd)); chart.getAxisRight().setEnabled(false); // Deactivates horizontal lines chart.animateX(1300); chart.notifyDataSetChanged(); }
Example 17
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 18
Source File: MiniDateGraph.java From fastnfitness with BSD 3-Clause "New" or "Revised" License | 4 votes |
public MiniDateGraph(Context context, LineChart chart, String name) { mChart = chart; mChartName = name; mChart.getDescription().setEnabled(false); mChart.setDoubleTapToZoomEnabled(false); mChart.setHorizontalScrollBarEnabled(false); mChart.setVerticalScrollBarEnabled(false); mChart.setAutoScaleMinMaxEnabled(false); mChart.setDrawBorders(false); mChart.setViewPortOffsets(6f, 6f, 6f, 6f); mChart.animateY(1000, Easing.EaseInOutBack); // animate horizontal 3000 milliseconds mChart.setClickable(false); mChart.getAxisRight().setDrawLabels(false); mChart.getAxisLeft().setDrawLabels(false); mChart.getLegend().setEnabled(false); mChart.setPinchZoom(false); mChart.setDescription(null); mChart.setTouchEnabled(false); mChart.setDoubleTapToZoomEnabled(false); mChart.setNoDataText(context.getString(R.string.no_chart_data_available)); mContext = context; // get the legend (only possible after setting data) Legend l = mChart.getLegend(); l.setEnabled(false); XAxis xAxis = mChart.getXAxis(); xAxis.setDrawLabels(false); xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); xAxis.setTextColor(ColorTemplate.getHoloBlue()); xAxis.setDrawAxisLine(false); xAxis.setDrawGridLines(false); xAxis.setCenterAxisLabels(false); xAxis.setGranularity(1); // 1 jour YAxis leftAxis = mChart.getAxisLeft(); leftAxis.setEnabled(false); leftAxis.setDrawZeroLine(false); leftAxis.setDrawLabels(false); leftAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART); leftAxis.setTextColor(ColorTemplate.getHoloBlue()); leftAxis.setDrawGridLines(false); leftAxis.setGranularityEnabled(false); mChart.getAxisRight().setEnabled(false); }
Example 19
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 20
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(); }