Java Code Examples for com.github.mikephil.charting.data.BarData#setValueTypeface()
The following examples show how to use
com.github.mikephil.charting.data.BarData#setValueTypeface() .
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: SimpleFragment.java From StockChart-MPAndroidChart with MIT License | 6 votes |
protected BarData generateBarData(int dataSets, float range, int count) { ArrayList<IBarDataSet> sets = new ArrayList<>(); for(int i = 0; i < dataSets; i++) { ArrayList<BarEntry> entries = new ArrayList<>(); for(int j = 0; j < count; j++) { entries.add(new BarEntry(j, (float) (Math.random() * range) + range / 4)); } BarDataSet ds = new BarDataSet(entries, getLabel(i)); ds.setColors(ColorTemplate.VORDIPLOM_COLORS); sets.add(ds); } BarData d = new BarData(sets); d.setValueTypeface(tf); return d; }
Example 2
Source File: SimpleFragment.java From Stayfit with Apache License 2.0 | 6 votes |
protected BarData generateBarData(int dataSets, float range, int count) { ArrayList<IBarDataSet> sets = new ArrayList<IBarDataSet>(); for(int i = 0; i < dataSets; i++) { ArrayList<BarEntry> entries = new ArrayList<BarEntry>(); // entries = FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "stacked_bars.txt"); for(int j = 0; j < count; j++) { entries.add(new BarEntry((float) (Math.random() * range) + range / 4, j)); } BarDataSet ds = new BarDataSet(entries, getLabel(i)); ds.setColors(ColorTemplate.VORDIPLOM_COLORS); sets.add(ds); } BarData d = new BarData(ChartData.generateXVals(0, count), sets); d.setValueTypeface(tf); return d; }
Example 3
Source File: BarChartActivitySinus.java From Stayfit with Apache License 2.0 | 6 votes |
private void setData(int count) { ArrayList<String> xVals = new ArrayList<String>(); ArrayList<BarEntry> entries = new ArrayList<BarEntry>(); for (int i = 0; i < count; i++) { xVals.add(i+""); entries.add(mSinusData.get(i)); } BarDataSet set = new BarDataSet(entries, "Sinus Function"); set.setBarSpacePercent(40f); set.setColor(Color.rgb(240, 120, 124)); BarData data = new BarData(xVals, set); data.setValueTextSize(10f); data.setValueTypeface(mTf); data.setDrawValues(false); mChart.setData(data); }
Example 4
Source File: HorizontalBarChartActivity.java From Stayfit with Apache License 2.0 | 6 votes |
private void setData(int count, float range) { ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>(); ArrayList<String> xVals = new ArrayList<String>(); for (int i = 0; i < count; i++) { xVals.add(mMonths[i % 12]); yVals1.add(new BarEntry((float) (Math.random() * range), i)); } BarDataSet set1 = new BarDataSet(yVals1, "DataSet 1"); ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>(); dataSets.add(set1); BarData data = new BarData(xVals, dataSets); data.setValueTextSize(10f); data.setValueTypeface(tf); mChart.setData(data); }
Example 5
Source File: BarChartActivity.java From Stayfit with Apache License 2.0 | 5 votes |
private void setData(int count, float range) { ArrayList<String> xVals = new ArrayList<String>(); for (int i = 0; i < count; i++) { xVals.add(mMonths[i % 12]); } ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>(); for (int i = 0; i < count; i++) { float mult = (range + 1); float val = (float) (Math.random() * mult); yVals1.add(new BarEntry(val, i)); } BarDataSet set1 = new BarDataSet(yVals1, "DataSet"); set1.setBarSpacePercent(35f); ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>(); dataSets.add(set1); BarData data = new BarData(xVals, dataSets); data.setValueTextSize(10f); data.setValueTypeface(mTf); mChart.setData(data); }
Example 6
Source File: BarChartPositiveNegative.java From Stayfit with Apache License 2.0 | 5 votes |
private void setData(List<Data> dataList) { ArrayList<BarEntry> values = new ArrayList<BarEntry>(); String[] dates = new String[dataList.size()]; List<Integer> colors = new ArrayList<Integer>(); int green = Color.rgb(110, 190, 102); int red = Color.rgb(211, 74, 88); for (int i = 0; i < dataList.size(); i++) { Data d = dataList.get(i); BarEntry entry = new BarEntry(d.yValue, d.xIndex); values.add(entry); dates[i] = dataList.get(i).xAxisValue; // specific colors if (d.yValue >= 0) colors.add(red); else colors.add(green); } BarDataSet set = new BarDataSet(values, "Values"); set.setBarSpacePercent(40f); set.setColors(colors); set.setValueTextColors(colors); BarData data = new BarData(dates, set); data.setValueTextSize(13f); data.setValueTypeface(mTf); data.setValueFormatter(new ValueFormatter()); mChart.setData(data); mChart.invalidate(); }
Example 7
Source File: ListViewBarChartActivity.java From StockChart-MPAndroidChart with MIT License | 4 votes |
@SuppressLint("InflateParams") @NonNull @Override public View getView(int position, View convertView, @NonNull ViewGroup parent) { BarData data = getItem(position); ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = LayoutInflater.from(getContext()).inflate( R.layout.list_item_barchart, null); holder.chart = convertView.findViewById(R.id.chart); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } // apply styling if (data != null) { data.setValueTypeface(tfLight); data.setValueTextColor(Color.BLACK); } holder.chart.getDescription().setEnabled(false); holder.chart.setDrawGridBackground(false); XAxis xAxis = holder.chart.getXAxis(); xAxis.setPosition(XAxisPosition.BOTTOM); xAxis.setTypeface(tfLight); xAxis.setDrawGridLines(false); YAxis leftAxis = holder.chart.getAxisLeft(); leftAxis.setTypeface(tfLight); leftAxis.setLabelCount(5, false); leftAxis.setSpaceTop(15f); YAxis rightAxis = holder.chart.getAxisRight(); rightAxis.setTypeface(tfLight); rightAxis.setLabelCount(5, false); rightAxis.setSpaceTop(15f); // set data holder.chart.setData(data); holder.chart.setFitBars(true); // do not forget to refresh the chart // holder.chart.invalidate(); holder.chart.animateY(700); return convertView; }
Example 8
Source File: BarChartActivity.java From iMoney with Apache License 2.0 | 4 votes |
@Override protected void initData() { ivBack.setVisibility(View.VISIBLE); ivSetting.setVisibility(View.GONE); tvTitle.setText("柱状图"); //初始化字体库 mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf"); //图表的描述 barChart.setDescription("三星note7爆炸事件关注度"); //设置网格背景 barChart.setDrawGridBackground(false); //是否设置阴影的显示 barChart.setDrawBarShadow(false); //获取x轴 XAxis xAxis = barChart.getXAxis(); //设置x轴的显示位置 xAxis.setPosition(XAxis.XAxisPosition.TOP); //设置x轴的字体 xAxis.setTypeface(mTf); //是否绘制x轴网格线 xAxis.setDrawGridLines(false); //是否绘制x轴轴线 xAxis.setDrawAxisLine(true); //获取y轴 YAxis leftAxis = barChart.getAxisLeft(); //设置y轴的字体 leftAxis.setTypeface(mTf); //参数1:设置显示的区间的个数。参数2:是否均匀分布。fasle:均匀显示区间的端点值。 leftAxis.setLabelCount(5, false); //设置最高的柱状图距离顶端的距离 leftAxis.setSpaceTop(50f); YAxis rightAxis = barChart.getAxisRight(); rightAxis.setEnabled(false);//是否显示右边的y轴 BarData mChartData = generateDataBar(); mChartData.setValueTypeface(mTf); // set data barChart.setData(mChartData); // do not forget to refresh the chart // barChart.invalidate(); barChart.animateY(700); }
Example 9
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; }