本文整理汇总了Java中com.github.mikephil.charting.interfaces.datasets.IBarDataSet类的典型用法代码示例。如果您正苦于以下问题:Java IBarDataSet类的具体用法?Java IBarDataSet怎么用?Java IBarDataSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IBarDataSet类属于com.github.mikephil.charting.interfaces.datasets包,在下文中一共展示了IBarDataSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateBarData
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入依赖的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: getBarBounds
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入依赖的package包/类
/**
* The passed outputRect will be assigned the values of the bounding box of the specified Entry in the specified DataSet.
* The rect will be assigned Float.MIN_VALUE in all locations if the Entry could not be found in the charts data.
*
* @param e
* @return
*/
public void getBarBounds(BarEntry e, RectF outputRect) {
RectF bounds = outputRect;
IBarDataSet set = mData.getDataSetForEntry(e);
if (set == null) {
bounds.set(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE);
return;
}
float y = e.getY();
float x = e.getX();
float barWidth = mData.getBarWidth();
float left = x - barWidth / 2f;
float right = x + barWidth / 2f;
float top = y >= 0 ? y : 0;
float bottom = y <= 0 ? y : 0;
bounds.set(left, top, right, bottom);
getTransformer(set.getAxisDependency()).rectValueToPixel(outputRect);
}
示例3: getBarBounds
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入依赖的package包/类
@Override
public void getBarBounds(BarEntry e, RectF outputRect) {
RectF bounds = outputRect;
IBarDataSet set = mData.getDataSetForEntry(e);
if (set == null) {
outputRect.set(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE);
return;
}
float y = e.getY();
float x = e.getX();
float barWidth = mData.getBarWidth();
float top = x - barWidth / 2f;
float bottom = x + barWidth / 2f;
float left = y >= 0 ? y : 0;
float right = y <= 0 ? y : 0;
bounds.set(left, top, right, bottom);
getTransformer(set.getAxisDependency()).rectValueToPixel(bounds);
}
示例4: getHighlight
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入依赖的package包/类
@Override
public Highlight getHighlight(float x, float y) {
Highlight high = super.getHighlight(x, y);
if(high == null) {
return null;
}
MPPointD pos = getValsForTouch(x, y);
BarData barData = mChart.getBarData();
IBarDataSet set = barData.getDataSetByIndex(high.getDataSetIndex());
if (set.isStacked()) {
return getStackedHighlight(high,
set,
(float) pos.x,
(float) pos.y);
}
MPPointD.recycleInstance(pos);
return high;
}
示例5: getHighlight
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入依赖的package包/类
@Override
public Highlight getHighlight(float x, float y) {
BarData barData = mChart.getBarData();
MPPointD pos = getValsForTouch(y, x);
Highlight high = getHighlightForX((float) pos.y, y, x);
if (high == null)
return null;
IBarDataSet set = barData.getDataSetByIndex(high.getDataSetIndex());
if (set.isStacked()) {
return getStackedHighlight(high,
set,
(float) pos.y,
(float) pos.x);
}
MPPointD.recycleInstance(pos);
return high;
}
示例6: generateBarData
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入依赖的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;
}
示例7: generateData
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入依赖的package包/类
/**
* generates a random ChartData object with just one DataSet
*
* @return
*/
private BarData generateData(int cnt) {
ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
for (int i = 0; i < 12; i++) {
entries.add(new BarEntry(i, (float) (Math.random() * 70) + 30));
}
BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt);
d.setColors(ColorTemplate.VORDIPLOM_COLORS);
d.setBarShadowColor(Color.rgb(203, 203, 203));
ArrayList<IBarDataSet> sets = new ArrayList<IBarDataSet>();
sets.add(d);
BarData cd = new BarData(sets);
cd.setBarWidth(0.9f);
return cd;
}
示例8: setData
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入依赖的package包/类
private void setData() {
RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
//RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "xValue", "stackValues", "floatValue"); // stacked entries
set.setColors(new int[]{ColorTemplate.rgb("#8BC34A"), ColorTemplate.rgb("#FFC107"), ColorTemplate.rgb("#9E9E9E")});
set.setLabel("Mobile OS distribution");
set.setStackLabels(new String[]{"iOS", "Android", "Other"});
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set); // add the dataset
// create a data object with the dataset list
BarData data = new BarData(dataSets);
styleData(data);
data.setValueTextColor(Color.WHITE);
// set data
mChart.setData(data);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
}
示例9: setData
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入依赖的package包/类
private void setData() {
RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
//RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "xValue", "yValue"); // stacked entries
set.setColors(new int[] {ColorTemplate.rgb("#FF5722"), ColorTemplate.rgb("#03A9F4")});
set.setLabel("Realm BarDataSet");
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set); // add the dataset
// create a data object with the dataset list
BarData data = new BarData(dataSets);
styleData(data);
// set data
mChart.setData(data);
mChart.setFitBars(true);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
}
示例10: getBarBounds
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入依赖的package包/类
/**
* Returns the bounding box of the specified Entry in the specified DataSet. Returns null if the Entry could not be
* found in the charts data.
*
* @param e
* @return
*/
public RectF getBarBounds(BarEntry e) {
IBarDataSet set = mData.getDataSetForEntry(e);
if (set == null)
return null;
float barspace = set.getBarSpace();
float y = e.getVal();
float x = e.getXIndex();
float barWidth = 0.5f;
float spaceHalf = barspace / 2f;
float left = x - barWidth + spaceHalf;
float right = x + barWidth - spaceHalf;
float top = y >= 0 ? y : 0;
float bottom = y <= 0 ? y : 0;
RectF bounds = new RectF(left, top, right, bottom);
getTransformer(set.getAxisDependency()).rectValueToPixel(bounds);
return bounds;
}
示例11: getHighlight
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入依赖的package包/类
@Override
public Highlight getHighlight(float x, float y) {
Highlight h = super.getHighlight(x, y);
if (h == null)
return h;
else {
IBarDataSet set = mChart.getBarData().getDataSetByIndex(h.getDataSetIndex());
if (set.isStacked()) {
// create an array of the touch-point
float[] pts = new float[2];
pts[0] = y;
// take any transformer to determine the x-axis value
mChart.getTransformer(set.getAxisDependency()).pixelsToValue(pts);
return getStackedHighlight(h, set, h.getXIndex(), h.getDataSetIndex(), pts[0]);
} else
return h;
}
}
示例12: getHighlight
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入依赖的package包/类
@Override
public Highlight getHighlight(float x, float y) {
Highlight h = super.getHighlight(x, y);
if (h == null)
return h;
else {
IBarDataSet set = mChart.getBarData().getDataSetByIndex(h.getDataSetIndex());
if (set.isStacked()) {
// create an array of the touch-point
float[] pts = new float[2];
pts[1] = y;
// take any transformer to determine the x-axis value
mChart.getTransformer(set.getAxisDependency()).pixelsToValue(pts);
return getStackedHighlight(h, set, h.getXIndex(), h.getDataSetIndex(), pts[1]);
} else
return h;
}
}
示例13: generateData
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入依赖的package包/类
/**
* generates a random ChartData object with just one DataSet
*
* @return
*/
private BarData generateData(int cnt) {
ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
for (int i = 0; i < 12; i++) {
entries.add(new BarEntry((int) (Math.random() * 70) + 30, i));
}
BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt);
d.setBarSpacePercent(20f);
d.setColors(ColorTemplate.VORDIPLOM_COLORS);
d.setBarShadowColor(Color.rgb(203, 203, 203));
ArrayList<IBarDataSet> sets = new ArrayList<IBarDataSet>();
sets.add(d);
BarData cd = new BarData(getMonths(), sets);
return cd;
}
示例14: setData
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入依赖的package包/类
private void setData() {
RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class);
//RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex", "floatValue"); // stacked entries
set.setColors(new int[]{ColorTemplate.rgb("#8BC34A"), ColorTemplate.rgb("#FFC107"), ColorTemplate.rgb("#9E9E9E")});
set.setLabel("Mobile OS distribution");
set.setStackLabels(new String[]{"iOS", "Android", "Other"});
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set); // add the dataset
// create a data object with the dataset list
RealmBarData data = new RealmBarData(result, "xValue", dataSets);
styleData(data);
data.setValueTextColor(Color.WHITE);
// set data
mChart.setData(data);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
}
示例15: setData
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入依赖的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);
}