本文整理汇总了Java中com.github.mikephil.charting.data.LineData.addEntry方法的典型用法代码示例。如果您正苦于以下问题:Java LineData.addEntry方法的具体用法?Java LineData.addEntry怎么用?Java LineData.addEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.data.LineData
的用法示例。
在下文中一共展示了LineData.addEntry方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addEntry
import com.github.mikephil.charting.data.LineData; //导入方法依赖的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: addEntry
import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
private void addEntry(int db) {
LineData data = mLineChart.getData();
if (data != null) {
ILineDataSet set = data.getDataSetByIndex(0);
// set.addEntry(...); // can be called as well
if (set == null) {
set = createSet();
data.addDataSet(set);
}
data.addEntry(new Entry(set.getEntryCount(), db), 0);
data.notifyDataChanged();
// let the chart know it's data has changed
mLineChart.notifyDataSetChanged();
// limit the number of visible entries
mLineChart.setVisibleXRangeMaximum(60);
//mLineChart.setVisibleYRange(30, AxisDependency.LEFT);
// move to the latest entry
mLineChart.moveViewToX(data.getEntryCount());
}
}
示例3: updateChart
import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
public void updateChart(float value, int index) {
LineData data = messagesChart.getData();
ILineDataSet set = data.getDataSetByIndex(index);
if (set == null) {
set = createSet(getLineColor(index));
data.addDataSet(set);
}
data.addEntry(new Entry(set.getEntryCount(), value), index);
data.notifyDataChanged();
messagesChart.notifyDataSetChanged();
messagesChart.setVisibleXRangeMaximum(getVisibleRange().getRange());
messagesChart.moveViewToX(data.getEntryCount());
}
示例4: addEntry
import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
private void addEntry() {
LineData data = mChart.getData();
ILineDataSet set = data.getDataSetByIndex(0);
// set.addEntry(...); // can be called as well
if (set == null) {
set = createSet();
data.addDataSet(set);
}
// choose a random dataSet
int randomDataSetIndex = (int) (Math.random() * data.getDataSetCount());
float yValue = (float) (Math.random() * 10) + 50f;
data.addEntry(new Entry(data.getDataSetByIndex(randomDataSetIndex).getEntryCount(), yValue), randomDataSetIndex);
data.notifyDataChanged();
// let the chart know it's data has changed
mChart.notifyDataSetChanged();
mChart.setVisibleXRangeMaximum(6);
//mChart.setVisibleYRangeMaximum(15, AxisDependency.LEFT);
//
// // this automatically refreshes the chart (calls invalidate())
mChart.moveViewTo(data.getEntryCount() - 7, 50f, AxisDependency.LEFT);
}
示例5: addEntry
import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
private void addEntry() {
LineData data = mChart.getData();
if (data != null) {
ILineDataSet set = data.getDataSetByIndex(0);
// set.addEntry(...); // can be called as well
if (set == null) {
set = createSet();
data.addDataSet(set);
}
data.addEntry(new Entry(set.getEntryCount(), (float) (Math.random() * 40) + 30f), 0);
data.notifyDataChanged();
// let the chart know it's data has changed
mChart.notifyDataSetChanged();
// limit the number of visible entries
mChart.setVisibleXRangeMaximum(120);
// mChart.setVisibleYRange(30, AxisDependency.LEFT);
// move to the latest entry
mChart.moveViewToX(data.getEntryCount());
// this automatically refreshes the chart (calls invalidate())
// mChart.moveViewTo(data.getXValCount()-7, 55f,
// AxisDependency.LEFT);
}
}
示例6: addEntry
import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
private void addEntry() {
LineData data = mChart.getData();
if(data != null) {
ILineDataSet set = data.getDataSetByIndex(0);
// set.addEntry(...); // can be called as well
if (set == null) {
set = createSet();
data.addDataSet(set);
}
// add a new x-value first
data.addXValue(set.getEntryCount() + "");
// choose a random dataSet
int randomDataSetIndex = (int) (Math.random() * data.getDataSetCount());
data.addEntry(new Entry((float) (Math.random() * 10) + 50f, set.getEntryCount()), randomDataSetIndex);
// let the chart know it's data has changed
mChart.notifyDataSetChanged();
mChart.setVisibleXRangeMaximum(6);
mChart.setVisibleYRangeMaximum(15, AxisDependency.LEFT);
//
// // this automatically refreshes the chart (calls invalidate())
mChart.moveViewTo(data.getXValCount()-7, 50f, AxisDependency.LEFT);
}
}
示例7: addEntry
import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
private void addEntry() {
LineData data = mChart.getData();
if (data != null) {
ILineDataSet set = data.getDataSetByIndex(0);
// set.addEntry(...); // can be called as well
if (set == null) {
set = createSet();
data.addDataSet(set);
}
// add a new x-value first
data.addXValue(mMonths[data.getXValCount() % 12] + " "
+ (year + data.getXValCount() / 12));
data.addEntry(new Entry((float) (Math.random() * 40) + 30f, set.getEntryCount()), 0);
// let the chart know it's data has changed
mChart.notifyDataSetChanged();
// limit the number of visible entries
mChart.setVisibleXRangeMaximum(120);
// mChart.setVisibleYRange(30, AxisDependency.LEFT);
// move to the latest entry
mChart.moveViewToX(data.getXValCount() - 121);
// this automatically refreshes the chart (calls invalidate())
// mChart.moveViewTo(data.getXValCount()-7, 55f,
// AxisDependency.LEFT);
}
}
示例8: runOnTick
import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
private void runOnTick() {
if (coreResult != null && liveGame != null && coreResult.getStatus() >= 2) {
LineData lineData = mChart.getLineData();
LineDataSet lineDataSet = lineData.getDataSetByIndex(0);
long[] ticks = liveGame.getStats().get("tick");
if (ticks != null) {
switch (mSelectedStat) {
case 0:
lineDataSet.setColor(getResources().getColor(R.color.gold));
for (int i = lineDataSet.getEntryCount(); i < ticks.length; i++) {
mTicks.add(String.valueOf(ticks[i]));
lineData.addEntry(
new Entry(
liveGame.getRadiant().getStats().getNetGold()[i] - liveGame.getDire().getStats().getNetGold()[i],
lineDataSet.getEntryCount()),
0);
}
break;
case 1:
lineDataSet.setColor(getResources().getColor(R.color.xp));
for (int i = lineDataSet.getEntryCount(); i < ticks.length; i++) {
mTicks.add(String.valueOf(ticks[i]));
lineData.addEntry(
new Entry(
liveGame.getRadiant().getStats().getNetExp()[i] - liveGame.getDire().getStats().getNetExp()[i],
lineDataSet.getEntryCount()),
0);
}
break;
}
}
mChart.notifyDataSetChanged();
mChart.invalidate();
}
}
示例9: addEntry
import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
private void addEntry(float entry) {
LineData data = lchScope.getData();
if (data != null) {
ILineDataSet set = data.getDataSetByIndex(0);
// set.addEntry(...); // can be called as well
if (set == null) {
set = createSet();
data.addDataSet(set);
}
Long tsLong = (System.currentTimeMillis() - relTime) / 1000;
// if(tsLong != curTime) {
data.addXValue(tsLong.toString());
curTime = tsLong;
//}
data.addEntry(new Entry(entry, set.getEntryCount()), 0);
lchScope.notifyDataSetChanged();
lchScope.setVisibleXRangeMaximum(60);
lchScope.moveViewToX(data.getXValCount() - 61);
}
}
示例10: refreshData
import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
private void refreshData() {
LineData data = lineChart.getData();
if (data != null) {
LineDataSet set = (LineDataSet) data.getDataSetByIndex(0);
if (set == null) {
set = createSet();
data.addDataSet(set);
}
if (set.getEntryCount() == timeframe) {
data.removeXValue(0);
set.removeEntry(0);
for (Entry entry : set.getYVals()) {
entry.setXIndex(entry.getXIndex() - 1);
}
}
// add x-value
Date date = new Date();
Calendar calendar = GregorianCalendar.getInstance();
calendar.setTime(date);
int inthours = calendar.get(Calendar.HOUR_OF_DAY);
int intminute = calendar.get(Calendar.MINUTE);
String hourString = String.format("%02d:", inthours);
String minuteString = String.format("%02d", intminute);
XAxisTimeValue.add(hourString + minuteString);
data.addXValue(XAxisTimeValue.get(data.getXValCount()));
// choose a dataSet
//RealmResults<BGdata> results = realm.allObjects(BGdata.class);
//RealmLineDataSet(RealmResults<T> results, "calculated_value")
//RealmLineDataSet<BGdata> dataSet = new RealmLineDataSet<BGdata>(results, "calculated_value");
//RealmLineData dataset = new RealmLineData(results, "calculated_value", (List<ILineDataSet>) data);
//lineChart.setData(dataset);
data.addEntry(new Entry((float) calculated_value, set.getEntryCount()), 0);
lineChart.notifyDataSetChanged();
lineChart.setVisibleYRangeMaximum((float) calculated_value, YAxis.AxisDependency.LEFT);
// this automatically refreshes the chart (calls invalidate())
lineChart.moveViewTo(data.getXValCount(), (float) calculated_value, YAxis.AxisDependency.LEFT);
}
}