本文整理汇总了Java中com.github.mikephil.charting.data.Entry类的典型用法代码示例。如果您正苦于以下问题:Java Entry类的具体用法?Java Entry怎么用?Java Entry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Entry类属于com.github.mikephil.charting.data包,在下文中一共展示了Entry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addEntry
import com.github.mikephil.charting.data.Entry; //导入依赖的package包/类
private void addEntry(String label, int value) {
LineData data = chart.getData();
if (data != null) {
int index;
if (label.equals(pm1Label)) {
index = 0;
} else if (label.equals(pm25Label)) {
index = 1;
} else {
index = 2;
}
ILineDataSet set = data.getDataSetByIndex(index);
if (set == null) {
set = createSet(label);
data.addDataSet(set);
}
data.addEntry(new Entry(set.getEntryCount(), value), index);
}
}
示例2: buildLineData
import com.github.mikephil.charting.data.Entry; //导入依赖的package包/类
private LineData buildLineData(List<Entry> seniors, List<Entry> engineer,
List<Entry> juniors, String[] jobTitles ){
List<ILineDataSet> sets = new ArrayList<>();
if (!seniors.isEmpty()){
LineDataSet dSenior = buildLineDataSet(seniors, jobTitles[0]);
sets.add(dSenior);
}
if (!engineer.isEmpty()){
LineDataSet dEngineer = buildLineDataSet(engineer, jobTitles[1]);
dEngineer.setColor(ColorTemplate.VORDIPLOM_COLORS[0]);
dEngineer.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[0]);
sets.add(dEngineer);
}
if (!juniors.isEmpty()) {
LineDataSet dJunior = buildLineDataSet(juniors, jobTitles[2]);
dJunior.setColor(ColorTemplate.VORDIPLOM_COLORS[2]);
dJunior.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[2]);
sets.add(dJunior);//add data
}
return new LineData(sets);
}
示例3: refreshContent
import com.github.mikephil.charting.data.Entry; //导入依赖的package包/类
@Override
public void refreshContent(Entry e, Highlight highlight) {
if (e instanceof CandleEntry) {
CandleEntry ce = (CandleEntry) e;
tvContent.setText(getContext().getString(R.string.salaries_format_salary,
(int) ce.getHigh()));
} else {
EntryMarkerData data = (EntryMarkerData) e.getData();
tvContent.setText(getContext().getString(R.string.exp_format_marker,
String.valueOf(data.getValue()),
String.valueOf(data.getCount())
)
);
}
super.refreshContent(e, highlight);
}
示例4: getData
import com.github.mikephil.charting.data.Entry; //导入依赖的package包/类
private LineData getData(ArrayList<Entry> yVals) {
LineDataSet set1 = new LineDataSet(yVals, "");
set1.setLineWidth(1.45f);
set1.setColor(Color.argb(240, 255, 255, 255));
set1.setCircleColor(Color.WHITE);
set1.setHighLightColor(Color.WHITE);
set1.setFillColor(getResources().getColor(R.color.chartFilled));
set1.setDrawCircles(false);
set1.setDrawValues(false);
set1.setDrawFilled(true);
set1.setFillFormatter(new IFillFormatter() {
@Override
public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) {
return priceChart.getAxisLeft().getAxisMinimum();
}
});
LineData data = new LineData(set1);
return data;
}
示例5: onValueSelected
import com.github.mikephil.charting.data.Entry; //导入依赖的package包/类
@SuppressLint("NewApi")
@Override
public void onValueSelected(Entry e, Highlight h) {
if (e == null)
return;
RectF bounds = mOnValueSelectedRectF;
mChart.getBarBounds((BarEntry) e, bounds);
MPPointF position = mChart.getPosition(e, AxisDependency.LEFT);
Log.i("bounds", bounds.toString());
Log.i("position", position.toString());
Log.i("x-index",
"low: " + mChart.getLowestVisibleX() + ", high: "
+ mChart.getHighestVisibleX());
MPPointF.recycleInstance(position);
}
示例6: populateDiagram
import com.github.mikephil.charting.data.Entry; //导入依赖的package包/类
@BindingAdapter({"bind:items"})
public static void populateDiagram(LineChart view, List<SingleValue> items) {
if (null == items || items.size() == 0) {
return;
}
List<Entry> entries = new ArrayList<>();
for (int i = 0; i < items.size(); i++) {
final SingleValue item = items.get(i);
final Entry entry = new Entry(i, (float) item.getValue(), item);
entries.add(entry);
}
LineDataSet dataSet = new LineDataSet(entries, view.getContext().getString(R.string.currency_value));
LineData lineData = new LineData(dataSet);
formatXAxisLabels(view, items);
view.setData(lineData);
view.invalidate();
}
示例7: generateLineData
import com.github.mikephil.charting.data.Entry; //导入依赖的package包/类
private LineData generateLineData() {
LineData d = new LineData();
ArrayList<Entry> entries = new ArrayList<Entry>();
for (int index = 0; index < itemcount; index++)
entries.add(new Entry(index + 0.5f, getRandom(15, 5)));
LineDataSet set = new LineDataSet(entries, "Line DataSet");
set.setColor(Color.rgb(240, 238, 70));
set.setLineWidth(2.5f);
set.setCircleColor(Color.rgb(240, 238, 70));
set.setCircleRadius(5f);
set.setFillColor(Color.rgb(240, 238, 70));
set.setMode(LineDataSet.Mode.CUBIC_BEZIER);
set.setDrawValues(true);
set.setValueTextSize(10f);
set.setValueTextColor(Color.rgb(240, 238, 70));
set.setAxisDependency(YAxis.AxisDependency.LEFT);
d.addDataSet(set);
return d;
}
示例8: removeLastEntry
import com.github.mikephil.charting.data.Entry; //导入依赖的package包/类
private void removeLastEntry() {
LineData data = mChart.getData();
if (data != null) {
ILineDataSet set = data.getDataSetByIndex(0);
if (set != null) {
Entry e = set.getEntryForXValue(set.getEntryCount() - 1, Float.NaN);
data.removeEntry(e, 0);
// or remove by index
// mData.removeEntryByXValue(xIndex, dataSetIndex);
data.notifyDataChanged();
mChart.notifyDataSetChanged();
mChart.invalidate();
}
}
}
示例9: generateScatterData
import com.github.mikephil.charting.data.Entry; //导入依赖的package包/类
protected ScatterData generateScatterData() {
ScatterData d = new ScatterData();
ArrayList<Entry> entries = new ArrayList<Entry>();
for (float index = 0; index < itemcount; index += 0.5f)
entries.add(new Entry(index + 0.25f, getRandom(10, 55)));
ScatterDataSet set = new ScatterDataSet(entries, "Scatter DataSet");
set.setColors(ColorTemplate.MATERIAL_COLORS);
set.setScatterShapeSize(7.5f);
set.setDrawValues(false);
set.setValueTextSize(10f);
d.addDataSet(set);
return d;
}
示例10: refreshContent
import com.github.mikephil.charting.data.Entry; //导入依赖的package包/类
@Override
public void refreshContent(Entry e, Highlight highlight) {
String content;
if (mWhatData == SHOW_FUEL_PRICE_EVOLUTION)
content = String.format(mCtx.getString(R.string.line_chart_fuel_price_marker_text),
Utils.numberToString(e.getY(), true, ConstantValues.DECIMALS_PRICE, ConstantValues.ROUNDING_MODE_PRICE),
Utils.getFormattedDateTime((mChartDates.get((int) e.getX())) * 1000, true));
else
content = Utils.numberToString(e.getY(), true, ConstantValues.DECIMALS_FUEL_EFF, ConstantValues.ROUNDING_MODE_FUEL_EFF);
tvContent.setText(content);
//resize the marker view.
//see https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartLib/src/main/java/com/github/mikephil/charting/components/MarkerView.java
measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
layout(0, 0, getMeasuredWidth(), getMeasuredHeight());
}
示例11: setData
import com.github.mikephil.charting.data.Entry; //导入依赖的package包/类
private void setData(int count, float range) {
ArrayList<Entry> entries = new ArrayList<Entry>();
for (int i = 0; i < count; i++) {
float xVal = (float) (Math.random() * range);
float yVal = (float) (Math.random() * range);
entries.add(new Entry(xVal, yVal));
}
// sort by x-value
Collections.sort(entries, new EntryXComparator());
// create a dataset and give it a type
LineDataSet set1 = new LineDataSet(entries, "DataSet 1");
set1.setLineWidth(1.5f);
set1.setCircleRadius(4f);
// create a data object with the datasets
LineData data = new LineData(set1);
// set data
mChart.setData(data);
}
示例12: onValueSelected
import com.github.mikephil.charting.data.Entry; //导入依赖的package包/类
@SuppressLint("NewApi")
@Override
public void onValueSelected(Entry e, Highlight h) {
if (e == null)
return;
RectF bounds = mOnValueSelectedRectF;
mChart.getBarBounds((BarEntry) e, bounds);
MPPointF position = mChart.getPosition(e, mChart.getData().getDataSetByIndex(h.getDataSetIndex())
.getAxisDependency());
Log.i("bounds", bounds.toString());
Log.i("position", position.toString());
MPPointF.recycleInstance(position);
}
示例13: generateCholesterolData
import com.github.mikephil.charting.data.Entry; //导入依赖的package包/类
private LineData generateCholesterolData() {
List<String> xVals = new ArrayList<>();
List<Entry> yVals = new ArrayList<>();
for (int i = 0; i < presenter.getCholesterolReadings().size(); i++) {
float val = Float.parseFloat(presenter.getCholesterolReadings().get(i).toString());
yVals.add(new Entry(val, i));
}
xVals.clear();
for (int i = 0; i < presenter.getCholesterolReadingsDateTime().size(); i++) {
String date = presenter.convertDate(presenter.getCholesterolReadingsDateTime().get(i));
xVals.add(date + "");
}
// create a data object with the datasets
return new LineData(xVals,
generateLineDataSet(yVals, getResources().getColor(R.color.glucosio_fab_cholesterol)));
}
示例14: updateBalance
import com.github.mikephil.charting.data.Entry; //导入依赖的package包/类
/**
*
* @param balance
*/
public void updateBalance(String balance) {
// _balanceTxt.setText(balance);
_lastBalance = balance;
_walletFragView.updateBalance(balance);
if(_btcChartEntries != null && !_btcChartEntries.isEmpty()) {
Entry latestValue = _btcChartEntries.get(_btcChartEntries.size() - 1);
Double actualBalance = Double.parseDouble(balance);
Locale locale = new Locale("en", "US");
NumberFormat currencyFormatter = NumberFormat.getCurrencyInstance(locale);
double conversionValue = actualBalance * latestValue.getY();
String subBalance = String.format(Locale.getDefault(), "(%s$)", currencyFormatter.format(conversionValue));
//_subBalanceTxt.setText(subBalance);
_walletFragView.updateConversion(subBalance);
}
}
示例15: addDragListenerMarkerMaker
import com.github.mikephil.charting.data.Entry; //导入依赖的package包/类
private void addDragListenerMarkerMaker(LineChart speedChart) {
speedChart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
@Override
public void onValueSelected(Entry entry, Highlight h) {
Long entryX = (long) entry.getX();
if (timeLocationMap.containsKey(entryX)) {
clearAllMarkersFromMap();
LatLng latLng = timeLocationMap.get(entryX);
mapMarkers.add(googleMap.addMarker(new MarkerOptions().position(latLng)));
}
}
@Override
public void onNothingSelected() {
clearAllMarkersFromMap();
}
});
}