Java Code Examples for com.github.mikephil.charting.components.YAxis#setTypeface()
The following examples show how to use
com.github.mikephil.charting.components.YAxis#setTypeface() .
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: 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 2
Source File: DrawChartActivity.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_draw_chart); mChart = (LineChart) findViewById(R.id.chart1); // listener for selecting and drawing mChart.setOnChartValueSelectedListener(this); mChart.setOnDrawListener(this); // if disabled, drawn datasets with the finger will not be automatically // finished // mChart.setAutoFinish(true); mChart.setDrawGridBackground(false); // add dummy-data to the chart initWithDummyData(); Typeface tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf"); XAxis xl = mChart.getXAxis(); xl.setTypeface(tf); xl.setAvoidFirstLastClipping(true); YAxis yl = mChart.getAxisLeft(); yl.setTypeface(tf); mChart.getLegend().setEnabled(false); // mChart.setYRange(-40f, 40f, true); // call this to reset the changed y-range // mChart.resetYRange(true); }
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: ListViewBarChartActivity.java From Stayfit with Apache License 2.0 | 4 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { BarData data = getItem(position); ViewHolder holder = null; if (convertView == null) { holder = new ViewHolder(); convertView = LayoutInflater.from(getContext()).inflate( R.layout.list_item_barchart, null); holder.chart = (BarChart) convertView.findViewById(R.id.chart); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } // apply styling data.setValueTypeface(mTf); data.setValueTextColor(Color.BLACK); holder.chart.setDescription(""); holder.chart.setDrawGridBackground(false); XAxis xAxis = holder.chart.getXAxis(); xAxis.setPosition(XAxisPosition.BOTTOM); xAxis.setTypeface(mTf); xAxis.setDrawGridLines(false); YAxis leftAxis = holder.chart.getAxisLeft(); leftAxis.setTypeface(mTf); leftAxis.setLabelCount(5, false); leftAxis.setSpaceTop(15f); YAxis rightAxis = holder.chart.getAxisRight(); rightAxis.setTypeface(mTf); rightAxis.setLabelCount(5, false); rightAxis.setSpaceTop(15f); // set data holder.chart.setData(data); // do not forget to refresh the chart // holder.chart.invalidate(); holder.chart.animateY(700, Easing.EasingOption.EaseInCubic); return convertView; }
Example 6
Source File: BarChartItem.java From StockChart-MPAndroidChart with MIT License | 4 votes |
@SuppressLint("InflateParams") @Override public View getView(int position, View convertView, Context c) { ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = LayoutInflater.from(c).inflate( R.layout.list_item_barchart, null); holder.chart = convertView.findViewById(R.id.chart); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } // apply styling holder.chart.getDescription().setEnabled(false); holder.chart.setDrawGridBackground(false); holder.chart.setDrawBarShadow(false); XAxis xAxis = holder.chart.getXAxis(); xAxis.setPosition(XAxisPosition.BOTTOM); xAxis.setTypeface(mTf); xAxis.setDrawGridLines(false); xAxis.setDrawAxisLine(true); YAxis leftAxis = holder.chart.getAxisLeft(); leftAxis.setTypeface(mTf); leftAxis.setLabelCount(5, false); leftAxis.setSpaceTop(20f); leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true) YAxis rightAxis = holder.chart.getAxisRight(); rightAxis.setTypeface(mTf); rightAxis.setLabelCount(5, false); rightAxis.setSpaceTop(20f); rightAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true) mChartData.setValueTypeface(mTf); // set data holder.chart.setData((BarData) mChartData); holder.chart.setFitBars(true); // do not forget to refresh the chart // holder.chart.invalidate(); holder.chart.animateY(700); return convertView; }
Example 7
Source File: LineChartItem.java From StockChart-MPAndroidChart with MIT License | 4 votes |
@SuppressLint("InflateParams") @Override public View getView(int position, View convertView, Context c) { ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = LayoutInflater.from(c).inflate( R.layout.list_item_linechart, null); holder.chart = convertView.findViewById(R.id.chart); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } // apply styling // holder.chart.setValueTypeface(mTf); holder.chart.getDescription().setEnabled(false); holder.chart.setDrawGridBackground(false); XAxis xAxis = holder.chart.getXAxis(); xAxis.setPosition(XAxisPosition.BOTTOM); xAxis.setTypeface(mTf); xAxis.setDrawGridLines(false); xAxis.setDrawAxisLine(true); YAxis leftAxis = holder.chart.getAxisLeft(); leftAxis.setTypeface(mTf); leftAxis.setLabelCount(5, false); leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true) YAxis rightAxis = holder.chart.getAxisRight(); rightAxis.setTypeface(mTf); rightAxis.setLabelCount(5, false); rightAxis.setDrawGridLines(false); rightAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true) // set data holder.chart.setData((LineData) mChartData); // do not forget to refresh the chart // holder.chart.invalidate(); holder.chart.animateX(750); return convertView; }
Example 8
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 9
Source File: BubbleChartActivity.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_bubblechart); setTitle("BubbleChartActivity"); tvX = findViewById(R.id.tvXMax); tvY = findViewById(R.id.tvYMax); seekBarX = findViewById(R.id.seekBar1); seekBarX.setOnSeekBarChangeListener(this); seekBarY = findViewById(R.id.seekBar2); seekBarY.setOnSeekBarChangeListener(this); chart = findViewById(R.id.chart1); chart.getDescription().setEnabled(false); chart.setOnChartValueSelectedListener(this); chart.setDrawGridBackground(false); chart.setTouchEnabled(true); // enable scaling and dragging chart.setDragEnabled(true); chart.setScaleEnabled(true); chart.setMaxVisibleValueCount(200); chart.setPinchZoom(true); seekBarX.setProgress(10); seekBarY.setProgress(50); Legend l = chart.getLegend(); l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP); l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT); l.setOrientation(Legend.LegendOrientation.VERTICAL); l.setDrawInside(false); l.setTypeface(tfLight); YAxis yl = chart.getAxisLeft(); yl.setTypeface(tfLight); yl.setSpaceTop(30f); yl.setSpaceBottom(30f); yl.setDrawZeroLine(false); chart.getAxisRight().setEnabled(false); XAxis xl = chart.getXAxis(); xl.setPosition(XAxis.XAxisPosition.BOTTOM); xl.setTypeface(tfLight); }
Example 10
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 11
Source File: BarChartItem.java From Stayfit with Apache License 2.0 | 4 votes |
@Override public View getView(int position, View convertView, Context c) { ViewHolder holder = null; if (convertView == null) { holder = new ViewHolder(); convertView = LayoutInflater.from(c).inflate( R.layout.list_item_barchart, null); holder.chart = (BarChart) convertView.findViewById(R.id.chart); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } // apply styling holder.chart.setDescription(""); holder.chart.setDrawGridBackground(false); holder.chart.setDrawBarShadow(false); XAxis xAxis = holder.chart.getXAxis(); xAxis.setPosition(XAxisPosition.BOTTOM); xAxis.setTypeface(mTf); xAxis.setDrawGridLines(false); xAxis.setDrawAxisLine(true); YAxis leftAxis = holder.chart.getAxisLeft(); leftAxis.setTypeface(mTf); leftAxis.setLabelCount(5, false); leftAxis.setSpaceTop(20f); leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true) YAxis rightAxis = holder.chart.getAxisRight(); rightAxis.setTypeface(mTf); rightAxis.setLabelCount(5, false); rightAxis.setSpaceTop(20f); rightAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true) mChartData.setValueTypeface(mTf); // set data holder.chart.setData((BarData) mChartData); // do not forget to refresh the chart // holder.chart.invalidate(); holder.chart.animateY(700); return convertView; }
Example 12
Source File: ScatterChartActivity.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_scatterchart); setTitle("ScatterChartActivity"); tvX = findViewById(R.id.tvXMax); tvY = findViewById(R.id.tvYMax); seekBarX = findViewById(R.id.seekBar1); seekBarX.setOnSeekBarChangeListener(this); seekBarY = findViewById(R.id.seekBar2); seekBarY.setOnSeekBarChangeListener(this); chart = findViewById(R.id.chart1); chart.getDescription().setEnabled(false); chart.setOnChartValueSelectedListener(this); chart.setDrawGridBackground(false); chart.setTouchEnabled(true); chart.setMaxHighlightDistance(50f); // enable scaling and dragging chart.setDragEnabled(true); chart.setScaleEnabled(true); chart.setMaxVisibleValueCount(200); chart.setPinchZoom(true); seekBarX.setProgress(45); seekBarY.setProgress(100); Legend l = chart.getLegend(); l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP); l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT); l.setOrientation(Legend.LegendOrientation.VERTICAL); l.setDrawInside(false); l.setTypeface(tfLight); l.setXOffset(5f); YAxis yl = chart.getAxisLeft(); yl.setTypeface(tfLight); yl.setAxisMinimum(0f); // this replaces setStartAtZero(true) chart.getAxisRight().setEnabled(false); XAxis xl = chart.getXAxis(); xl.setTypeface(tfLight); xl.setDrawGridLines(false); }
Example 13
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 14
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 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: 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 17
Source File: BarChartActivity.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); setTitle("BarChartActivity"); tvX = findViewById(R.id.tvXMax); tvY = findViewById(R.id.tvYMax); seekBarX = findViewById(R.id.seekBar1); seekBarY = findViewById(R.id.seekBar2); seekBarY.setOnSeekBarChangeListener(this); seekBarX.setOnSeekBarChangeListener(this); chart = findViewById(R.id.chart1); chart.setOnChartValueSelectedListener(this); 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); chart.setDrawGridBackground(false); // chart.setDrawYLabels(false); ValueFormatter xAxisFormatter = new DayAxisValueFormatter(chart); XAxis xAxis = chart.getXAxis(); xAxis.setPosition(XAxisPosition.BOTTOM); xAxis.setTypeface(tfLight); xAxis.setDrawGridLines(false); xAxis.setGranularity(1f); // only intervals of 1 day xAxis.setLabelCount(7); xAxis.setValueFormatter(xAxisFormatter); ValueFormatter custom = new MyValueFormatter("$"); YAxis leftAxis = chart.getAxisLeft(); leftAxis.setTypeface(tfLight); leftAxis.setLabelCount(8, false); leftAxis.setValueFormatter(custom); leftAxis.setPosition(YAxisLabelPosition.OUTSIDE_CHART); leftAxis.setSpaceTop(15f); leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true) YAxis rightAxis = chart.getAxisRight(); rightAxis.setDrawGridLines(false); rightAxis.setTypeface(tfLight); rightAxis.setLabelCount(8, false); rightAxis.setValueFormatter(custom); rightAxis.setSpaceTop(15f); rightAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true) 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); XYMarkerView mv = new XYMarkerView(this, xAxisFormatter); mv.setChartView(chart); // For bounds control chart.setMarker(mv); // Set the marker to the chart // setting data seekBarY.setProgress(50); seekBarX.setProgress(12); // chart.setDrawLegend(false); }
Example 18
Source File: ScatterChartActivity.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_scatterchart); tvX = (TextView) findViewById(R.id.tvXMax); tvY = (TextView) findViewById(R.id.tvYMax); mSeekBarX = (SeekBar) findViewById(R.id.seekBar1); mSeekBarX.setOnSeekBarChangeListener(this); mSeekBarY = (SeekBar) findViewById(R.id.seekBar2); mSeekBarY.setOnSeekBarChangeListener(this); mChart = (ScatterChart) findViewById(R.id.chart1); mChart.setDescription(""); tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf"); mChart.setOnChartValueSelectedListener(this); mChart.setDrawGridBackground(false); mChart.setTouchEnabled(true); // enable scaling and dragging mChart.setDragEnabled(true); mChart.setScaleEnabled(true); mChart.setMaxVisibleValueCount(200); mChart.setPinchZoom(true); mSeekBarX.setProgress(45); mSeekBarY.setProgress(100); Legend l = mChart.getLegend(); l.setPosition(LegendPosition.RIGHT_OF_CHART); l.setTypeface(tf); YAxis yl = mChart.getAxisLeft(); yl.setTypeface(tf); yl.setAxisMinValue(0f); // this replaces setStartAtZero(true) mChart.getAxisRight().setEnabled(false); XAxis xl = mChart.getXAxis(); xl.setTypeface(tf); xl.setDrawGridLines(false); }
Example 19
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 20
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; }