本文整理汇总了Java中com.github.mikephil.charting.data.BarData.setValueTypeface方法的典型用法代码示例。如果您正苦于以下问题:Java BarData.setValueTypeface方法的具体用法?Java BarData.setValueTypeface怎么用?Java BarData.setValueTypeface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.data.BarData
的用法示例。
在下文中一共展示了BarData.setValueTypeface方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateBarData
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
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;
}
示例2: generateBarData
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
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(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;
}
示例3: setData
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
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);
}
示例4: generateBarData
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
/**
* Generate bar data bar data.
*
* @param dataSets the data sets
* @param range the range
* @param count the count
* @return the bar data
*/
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(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;
}
示例5: createBarChartData
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
public BarData createBarChartData()
{
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMinimumFractionDigits(0);
numberFormat.setMaximumFractionDigits(2);
mDashboardHelper = new DashboardHelper(getActivity());
HashMap<String, ArrayList> holder = mDashboardHelper.generateTimesPerDayMap();
ArrayList<String> xVals = holder.get("dayOfThisMonth");
ArrayList<BarEntry> yVals1 = holder.get("episodesPerDay");
BarDataSet set1 = new BarDataSet(yVals1, "DataSet");
set1.setColor(0xFF2196f3);
set1.setBarSpacePercent(40f);
ArrayList<IBarDataSet> dataSets = new ArrayList<>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10);
data.setValueTypeface(Typeface.create("sans-serif-medium", Typeface.BOLD));
data.setValueTextColor(Color.WHITE);
data.setValueFormatter((value, entry, dataSetIndex, viewPortHandler) -> numberFormat.format(
value));
return data;
}
示例6: setData
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
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);
}
示例7: setData
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
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);
}
示例8: setData
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
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();
}
示例9: createBarChartData
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
public BarData createBarChartData()
{
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMinimumFractionDigits(0);
numberFormat.setMaximumFractionDigits(2);
ArrayList<String> xVals = new ArrayList<>();
for(int i = 0; i < 12; i++)
{
xVals.add(i + "");
}
ArrayList<BarEntry> yVals1 = new ArrayList<>();
for(int i = 0; i < 12; i++)
{
float mult = (5 + 1);
int val = (int) (Math.random() * mult);
yVals1.add(new BarEntry((val == 0 ? 1 : val), i));
}
BarDataSet set1 = new BarDataSet(yVals1, "DataSet");
set1.setColor(0xFF2196f3);
set1.setBarSpacePercent(40f);
ArrayList<IBarDataSet> dataSets = new ArrayList<>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10);
data.setValueTypeface(Typeface.create("sans-serif-medium", Typeface.BOLD));
data.setValueTextColor(Color.WHITE);
data.setValueFormatter((value, entry, dataSetIndex, viewPortHandler) -> numberFormat.format(
value));
return data;
}
示例10: createStackedBarChartData
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
public BarData createStackedBarChartData()
{
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMinimumFractionDigits(0);
numberFormat.setMaximumFractionDigits(2);
ArrayList<String> xVals = new ArrayList<>();
for(int i = 0; i < 12; i++)
{
xVals.add(i + "");
}
ArrayList<BarEntry> yVals1 = new ArrayList<>();
for(int i = 0; i < 12; i++)
{
float mult = (5 + 1);
int val = (int) (Math.random() * mult);
yVals1.add(new BarEntry(new float[] {(val == 0 ? 1 : val - 1), 1}, i));
}
BarDataSet set1 = new BarDataSet(yVals1, "DataSet");
set1.setColors(new int[] {0xFF2196f3, 0xFF3f51b5});
set1.setBarSpacePercent(40f);
ArrayList<IBarDataSet> dataSets = new ArrayList<>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10);
data.setValueTypeface(Typeface.create("sans-serif-medium", Typeface.BOLD));
data.setValueTextColor(Color.WHITE);
data.setValueFormatter((value, entry, dataSetIndex, viewPortHandler) -> numberFormat.format(
value));
return data;
}
示例11: getView
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
@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(mTfLight);
data.setValueTextColor(Color.BLACK);
holder.chart.getDescription().setEnabled(false);
holder.chart.setDrawGridBackground(false);
XAxis xAxis = holder.chart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTypeface(mTfLight);
xAxis.setDrawGridLines(false);
YAxis leftAxis = holder.chart.getAxisLeft();
leftAxis.setTypeface(mTfLight);
leftAxis.setLabelCount(5, false);
leftAxis.setSpaceTop(15f);
YAxis rightAxis = holder.chart.getAxisRight();
rightAxis.setTypeface(mTfLight);
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;
}
示例12: getView
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
@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;
}
示例13: initData
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
@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);
}